Symfony\Component\DependencyInjection\Definition::setAbstract PHP Method

setAbstract() public method

Whether this definition is abstract, that means it merely serves as a template for other definitions.
public setAbstract ( boolean $boolean ) : Definition
$boolean boolean
return Definition the current instance
    public function setAbstract($boolean)
    {
        $this->abstract = (bool) $boolean;

        return $this;
    }

Usage Example

 public function testProcess()
 {
     $container = new ContainerBuilder();
     $simpleFactory = new Definition();
     $simpleProcessor = new Definition('Test\\SimpleProcessor');
     $simpleProcessor->addTag('processor');
     $abstractProcessor = new Definition();
     $abstractProcessor->setAbstract(true);
     $abstractProcessor->addTag('processor');
     $lazyProcessor = new Definition('Test\\LazyProcessor');
     $lazyProcessor->setLazy(true);
     $lazyProcessor->addTag('processor');
     $withArgumentsProcessor = new Definition('Test\\WithArgumentsProcessor', ['test']);
     $withArgumentsProcessor->addTag('processor');
     $container->addDefinitions(['simple_factory' => $simpleFactory, 'simple_processor' => $simpleProcessor, 'abstract_processor' => $abstractProcessor, 'lazy_processor' => $lazyProcessor, 'with_arguments_processor' => $withArgumentsProcessor]);
     $compilerPass = new CleanUpProcessorsCompilerPass('simple_factory', 'processor');
     $compilerPass->process($container);
     $this->assertFalse($container->hasDefinition('simple_processor'));
     $this->assertTrue($container->hasDefinition('abstract_processor'));
     $this->assertTrue($container->hasDefinition('lazy_processor'));
     $this->assertTrue($container->hasDefinition('with_arguments_processor'));
     $methodCalls = $simpleFactory->getMethodCalls();
     $this->assertCount(1, $methodCalls);
     $this->assertEquals(['addProcessor', ['simple_processor', 'Test\\SimpleProcessor']], $methodCalls[0]);
 }
All Usage Examples Of Symfony\Component\DependencyInjection\Definition::setAbstract