diff --git a/.buildpath b/.buildpath deleted file mode 100644 index cec864d..0000000 --- a/.buildpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 12ddb65..daa8684 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ | Q | A | ------------- | --- -| Branch? | `master` for new features / `1.1` for fixes +| Branch? | master for new features / 1.2 for fixes | Bug fix? | yes/no | New feature? | yes/no | BC breaks? | yes/no diff --git a/.gitignore b/.gitignore index 9512970..fba26e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ +/.buildpath /.composer/ +/.idea/ +/.php_cs.cache +/.project +/.settings/ /composer.lock /composer.phar /docker-compose.yml @@ -9,3 +14,4 @@ /tests/Feature/app/logs/* !/tests/Feature/app/cache/.gitkeep !/tests/Feature/app/logs/.gitkeep +*.iml diff --git a/.project b/.project deleted file mode 100644 index 536f5c5..0000000 --- a/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - proxy-url-rewrite-bundle - - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.dltk.core.scriptbuilder - - - - - - org.eclipse.php.core.PHPNature - org.eclipse.wst.common.project.facet.core.nature - - diff --git a/.settings/com.piece_framework.makegood.core.prefs b/.settings/com.piece_framework.makegood.core.prefs deleted file mode 100644 index 5e68a39..0000000 --- a/.settings/com.piece_framework.makegood.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -phpunit_config_file= -preload_script=/proxy-url-rewrite-bundle/tests/bootstrap.php -test_file_pattern= -test_folders=/proxy-url-rewrite-bundle/tests -testing_framework=PHPUnit diff --git a/.settings/org.eclipse.php.core.prefs b/.settings/org.eclipse.php.core.prefs deleted file mode 100644 index 5f7d896..0000000 --- a/.settings/org.eclipse.php.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -include_path= diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index ad32966..0000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.travis.yml b/.travis.yml index 3385399..2bd4887 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,16 +7,14 @@ cache: - $HOME/.composer/cache php: - - 5.3 - 5.4 - 5.5 - 5.6 - 7.0 - - hhvm + - 7.1 + - 7.2 matrix: - allow_failures: - - php: hhvm fast_finish: true before_script: diff --git a/composer.json b/composer.json index 0deaf1c..0cace9e 100644 --- a/composer.json +++ b/composer.json @@ -13,20 +13,21 @@ "require": { "php": ">=5.3.9", "phpmentors/domain-kata": "~1.4", - "symfony/config": "~2.8", - "symfony/dependency-injection": "~2.8", - "symfony/framework-bundle": "~2.8", - "symfony/http-kernel": "~2.8", - "symfony/routing": "~2.8" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~2.8|~3.0|~4.0", + "symfony/framework-bundle": "~2.8|~3.0|~4.0", + "symfony/http-kernel": "~2.8|~3.0|~4.0", + "symfony/routing": "~2.8|~3.0|~4.0", + "symfony/templating": "~2.8|~3.0|~4.0" }, "require-dev": { "phpunit/phpunit": "~4.0", - "symfony/asset": "~2.8", - "symfony/browser-kit": "~2.8", - "symfony/filesystem": "~2.8", - "symfony/http-foundation": "~2.8", - "symfony/twig-bridge": "~2.8", - "symfony/twig-bundle": "~2.8" + "symfony/asset": "~2.8|~3.0|~4.0", + "symfony/browser-kit": "~2.8|~3.0|~4.0", + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0", + "symfony/twig-bridge": "~2.8|~3.0|~4.0", + "symfony/twig-bundle": "~2.8|~3.0|~4.0" }, "autoload": { "psr-4": { diff --git a/docker-compose.yml.dist b/docker-compose.yml.dist index 894ad47..3a6582b 100644 --- a/docker-compose.yml.dist +++ b/docker-compose.yml.dist @@ -2,11 +2,11 @@ version: '2' services: app: container_name: "phpmentors.proxy-url-rewrite-bundle.app" - image: "phpmentors/php-app:php55" + image: "phpmentors/php-app:php53" volumes: - ".:/var/app" environment: TERM: "xterm" TZ: "Asia/Tokyo" LANG: "ja_JP.UTF-8" - PHP_INI: "docker/php.ini" +# PHP_INI: "docker/php.ini" diff --git a/docker/php.ini.dist b/docker/php.ini.dist index 438e687..258e69a 100644 --- a/docker/php.ini.dist +++ b/docker/php.ini.dist @@ -1,3 +1,4 @@ +;memory_limit=256M ;xdebug.remote_autostart=on -;xdebug.remote_port=9100 +;xdebug.remote_port=9000 ;xdebug.remote_host=172.17.0.1 diff --git a/src/DependencyInjection/Compiler/ReplaceAssetExtensionAndPakcagesDefinitionPass.php b/src/DependencyInjection/Compiler/ReplaceAssetExtensionAndPakcagesDefinitionPass.php index 2b204eb..11b9078 100644 --- a/src/DependencyInjection/Compiler/ReplaceAssetExtensionAndPakcagesDefinitionPass.php +++ b/src/DependencyInjection/Compiler/ReplaceAssetExtensionAndPakcagesDefinitionPass.php @@ -23,9 +23,6 @@ class ReplaceAssetExtensionAndPakcagesDefinitionPass implements CompilerPassInte public function process(ContainerBuilder $container) { if ($container->hasDefinition('twig.extension.assets') && $container->hasDefinition('assets.packages')) { - $container->getDefinition('phpmentors_proxy_url_rewrite.proxy_asset_extension')->setArguments($container->getDefinition('twig.extension.assets')->getArguments()); - $container->setAlias('twig.extension.assets', 'phpmentors_proxy_url_rewrite.proxy_asset_extension'); - $container->getDefinition('phpmentors_proxy_url_rewrite.proxy_packages')->setArguments($container->getDefinition('assets.packages')->getArguments()); $container->setAlias('assets.packages', 'phpmentors_proxy_url_rewrite.proxy_packages'); } diff --git a/src/DependencyInjection/PHPMentorsProxyURLRewriteExtension.php b/src/DependencyInjection/PHPMentorsProxyURLRewriteExtension.php index 826f0a6..fdfc83e 100644 --- a/src/DependencyInjection/PHPMentorsProxyURLRewriteExtension.php +++ b/src/DependencyInjection/PHPMentorsProxyURLRewriteExtension.php @@ -14,7 +14,6 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -50,7 +49,13 @@ private function transformConfigToContainer(array $config, ContainerBuilder $con { if ($config['enabled']) { foreach ($config['proxy_urls'] as $id => $proxyUrl) { - $definition = new DefinitionDecorator('phpmentors_proxy_url_rewrite.proxy_url'); + if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) { + $definitionClass = 'Symfony\Component\DependencyInjection\ChildDefinition'; + } else { + $definitionClass = 'Symfony\Component\DependencyInjection\DefinitionDecorator'; + } + + $definition = new $definitionClass('phpmentors_proxy_url_rewrite.proxy_url'); $definition->setArguments(array($id, $proxyUrl['path'], $proxyUrl['proxy_url'], $proxyUrl['proxy_host_filter_service'] === null ? null : new Reference($proxyUrl['proxy_host_filter_service']))); $serviceId = 'phpmentors_proxy_url_rewrite.proxy_url.'.sha1($id); diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 0da468e..fd0ab31 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -1,7 +1,6 @@ - PHPMentors\ProxyURLRewriteBundle\Templating\ProxyAssetExtension PHPMentors\ProxyURLRewriteBundle\Asset\ProxyPackages PHPMentors\ProxyURLRewriteBundle\ProxyUrl\ProxyUrl PHPMentors\ProxyURLRewriteBundle\ProxyUrl\ProxyUrlCollection @@ -15,7 +14,6 @@ - diff --git a/src/Templating/ProxyAssetExtension.php b/src/Templating/ProxyAssetExtension.php deleted file mode 100644 index b093265..0000000 --- a/src/Templating/ProxyAssetExtension.php +++ /dev/null @@ -1,29 +0,0 @@ -, - * All rights reserved. - * - * This file is part of PHPMentorsProxyURLRewriteBundle. - * - * This program and the accompanying materials are made available under - * the terms of the BSD 2-Clause License which accompanies this - * distribution, and is available at http://opensource.org/licenses/BSD-2-Clause - */ - -namespace PHPMentors\ProxyURLRewriteBundle\Templating; - -use Symfony\Bridge\Twig\Extension\AssetExtension; - -/** - * @since Class available since Release 1.1.0 - */ -class ProxyAssetExtension extends AssetExtension -{ - /** - * {@inheritdoc} - */ - public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null) - { - return parent::getAssetUrl(sprintf('absolute=%s'.$path, $absolute ? '1' : '0'), $packageName, $absolute, $version); - } -} diff --git a/tests/Functional/Bundle/TestBundle/Resources/views/UrlRewritingInTemplates/index.html.twig b/tests/Functional/Bundle/TestBundle/Resources/views/UrlRewritingInTemplates/index.html.twig index 4d4013a..af0e90f 100644 --- a/tests/Functional/Bundle/TestBundle/Resources/views/UrlRewritingInTemplates/index.html.twig +++ b/tests/Functional/Bundle/TestBundle/Resources/views/UrlRewritingInTemplates/index.html.twig @@ -4,5 +4,5 @@ {% block body %}
{{ referenceType }}
-
{{ asset('/bundles/test/foo.png', null, referenceType) }}
+
{{ asset('/bundles/test/foo.png') }}
{% endblock %} diff --git a/tests/Functional/HostFilterTest.php b/tests/Functional/HostFilterTest.php index 950df21..47f5ece 100644 --- a/tests/Functional/HostFilterTest.php +++ b/tests/Functional/HostFilterTest.php @@ -31,7 +31,8 @@ protected function setUp() parent::setUp(); $_SERVER['KERNEL_DIR'] = __DIR__.'/app'; - $_SERVER['SYMFONY__SECRET'] = hash('sha1', uniqid(mt_rand())); + require_once $_SERVER['KERNEL_DIR'].'/AppKernel.php'; + $_SERVER['KERNEL_CLASS'] = 'AppKernel'; $this->removeCacheDir(); } @@ -100,6 +101,9 @@ public function filter($proxyUrl, $proxyHostFilterService, $rewroteUrl) $config['proxy_host_filter_service'] = 'phpmentors_proxy_url_rewrite_test.proxy_host_filter'; } + $container->loadFromExtension('framework', array( + 'secret' => '$ecret', + )); $container->loadFromExtension('phpmentors_proxy_url_rewrite', array( 'proxy_urls' => array( 'foo' => $config, diff --git a/tests/Functional/UrlRewritingInControllersTest.php b/tests/Functional/UrlRewritingInControllersTest.php index 721cf35..0f10867 100644 --- a/tests/Functional/UrlRewritingInControllersTest.php +++ b/tests/Functional/UrlRewritingInControllersTest.php @@ -28,7 +28,8 @@ protected function setUp() parent::setUp(); $_SERVER['KERNEL_DIR'] = __DIR__.'/app'; - $_SERVER['SYMFONY__SECRET'] = hash('sha1', uniqid(mt_rand())); + require_once $_SERVER['KERNEL_DIR'].'/AppKernel.php'; + $_SERVER['KERNEL_CLASS'] = 'AppKernel'; $this->removeCacheDir(); } @@ -66,19 +67,14 @@ public function rewriteUrlInGenerateUrlData() { return array( array('/foo/bar/', UrlGeneratorInterface::ABSOLUTE_PATH, '/foo/bar/url-rewriting-in-controllers/'), - array('/foo/bar/', UrlGeneratorInterface::ABSOLUTE_URL, 'http://backend1.example.com/foo/bar/url-rewriting-in-controllers/'), array('/foo/bar/', UrlGeneratorInterface::NETWORK_PATH, '//backend1.example.com/foo/bar/url-rewriting-in-controllers/'), array('//example.com/foo/bar/', UrlGeneratorInterface::ABSOLUTE_PATH, '/foo/bar/url-rewriting-in-controllers/'), - array('//example.com/foo/bar/', UrlGeneratorInterface::ABSOLUTE_URL, 'http://example.com/foo/bar/url-rewriting-in-controllers/'), array('//example.com/foo/bar/', UrlGeneratorInterface::NETWORK_PATH, '//example.com/foo/bar/url-rewriting-in-controllers/'), array('http://example.com/foo/bar/', UrlGeneratorInterface::ABSOLUTE_PATH, '/foo/bar/url-rewriting-in-controllers/'), - array('http://example.com/foo/bar/', UrlGeneratorInterface::ABSOLUTE_URL, 'http://example.com/foo/bar/url-rewriting-in-controllers/'), array('http://example.com/foo/bar/', UrlGeneratorInterface::NETWORK_PATH, '//example.com/foo/bar/url-rewriting-in-controllers/'), array('https://example.com/foo/bar/', UrlGeneratorInterface::ABSOLUTE_PATH, '/foo/bar/url-rewriting-in-controllers/'), - array('https://example.com/foo/bar/', UrlGeneratorInterface::ABSOLUTE_URL, 'https://example.com/foo/bar/url-rewriting-in-controllers/'), array('https://example.com/foo/bar/', UrlGeneratorInterface::NETWORK_PATH, '//example.com/foo/bar/url-rewriting-in-controllers/'), array('http://example.com:8180/foo/bar/', UrlGeneratorInterface::ABSOLUTE_PATH, '/foo/bar/url-rewriting-in-controllers/'), - array('http://example.com:8180/foo/bar/', UrlGeneratorInterface::ABSOLUTE_URL, 'http://example.com:8180/foo/bar/url-rewriting-in-controllers/'), array('http://example.com:8180/foo/bar/', UrlGeneratorInterface::NETWORK_PATH, '//example.com:8180/foo/bar/url-rewriting-in-controllers/'), ); } @@ -90,6 +86,9 @@ public function rewriteUrlInGenerateUrlData() public function rewriteUrlInGenerateUrl($proxyUrl, $referenceType, $rewroteUrl) { $client = $this->createClient(array('config' => function (ContainerBuilder $container) use ($proxyUrl) { + $container->loadFromExtension('framework', array( + 'secret' => '$ecret', + )); $container->loadFromExtension('phpmentors_proxy_url_rewrite', array( 'proxy_urls' => array( 'foo' => array( diff --git a/tests/Functional/UrlRewritingInTemplatesTest.php b/tests/Functional/UrlRewritingInTemplatesTest.php index d92d858..22efad6 100644 --- a/tests/Functional/UrlRewritingInTemplatesTest.php +++ b/tests/Functional/UrlRewritingInTemplatesTest.php @@ -27,7 +27,8 @@ protected function setUp() parent::setUp(); $_SERVER['KERNEL_DIR'] = __DIR__.'/app'; - $_SERVER['SYMFONY__SECRET'] = hash('sha1', uniqid(mt_rand())); + require_once $_SERVER['KERNEL_DIR'].'/AppKernel.php'; + $_SERVER['KERNEL_CLASS'] = 'AppKernel'; $this->removeCacheDir(); } @@ -67,17 +68,12 @@ protected function removeCacheDir() public function rewriteUrlInAssetData() { return array( - array('/foo/bar/', false, '/foo/bar/bundles/test/foo.png'), - array('//example.com/foo/bar/', false, '/foo/bar/bundles/test/foo.png'), - array('//example.com/foo/bar/', true, 'http://example.com/foo/bar/bundles/test/foo.png'), - array('http://example.com/foo/bar/', false, '/foo/bar/bundles/test/foo.png'), - array('http://example.com/foo/bar/', true, 'http://example.com/foo/bar/bundles/test/foo.png'), - array('https://example.com/foo/bar/', false, '/foo/bar/bundles/test/foo.png'), - array('https://example.com/foo/bar/', true, 'https://example.com/foo/bar/bundles/test/foo.png'), - array('http://example.com:8180/foo/bar/', false, '/foo/bar/bundles/test/foo.png'), - array('http://example.com:8180/foo/bar/', true, 'http://example.com:8180/foo/bar/bundles/test/foo.png'), - array('https://example.com:8180/foo/bar/', false, '/foo/bar/bundles/test/foo.png'), - array('https://example.com:8180/foo/bar/', true, 'https://example.com:8180/foo/bar/bundles/test/foo.png'), + array('/foo/bar/', '/foo/bar/bundles/test/foo.png'), + array('//example.com/foo/bar/', '/foo/bar/bundles/test/foo.png'), + array('http://example.com/foo/bar/', '/foo/bar/bundles/test/foo.png'), + array('https://example.com/foo/bar/', '/foo/bar/bundles/test/foo.png'), + array('http://example.com:8180/foo/bar/', '/foo/bar/bundles/test/foo.png'), + array('https://example.com:8180/foo/bar/', '/foo/bar/bundles/test/foo.png'), ); } @@ -85,9 +81,12 @@ public function rewriteUrlInAssetData() * @test * @dataProvider rewriteUrlInAssetData */ - public function rewriteUrlInAsset($proxyUrl, $referenceType, $rewroteUrl) + public function rewriteUrlInAsset($proxyUrl, $rewroteUrl) { $client = $this->createClient(array('config' => function (ContainerBuilder $container) use ($proxyUrl) { + $container->loadFromExtension('framework', array( + 'secret' => '$ecret', + )); $container->loadFromExtension('phpmentors_proxy_url_rewrite', array( 'proxy_urls' => array( 'foo' => array( @@ -98,7 +97,7 @@ public function rewriteUrlInAsset($proxyUrl, $referenceType, $rewroteUrl) )); })); - $client->request('GET', sprintf('http://backend1.example.com:8080/url-rewriting-in-templates/?referenceType=%s', $referenceType)); + $client->request('GET', 'http://backend1.example.com:8080/url-rewriting-in-templates/'); $this->assertThat($client->getResponse()->getStatusCode(), $this->equalTo(200), $client->getResponse()->getContent()); $this->assertThat($client->getCrawler()->filterXpath("//*[@id='asset']")->text(), $this->equalTo($rewroteUrl)); diff --git a/tests/Functional/app/config/config.yml b/tests/Functional/app/config/config.yml index b0b39d0..355acbd 100644 --- a/tests/Functional/app/config/config.yml +++ b/tests/Functional/app/config/config.yml @@ -2,7 +2,6 @@ imports: - { resource: services.yml } framework: - secret: "%secret%" router: resource: "%kernel.root_dir%/config/routing.yml" templating: