Ejemplo n.º 1
0
 /**
  * @param string callback key
  * @return string callback function name
  * @throws Exception
  */
 static function callback($key, PixlikesMeta $meta)
 {
     $defaults = pixlikes::defaults();
     $default_callbacks = $defaults['callbacks'];
     $plugin_callbacks = $meta->get('callbacks', array());
     $callbacks = array_merge($default_callbacks, $plugin_callbacks);
     if (isset($callbacks[$key])) {
         return $callbacks[$key];
     } else {
         // missing callback
         throw new Exception('Missing callback for [' . $key . '].');
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string rule
  * @return string error message
  */
 function error_message($rule)
 {
     if (self::$error_message_cache === null) {
         $defaults = pixlikes::defaults();
         $default_errors = $defaults['errors'];
         $plugin_errors = $this->meta->get('errors', array());
         self::$error_message_cache = array_merge($default_errors, $plugin_errors);
     }
     return self::$error_message_cache[$rule];
 }
Ejemplo n.º 3
0
 /**
  * Execute postupdate hooks on input.
  */
 protected function postupdate($input)
 {
     $defaults = pixlikes::defaults();
     $plugin_hooks = $this->meta->get('processor', array('preupdate' => array(), 'postupdate' => array()));
     // Calculate hooks
     // ---------------
     $hooks = array();
     // check pixlikes defaults
     if (isset($defaults['processor']['postupdate'])) {
         $hooks = $defaults['processor']['postupdate'];
     }
     // check plugin defaults
     if (isset($plugin_hooks['postupdate'])) {
         $hooks = array_merge($hooks, $plugin_hooks['postupdate']);
     }
     // Execute hooks
     // -------------
     foreach ($hooks as $rule) {
         $callback = pixlikes::callback($rule, $this->meta);
         call_user_func($callback, $input, $this);
     }
 }