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


PHP ServiceManager::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * Add a default initializer to ensure the plugin is valid after instance
  * creation.
  *
  * @param null|ConfigInterface $configuration
  */
 public function __construct(ConfigInterface $configuration = null)
 {
     parent::__construct($configuration);
     $this->addInitializer(function ($instance) {
         if ($instance instanceof ServiceLocatorAwareInterface) {
             $instance->setServiceLocator($this);
         }
     });
 }
开发者ID:Colmea,项目名称:zend-servicemanager,代码行数:17,代码来源:AbstractPluginManager.php

示例2: __construct

 /**
  * Constructor
  *
  * Add a default initializer to ensure the plugin is valid after instance
  * creation.
  *
  * @param  null|ConfigurationInterface $configuration
  * @return void
  */
 public function __construct(ConfigurationInterface $configuration = null)
 {
     parent::__construct($configuration);
     $self = $this;
     $this->addInitializer(function ($instance) use($self) {
         if ($instance instanceof ServiceManagerAwareInterface) {
             $instance->setServiceManager($self);
         }
     });
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:19,代码来源:AbstractPluginManager.php

示例3: __construct

 public function __construct(ConfigInterface $config = null)
 {
     parent::__construct($config);
     /*
      * @note Unfortunately we need this to allow 'response' key to be overridden.
      * Hopefully in a later version we can refactor and break Backwards
      * Compatibility and thus disable this feature.
      */
     $this->setAllowOverride(true);
 }
开发者ID:dragoonis,项目名称:framework,代码行数:10,代码来源:ServiceManager.php

示例4: __construct

 /**
  * Constructor.
  *
  * Sets the provided $parentLocator as the creation context for all
  * factories; for $config, {@see \Zend\ServiceManager\ServiceManager::configure()}
  * for details on its accepted structure.
  *
  * @param null|ConfigInterface|ContainerInterface $configInstanceOrParentLocator
  * @param array $config
  */
 public function __construct($configInstanceOrParentLocator = null, array $config = [])
 {
     if (null !== $configInstanceOrParentLocator && !$configInstanceOrParentLocator instanceof ConfigInterface && !$configInstanceOrParentLocator instanceof ContainerInterface) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects a ConfigInterface or ContainerInterface instance as the first argument; received %s', __CLASS__, is_object($configInstanceOrParentLocator) ? get_class($configInstanceOrParentLocator) : gettype($configInstanceOrParentLocator)));
     }
     if ($configInstanceOrParentLocator instanceof ConfigInterface) {
         trigger_error(sprintf('Usage of %s as a constructor argument for %s is now deprecated', ConfigInterface::class, get_class($this)), E_USER_DEPRECATED);
         $config = $configInstanceOrParentLocator->toArray();
     }
     parent::__construct($config);
     if (!$configInstanceOrParentLocator instanceof ContainerInterface) {
         trigger_error(sprintf('%s now expects a %s instance representing the parent container; please update your code', __METHOD__, ContainerInterface::class), E_USER_DEPRECATED);
     }
     $this->creationContext = $configInstanceOrParentLocator instanceof ContainerInterface ? $configInstanceOrParentLocator : $this;
 }
开发者ID:snapshotpl,项目名称:zend-servicemanager,代码行数:25,代码来源:AbstractPluginManager.php

