示例#1
0
 /**
  * Calls all handlers associated with an event group.
  *
  * @param   string  $event  The event name.
  * @param   array   $args   An array of arguments (optional).
  *
  * @return  array   An array of results from each function call, or null if no dispatcher is defined.
  *
  * @since   12.1
  */
 public function triggerEvent($event, array $args = null)
 {
     if ($this->dispatcher instanceof JEventDispatcher) {
         return $this->dispatcher->trigger($event, $args);
     }
     return null;
 }
示例#2
0
 /**
  * Test JEventDispatcher::trigger().
  *
  * @since    11.3
  *
  * @return void
  */
 public function testTrigger()
 {
     $this->object->register('onTestEvent', 'JEventMockFunction');
     $this->object->register('', 'JEventInspector');
     // We check a non-existing event
     $this->assertThat($this->object->trigger('onFakeEvent'), $this->equalTo(array()));
     // Let's check the existing event "onTestEvent" without parameters
     $this->assertThat($this->object->trigger('onTestEvent'), $this->equalTo(array('JEventDispatcherMockFunction executed', '')));
     // Let's check the existing event "onTestEvent" with parameters
     $this->assertThat($this->object->trigger('onTestEvent', array('one', 'two')), $this->equalTo(array('JEventDispatcherMockFunction executed', 'onetwo')));
     // We check a situation where the observer is broken. Joomla should handle this gracefully
     TestReflection::setValue($this->object, '_observers', array());
     $this->assertThat($this->object->trigger('onTestEvent'), $this->equalTo(array()));
 }
示例#3
0
 /**
  * Start a session.
  *
  * @return  void
  *
  * @since   12.2
  */
 public function start()
 {
     if ($this->_state === 'active') {
         return;
     }
     $this->_start();
     $this->_state = 'active';
     // Initialise the session
     $this->_setCounter();
     $this->_setTimers();
     // Perform security checks
     $this->_validate();
     if ($this->_dispatcher instanceof JEventDispatcher) {
         $this->_dispatcher->trigger('onAfterSessionStart');
     }
 }
示例#4
0
 /**
  * Use filter rules to filter value in fields.
  *
  * @param   string $field_type Type of this field.
  * @param   array  $data       The data array for filter.
  *
  * @return  array   Filtered dates.
  */
 public function filterFields($field_type = 'text', $data = array())
 {
     // Clean text
     // ==================================================================
     foreach ($data as $key => &$val) {
         if ($key == 'options' || is_array($val)) {
             continue;
         }
         $val = trim($val);
     }
     // Filter Text
     // ==================================================================
     $form = null;
     // Event
     $this->event->trigger('onCCKEngineBeforeFormLoad', array(&$form, &$data));
     $form = \JForm::getInstance('fields', $field_type, array(), false, false);
     // Event
     $this->event->trigger('onCCKEngineAfterFormLoad', array(&$form, &$data));
     $data = $form->filter($data);
     return $data;
 }
示例#5
0
 /**
  * Start a session.
  *
  * @return  void
  *
  * @since   12.2
  */
 public function start()
 {
     if ($this->_state === 'active') {
         return;
     }
     $this->_start();
     $this->_state = 'active';
     // Initialise the session
     $this->_setCounter();
     $this->_setTimers();
     // Perform security checks
     if (!$this->_validate()) {
         // If the session isn't valid because it expired try to restart it
         // else destroy it.
         if ($this->_state === 'expired') {
             $this->restart();
         } else {
             $this->destroy();
         }
     }
     if ($this->_dispatcher instanceof JEventDispatcher) {
         $this->_dispatcher->trigger('onAfterSessionStart');
     }
 }