Symfony\Component\DependencyInjection\InterfaceInjector::removeMethodCall PHP Method

removeMethodCall() public method

Removes a method to call after service initialization.
public removeMethodCall ( string $method ) : Definition
$method string The method name to remove
return Definition The current instance
    public function removeMethodCall($method)
    {
        foreach ($this->calls as $i => $call) {
            if ($call[0] === $method) {
                unset($this->calls[$i]);
                break;
            }
        }

        return $this;
    }

Usage Example

 /**
  * @covers Symfony\Component\DependencyInjection\InterfaceInjector::addMethodCall
  * @covers Symfony\Component\DependencyInjection\InterfaceInjector::hasMethodCall
  * @covers Symfony\Component\DependencyInjection\InterfaceInjector::removeMethodCall
  * @covers Symfony\Component\DependencyInjection\InterfaceInjector::getMethodCalls
  *
  * @dataProvider getMethodCalls
  *
  * @param string $method
  * @param array $arguments
  */
 public function testAddRemoveGetMethodCalls($method, array $arguments = array())
 {
     $injector = new InterfaceInjector('stdClass');
     $injector->addMethodCall($method, $arguments);
     $this->assertTrue($injector->hasMethodCall($method), '->hasMethodCall() returns true for methods that were added on InterfaceInjector');
     $methodCalls = $injector->getMethodCalls();
     $this->assertEquals(1, count($methodCalls), '->getMethodCalls() returns array, where each entry is a method call');
     $this->assertEquals(array($method, $arguments), $methodCalls[0], '->getMethodCalls() has all methods added to InterfaceInjector instance');
     $injector->removeMethodCall($method);
     $this->assertFalse($injector->hasMethodCall($method), '->removeMethodClass() deletes the method call from InterfaceInjector');
 }