[packages/satis] add autoload for Twig
glen
glen at pld-linux.org
Wed Jan 6 22:16:29 CET 2016
commit ba72ef5ab9f0578bad61016ea272348976b9e36d
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Wed Jan 6 23:09:24 2016 +0200
add autoload for Twig
autoload.patch | 4 ++--
autoload.php | 27 +++++++++++++++++++++++++++
satis.spec | 6 +++++-
3 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/satis.spec b/satis.spec
index 4d9fd39..6b15d88 100644
--- a/satis.spec
+++ b/satis.spec
@@ -1,5 +1,5 @@
-%define rel 0.8
+%define rel 0.12
%define githash 48191ff
# $ git rev-list 1.0.0-alpha1..%{githash} --count
%define commits 152
@@ -15,6 +15,7 @@ Group: Development/Languages/PHP
#Source0: https://github.com/composer/satis/archive/%{version}-%{subver}/%{name}-%{version}%{subver}.tar.gz
Source0: https://github.com/composer/satis/archive/%{githash}/%{name}-%{version}-%{subver}-%{commits}-g%{githash}.tar.gz
# Source0-md5: adee07882bc8c526b6bd3489812bc194
+Source1: autoload.php
Patch0: autoload.patch
URL: https://github.com/composer/satis
BuildRequires: composer
@@ -26,6 +27,7 @@ Requires: php(core) >= %{php_min_version}
Requires: php(hash)
Requires: php(json)
Requires: php(pcre)
+Requires: php-twig-Twig >= 1.7
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -45,6 +47,8 @@ mv %{name}-*/* .
%{__sed} -i -e '1s,^#!.*env php,#!/usr/bin/php,' bin/*
+cp -p %{SOURCE1} src/Composer/Satis/autoload.php
+
# move to Source dir, eases packaging
mv res views src/Composer/Satis
diff --git a/autoload.patch b/autoload.patch
index f29427a..322337e 100644
--- a/autoload.patch
+++ b/autoload.patch
@@ -5,10 +5,10 @@
<?php
-require __DIR__.'/../src/bootstrap.php';
-+if (file_exists($autoload = __DIR__ . '/../src/bootstrap.php')) {
++if (file_exists($autoload = __DIR__ . '/../src/Composer/Satis/autoload.php')) {
+ require $autoload;
+} else {
-+ require '/usr/share/php/Composer/autoload.php';
++ require '/usr/share/php/Composer/Satis/autoload.php';
+}
use Composer\Satis\Console\Application;
diff --git a/autoload.php b/autoload.php
new file mode 100644
index 0000000..6c5e78c
--- /dev/null
+++ b/autoload.php
@@ -0,0 +1,27 @@
+<?php
+$phpDir = defined('PHP_DATADIR') && PHP_DATADIR ? PHP_DATADIR . '/php' : '/usr/share/php';
+$pearDir = defined('PEAR_INSTALL_DIR') && PEAR_INSTALL_DIR ? PEAR_INSTALL_DIR : '/usr/share/pear';
+
+// Use Symfony autoloader
+if (!isset($loader) || !($loader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
+ if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
+ require_once $phpDir . '/Symfony/Component/ClassLoader/ClassLoader.php';
+ }
+
+ $loader = new \Symfony\Component\ClassLoader\ClassLoader();
+ $loader->register();
+}
+
+$baseDir = dirname(__DIR__);
+
+$loader->addPrefixes(array(
+ 'Composer\\Satis\\' => $baseDir,
+
+ // Dependencies
+ 'Twig' => $pearDir,
+));
+
+// Dependencies
+require_once $phpDir . '/Composer/autoload.php';
+
+return $loader;
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/satis.git/commitdiff/6e081214c793bea621ff2433481c9dfaf52d08a9
More information about the pld-cvs-commit
mailing list