Exemplo n.º 1
0
 /**
  * Test the offsetSet method.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testOffsetSet()
 {
     $this->instance['foo'] = 'bar';
     $this->assertTrue($this->instance->hasArgument('foo'));
     $this->assertEquals('bar', $this->instance->getArgument('foo'));
     $argument = array('test' => array('foo' => 'bar', 'test' => 'test'), 'foo' => new \stdClass());
     $this->instance['foo'] = $argument;
     $this->assertTrue($this->instance->hasArgument('foo'));
     $this->assertSame($argument, $this->instance->getArgument('foo'));
 }
Exemplo n.º 2
0
 /**
  * Get an event argument value. It will use a getter method if one exists. The getters have the signature:
  *
  * get<ArgumentName>($value): mixed
  *
  * where:
  *
  * $value  is the value currently stored in the $arguments array of the event
  * It returns the value to return to the caller.
  *
  * @param   string  $name     The argument name.
  * @param   mixed   $default  The default value if not found.
  *
  * @return  mixed  The argument value or the default value.
  *
  * @since   __DEPLOY_VERSION__
  */
 public function getArgument($name, $default = null)
 {
     $methodName = 'get' . ucfirst($name);
     $value = parent::getArgument($name, $default);
     if (method_exists($this, $methodName)) {
         return $this->{$methodName}($value);
     }
     return $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);
 }