本文整理汇总了PHP中Pimple\Container::raw方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::raw方法的具体用法?PHP Container::raw怎么用?PHP Container::raw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimple\Container
的用法示例。
在下文中一共展示了Container::raw方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(Container $app)
{
$app['logger'] = function () use($app) {
return $app['monolog'];
};
if ($bridge = class_exists('Symfony\\Bridge\\Monolog\\Logger')) {
$app['monolog.handler.debug'] = function () use($app) {
$level = MonologServiceProvider::translateLevel($app['monolog.level']);
return new DebugHandler($level);
};
if (isset($app['request_stack'])) {
$app['monolog.not_found_activation_strategy'] = function () use($app) {
return new NotFoundActivationStrategy($app['request_stack'], array('^/'), $app['monolog.level']);
};
}
}
$app['monolog.logger.class'] = $bridge ? 'Symfony\\Bridge\\Monolog\\Logger' : 'Monolog\\Logger';
$app['monolog'] = function ($app) {
$log = new $app['monolog.logger.class']($app['monolog.name']);
$handler = new Handler\GroupHandler($app['monolog.handlers']);
if (isset($app['monolog.not_found_activation_strategy'])) {
$handler = new Handler\FingersCrossedHandler($handler, $app['monolog.not_found_activation_strategy']);
}
$log->pushHandler($handler);
if ($app['debug'] && isset($app['monolog.handler.debug'])) {
$log->pushHandler($app['monolog.handler.debug']);
}
return $log;
};
$app['monolog.formatter'] = function () {
return new LineFormatter();
};
$app['monolog.handler'] = $defaultHandler = function () use($app) {
$level = MonologServiceProvider::translateLevel($app['monolog.level']);
$handler = new Handler\StreamHandler($app['monolog.logfile'], $level, $app['monolog.bubble'], $app['monolog.permission']);
$handler->setFormatter($app['monolog.formatter']);
return $handler;
};
$app['monolog.handlers'] = function () use($app, $defaultHandler) {
$handlers = array();
// enables the default handler if a logfile was set or the monolog.handler service was redefined
if ($app['monolog.logfile'] || $defaultHandler !== $app->raw('monolog.handler')) {
$handlers[] = $app['monolog.handler'];
}
return $handlers;
};
$app['monolog.level'] = function () {
return Logger::DEBUG;
};
$app['monolog.listener'] = function () use($app) {
return new LogListener($app['logger'], $app['monolog.exception.logger_filter']);
};
$app['monolog.name'] = 'app';
$app['monolog.bubble'] = true;
$app['monolog.permission'] = null;
$app['monolog.exception.logger_filter'] = null;
$app['monolog.logfile'] = null;
$app['monolog.use_error_handler'] = !$app['debug'];
}
示例2: register
/**
* {@inheritDoc}
*/
public function register(Container $container)
{
$container['defaultErrorHandler'] = $container->raw('phpErrorHandler');
$container['errorHandler'] = function ($container) {
return new ErrorHandler($container);
};
$container['phpErrorHandler'] = function ($container) {
return new ErrorHandler($container);
};
}
示例3: register
/**
* {@inheritDoc}
*/
public function register(Container $container)
{
// Save default handler under new name
$container['defaultNotAllowedHandler'] = $container->raw('notAllowedHandler');
/**
* Add dependency (DI).
*
* @param Container $c
*
* @return NotAllowedHandler
*/
$container['notAllowedHandler'] = function ($c) {
return new NotAllowedHandler($c);
};
}
示例4: testConstructor
/**
* Test __construct().
*/
public function testConstructor()
{
$app = new Application(['foo' => 'bar']);
$this->assertInstanceOf(Config::class, $app['config']);
$providers = $app->getProviders();
foreach ($providers as $provider) {
$container = new Container();
$container->register(new $provider());
$container['config'] = $app->raw('config');
$container['access_token'] = $app->raw('access_token');
$container['request'] = $app->raw('request');
$container['cache'] = $app->raw('cache');
foreach ($container->keys() as $providerName) {
$this->assertEquals($container->raw($providerName), $app->raw($providerName));
}
unset($container);
}
}
示例5: raw
public function raw($id)
{
return $this->pimpleContainer->raw($this->ensureNamespacesLoaded($id));
}
示例6: testRawValidatesKeyIsPresent
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Identifier "foo" is not defined.
*/
public function testRawValidatesKeyIsPresent()
{
$pimple = new Container();
$pimple->raw('foo');
}
示例7: register
/**
* {@inheritDoc}
*/
public function register(PimpleContainer $slimContainer)
{
foreach ($this->pimpleContainer->keys() as $key) {
$slimContainer[$key] = $this->pimpleContainer->raw($key);
}
}