Exemplo n.º 1
0
 /**
  * Test the setArgument method when the argument already exists, it should be overriden.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testSetArgumentExisting()
 {
     $this->instance->setArgument('foo', 'bar');
     $this->instance->setArgument('foo', 'foo');
     $this->assertTrue($this->instance->hasArgument('foo'));
     $this->assertEquals('foo', $this->instance->getArgument('foo'));
 }
Exemplo n.º 2
0
 /**
  * Add argument to event. It will use a setter method if one exists. The setters have the signature:
  *
  * set<ArgumentName>($value): mixed
  *
  * where:
  *
  * $value  is the value being set by the user
  * It returns the value to return to set in the $arguments array of the event.
  *
  * @param   string  $name   Argument name.
  * @param   mixed   $value  Value.
  *
  * @return  $this
  *
  * @since   __DEPLOY_VERSION__
  */
 public function setArgument($name, $value)
 {
     $methodName = 'set' . ucfirst($name);
     if (method_exists($this, $methodName)) {
         $value = $this->{$methodName}($value);
     }
     return parent::setArgument($name, $value);
 }
Exemplo n.º 3
0
 /**
  * Listen to onSomething.
  *
  * @param   Event  $event  The event.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onSomething(Event $event)
 {
     $listeners = $event->getArgument('listeners');
     $listeners[] = 'third';
     $event->setArgument('listeners', $listeners);
 }
Exemplo n.º 4
0
 /**
  * Listen to onSomething.
  *
  * @param   Event  $event  The event.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onSomething(Event $event)
 {
     $event->setArgument('listeners', array('first'));
 }