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


PHP Pimple::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Constructs the container and set up default services and properties
  */
 public function __construct()
 {
     parent::__construct();
     //Shared services
     $this['twig'] = $this->share(function ($c) {
         $envOptions = array_merge(array('cache' => $c['twig.compilation_cache']), $c['twig.environment_options']);
         $twig = new Twig_Environment($c['twig.loader'], $envOptions);
         if (isset($envOptions['debug']) && $envOptions['debug']) {
             $twig->addExtension(new Twig_Extension_Debug());
         }
         return $twig;
     });
     $this['twig.loader'] = $this->share(function ($c) {
         return new $c['twig.loader_class']($c['twig.template_paths']);
     });
     //Dynamic props
     $this['twig.compilation_cache'] = BASE_PATH . '/twig-cache';
     $this['twig.template_paths'] = THEMES_PATH . '/' . SSViewer::current_theme() . '/twig';
     //Default config
     foreach (self::$config as $key => $value) {
         $this[$key] = $value;
     }
     //Extensions
     if (is_array(self::$extensions)) {
         foreach (self::$extensions as $value) {
             $this->extend($value[0], $value[1]);
         }
     }
     //Shared
     if (is_array(self::$shared)) {
         foreach (self::$shared as $value) {
             $this[$value[0]] = $this->share($value[1]);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:camspiers-silverstripe-twig,代码行数:38,代码来源:TwigContainer.php

示例2: __construct

 /**
  * @param array         $config   The SlotMachine configuration data
  * @param Request|null  $request  The Request object
  */
 public function __construct(array $config = array(), Request $request = null)
 {
     parent::__construct();
     $this->config = $config;
     $this->request = !is_null($request) ? $request : Request::createFromGlobals();
     $this->initialize();
 }
开发者ID:VaporFan,项目名称:slotmachine,代码行数:11,代码来源:SlotMachine.php

示例3: __construct

 public function __construct(Application $app, array $values = array())
 {
     parent::__construct();
     $this->app = $app;
     $this['debug'] = false;
     $this['admin'] = false;
     $this['admin_content'] = '';
     $this['block_type_factory'] = $app->protect(function ($blockTypeData) {
         return BlockType::factory($blockTypeData);
     });
     $this['block_types'] = $this->share(function () {
         return array();
     });
     $this['twig_extensions'] = $this->share(function () {
         return array();
     });
     $this['snippet_queue'] = $this->share(function () {
         return new SnippetQueue();
     });
     $this['loader_class'] = 'NodePub\\Core\\Extension\\Loader';
     $app['loader'] = $app->share(function ($app) {
         return new $app['extension_loader_class']();
     });
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
 }
开发者ID:nodepub,项目名称:core,代码行数:27,代码来源:ExtensionContainer.php

示例4: __construct

 public function __construct()
 {
     parent::__construct();
     $this->initializeFilesystem();
     $this->initializeServices();
     $this->initializeSubscribers();
 }
开发者ID:niktux,项目名称:solidifier,代码行数:7,代码来源:Application.php

示例5: __construct

 public function __construct($configDir)
 {
     parent::__construct();
     $this['configDir'] = $this->protect(function () use($configDir) {
         return $configDir;
     });
 }
开发者ID:fobiaweb,项目名称:base,代码行数:7,代码来源:AutoloadConfig.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param array $values
  */
 public function __construct(array $values = [])
 {
     parent::__construct($values);
     $this['app'] = $this;
     $this->register(new EventServiceProvider());
     $this->register(new RoutingServiceProvider());
     ApplicationTrait::setApplication($this);
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:13,代码来源:Application.php

示例7: __construct

 /**
  * Instantiate the container.
  *
  * Objects and parameters can be passed as argument to the constructor.
  * 
  * @param ContainerInterface $container The root container of the application (if any)
  * @param array $values The parameters or objects.
  */
 public function __construct(ContainerInterface $container = null, array $values = array())
 {
     parent::__construct($values);
     if ($container) {
         $this->fallbackContainer = $container;
         $this->wrappedFallbackContainer = new FallbackContainerAdapter($container);
     }
 }
开发者ID:bangpound,项目名称:pimple-interop,代码行数:16,代码来源:PimpleInterop.php

示例8: __construct

 public function __construct($blueprints = '')
 {
     parent::__construct();
     if (!is_array($blueprints)) {
         return;
     }
     $this->blueprints = array_merge_recursive($this->blueprints, $blueprints);
 }
开发者ID:cangit,项目名称:beatrix,代码行数:8,代码来源:Factory.php

示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->initializeParameters();
     $this->initializeConfiguration();
     $this->initializeProfile();
     $this->initializeFinder();
     $this->initializeSourceFileSystem();
     $this->initializeVcs();
     $this->initializeServices();
 }
开发者ID:lebris,项目名称:karma,代码行数:11,代码来源:Application.php

示例10: __construct

 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['Request'] = $this->share(function () {
         return \Symfony\Component\HttpFoundation\Request::createFromGlobals();
     });
     $this['Response'] = function () {
         $response = new \Symfony\Component\HttpFoundation\Response();
         return $response;
     };
 }
开发者ID:natxet,项目名称:operacore,代码行数:11,代码来源:Container.php

示例11: __construct

 /**
  * Registers the autoloader and necessary components.
  *
  * @param string      $name    Name for this application.
  * @param string|null $version Version number for this application.
  */
 public function __construct($name, $version = null, array $values = array())
 {
     parent::__construct();
     $consoleConfig = array('console.name' => $name);
     if (null !== $version) {
         $consoleConfig['console.version'] = $version;
     }
     $this->register(new ConsoleServiceProvider(), $consoleConfig);
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
 }
开发者ID:corcre,项目名称:elabftw,代码行数:18,代码来源:Application.php

示例12: function

 /**
  * Constructs the object. You can inject a logger instance here, for
  * the lib to use.
  *
  * Also registers shutdown function and an exception handler to make sure
  * all errors that could occur are provided to the client in JSON format
  * with varying debug information.
  *
  * @param bool $debug
  */
 function __construct($debug = false)
 {
     parent::__construct();
     ob_start();
     self::$debug = $debug;
     $this['logger'] = function ($c) {
         $logger = new Logger('jsonrpc');
         $logger->pushHandler(new NullHandler());
         return $logger;
     };
     // register shutdown function so that we can report parse errors and such to the client.
     register_shutdown_function(array($this, 'handleShutdown'));
     set_error_handler(array($this, 'handleError'));
     set_exception_handler(array($this, 'handleException'));
 }
开发者ID:paulgessinger,项目名称:jsonrpc,代码行数:25,代码来源:Server.php

示例13: function

 function __construct()
 {
     parent::__construct();
     $this['config'] = function ($c) {
         return new Config(__DIR__ . "/../config.ini");
     };
     $this['db'] = function ($c) {
         $db = new \Services\MySQL\MySqlConnection($c->config->mysql->host, $c->config->mysql->username, $c->config->mysql->password, $c->config->mysql->db_name);
         $db->setTimeZone("+00:00");
         return $db;
     };
     $this['eb'] = function ($c) {
         return new \Services\Eventbrite\Eventbrite(array('app_key' => $c->config->eventbrite->appkey, 'user_key' => $c->config->eventbrite->userkey));
     };
     $this['mailchimp'] = function ($c) {
         return new \Services\Mailchimp\MCAPI($c->config->mailchimp->api_key);
     };
     $this['view'] = function ($c) {
         $loader = new Twig_Loader_Filesystem(realpath(__DIR__ . '/../../app/views'));
         $twig = new Twig_Environment($loader, array('cache' => realpath(__DIR__ . '/../../' . $c->config->view->cache_path), 'debug' => true));
         $twig->addFilter(new Twig_SimpleFilter('slugify', function ($string) {
             return strtolower(str_replace(' ', '-', $string));
         }));
         $twig->addFilter(new Twig_SimpleFilter('tourl', function ($string) {
             return rawurlencode(str_replace('\\n', ',', $string));
         }));
         $twig->addFilter(new Twig_SimpleFilter('timeago', function ($date) {
             return Carbon::instance($date)->diffForHumans();
         }));
         $twig->addGlobal('server', array('request_uri' => $_SERVER['REQUEST_URI']));
         $twig->addGlobal('layout', array('allevents' => $c->db->queryAllRows('(SELECT * FROM events WHERE end_time < NOW()) UNION (SELECT * FROM events WHERE end_time > NOW() ORDER BY end_time LIMIT 1) ORDER BY start_time DESC')));
         $twig->addExtension(new Twig_Extension_Debug());
         return $twig;
     };
     $this['auth'] = function ($c) {
         if (!session_id()) {
             session_start();
         }
         $host = $_SERVER['HTTP_HOST'];
         return new \Services\GoogleAuth\GoogleAuth($_SESSION, $c->config->google->client_id, $c->config->google->secret, array('canceldest' => 'http://edgeconf.com/', 'callback' => $c->config->google->callback));
     };
     $this['sentry'] = function ($c) {
         return new Raven_Client($c->config->sentry->dsn, array('tags' => array('php_version' => phpversion())));
     };
 }
开发者ID:phamann,项目名称:edgeconf,代码行数:45,代码来源:ServicesContainer.php

示例14: __construct

 /**
  * @inheritDoc
  */
 public function __construct(array $values = array())
 {
     $this->defaultValues['params']['storage']['filesystem'] = __DIR__ . '/../../../var';
     $values['storage'] = $this->share(function ($c) {
         $factory = new Storage\Factory(array('filesystem' => function () use($c) {
             return new Storage\FileSystem($c['params']['storage']['filesystem'], new Finder());
         }, 'database' => function () use($c) {
             return new Storage\DoctrineDbal($c['params']['storage']['database']['dsn'], $c['params']['storage']['database']['table_prefix']);
         }));
         return $factory->create($c['params']['storage']['type']);
     });
     $values['rsa'] = function () {
         return new \phpseclib\Crypt\RSA();
     };
     $values['ssl'] = $this->share(function ($c) {
         return new Ssl\PhpSecLib($c->raw('rsa'));
     });
     $values['http-client'] = $this->share(function ($c) {
         return new Http\GuzzleClient(new \Guzzle\Http\Client(), $c->raw('rsa'), $c['storage']);
     });
     $values['certificate'] = $this->share(function ($c) {
         return new Certificate($c['storage'], $c['http-client'], $c['ssl']);
     });
     $values['account'] = $this->share(function ($c) {
         return new Account($c['storage'], $c['http-client'], $c['ssl']);
     });
     $values['ownership'] = function ($c) {
         return new Ownership($c['storage'], $c['http-client'], $c['ssl']);
     };
     $values['challenge-solver-http'] = $this->share(function ($c) {
         return new \Octopuce\Acme\ChallengeSolver\Http($c['params']['challenge']['config']);
     });
     /*
     $values['challenge-solver-dns'] = $this->share(function () {
         return new Octopuce\Acme\ChallengeSolver\Dns;
     });
     $values['challenge-solver-dvsni'] = $this->share(function () {
         return new Octopuce\Acme\ChallengeSolver\DvSni;
     });
     */
     // Override default values with provided config
     $values = array_replace_recursive($this->defaultValues, $values);
     parent::__construct($values);
 }
开发者ID:albancrommer,项目名称:acmephpc,代码行数:47,代码来源:Client.php

示例15: __construct

 /**
  * Constructor
  * @param array $config Configuration data
  */
 public function __construct(array $config = [])
 {
     parent::__construct();
     $this['config'] = $config;
     $this['request'] = function () {
         return Request::createFromGlobals();
     };
     $this['router'] = function () {
         return new \AltoRouter([], $this['request']->getBasePath());
     };
     $this['session'] = function () {
         $config = $this->config('session') ?: [];
         $storage = new NativeSessionStorage($config, new NativeSessionHandler());
         return new Session($storage);
     };
     $this['event'] = function () {
         return new EventEmitter();
     };
 }
开发者ID:oito,项目名称:php-micro,代码行数:23,代码来源:Application.php


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