summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2019-05-09 09:57:38 -0400
committerBrian Evans <grknight@gentoo.org>2019-05-09 09:57:38 -0400
commitd77e12134dd5df6bf717799d8eeb256094644c60 (patch)
treea3352a2913ecd5bb95e95bd3e51c50d61fcd6ab6 /dev-php/twig
parentwww-plugins/chrome-binary-plugins: automated update (75.0.3770.27) (diff)
downloadgentoo-d77e12134dd5df6bf717799d8eeb256094644c60.tar.gz
gentoo-d77e12134dd5df6bf717799d8eeb256094644c60.tar.bz2
gentoo-d77e12134dd5df6bf717799d8eeb256094644c60.zip
dev-php/twig: Remove obsolete extension and use new autoloader
The twig extension is no longer necessary as PHP 5.6 is end-of-life Also, use the dev-php/fedora-autoloader to replace Twig's autoloader so that it simulates composer loading with Psr4 and does not throw errors in the logs In addition, the ctype USE on dev-lang/php is now required Package-Manager: Portage-2.3.66, Repoman-2.3.12 Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'dev-php/twig')
-rw-r--r--dev-php/twig/files/Autoloader.php18
-rw-r--r--dev-php/twig/twig-1.40.1-r1.ebuild49
2 files changed, 67 insertions, 0 deletions
diff --git a/dev-php/twig/files/Autoloader.php b/dev-php/twig/files/Autoloader.php
new file mode 100644
index 000000000000..e4bef5471257
--- /dev/null
+++ b/dev-php/twig/files/Autoloader.php
@@ -0,0 +1,18 @@
+<?php
+/* Autoloader for dev-php/twig */
+
+if (!class_exists('Twig_Autoloader', false)) {
+ // polyfill for old code
+ class Twig_Autoloader {
+ public static function register(){}
+ public static function autoload(){}
+ }
+}
+
+if (!class_exists('Fedora\\Autoloader\\Autoload', false)) {
+ require_once '/usr/share/php/Fedora/Autoloader/autoload.php';
+}
+
+\Fedora\Autoloader\Autoload::addPsr0('Twig_', __DIR__.'/lib');
+\Fedora\Autoloader\Autoload::addPsr4('Twig\\', __DIR__.'/src');
+
diff --git a/dev-php/twig/twig-1.40.1-r1.ebuild b/dev-php/twig/twig-1.40.1-r1.ebuild
new file mode 100644
index 000000000000..c06e5c627361
--- /dev/null
+++ b/dev-php/twig/twig-1.40.1-r1.ebuild
@@ -0,0 +1,49 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+MY_PN="Twig"
+S="${WORKDIR}/${MY_PN}-${PV}"
+
+DESCRIPTION="PHP templating engine with syntax similar to Django"
+HOMEPAGE="http://twig.sensiolabs.org/"
+SRC_URI="https://github.com/twigphp/${MY_PN}/archive/v${PV}.tar.gz
+ -> ${P}.tar.gz"
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="doc test"
+
+RDEPEND="dev-lang/php:*[ctype] dev-php/fedora-autoloader"
+DEPEND="test? ( dev-php/phpunit ${RDEPEND} )"
+# Test fail due to missing Symphony dependencies
+RESTRICT="test"
+
+src_install(){
+ # The autoloader requires the 'T' in "Twig" capitalized.
+ insinto "/usr/share/php/${MY_PN}/lib"
+ doins -r lib/"${MY_PN}"/*
+ insinto "/usr/share/php/${MY_PN}/src"
+ doins -r src/*
+ insinto "/usr/share/php/${MY_PN}"
+ doins "${FILESDIR}/Autoloader.php"
+
+ dodoc README.rst CHANGELOG
+
+ # This installs the reStructuredText source documents. There's got
+ # to be some way to turn them into HTML using Sphinx, but upstream
+ # doesn't provide for it.
+ use doc && dodoc -r doc
+}
+
+src_test(){
+ cp "${FILESDIR}/Autoloader.php" "${S}" || die
+ phpunit --bootstrap Autoloader.php || die "test suite failed"
+ rm "${S}/Autoloader.php" || die
+}
+
+pkg_postinst(){
+ elog "${PN} has been installed in /usr/share/php/${MY_PN}/."
+ elog "To use it in a script, require('${MY_PN}/Autoloader.php')"
+}