mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Sylius] Clean up application kernels, front controllers and autoloading
This commit is contained in:
parent
5e4fa3b79a
commit
5dace4c289
12 changed files with 62 additions and 73 deletions
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Kernel\Kernel;
|
||||
|
||||
/**
|
||||
* Sylius application kernel.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
*/
|
||||
class AppKernel extends Kernel
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function registerBundles()
|
||||
{
|
||||
$bundles = array(
|
||||
// Put here your own bundles!
|
||||
);
|
||||
|
||||
if (in_array($this->environment, array('dev', 'test'))) {
|
||||
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
|
||||
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
|
||||
}
|
||||
|
||||
return array_merge(parent::registerBundles(), $bundles);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,10 +9,10 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__.'/AppKernel.php';
|
||||
namespace Sylius\Application;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
|
||||
|
||||
class AppCache extends HttpCache
|
||||
class Cache extends HttpCache
|
||||
{
|
||||
}
|
||||
|
|
@ -9,17 +9,17 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Kernel;
|
||||
namespace Sylius\Application;
|
||||
|
||||
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\HttpKernel\Kernel as HttpKernel;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
||||
*/
|
||||
abstract class Kernel extends BaseKernel
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
const VERSION = '0.19.0-dev';
|
||||
const VERSION_ID = '00190';
|
||||
|
|
@ -31,7 +31,7 @@ abstract class Kernel extends BaseKernel
|
|||
const ENV_DEV = 'dev';
|
||||
const ENV_PROD = 'prod';
|
||||
const ENV_TEST = 'test';
|
||||
const ENV_STAGING = 'staging';
|
||||
const ENV_TEST_CACHED = 'test_cached';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -122,6 +122,11 @@ abstract class Kernel extends BaseKernel
|
|||
new \Sylius\Bundle\ThemeBundle\SyliusThemeBundle(), // must be added after FrameworkBundle
|
||||
];
|
||||
|
||||
if (in_array($this->environment, array('dev', 'test'))) {
|
||||
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
|
||||
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
|
||||
}
|
||||
|
||||
return $bundles;
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +1,17 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Application;
|
||||
|
||||
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
|
||||
use Sylius\Bundle\CoreBundle\Kernel\Kernel;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -18,7 +28,7 @@ class TestKernel extends Kernel
|
|||
return;
|
||||
}
|
||||
|
||||
if (!in_array($this->environment, ['test', 'test_cached'])) {
|
||||
if (!in_array($this->environment, ['test', 'test_cached'], true)) {
|
||||
parent::shutdown();
|
||||
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@
|
|||
set_time_limit(0);
|
||||
|
||||
require_once __DIR__.'/bootstrap.php.cache';
|
||||
require_once __DIR__.'/AppKernel.php';
|
||||
require_once __DIR__.'/Kernel.php';
|
||||
|
||||
use Sylius\Application\Kernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
|
|
@ -22,5 +23,5 @@ $input = new ArgvInput();
|
|||
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
|
||||
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'live';
|
||||
|
||||
$application = new Application(new AppKernel($env, $debug));
|
||||
$application = new Application(new Kernel($env, $debug));
|
||||
$application->run($input);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,16 @@
|
|||
]
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Sylius\\": "src/" }
|
||||
"psr-4": {
|
||||
"Sylius\\Application\\": "app/",
|
||||
"Sylius\\Bundle\\": "src/Sylius/Bundle/",
|
||||
"Sylius\\Component\\": "src/Sylius/Component/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Sylius\\Behat\\": "src/Sylius/Behat/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
|
|
@ -202,8 +211,7 @@
|
|||
"dev-master": "0.19-dev"
|
||||
},
|
||||
"incenteev-parameters": {
|
||||
"file": "app/config/parameters.yml",
|
||||
"dist-file": "src/Sylius/Bundle/CoreBundle/Resources/config/app/parameters.yml.dist"
|
||||
"file": "app/config/parameters.yml"
|
||||
},
|
||||
"symfony-app-dir": "app",
|
||||
"symfony-web-dir": "web"
|
||||
|
|
|
|||
4
composer.lock
generated
4
composer.lock
generated
|
|
@ -4,8 +4,8 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "7175e59136873dd4de99cf15d6853591",
|
||||
"content-hash": "b63518d975ea95502497a6d379f015d5",
|
||||
"hash": "31a1a37000f512377d205db0158cd612",
|
||||
"content-hash": "d4896dae3b6edf958e5908676687e8e2",
|
||||
"packages": [
|
||||
{
|
||||
"name": "behat/transliterator",
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ suites:
|
|||
UserBundle: { namespace: Sylius\Bundle\UserBundle, psr4_prefix: Sylius\Bundle\UserBundle, spec_path: src/Sylius/Bundle/UserBundle, src_path: src/Sylius/Bundle/UserBundle }
|
||||
VariationBundle: { namespace: Sylius\Bundle\VariationBundle, psr4_prefix: Sylius\Bundle\VariationBundle, spec_path: src/Sylius/Bundle/VariationBundle, src_path: src/Sylius/Bundle/VariationBundle }
|
||||
|
||||
SyliusBehat: { namespace: Sylius\Behat, psr4_prefix: Sylius\Behat, spec_path: src/Sylius/Behat, src_path: src/Sylius/Behat }
|
||||
Behat: { namespace: Sylius\Behat, psr4_prefix: Sylius\Behat, spec_path: src/Sylius/Behat, src_path: src/Sylius/Behat }
|
||||
|
||||
extensions:
|
||||
- Akeneo\SkipExampleExtension
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\ClassLoader\ApcClassLoader;
|
||||
use Sylius\Application\Kernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/*
|
||||
|
|
@ -18,9 +18,9 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
*/
|
||||
|
||||
require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
require_once __DIR__.'/../app/AppKernel.php';
|
||||
require_once __DIR__.'/../app/Kernel.php';
|
||||
|
||||
$kernel = new AppKernel('prod', false);
|
||||
$kernel = new Kernel('prod', false);
|
||||
$kernel->loadClassCache();
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Sylius\Application\Kernel;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
* Sylius front controller.
|
||||
* Dev environment.
|
||||
*
|
||||
* To develop on Sylius in vagrant set the SYLIUS_APP_DEV_PERMITTED to a non zero value.
|
||||
* To develop on Sylius in Vagrant set the SYLIUS_APP_DEV_PERMITTED to a non zero value.
|
||||
* e.g. in apache, through your vhost configuration file:
|
||||
*
|
||||
* SetEnv SYLIUS_APP_DEV_PERMITTED 1
|
||||
|
|
@ -24,19 +25,18 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
if (!getenv("SYLIUS_APP_DEV_PERMITTED") && (
|
||||
isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1', '113.0.0.1'))
|
||||
|| php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
)) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
}
|
||||
|
||||
require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
require_once __DIR__.'/../app/Kernel.php';
|
||||
|
||||
Debug::enable();
|
||||
|
||||
require_once __DIR__.'/../app/AppKernel.php';
|
||||
|
||||
$kernel = new AppKernel('dev', true);
|
||||
$kernel = new Kernel('dev', true);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Sylius\Application\Kernel;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/*
|
||||
|
|
@ -18,18 +20,18 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1', '113.0.0.1'))
|
||||
|| php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
}
|
||||
|
||||
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
require_once __DIR__.'/../app/Kernel.php';
|
||||
|
||||
require_once __DIR__.'/../app/AppKernel.php';
|
||||
Debug::enable();
|
||||
|
||||
$kernel = new AppKernel('test', true);
|
||||
$kernel = new Kernel('test', true);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Sylius\Application\Kernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/*
|
||||
|
|
@ -18,18 +19,16 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1', '113.0.0.1'))
|
||||
|| php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
}
|
||||
|
||||
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
require_once __DIR__.'/../app/Kernel.php';
|
||||
|
||||
require_once __DIR__.'/../app/AppKernel.php';
|
||||
|
||||
$kernel = new AppKernel('test_cached', false);
|
||||
$kernel = new Kernel('test_cached', false);
|
||||
$kernel->loadClassCache();
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue