本文整理匯總了PHP中Symfony\Component\DependencyInjection\DefinitionDecorator::setAbstract方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefinitionDecorator::setAbstract方法的具體用法?PHP DefinitionDecorator::setAbstract怎麽用?PHP DefinitionDecorator::setAbstract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\DefinitionDecorator
的用法示例。
在下文中一共展示了DefinitionDecorator::setAbstract方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: convert
/**
* Converts class hierarchy metadata to definition instances.
*
* @param ClassHierarchyMetadata $metadata
* @return array an array of Definition instances
*/
public function convert(ClassHierarchyMetadata $metadata)
{
static $count = 0;
$definitions = array();
$previous = null;
foreach ($metadata->classMetadata as $classMetadata) {
if (null === $previous && null === $classMetadata->parent) {
$definition = new Definition();
} else {
$definition = new DefinitionDecorator($classMetadata->parent ?: $previous->id);
}
$definition->setClass($classMetadata->name);
if (null !== $classMetadata->scope) {
$definition->setScope($classMetadata->scope);
}
if (null !== $classMetadata->public) {
$definition->setPublic($classMetadata->public);
}
if (null !== $classMetadata->abstract) {
$definition->setAbstract($classMetadata->abstract);
}
if (null !== $classMetadata->lazy) {
$definition->setLazy($classMetadata->lazy);
}
if (null !== $classMetadata->arguments) {
$definition->setArguments($classMetadata->arguments);
}
$definition->setMethodCalls($classMetadata->methodCalls);
$definition->setTags($classMetadata->tags);
$definition->setProperties($classMetadata->properties);
if (null !== $classMetadata->decorates) {
if (!method_exists($definition, 'setDecoratedService')) {
throw new InvalidAnnotationException(sprintf("decorations require symfony >=2.8 on class %s", $classMetadata->name));
}
$definition->setDecoratedService($classMetadata->decorates, $classMetadata->decoration_inner_name);
}
if (null !== $classMetadata->deprecated && method_exists($definition, 'setDeprecated')) {
$definition->setDeprecated(true, $classMetadata->deprecated);
}
if (null === $classMetadata->id) {
$classMetadata->id = '_jms_di_extra.unnamed.service_' . $count++;
}
if (0 !== count($classMetadata->initMethods)) {
foreach ($classMetadata->initMethods as $initMethod) {
$definition->addMethodCall($initMethod);
}
} elseif (null !== $classMetadata->initMethod) {
@trigger_error('ClassMetadata::$initMethod is deprecated since version 1.7 and will be removed in 2.0. Use ClassMetadata::$initMethods instead.', E_USER_DEPRECATED);
$definition->addMethodCall($classMetadata->initMethod);
}
$definitions[$classMetadata->id] = $definition;
$previous = $classMetadata;
}
return $definitions;
}
示例2: convert
/**
* Converts class hierarchy metadata to definition instances.
*
* @param ClassHierarchyMetadata $metadata
* @return array an array of Definition instances
*/
public function convert(ClassHierarchyMetadata $metadata)
{
static $count = 0;
$definitions = array();
$previous = null;
foreach ($metadata->classMetadata as $classMetadata) {
if (null === $previous && null === $classMetadata->parent) {
$definition = new Definition();
} else {
$definition = new DefinitionDecorator($classMetadata->parent ?: $previous->id);
}
$definition->setClass($classMetadata->name);
if (null !== $classMetadata->scope) {
$definition->setScope($classMetadata->scope);
}
if (null !== $classMetadata->public) {
$definition->setPublic($classMetadata->public);
}
if (null !== $classMetadata->abstract) {
$definition->setAbstract($classMetadata->abstract);
}
if (null !== $classMetadata->arguments) {
$definition->setArguments($classMetadata->arguments);
}
$definition->setMethodCalls($classMetadata->methodCalls);
$definition->setTags($classMetadata->tags);
$definition->setProperties($classMetadata->properties);
if (null === $classMetadata->id) {
$classMetadata->id = '_jms_di_extra.unnamed.service_' . $count++;
}
if ($classMetadata->initMethod) {
if (!method_exists($definition, 'setInitMethod')) {
throw new \RuntimeException(sprintf('@AfterSetup is not available on your Symfony version.'));
}
$definition->setInitMethod($classMetadata->initMethod);
}
$definitions[$classMetadata->id] = $definition;
$previous = $classMetadata;
}
return $definitions;
}
示例3: testDataCacheManagerConfiguration
public function testDataCacheManagerConfiguration()
{
$dataCacheManagerDef = new Definition('Oro\\Bundle\\CacheBundle\\Manager\\OroDataCacheManager');
$fileCacheDef = new DefinitionDecorator(CacheConfigurationPass::FILE_CACHE_SERVICE);
$abstractFileCacheDef = new DefinitionDecorator(CacheConfigurationPass::FILE_CACHE_SERVICE);
$abstractFileCacheDef->setAbstract(true);
$dataCacheDef = new DefinitionDecorator(CacheConfigurationPass::DATA_CACHE_SERVICE);
$abstractDataCacheDef = new DefinitionDecorator(CacheConfigurationPass::FILE_CACHE_SERVICE);
$abstractDataCacheDef->setAbstract(true);
$otherCacheDef = new DefinitionDecorator('some_abstract_cache');
$container = new ContainerBuilder();
$container->setDefinition(CacheConfigurationPass::MANAGER_SERVICE_KEY, $dataCacheManagerDef);
$container->setDefinition('file_cache', $fileCacheDef);
$container->setDefinition('abstract_file_cache', $abstractFileCacheDef);
$container->setDefinition('data_cache', $dataCacheDef);
$container->setDefinition('abstract_data_cache', $abstractDataCacheDef);
$container->setDefinition('other_cache', $otherCacheDef);
$compiler = new CacheConfigurationPass();
$compiler->process($container);
$expectedDataCacheManagerDef = new Definition('Oro\\Bundle\\CacheBundle\\Manager\\OroDataCacheManager');
$expectedDataCacheManagerDef->addMethodCall('registerCacheProvider', [new Reference('file_cache')]);
$expectedDataCacheManagerDef->addMethodCall('registerCacheProvider', [new Reference('data_cache')]);
$this->assertEquals($expectedDataCacheManagerDef, $container->getDefinition(CacheConfigurationPass::MANAGER_SERVICE_KEY));
}