当前位置: 首页>>代码示例>>PHP>>正文


PHP System::setContainer方法代码示例

本文整理汇总了PHP中Contao\System::setContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP System::setContainer方法的具体用法?PHP System::setContainer怎么用?PHP System::setContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contao\System的用法示例。


在下文中一共展示了System::setContainer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runTests

 /**
  * Runs the actual tests.
  */
 protected function runTests()
 {
     // Environment::get('ip') needs the request stack
     System::setContainer($this->mockContainerWithContaoScopes());
     $agent = Environment::get('agent');
     $this->assertEquals('mac', $agent->os);
     $this->assertEquals('mac chrome webkit ch33', $agent->class);
     $this->assertEquals('chrome', $agent->browser);
     $this->assertEquals('ch', $agent->shorty);
     $this->assertEquals(33, $agent->version);
     $this->assertEquals('webkit', $agent->engine);
     $this->assertEquals([33, 0, 1750, 149], $agent->versions);
     $this->assertFalse($agent->mobile);
     $this->assertEquals('HTTP/1.1', Environment::get('serverProtocol'));
     $this->assertEquals($this->getRootDir() . '/core/index.php', Environment::get('scriptFilename'));
     $this->assertEquals('/core/index.php', Environment::get('scriptName'));
     $this->assertEquals($this->getRootDir(), Environment::get('documentRoot'));
     $this->assertEquals('/core/en/academy.html?do=test', Environment::get('requestUri'));
     $this->assertEquals(['de-DE', 'de', 'en-GB', 'en'], Environment::get('httpAcceptLanguage'));
     $this->assertEquals(['gzip', 'deflate', 'sdch'], Environment::get('httpAcceptEncoding'));
     $this->assertEquals('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36', Environment::get('httpUserAgent'));
     $this->assertEquals('localhost', Environment::get('httpHost'));
     $this->assertEmpty(Environment::get('httpXForwardedHost'));
     $this->assertFalse(Environment::get('ssl'));
     $this->assertEquals('http://localhost', Environment::get('url'));
     $this->assertEquals('http://localhost/core/en/academy.html?do=test', Environment::get('uri'));
     $this->assertEquals('123.456.789.0', Environment::get('ip'));
     $this->assertEquals('127.0.0.1', Environment::get('server'));
     $this->assertEquals('index.php', Environment::get('script'));
     $this->assertEquals('en/academy.html?do=test', Environment::get('request'));
     $this->assertEquals('en/academy.html?do=test', Environment::get('indexFreeRequest'));
     $this->assertEquals('http://localhost' . Environment::get('path') . '/', Environment::get('base'));
     $this->assertFalse(Environment::get('isAjaxRequest'));
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:37,代码来源:EnvironmentTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     System::setContainer($this->mockContainerWithContaoScopes());
     require_once __DIR__ . '/../../src/Resources/contao/config/config.php';
     $this->connection = $this->getMock('Doctrine\\DBAL\\Connection', ['fetchAll'], [], '', false);
     $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->imageSizes = new ImageSizes($this->connection, $this->eventDispatcher, $this->mockContaoFramework());
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:11,代码来源:ImageSizesTest.php

示例3: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     copy(__DIR__ . '/../Fixtures/images/dummy.jpg', self::$rootDir . '/dummy.jpg');
     $GLOBALS['TL_CONFIG']['debugMode'] = false;
     $GLOBALS['TL_CONFIG']['gdMaxImgWidth'] = 3000;
     $GLOBALS['TL_CONFIG']['gdMaxImgHeight'] = 3000;
     $GLOBALS['TL_CONFIG']['validImageTypes'] = 'jpeg,jpg,svg,svgz';
     define('TL_ERROR', 'ERROR');
     define('TL_ROOT', self::$rootDir);
     System::setContainer($this->mockContainerWithContaoScopes());
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:15,代码来源:ImageTest.php

示例4: initializeFramework

 /**
  * Initializes the framework.
  */
 private function initializeFramework()
 {
     // Set the error_reporting level
     error_reporting($this->errorLevel);
     $this->includeHelpers();
     // TODO: use Monolog to log errors
     $this->iniSet('error_log', $this->rootDir . '/system/logs/error.log');
     $this->includeBasicClasses();
     // Set the container
     System::setContainer($this->container);
     // Preload the configuration (see #5872)
     $this->config->preload();
     // Register the class loader
     ClassLoader::scanAndRegister();
     $this->initializeLegacySessionAccess();
     $this->setDefaultLanguage();
     // Fully load the configuration
     $this->config->initialize();
     $this->validateInstallation();
     Input::initialize();
     $this->setTimezone();
     // Set the mbstring encoding
     if (USE_MBSTRING && function_exists('mb_regex_encoding')) {
         mb_regex_encoding($this->config->get('characterSet'));
     }
     $this->triggerInitializeSystemHook();
     $this->handleRequestToken();
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:31,代码来源:ContaoFramework.php

示例5: bootHelperSystem

 /**
  * Boots the helper system.
  */
 private function bootHelperSystem()
 {
     $contaoDir = $this->getRootDir() . '/../vendor/contao/core-bundle';
     require_once $contaoDir . '/src/Resources/contao/config/constants.php';
     require_once $contaoDir . '/src/Resources/contao/helper/functions.php';
     // Register the class loader
     $libraryLoader = new LibraryLoader($this->getRootDir());
     $libraryLoader->register();
     Config::preload();
     // Create the container
     $this->container = ContainerFactory::create($this);
     System::setContainer($this->container);
     ClassLoader::scanAndRegister();
 }
开发者ID:burguin,项目名称:test02,代码行数:17,代码来源:InstallationKernel.php

示例6: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     System::setContainer($this->mockContainerWithContaoScopes());
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:7,代码来源:StringUtilTest.php

示例7: testEmptyHooks

 /**
  * Tests empty getImage and executeResize hooks.
  *
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testEmptyHooks()
 {
     define('TL_ROOT', $this->getRootDir());
     $GLOBALS['TL_CONFIG']['validImageTypes'] = 'jpg';
     System::setContainer($this->mockContainerWithContaoScopes());
     $path = $this->getRootDir() . '/images/dummy.jpg';
     $resizer = new LegacyResizer($this->getRootDir() . '/assets/images', new ResizeCalculator());
     $imagine = new Imagine();
     $framework = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\ContaoFramework')->disableOriginalConstructor()->getMock();
     $filesModel = $this->getMock('Contao\\FilesModel');
     $filesAdapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->disableOriginalConstructor()->getMock();
     $filesAdapter->expects($this->any())->method('__call')->willReturn($filesModel);
     $configAdapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->disableOriginalConstructor()->getMock();
     $configAdapter->expects($this->any())->method('__call')->willReturn(3000);
     $framework->expects($this->any())->method('getAdapter')->will($this->returnCallback(function ($key) use($filesAdapter, $configAdapter) {
         return ['Contao\\FilesModel' => $filesAdapter, 'Contao\\Config' => $configAdapter][$key];
     }));
     $resizer->setFramework($framework);
     $imageFactory = $this->createImageFactory($resizer, $imagine, $imagine, null, $framework);
     $GLOBALS['TL_HOOKS'] = ['executeResize' => [[get_class($this), 'emptyHookCallback']]];
     $GLOBALS['TL_HOOKS'] = ['getImage' => [[get_class($this), 'emptyHookCallback']]];
     $image = $imageFactory->create($path, [100, 100, ResizeConfiguration::MODE_CROP]);
     $this->assertRegExp('(/images/.*dummy.*.jpg$)', $image->getPath(), 'Empty hook should be ignored');
     $this->assertEquals(100, $image->getDimensions()->getSize()->getWidth());
     $this->assertEquals(100, $image->getDimensions()->getSize()->getHeight());
     unset($GLOBALS['TL_HOOKS']);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:33,代码来源:ImageFactoryTest.php

示例8: initializeFramework

 /**
  * Initializes the framework.
  */
 private function initializeFramework()
 {
     // Set the error_reporting level
     error_reporting($this->errorLevel);
     $this->includeHelpers();
     $this->includeBasicClasses();
     // Set the container
     System::setContainer($this->container);
     /** @var Config $config */
     $config = $this->getAdapter('Contao\\Config');
     // Preload the configuration (see #5872)
     $config->preload();
     // Register the class loader
     ClassLoader::scanAndRegister();
     $this->initializeLegacySessionAccess();
     $this->setDefaultLanguage();
     // Fully load the configuration
     $config->getInstance();
     $this->validateInstallation();
     Input::initialize();
     $this->setTimezone();
     $this->triggerInitializeSystemHook();
     $this->handleRequestToken();
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:27,代码来源:ContaoFramework.php

示例9: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     define('TL_ROOT', self::$rootDir);
     System::setContainer($this->mockContainerWithContaoScopes());
 }
开发者ID:contao,项目名称:core-bundle,代码行数:9,代码来源:GdImageTest.php

示例10: AppKernel

 * Copyright (c) 2005-2015 Leo Feyer
 *
 * @license LGPL-3.0+
 */
use Contao\ClassLoader;
use Contao\Config;
use Contao\InstallationBundle\ClassLoader\LibraryLoader;
use Contao\InstallationBundle\Controller\InstallationController;
use Contao\InstallationBundle\DependencyInjection\ContainerFactory;
use Contao\System;
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED);
$loader = (require_once __DIR__ . '/../vendor/autoload.php');
require_once __DIR__ . '/../app/AppKernel.php';
require_once __DIR__ . '/../vendor/contao/core-bundle/src/Resources/contao/config/constants.php';
require_once __DIR__ . '/../vendor/contao/core-bundle/src/Resources/contao/helper/functions.php';
$kernel = new AppKernel('prod', false);
// Un-normalize the path (see #208)
$rootDir = strtr($kernel->getRootDir(), '/', DIRECTORY_SEPARATOR);
// Register the class loader
$libraryLoader = new LibraryLoader($rootDir);
$libraryLoader->register();
Config::preload();
// Create the container
$container = ContainerFactory::create($rootDir);
System::setContainer($container);
ClassLoader::scanAndRegister();
// Run the controller
$controller = new InstallationController();
$controller->setContainer($container);
$response = $controller->indexAction();
$response->send();
开发者ID:siggj,项目名称:standard-edition,代码行数:31,代码来源:install.php


注:本文中的Contao\System::setContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。