當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。