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


PHP Container::__construct方法代码示例

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


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

示例1: __construct

 public function __construct(array $settings = [])
 {
     parent::__construct();
     $this['settings'] = function () use($settings) {
         return new Settings($settings);
     };
 }
开发者ID:iceberg2,项目名称:iceberg-app,代码行数:7,代码来源:Container.php

示例2: __construct

 public function __construct()
 {
     parent::__construct();
     $this['Request'] = $this->factory(function () {
         return new Request();
     });
 }
开发者ID:mickaelbaudoin,项目名称:simple-php,代码行数:7,代码来源:Application.php

示例3: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['app_name'] = 'UNKNOWN';
     $this['app_version'] = 'UNKNOWN';
     $this['config_file'] = '{base}/config.json';
     $this['config_defaults'] = array();
     $this['working_directory_sub_folder'] = '.console-kit';
     $this['working_directory'] = function ($c) {
         $working_directory = new WorkingDirectory($c['working_directory_sub_folder']);
         return $working_directory->get();
     };
     $this['config_editor'] = function ($c) {
         return new ConfigEditor(str_replace('{base}', $c['working_directory'], $c['config_file']), $c['config_defaults']);
     };
     $this['input'] = function () {
         return new ArgvInput();
     };
     $this['output'] = function () {
         return new ConsoleOutput();
     };
     $this['io'] = function ($c) {
         return new ConsoleIO($c['input'], $c['output'], $c['helper_set']);
     };
     // Would be replaced with actual HelperSet from extended Application class.
     $this['helper_set'] = function () {
         return new HelperSet();
     };
     $this['container_helper'] = function ($c) {
         return new ContainerHelper($c);
     };
 }
开发者ID:console-helpers,项目名称:console-kit,代码行数:35,代码来源:Container.php

示例4: __construct

 /**
  * Instantiate the container.
  *
  * Objects and parameters can be passed as argument to the constructor.
  *
  * @param array $values The parameters or objects.
  */
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['config_options'] = array();
     $this['config'] = function ($c) {
         return new Config($c['config_options']);
     };
     $this['annotation_manager'] = function () {
         $annotation_manager = new AnnotationManager();
         $annotation_manager->cache = new AnnotationCache(sys_get_temp_dir());
         return $annotation_manager;
     };
     $this['url_factory'] = function () {
         return new UrlFactory();
     };
     $this['url_normalizer'] = function ($c) {
         /** @var Config $config */
         $config = $c['config'];
         return new Normalizer($config->getOption('base_url'));
     };
     $this['page_locator'] = function ($c) {
         /** @var Config $config */
         $config = $c['config'];
         return new DefaultPageLocator((array) $config->getOption('page_namespace_prefix'));
     };
     $this['page_url_matcher_registry'] = function ($c) {
         $page_url_matcher_registry = new PageUrlMatcherRegistry($c['annotation_manager']);
         /** @var Config $config */
         $config = $c['config'];
         foreach ($config->getOption('page_url_matchers') as $matcher_class) {
             $page_url_matcher_registry->add(new $matcher_class());
         }
         return $page_url_matcher_registry;
     };
 }
开发者ID:qa-tools,项目名称:qa-tools,代码行数:42,代码来源:Container.php

