本文整理汇总了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]);
}
}
}
示例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();
}
示例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;
}
}
示例4: __construct
public function __construct()
{
parent::__construct();
$this->initializeFilesystem();
$this->initializeServices();
$this->initializeSubscribers();
}
示例5: __construct
public function __construct($configDir)
{
parent::__construct();
$this['configDir'] = $this->protect(function () use($configDir) {
return $configDir;
});
}
示例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);
}
示例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);
}
}
示例8: __construct
public function __construct($blueprints = '')
{
parent::__construct();
if (!is_array($blueprints)) {
return;
}
$this->blueprints = array_merge_recursive($this->blueprints, $blueprints);
}
示例9: __construct
public function __construct()
{
parent::__construct();
$this->initializeParameters();
$this->initializeConfiguration();
$this->initializeProfile();
$this->initializeFinder();
$this->initializeSourceFileSystem();
$this->initializeVcs();
$this->initializeServices();
}
示例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;
};
}
示例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;
}
}
示例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'));
}
示例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())));
};
}
示例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);
}
示例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();
};
}