示例5: __construct

 /**
  * Constructor
  *
  * Add a default initializer to ensure the plugin is valid after instance
  * creation.
  *
  * Additionally, the constructor provides forwards compatibility with v3 by
  * overloading the initial argument. v2 usage expects either null or a
  * ConfigInterface instance, and will ignore any other arguments. v3 expects
  * a ContainerInterface instance, and will use an array of configuration to
  * seed the current instance with services. In most cases, you can ignore the
  * constructor unless you are writing a specialized factory for your plugin
  * manager or overriding it.
  *
  * @param null|ConfigInterface|ContainerInterface $configOrContainerInstance
  * @param array $v3config If $configOrContainerInstance is a container, this
  *     value will be passed to the parent constructor.
  * @throws Exception\InvalidArgumentException if $configOrContainerInstance
  *     is neither null, nor a ConfigInterface, nor a ContainerInterface.
  */
 public function __construct($configOrContainerInstance = null, array $v3config = [])
 {
     if (null !== $configOrContainerInstance && !$configOrContainerInstance instanceof ConfigInterface && !$configOrContainerInstance instanceof ContainerInterface) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects a ConfigInterface instance or ContainerInterface instance; received %s', get_class($this), is_object($configOrContainerInstance) ? get_class($configOrContainerInstance) : gettype($configOrContainerInstance)));
     }
     if ($configOrContainerInstance instanceof ContainerInterface) {
         if (property_exists($this, 'serviceLocator')) {
             if (!empty($v3config)) {
                 parent::__construct(new Config($v3config));
             }
             $this->serviceLocator = $configOrContainerInstance;
         }
         if (property_exists($this, 'creationContext')) {
             if (!empty($v3config)) {
                 parent::__construct($v3config);
             }
             $this->creationContext = $configOrContainerInstance;
         }
     }
     if ($configOrContainerInstance instanceof ConfigInterface) {
         parent::__construct($configOrContainerInstance);
     }
     $this->addInitializer(function ($instance) {
         if ($instance instanceof ServiceLocatorAwareInterface) {
             $instance->setServiceLocator($this);
         }
     });
 }
开发者ID:baardbaard,项目名称:bb-twitterfeed,代码行数:48,代码来源:AbstractPluginManager.php