示例5: __construct

 /**
  * Class constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this['debug'] = true;
     $this['logger'] = function ($app) {
         return new Logger('app', [new StreamHandler('php://stdout')]);
     };
     $this['console'] = function ($app) {
         return new Console();
     };
     $this['dispatcher'] = function ($app) {
         $dispatcher = new Dispatcher();
         $dispatcher->setLogger($app['logger']);
         $dispatcher->addLayer(new RouteMiddlewareLayer('route', $app));
         $dispatcher->addLayer(new MiddlewareLayer('default'));
         return $dispatcher;
     };
     $this['server'] = function ($app) {
         $server = new Server();
         $server->setLogger($app['logger']);
         $server->setDispatcher($app['dispatcher']);
         return $server;
     };
     $this['request'] = function ($app) {
         return $app['server']->getRequest();
     };
     $this['route'] = null;
 }
开发者ID:spajak,项目名称:flow,代码行数:31,代码来源:Application.php

示例6: __construct

 /**
  * @param array  $settings
  * @param string $environment
  */
 public function __construct(array $settings = [], $environment = self::ENV_DEVELOPMENT)
 {
     parent::__construct();
     if (!defined('INFUSE_BASE_DIR')) {
         die('INFUSE_BASE_DIR has not been defined!');
     }
     /* Load Configuration */
     $configWithDirs = ['dirs' => ['app' => INFUSE_BASE_DIR . '/app', 'assets' => INFUSE_BASE_DIR . '/assets', 'public' => INFUSE_BASE_DIR . '/public', 'temp' => INFUSE_BASE_DIR . '/temp', 'views' => INFUSE_BASE_DIR . '/views']];
     $settings = array_replace_recursive(static::$baseConfig, $configWithDirs, $settings);
     $config = new Config($settings);
     $this['config'] = $config;
     $this['environment'] = $environment;
     /* Base URL */
     $this['base_url'] = function () use($config) {
         $url = ($config->get('app.ssl') ? 'https' : 'http') . '://';
         $url .= $config->get('app.hostname');
         $port = $config->get('app.port');
         $url .= (!in_array($port, [0, 80, 443]) ? ':' . $port : '') . '/';
         return $url;
     };
     /* Services  */
     foreach ($config->get('services') as $name => $class) {
         $this[$name] = new $class($this);
     }
     // set the last created app instance
     self::$default = $this;
 }
开发者ID:idealistsoft,项目名称:framework-bootstrap,代码行数:31,代码来源:Application.php

示例7: __construct

 public function __construct(array $values)
 {
     parent::__construct($values);
     $this['apiService'] = function ($c) {
         return new ApiService($c);
     };
     $this['etkinlikService'] = function ($c) {
         return new EtkinlikService($c);
     };
     $this['mekanService'] = function ($c) {
         return new MekanService($c);
     };
     $this['ilceService'] = function ($c) {
         return new IlceService($c);
     };
     $this['kategoriService'] = function ($c) {
         return new KategoriService($c);
     };
     $this['sehirService'] = function ($c) {
         return new SehirService($c);
     };
     $this['semtService'] = function ($c) {
         return new SemtService($c);
     };
     $this['turService'] = function ($c) {
         return new TurService($c);
     };
 }
开发者ID:etkinlik,项目名称:php-api-client,代码行数:28,代码来源:Container.php

示例8: __construct

 public function __construct($baseUrl = null, array $config = array())
 {
     parent::__construct();
     $this['base_url'] = $baseUrl;
     $this['output'] = null;
     $this['client'] = function () {
         return new Client(['allow_redirects' => false]);
     };
     $this['queue'] = function () {
         if (isset($this['doctrine'])) {
             return new DoctrineRequestQueue($this['doctrine']);
         }
         return new ArrayRequestQueue();
     };
     $this['datastore'] = function () {
         if (isset($this['doctrine'])) {
             return new DoctrineRequestDataStore($this['doctrine']);
         }
         return new ArrayRequestDataStore();
     };
     $this['logger'] = function () {
         return new NullLogger();
     };
     $this['redispatcher'] = function () {
         return new HtmlRedispatcher();
     };
     $this['initial_requests'] = function () {
         return [new Request('GET', $this['base_url'])];
     };
     $this['loggers'] = [];
     $this['discoverers'] = [];
     $this['recursors'] = [];
     $this->configure($config);
 }
开发者ID:LastCallMedia,项目名称:Crawler,代码行数:34,代码来源:Configuration.php

示例9:

 /**
  * The current globally available container (if any).
  *
  * @var static
  */
 function __construct(array $values = [])
 {
     parent::__construct($values);
     // var_dump ( $this );
     // exit ();
     $this->registerDefaultServices();
 }
开发者ID:mclkim,项目名称:kaiser,代码行数:12,代码来源:Container.php

示例10: __construct

 public function __construct(array $values = array())
 {
     parent::__construct($values);
     if (is_null(static::$container)) {
         static::$container = $this;
     }
 }
开发者ID:pokmot,项目名称:pimple-singleton,代码行数:7,代码来源:Container.php

