本文整理汇总了PHP中Pimple::extend方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimple::extend方法的具体用法?PHP Pimple::extend怎么用?PHP Pimple::extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimple
的用法示例。
在下文中一共展示了Pimple::extend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(\Pimple $container)
{
$container['doctrine'] = $container->share(function ($container) {
return new ManagerRegistry($container);
});
if (isset($container['form.extensions']) && class_exists('Symfony\\Bridge\\Doctrine\\Form\\DoctrineOrmExtension')) {
$container['form.extensions'] = $container->share($container->extend('form.extensions', function ($extensions, $container) {
$extensions[] = new DoctrineOrmExtension($container['doctrine']);
return $extensions;
}));
}
if (isset($container['validator']) && class_exists('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator')) {
$container['doctrine.orm.validator.unique_validator'] = $container->share(function ($container) {
return new UniqueEntityValidator($container['doctrine']);
});
if (!isset($container['validator.validator_service_ids'])) {
$container['validator.validator_service_ids'] = array();
}
$container['validator.validator_service_ids'] = array_merge($container['validator.validator_service_ids'], array('doctrine.orm.validator.unique' => 'doctrine.orm.validator.unique_validator'));
$container['validator.object_initializers'] = $container->share($container->extend('validator.object_initializers', function (array $objectInitializers) use($container) {
$objectInitializers[] = new DoctrineInitializer($container['doctrine']);
return $objectInitializers;
}));
}
if (class_exists('Saxulum\\DoctrineOrmCommands\\Command\\CreateDatabaseDoctrineCommand')) {
if (isset($container['console'])) {
$container['console'] = $container->share($container->extend('console', function (ConsoleApplication $consoleApplication) use($container) {
$helperSet = $consoleApplication->getHelperSet();
$helperSet->set(new ManagerRegistryHelper($container['doctrine']), 'doctrine');
return $consoleApplication;
}));
}
if (isset($container['console.commands'])) {
$container['console.commands'] = $container->share($container->extend('console.commands', function ($commands) use($container) {
$commands[] = new CreateDatabaseDoctrineCommand();
$commands[] = new DropDatabaseDoctrineCommand();
$commands[] = new CreateSchemaDoctrineCommand();
$commands[] = new UpdateSchemaDoctrineCommand();
$commands[] = new DropSchemaDoctrineCommand();
$commands[] = new RunDqlDoctrineCommand();
$commands[] = new RunSqlDoctrineCommand();
$commands[] = new ConvertMappingDoctrineCommand();
$commands[] = new ClearMetadataCacheDoctrineCommand();
$commands[] = new ClearQueryCacheDoctrineCommand();
$commands[] = new ClearResultCacheDoctrineCommand();
$commands[] = new InfoDoctrineCommand();
$commands[] = new ValidateSchemaCommand();
$commands[] = new EnsureProductionSettingsDoctrineCommand();
return $commands;
}));
}
}
}
示例2: registerFilters
public static function registerFilters(\Pimple $container)
{
$container['inspector.filter_listener'] = $container->share($container->extend('inspector.filter_listener', function ($listener, $c) {
$listener->addAvailableFilter('gitignore', function () {
return new Filter\GitIgnoreFilter();
});
return $listener;
}));
}
示例3: process
public function process(Definition $serviceConf, array $tags, \Pimple $container)
{
foreach ($tags as $tag) {
if (strtolower($tag['name']) === 'konfigurator.event_listener') {
$container[$this->dispatcher] = $container->extend($this->dispatcher, function ($dispatcher, $c) use($serviceConf, $tag) {
$dispatcher->addListener($tag['event'], function () use($serviceConf, $tag, $c) {
$service = $serviceConf->getName();
$method = $tag['method'];
if (isset($c[$service])) {
return call_user_func_array(array($c[$service], $method), func_get_args());
}
return false;
});
return $dispatcher;
});
}
}
}
示例4: extend
/**
* {@inheritdoc}
*/
public function extend($id, $callable)
{
return $this->container->extend($id, $callable);
}