Symfony\Component\DependencyInjection\ChildDefinition::replaceArgument PHP 메소드

replaceArgument() 공개 메소드

If you directly call setArguments() keep in mind that you must follow certain conventions when you want to overwrite the arguments of the parent definition, otherwise your arguments will only be appended.
public replaceArgument ( integer $index, mixed $value ) : self
$index integer
$value mixed
리턴 self the current instance
    public function replaceArgument($index, $value)
    {
        if (!is_int($index)) {
            throw new InvalidArgumentException('$index must be an integer.');
        }

        $this->arguments['index_'.$index] = $value;

        return $this;
    }

Usage Example

예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function createListener($container, $id, $config, $userProvider)
 {
     $listenerId = $this->getListenerId();
     $listener = new ChildDefinition($listenerId);
     $listener->replaceArgument(2, $id);
     $listener->replaceArgument(3, new Reference($this->createAuthenticationSuccessHandler($container, $id, $config)));
     $listener->replaceArgument(4, new Reference($this->createAuthenticationFailureHandler($container, $id, $config)));
     $listener->replaceArgument(5, array_intersect_key($config, $this->options));
     $listenerId .= '.' . $id;
     $container->setDefinition($listenerId, $listener);
     return $listenerId;
 }
All Usage Examples Of Symfony\Component\DependencyInjection\ChildDefinition::replaceArgument