示例11: __construct

 public function __construct(array $values = array())
 {
     parent::__construct();
     $this['debug'] = false;
     $this['logger'] = null;
     $this['migration.directories'] = new \ArrayObject();
     $this['autoload.aliases'] = new \ArrayObject(array('' => 'Biz'));
     $this['autoload.object_maker.service'] = function ($biz) {
         return function ($namespace, $name) use($biz) {
             $class = "{$namespace}\\Service\\Impl\\{$name}Impl";
             return new $class($biz);
         };
     };
     $this['autoload.object_maker.dao'] = function ($biz) {
         return function ($namespace, $name) use($biz) {
             $class = "{$namespace}\\Dao\\Impl\\{$name}Impl";
             return new DaoProxy($biz, new $class($biz));
         };
     };
     $this['autoloader'] = function ($biz) {
         return new ContainerAutoloader($biz, $biz['autoload.aliases'], array('service' => $biz['autoload.object_maker.service'], 'dao' => $biz['autoload.object_maker.dao']));
     };
     $this['dispatcher'] = function ($biz) {
         return new EventDispatcher();
     };
     $this['callback_resolver'] = function ($biz) {
         return new CallbackResolver($biz);
     };
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
 }
开发者ID:codeages,项目名称:biz-framework,代码行数:32,代码来源:Biz.php

示例12: __construct

 /**
  * Add service providers and application options.
  *
  * @param array $values
  */
 public function __construct(array $values = [])
 {
     parent::__construct($values);
     $this->register(new DoctrineServiceProvider());
     $this->register(new TwigServiceProvider());
     $this->register(new HexagonalServiceProvider());
     $this->register(new EwalletConsoleServiceProvider());
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:13,代码来源:EwalletConsoleContainer.php

示例13: __construct

 /**
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->_middleware = new \ArrayObject();
     $this->_routeMap = new RouteMap();
     $this->_request = ServerRequestFactory::fromGlobals();
     $this->_response = new Response();
 }
开发者ID:prezto,项目名称:espresso,代码行数:11,代码来源:App.php

示例14: __construct

 /**
  * Add service providers and application options.
  *
  * @param array $values
  * @param Slim $app
  */
 public function __construct(array $values = [], Slim $app)
 {
     parent::__construct($values);
     $this->register(new DoctrineServiceProvider());
     $this->register(new TwigServiceProvider());
     $this->register(new FormsServiceProvider());
     $this->register(new EwalletWebServiceProvider($app));
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:14,代码来源:EwalletWebContainer.php

示例15: __construct

 public function __construct($root_directory)
 {
     //init Pimple
     parent::__construct();
     //make sure root has a trailing slash
     if (substr($root_directory, -1) !== '/') {
         $root_directory .= '/';
     }
     $this->root_directory = $root_directory;
     $this['config.cache'] = function () {
         $cache_file = $this->root_directory . 'storage/cache/config-' . $this->env . '.php';
         return new ConfigCache($cache_file);
     };
     $this['config'] = function () {
         $this->env_locked = true;
         if ($this->cache_enabled) {
             $cache = $this['config.cache'];
             if ($cache->isSaved()) {
                 return $cache->getConfig();
             }
         }
         $manager = $this['config.manager'];
         //load configuration for each module
         foreach ($this->modules as $module) {
             $module->loadConfig($manager);
         }
         //then for the application (default is config/neptune.yml).
         $this->loadConfig($manager);
         $config = $manager->getConfig();
         if ($this->cache_enabled) {
             $cache->save($config, $manager->getCacheMessage());
         }
         return $config;
     };
     $this['config.manager'] = function ($neptune) {
         $manager = new ConfigManager();
         $manager->addLoader(new Loader\YamlLoader());
         $manager->addLoader(new Loader\JsonLoader());
         $manager->addLoader(new Loader\PhpLoader());
         $manager->addProcessor(new Processor\OptionsProcessor());
         $manager->addProcessor(new Processor\EnvironmentProcessor($neptune));
         $manager->addProcessor(new Processor\ReferenceProcessor());
         return $manager;
     };
     $this['dispatcher'] = function () {
         $dispatcher = new EventDispatcher();
         foreach ($this->getTaggedServices('neptune.dispatcher.subscribers') as $subscriber) {
             $dispatcher->addSubscriber($subscriber);
         }
         return $dispatcher;
     };
     $this['request_stack'] = function () {
         return new RequestStack();
     };
     $this['kernel'] = function () {
         return new HttpKernel($this['dispatcher'], $this['resolver'], $this['request_stack']);
     };
 }
开发者ID:glynnforrest,项目名称:neptune,代码行数:58,代码来源:Neptune.php


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