Exemple #1
0
 /**
  * Returns the global Event Dispatcher object, only creating it
  * if it doesn't already exist.
  *
  * @return  F0FUtilsObservableDispatcher  The EventDispatcher object.
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new static();
     }
     return self::$instance;
 }
Exemple #2
0
 /**
  * Method to allow derived classes to preprocess the form.
  *
  * @param   F0FForm  $form   A F0FForm object.
  * @param   mixed    &$data  The data expected for the form.
  * @param   string   $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @see     F0FFormField
  * @since   2.0
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(F0FForm &$form, &$data, $group = 'content')
 {
     // Import the appropriate plugin group.
     F0FPlatform::getInstance()->importPlugin($group);
     // Trigger the form preparation event.
     $results = F0FPlatform::getInstance()->runPlugins('onContentPrepareForm', array($form, $data));
     // Check for errors encountered while preparing the form.
     if (count($results) && in_array(false, $results, true)) {
         // Get the last error.
         $dispatcher = F0FUtilsObservableDispatcher::getInstance();
         $error = $dispatcher->getError();
         if (!$error instanceof Exception) {
             throw new Exception($error);
         }
     }
 }