本文整理汇总了PHP中static::container方法的典型用法代码示例。如果您正苦于以下问题:PHP static::container方法的具体用法?PHP static::container怎么用?PHP static::container使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::container方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: container
/**
* [container description]
* @return [type] [description]
*/
public static function container()
{
if (is_null(static::$container)) {
static::$container = new Feed();
}
return static::$container;
}
示例2: init
/**
* @throws \Exception
*/
protected function init()
{
$this->setEnvironment();
// Load class aliases
$aliases = Config::get('aliases');
foreach ($aliases as $orig => $new) {
class_alias($orig, $new, true);
}
static::$container = new Container();
Session::init();
Request::init();
$this->initRouter();
$databaseConfig = Config::get('database');
if ($databaseConfig !== null && is_array($databaseConfig)) {
$this->capsule = new Capsule();
foreach ($databaseConfig as $name => $conf) {
if (array_key_exists('name', $conf) && strlen($conf['name']) > 0) {
$name = $conf['name'];
unset($conf['name']);
}
$this->capsule->addConnection($conf, $name);
}
$this->capsule->bootEloquent();
}
$hookConfig = Config::get('hooks');
if (is_array($hookConfig)) {
foreach ($hookConfig as $event => $callable) {
EventHandler::addListener($event, $callable);
}
}
EventHandler::triggerEvent('whirlpool-initialized', $this);
}
示例3: __construct
public function __construct(array $values = array())
{
parent::__construct($values);
if (is_null(static::$container)) {
static::$container = $this;
}
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
static::$client = static::createClient();
static::$router = self::$client->getContainer()->get('router');
static::$em = self::$client->getContainer()->get('doctrine.orm.entity_manager');
static::$container = self::getContainer();
}
示例5: __construct
/**
* __construct function.
*
* @access public
* @param mixed $name (default: null)
* @return void
*/
public function __construct($name = null)
{
parent::__construct($name);
static::$kernel = static::createKernel();
static::$kernel->boot();
static::$container = static::$kernel->getContainer();
}
示例6: forget
public static function forget()
{
$cookie = Config::get('session.cookie');
static::$container = [];
setcookie(static::$name, '', time() - 3600, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
unset($_COOKIE[static::$name]);
}
示例7: register
/**
* Registers services to the container.
*
* @param ContainerBuilder $container
* The ContainerBuilder to register services to.
*/
public function register(ContainerBuilder $container)
{
static::$container = $container;
$class_map = $this->AutoloaderInit();
$ns = [];
foreach ($class_map as $name => $path) {
$path = preg_replace("/\\.php\$/i", '', $path);
$path = explode(DIRECTORY_SEPARATOR, $path);
$name = explode('\\', $name);
while (end($path) === end($name)) {
array_pop($path);
array_pop($name);
}
$path = implode(DIRECTORY_SEPARATOR, $path);
$name = implode('\\', $name);
if (is_dir($path)) {
if (is_dir($path . '/Plugin') || is_dir($path . '/Entity') || is_dir($path . '/Element')) {
$ns[$name][] = $path;
}
}
}
foreach ($ns as $name => $path) {
$path = array_unique($path);
$ns[$name] = count($path) == 1 ? reset($path) : $path;
}
$ns += $container->getParameter('container.namespaces');
$container->setParameter('container.namespaces', $ns);
$yaml_loader = new YamlFileLoader($container);
foreach (static::getFiles('/^.+\\.services\\.yml$/i') as $file) {
$yaml_loader->load($file);
}
}
示例8: getContainer
/**
* Gets container instance
* @return object
*/
private static function getContainer()
{
if (!static::$container) {
static::$container = Container::getInstance();
}
return static::$container;
}
示例9: foreach
/**
* @implement route_alter_variants
* @fast
*/
static function route_alter_variants()
{
$alters = [];
static::$container = \Drupal::getContainer();
foreach (static::getFiles('/^.+\\.routing\\.yml/i') as $file) {
$info = static::yamlDecode($file)['alter_variants'] ?? [];
$alters = NestedArray::mergeDeep($alters, $info);
}
foreach ($alters as $name => $variants) {
foreach ($variants as $k => $variant) {
if (isset($variant['cache'])) {
$variant['controller'] = new CacheController($variant['cache'], $variant['controller']);
unset($variant['cache']);
}
if (isset($variant['redirect'])) {
$variant['controller'] = new RedirectController($variant['redirect']);
unset($variant['redirect']);
}
if (isset($variant['error'])) {
$variant['controller'] = new ErrorController($variant['error']);
unset($variant['error']);
}
if (is_string($variant)) {
$variant = ['controller' => $variant];
}
if (isset($variant['controller']) && is_string($variant['controller']) && strpos($variant['controller'], '::') !== FALSE) {
$variant['controller'] = explode('::', $variant['controller']);
}
static::appliesRuleDetect($variant);
$variants[$k] = $variant;
}
$alters[$name] = static::sortByPriority($variants);
}
return $alters;
}
示例10: __construct
private function __construct()
{
static::$instance = $this;
static::$container = Forge::getInstance();
$this->installErrorHandling();
$this->detectEnvironment();
}
示例11: submoduleLibraryInfo
/**
* @implement submodule_library_info
* @fast
*/
static function submoduleLibraryInfo()
{
static $libraries = [];
if ($libraries) {
return $libraries;
}
static::$container = Drupal::getContainer();
foreach (static::getFiles('/^.+\\.libraries\\.yml/i') as $file) {
$name_prefix = str_replace('.libraries.yml', '', basename($file));
$path = dirname($file);
$info = self::yamlDecode($file);
foreach ($info as $name => $library) {
$library += ['js' => [], 'css' => []];
$src = [&$library['js']];
foreach (array_keys($library['css']) as $key) {
$src[] =& $library['css'][$key];
}
foreach ($src as $src_index => $src_type) {
foreach ($src_type as $source => $data) {
if ($source[0] !== '/' && file_exists($path . '/' . $source)) {
$src[$src_index]['/' . $path . '/' . $source] = $data;
unset($src[$src_index][$source]);
}
}
}
$libraries[$name_prefix][$name] = $library;
}
}
return $libraries;
}
示例12: initKernel
private static function initKernel()
{
static::$kernel = static::createKernel();
static::$kernel->boot();
static::$container = static::$kernel->getContainer();
static::$doctrine = static::$container->get('doctrine');
static::$om = static::$doctrine->getManager();
}
示例13: instantiateServiceContainer
/**
* Instantiate service container if it's not instantiated yet.
*/
protected static function instantiateServiceContainer()
{
$container = Container::getInstance();
if (!$container) {
$container = new Container();
Container::setInstance($container);
}
static::$container = $container;
}
示例14: tearDown
/**
* {@inheritdoc}
*/
protected function tearDown()
{
$this->rollbackTransaction();
BaseWebTestCase::tearDown();
static::$client = null;
static::$container = null;
static::$kernel = null;
$this->cleanFixtures();
}
示例15: __construct
/**
* Forge is a final Singleton.
*
* The Forge requires the illuminate/container for compatibility.
* Although the constructor exposes the dependency and auto-instantiates
* the illuminate/container, the option is provided to instantiate the
* illuminate/container outside of the Forge.
*
* @param IlluminateContainer $container
*/
public function __construct(IlluminateContainer $container = NULL)
{
if (!static::$instance) {
static::$container = $container ?: new IlluminateContainer();
static::$instance = $this;
$this->register_aliases();
}
return static::$instance;
}