示例6: __construct

 /**
  * Constructor
  *
  * Add a default initializer to ensure the plugin is valid after instance
  * creation.
  * 
  * @param  null|ConfigurationInterface $configuration 
  * @return void
  */
 public function __construct(ConfigurationInterface $configuration = null)
 {
     parent::__construct($configuration);
     $this->addInitializer(array($this, 'validatePlugin'), true);
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例7: __construct

 /**
  * Create new container
  *
  * @param array $settings Associative array of settings. User settings are in a 'settings' sub-array
  */
 public function __construct($settings = [])
 {
     $userSettings = [];
     if (isset($settings['settings'])) {
         $userSettings = $settings['settings'];
         unset($settings['settings']);
     }
     // Add settings factory that also collects the default settings
     $defaultSettings = $this->defaultSettings;
     $settings['factories']['settings'] = function ($c) use($userSettings, $defaultSettings) {
         return array_merge($defaultSettings, $userSettings);
     };
     // Add default services if they aren't added already
     if (!isset($settings['environment'])) {
         $settings['factories']['environment'] = function ($c) {
             return new Environment($_SERVER);
         };
     }
     if (!isset($settings['request'])) {
         $settings['factories']['request'] = function ($c) {
             return Request::createFromEnvironment($c['environment']);
         };
     }
     if (!isset($settings['response'])) {
         $settings['factories']['response'] = function ($c) {
             $headers = new Headers(['Content-Type' => 'text/html']);
             $response = new Response(200, $headers);
             return $response->withProtocolVersion($c['settings']['httpVersion']);
         };
     }
     if (!isset($settings['router'])) {
         $settings['factories']['router'] = function ($c) {
             return new Router();
         };
     }
     if (!isset($settings['callableResolver'])) {
         $settings['factories']['callableResolver'] = function ($c) {
             return new CallableResolver($c);
         };
     }
     if (!isset($settings['foundHandler'])) {
         $settings['invokables']['foundHandler'] = RequestResponse::class;
     }
     if (!isset($settings['errorHandler'])) {
         $settings['factories']['errorHandler'] = function ($c) {
             return new Error($c->get('settings')['displayErrorDetails']);
         };
     }
     if (!isset($settings['notFoundHandler'])) {
         $settings['invokables']['notFoundHandler'] = NotFound::class;
     }
     if (!isset($settings['notAllowedHandler'])) {
         $settings['invokables']['notAllowedHandler'] = NotAllowed::class;
     }
     parent::__construct($settings);
 }
开发者ID:akrabat,项目名称:rka-slim-zfsm-container,代码行数:61,代码来源:Container.php

示例8: __construct

 /**
  * constructor
  * @param \Zend\ServiceManager\ConfigInterface $config
  */
 public function __construct(\Zend\ServiceManager\ConfigInterface $config = null)
 {
     parent::__construct($config);
 }
开发者ID:corner82,项目名称:RabbitMQ_SanalFabrika,代码行数:8,代码来源:BLLManager.php

示例9: __construct

 /**
  * Constructor
  *
  * @param  null|ConfigInterface $configuration
  */
 public function __construct(ConfigInterface $configuration = null)
 {
     parent::__construct($configuration);
     $this->addInitializer('BlockManager\\BlockInitializer');
 }
开发者ID:labofidea,项目名称:block-manager,代码行数:10,代码来源:BlockManager.php

示例10: __construct

 /**
  * Create new container
  *
  * @param array $userSettings Associative array of application settings
  */
 public function __construct(array $userSettings = [])
 {
     parent::__construct();
     $defaultSettings = $this->defaultSettings;
     /**
      * This service MUST return an array or an
      * instance of \ArrayAccess.
      *
      * @param Container $c
      *
      * @return array|\ArrayAccess
      */
     $this->setFactory('settings', function ($c) use($userSettings, $defaultSettings) {
         return array_merge($defaultSettings, $userSettings);
     });
     /**
      * This service MUST return a shared instance
      * of \Slim\Interfaces\Http\EnvironmentInterface.
      *
      * @param Container $c
      *
      * @return EnvironmentInterface
      */
     $this->setFactory('environment', function ($c) {
         return new Environment($_SERVER);
     });
     /**
      * \Psr\Http\Message\ServerRequestInterface.
      */
     $this->setFactory('request', function ($c) {
         return Request::createFromEnvironment($c['environment']);
     });
     /**
      * \Psr\Http\Message\ResponseInterface.
      */
     $this->setFactory('response', function ($c) {
         $headers = new Headers(['Content-Type' => 'text/html']);
         $response = new Response(200, $headers);
         return $response->withProtocolVersion($c['settings']['httpVersion']);
     });
     /**
      * This service MUST return a SHARED instance
      * of \Slim\Interfaces\RouterInterface.
      *
      * @param Container $c
      *
      * @return RouterInterface
      */
     $this->setFactory('router', function ($c) {
         return new Router();
     });
     /**
      * This service MUST return a SHARED instance
      * of \Slim\Interfaces\InvocationStrategyInterface.
      *
      * @param Container $c
      *
      * @return InvocationStrategyInterface
      */
     $this->setFactory('foundHandler', function ($c) {
         return new RequestResponse();
     });
     /**
      * This service MUST return a callable
      * that accepts three arguments:
      *
      * 1. Instance of \Psr\Http\Message\ServerRequestInterface
      * 2. Instance of \Psr\Http\Message\ResponseInterface
      * 3. Instance of \Exception
      *
      * The callable MUST return an instance of
      * \Psr\Http\Message\ResponseInterface.
      *
      * @param Container $c
      *
      * @return callable
      */
     $this->setFactory('errorHandler', function ($c) {
         return new Error();
     });
     /**
      * This service MUST return a callable
      * that accepts two arguments:
      *
      * 1. Instance of \Psr\Http\Message\ServerRequestInterface
      * 2. Instance of \Psr\Http\Message\ResponseInterface
      *
      * The callable MUST return an instance of
      * \Psr\Http\Message\ResponseInterface.
      *
      * @param Container $c
      *
      * @return callable
      */
     $this->setFactory('notFoundHandler', function ($c) {
//.........这里部分代码省略.........
开发者ID:boosis,项目名称:rka-slim-zfsm-container,代码行数:101,代码来源:Container.php

示例11: __construct

 public function __construct(ConfigInterface $config = null)
 {
     parent::__construct($config);
 }
开发者ID:rostmefpoter,项目名称:bh,代码行数:4,代码来源:Bootstrap.php

示例12: __construct

 public function __construct(ConfigInterface $config, MonologLoggerFactory $loggerFactory, MonologHandlerFactory $handlerFactory)
 {
     parent::__construct($config);
     $this->loggerFactory = $loggerFactory;
     $this->handlerFactory = $handlerFactory;
 }
开发者ID:ebittleman,项目名称:monolog-zf2,代码行数:6,代码来源:LoggerManager.php


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