本文整理汇总了PHP中AppKernel类的典型用法代码示例。如果您正苦于以下问题:PHP AppKernel类的具体用法?PHP AppKernel怎么用?PHP AppKernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppKernel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$kernel = new \AppKernel('test', true);
$kernel->boot();
$this->container = $kernel->getContainer();
$this->service = $this->container->get('dugun_upload.service.upload_service');
}
示例2: __construct
public function __construct()
{
$kernel = new AppKernel('test', true);
$kernel->boot();
$this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
$this->kernel = $kernel;
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$environments = explode(',', $input->getArgument('environments'));
$table = (new Table($output))->setHeaders(['env', 'key', 'value']);
foreach ($environments as $key => $environment) {
if ($key > 0) {
$table->addRow(new TableSeparator());
}
$environmentKernel = new \AppKernel($environment, false);
$environmentKernel->initializeWithoutCaching();
foreach ($environmentKernel->getContainer()->getParameterBag()->all() as $parameter => $value) {
if ($input->getOption('filter') !== null) {
$pattern = sprintf('~%s~', $input->getOption('filter'));
if (!preg_match($pattern, $parameter)) {
continue;
}
}
if (is_array($value)) {
$value = json_encode($value);
}
$table->addRow([$environment, $parameter, $value]);
}
}
$table->render();
}
示例4: setUp
protected function setUp()
{
$kernel = new \AppKernel('test', true);
$kernel->boot();
$this->container = $kernel->getContainer();
$this->youtube = $this->container->get('awy.google.youtube');
}
示例5: process
/**
* @param AppKernel $kernel
* @param \Zero\Component\Kernel\Container $app_container
* @throws \Exception
*/
public static function process(AppKernel $kernel, $app_container)
{
global $argv;
if (!isset($argv[1])) {
throw new \Exception("命令行第一个参数应该是需要调用的方法");
}
$controller = $argv[1];
if (strpos($controller, ':') === false) {
throw new \Exception("第一个参数错误,格式应该为<module_name>:<command_name>:<action_name>");
}
$arguments = array_splice($argv, 2);
try {
list($module_name, $command_name, $action_name) = explode(':', $controller);
$module = $kernel->getModule($module_name);
$command = $module->getCommand($command_name, $action_name);
if (method_exists($command, '__invoke')) {
/** @var \Symfony\Component\HttpFoundation\Response $response */
call_user_func_array($command, $arguments);
} else {
throw new \Exception('Command must has the __invoke public function!');
}
} catch (\Exception $e) {
throw $e;
}
}
示例6: loadSf2
private function loadSf2()
{
global $kernel;
//@settings_fields('wp_symfony_settings');
//@do_settings_fields('wp_symfony_settings');
$path = get_option('symfony2_path');
$env = get_option('symfony2_env');
$url = get_option('symfony2_url');
if (!$this->isValidSymfonyPath($path)) {
add_action('admin_footer', array($this, 'symfony2_warning'));
return;
}
if ($kernel == null) {
$loader = (require_once $path . 'app/bootstrap.php.cache');
require_once $path . 'app/AppKernel.php';
$kernel = new AppKernel($env, true);
$kernel->loadClassCache();
$kernel->boot();
$this->kernel = $kernel;
$this->container = $kernel->getContainer();
if ($this->container->get('session')->isStarted() == false) {
$this->container->get('session')->start();
}
if ($url != null) {
$this->overloadUrlContext($url);
}
} else {
$this->kernel = $kernel;
$this->container = $kernel->getContainer();
}
$wp_loader = $this->container->get('wordpress.loader');
$wp_loader->load();
}
示例7: __construct
public function __construct()
{
$kernel = new \AppKernel("test", true);
$kernel->boot();
$this->container = $kernel->getContainer();
parent::__construct();
}
示例8: bootstrapApplication
protected static function bootstrapApplication()
{
$kernel = new \AppKernel(static::$environment, static::$debug);
$kernel->boot();
static::$application = new Application($kernel);
static::$application->setAutoExit(false);
}
示例9: prepend
/**
* @param ContainerBuilder $container
*
* @return void
*/
public function prepend(ContainerBuilder $container)
{
// Build fos_elastica config for each widget
$elasticaConfig = [];
$kernel = new \AppKernel('prod', false);
$yamlParser = new Yaml();
foreach ($kernel->registerBundles() as $bundle) {
/* @var Bundle $bundle */
$path = $bundle->getPath();
//If bundle is a widget
if (0 === strpos($bundle->getNamespace(), 'Victoire\\Widget\\')) {
//find for a fos_elastica.yml config file
$widgetConfig = $yamlParser->parse($path . '/Resources/config/config.yml');
if (is_array($widgetConfig)) {
foreach ($widgetConfig['victoire_core']['widgets'] as $_widgetConfig) {
if (array_key_exists('fos_elastica', $widgetConfig)) {
$_config = ['indexes' => ['widgets' => ['types' => [$_widgetConfig['name'] => ['serializer' => ['groups' => ['search']], 'mappings' => [], 'persistence' => ['driver' => 'orm', 'model' => $_widgetConfig['class'], 'provider' => [], 'listener' => [], 'finder' => []]]]]]];
$_config = array_merge_recursive($widgetConfig['fos_elastica'], $_config);
$elasticaConfig = array_merge_recursive($elasticaConfig, $_config);
}
}
}
}
}
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'fos_elastica':
$container->prependExtensionConfig($name, $elasticaConfig);
break;
}
}
}
示例10: __construct
public function __construct()
{
$kernel = new \AppKernel("test", true);
$kernel->boot();
$this->_container = $kernel->getContainer();
$this->searchEngine = $this->get('beecms.search.service');
}
示例11: setUpBeforeClass
public static function setUpBeforeClass()
{
@unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
@unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/CarController.php');
@unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/OrderController.php');
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(new GenerateRestControllerCommand()));
$kernel->boot();
$command = $app->find('generate:rest:controller');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Order', '--entity' => 'TestTestBundle:Order', '--mongo' => true), array('interactive' => false));
$kernel->shutdown();
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(new GenerateRestControllerCommand()));
$kernel->boot();
$command = $app->find('generate:rest:controller');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Car', '--entity' => 'TestTestBundle:Car'), array('interactive' => false));
$kernel->shutdown();
@unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php.meta');
@unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php');
@unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php.meta');
@unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php');
}
示例12: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$loader->load('forms.yml');
// We instanciate a new kernel and iterate on all it's bundles to load the victoire_core configs
$kernel = new \AppKernel('prod', false);
foreach ($kernel->registerBundles() as $bundle) {
$path = $bundle->getPath();
$yamlParser = new Yaml($container, $path . '/Resources/config/config.yml');
$victoireConfig = $yamlParser->parse($path . '/Resources/config/config.yml');
if (is_array($victoireConfig) && array_key_exists('victoire_core', $victoireConfig)) {
$config['widgets'] = array_merge($config['widgets'], $victoireConfig['victoire_core']['widgets'] ?: []);
}
}
$container->setParameter('victoire_core.cache_dir', $config['cache_dir']);
$container->setParameter('victoire_core.business_entity_debug', $config['business_entity_debug']);
if (array_key_exists('templates', $config)) {
$container->setParameter('victoire_core.templates', $config['templates']);
} else {
$container->setParameter('victoire_core.templates', '');
}
$container->setParameter('victoire_core.widgets', $config['widgets']);
$container->setParameter('victoire_core.layouts', $config['layouts']);
$container->setParameter('victoire_core.slots', $config['slots']);
$container->setParameter('victoire_core.user_class', $config['user_class']);
$container->setParameter('victoire_core.base_paths', $config['base_paths']);
$container->setParameter('victoire_core.base_paths', $config['base_paths']);
$container->setParameter('victoire_core.businessTemplates', $config['businessTemplates']);
}
示例13: buildKernel
private function buildKernel()
{
require_once __DIR__ . "/../../../../../app/AppKernel.php";
$kernel = new \AppKernel("test", true);
$kernel->boot();
return $kernel;
}
示例14: setUp
protected function setUp()
{
$kernel = new \AppKernel('test', false);
$kernel->boot();
$this->articleRepository = $kernel->getContainer()->get('app.article_repository');
$this->queryBus = $kernel->getContainer()->get('gnugat_query_bus.query_bus');
}
示例15: setUpBeforeClass
public static function setUpBeforeClass()
{
require_once "{$_SERVER['KERNEL_DIR']}/AppKernel.php";
$kernel = new \AppKernel('test', true);
$kernel->boot();
self::$validator = $kernel->getContainer()->get('validator');
}