本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::hasExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerBuilder::hasExtension方法的具體用法?PHP ContainerBuilder::hasExtension怎麽用?PHP ContainerBuilder::hasExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::hasExtension方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepend
/**
* Allow an extension to prepend the extension configurations.
*
* @param ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('sulu_search')) {
$container->prependExtensionConfig('sulu_search', ['indexes' => ['contact' => ['security_context' => 'sulu.contact.people'], 'account' => ['security_context' => 'sulu.contact.organizations']]]);
}
if ($container->hasExtension('sulu_media')) {
$container->prependExtensionConfig('sulu_media', ['system_collections' => ['sulu_contact' => ['meta_title' => ['en' => 'Sulu contacts', 'de' => 'Sulu Kontakte'], 'collections' => ['contact' => ['meta_title' => ['en' => 'People', 'de' => 'Personen']], 'account' => ['meta_title' => ['en' => 'Organizations', 'de' => 'Organisationen']]]]]]);
}
}
示例2: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('fos_rest')) {
$container->prependExtensionConfig('fos_rest', ['exception' => ['codes' => [CategoryIdNotFoundException::class => 404, CategoryKeyNotFoundException::class => 404, CategoryKeyNotUniqueException::class => 409, CategoryNameMissingException::class => 400, KeywordIsMultipleReferencedException::class => 409, KeywordNotUniqueException::class => 409]]]);
}
if ($container->hasExtension('jms_serializer')) {
$container->prependExtensionConfig('jms_serializer', ['metadata' => ['directories' => [['path' => __DIR__ . '/../Resources/config/serializer', 'namespace_prefix' => 'Sulu\\Bundle\\CategoryBundle\\Entity']]]]);
}
}
示例3: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('sulu_search')) {
$container->prependExtensionConfig('sulu_search', ['indexes' => ['media' => ['security_context' => 'sulu.media.collections']]]);
}
if ($container->hasExtension('sulu_media')) {
$container->prependExtensionConfig('sulu_media', ['system_collections' => ['sulu_media' => ['meta_title' => ['en' => 'Sulu media', 'de' => 'Sulu Medien'], 'collections' => ['preview_image' => ['meta_title' => ['en' => 'Preview images', 'de' => 'Vorschaubilder']]]]]]);
}
}
示例4: prependPrototype
/**
* Prepend activity prototype and field definitions.
*
* @param ContainerBuilder $container
* @param array $config
*/
private function prependPrototype(ContainerBuilder $container, array $config)
{
if (!$container->hasExtension('dag_prototype') || !$container->hasExtension('dag_field')) {
return;
}
// Prepend activity prototype.
$container->prependExtensionConfig('dag_prototype', array('classes' => array($this->applicationName . ':' . 'activity' => array('subject' => $config['classes']['activity']['model'], 'prototype' => array('model' => 'Accard\\Component\\Activity\\Model\\Prototype', 'repository' => 'DAG\\Bundle\\PrototypeBundle\\Doctrine\\ORM\\PrototypeRepository', 'form' => 'Accard\\Bundle\\ActivityBundle\\Form\\Type\\ActivityPrototypeType'), 'field' => array('model' => 'Accard\\Component\\Activity\\Model\\Field'), 'field_value' => array('model' => 'Accard\\Component\\Activity\\Model\\FieldValue')))));
// Prepend activity prototype field.
$container->prependExtensionConfig('dag_field', array('classes' => array($this->applicationName . ':' . 'activity_prototype' => array('subject' => $config['classes']['activity']['model'], 'field' => array('model' => 'Accard\\Component\\Activity\\Model\\Field'), 'field_value' => array('model' => 'Accard\\Component\\Activity\\Model\\FieldValue')))));
}
示例5: __construct
public function __construct(ContainerBuilder $container)
{
$this->container = $container;
// register factory builder extension if it doesn't exist
if (!$this->container->hasExtension(FactoryBuilderExtension::ALIAS)) {
$factoryBuilderExtension = new FactoryBuilderExtension();
$this->container->registerExtension($factoryBuilderExtension);
$this->container->loadFromExtension($factoryBuilderExtension::ALIAS);
}
}
示例6: prepend
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('sulu_core')) {
$prepend = ['content' => ['structure' => ['paths' => [['path' => __DIR__ . '/../Content/templates', 'type' => 'page']]]]];
$container->prependExtensionConfig('sulu_core', $prepend);
}
if ($container->hasExtension('jms_serializer')) {
$container->prependExtensionConfig('jms_serializer', ['metadata' => ['directories' => [['path' => __DIR__ . '/../Resources/config/serializer', 'namespace_prefix' => 'Sulu\\Bundle\\ContentBundle'], ['path' => __DIR__ . '/../Resources/config/serializer', 'namespace_prefix' => 'Sulu\\Component\\Content']]]]);
}
}
示例7: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $container->getExtensionConfig($this->getAlias()));
if (!$container->hasExtension('dag_prototype') || !$container->hasExtension('dag_field')) {
return;
}
// Prepend behavior prototype.
$container->prependExtensionConfig('dag_prototype', array('classes' => array($this->applicationName . ':' . 'behavior' => array('subject' => $config['classes']['behavior']['model'], 'prototype' => array('model' => 'Accard\\Component\\Behavior\\Model\\Prototype', 'repository' => 'DAG\\Bundle\\PrototypeBundle\\Doctrine\\ORM\\PrototypeRepository'), 'field' => array('model' => 'Accard\\Component\\Behavior\\Model\\Field'), 'field_value' => array('model' => 'Accard\\Component\\Behavior\\Model\\FieldValue')))));
// Prepend behavior prototype field.
$container->prependExtensionConfig('dag_field', array('classes' => array($this->applicationName . ':' . 'behavior_prototype' => array('subject' => $config['classes']['behavior']['model'], 'field' => array('model' => 'Accard\\Component\\Behavior\\Model\\Field'), 'field_value' => array('model' => 'Accard\\Component\\Behavior\\Model\\FieldValue')))));
}
示例8: it_loads_resources_config_only_if_resource_repository_extension_exists
/**
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $bag
*/
public function it_loads_resources_config_only_if_resource_repository_extension_exists($container, $bag)
{
$container->hasExtension(Argument::type('string'))->willReturn(false);
$container->hasExtension('fsi_resource_repository')->willReturn(true);
$container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\FileResource'), Argument::that(function ($value) {
return $value instanceof FileResource && preg_match('/context\\/resource\\.xml$/', $value->getResource());
})))->shouldBeCalled();
$container->getParameterBag()->willReturn($bag);
$container->setDefinition(Argument::type('string'), Argument::type('Symfony\\Component\\DependencyInjection\\Definition'))->shouldBeCalled();
$this->process($container);
}
示例9: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('sulu_search')) {
$container->prependExtensionConfig('sulu_search', ['indexes' => ['media' => ['security_context' => 'sulu.media.collections']]]);
}
if ($container->hasExtension('sulu_media')) {
$container->prependExtensionConfig('sulu_media', ['system_collections' => ['sulu_media' => ['meta_title' => ['en' => 'Sulu media', 'de' => 'Sulu Medien'], 'collections' => ['preview_image' => ['meta_title' => ['en' => 'Preview images', 'de' => 'Vorschaubilder']]]]], 'image_format_files' => ['%kernel.root_dir%/config/image-formats.xml', __DIR__ . '/../Resources/config/image-formats.xml'], 'search' => ['enabled' => $container->hasExtension('massive_search')]]);
}
if ($container->hasExtension('fos_rest')) {
$container->prependExtensionConfig('fos_rest', ['exception' => ['codes' => [MediaNotFoundException::class => 404, FileVersionNotFoundException::class => 404, FormatNotFoundException::class => 404, FormatOptionsMissingParameterException::class => 400]]]);
}
}
示例10: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('sulu_document_manager')) {
$container->prependExtensionConfig('sulu_document_manager', ['mapping' => ['custom_url' => ['class' => CustomUrlDocument::class, 'phpcr_type' => 'sulu:custom_url', 'mapping' => ['published' => ['property' => 'published'], 'baseDomain' => ['property' => 'baseDomain'], 'domainParts' => ['property' => 'domainParts', 'type' => 'json_array'], 'canonical' => ['property' => 'canonical'], 'redirect' => ['property' => 'redirect'], 'targetLocale' => ['property' => 'targetLocale']]], 'custom_url_route' => ['class' => RouteDocument::class, 'phpcr_type' => 'sulu:custom_url_route', 'mapping' => ['locale' => ['property' => 'locale']]]], 'path_segments' => ['custom_urls' => 'custom-urls', 'custom_urls_items' => 'items', 'custom_urls_routes' => 'routes']]);
}
if ($container->hasExtension('jms_serializer')) {
$container->prependExtensionConfig('jms_serializer', ['metadata' => ['directories' => [['path' => __DIR__ . '/../Resources/config/serializer', 'namespace_prefix' => 'Sulu\\Component\\CustomUrl']]]]);
}
if ($container->hasExtension('fos_rest')) {
$container->prependExtensionConfig('fos_rest', ['exception' => ['codes' => [DocumentNotFoundException::class => 404, TitleAlreadyExistsException::class => 400, MissingDomainPartException::class => 400, RouteNotRemovableException::class => 420]]]);
}
}
示例11:
function it_add_compiler_pass_during_build(ContainerBuilder $container)
{
$container->hasExtension('fsi_doctrine_extensions')->shouldBeCalled()->willReturn(true);
$container->hasExtension('fsi_form_extensions')->shouldBeCalled()->willReturn(true);
$container->hasExtension('ivory_ck_editor')->shouldBeCalled()->willReturn(true);
$container->addCompilerPass(Argument::type('FSi\\Bundle\\ResourceRepositoryBundle\\DependencyInjection\\Compiler\\ResourceFSiFilePass'))->shouldBeCalled();
$container->addCompilerPass(Argument::type('FSi\\Bundle\\ResourceRepositoryBundle\\DependencyInjection\\Compiler\\ResourceCKEditorPass'))->shouldBeCalled();
$container->addCompilerPass(Argument::type('FSi\\Bundle\\ResourceRepositoryBundle\\DependencyInjection\\Compiler\\ResourceFSiCKEditorPass'))->shouldBeCalled();
$container->addCompilerPass(Argument::type('FSi\\Bundle\\ResourceRepositoryBundle\\DependencyInjection\\Compiler\\TwigFormPass'))->shouldBeCalled();
$container->addCompilerPass(Argument::type('FSi\\Bundle\\ResourceRepositoryBundle\\DependencyInjection\\Compiler\\ResourcePass'))->shouldBeCalled();
$container->addCompilerPass(Argument::type('Doctrine\\Bundle\\DoctrineBundle\\DependencyInjection\\Compiler\\DoctrineOrmMappingsPass'))->shouldBeCalled();
$this->build($container);
}
示例12: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
if ($container->hasExtension('sulu_search')) {
$container->prependExtensionConfig('sulu_search', ['indexes' => ['snippet' => ['security_context' => 'sulu.global.snippets']]]);
}
if ($container->hasExtension('sulu_core')) {
$container->prependExtensionConfig('sulu_core', ['content' => ['structure' => ['paths' => [['path' => __DIR__ . '/../Content/templates', 'type' => 'page']], 'type_map' => ['snippet' => SnippetBridge::class]]]]);
}
if ($container->hasExtension('sulu_content')) {
$container->prependExtensionConfig('sulu_content', ['search' => ['mapping' => [SnippetDocument::class => ['index' => 'snippet']]]]);
}
if ($container->hasExtension('sulu_document_manager')) {
$container->prependExtensionConfig('sulu_document_manager', ['mapping' => ['snippet' => ['class' => SnippetDocument::class, 'phpcr_type' => 'sulu:snippet']]]);
}
}
示例13: build
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
if ($container->hasExtension('fsi_doctrine_extensions')) {
$container->addCompilerPass(new ResourceFSiFilePass());
}
if ($container->hasExtension('fsi_form_extensions')) {
$container->addCompilerPass(new ResourceFSiCKEditorPass());
}
if ($container->hasExtension('ivory_ck_editor')) {
$container->addCompilerPass(new ResourceCKEditorPass());
}
$container->addCompilerPass(new TwigFormPass());
$container->addCompilerPass(new ResourcePass());
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($this->getDoctrineMappings(), array('doctrine.orm.entity_manager')));
}
示例14: prependVariation
/**
* @param ContainerBuilder $container
* @param array $config
*/
private function prependVariation(ContainerBuilder $container, array $config)
{
if (!$container->hasExtension('sylius_variation')) {
return;
}
$container->prependExtensionConfig('sylius_variation', array('classes' => array('product' => array('variable' => $config['classes']['product']['model'], 'variant' => array('model' => 'Sylius\\Component\\Product\\Model\\Variant', 'controller' => 'Sylius\\Bundle\\ProductBundle\\Controller\\VariantController', 'form' => 'Sylius\\Bundle\\ProductBundle\\Form\\Type\\VariantType'), 'option' => array('model' => 'Sylius\\Component\\Product\\Model\\Option'), 'option_value' => array('model' => 'Sylius\\Component\\Product\\Model\\OptionValue')))));
}
示例15: prependField
private function prependField(ContainerBuilder $container, array $config)
{
if (!$container->hasExtension('dag_field')) {
return;
}
$container->prependExtensionConfig('dag_field', array('classes' => array($this->applicationName . ':' . 'patient' => array('subject' => $config['classes']['patient']['model'], 'field' => array('model' => 'Accard\\Component\\Patient\\Model\\Field'), 'field_value' => array('model' => 'Accard\\Component\\Patient\\Model\\FieldValue')))));
}