/**
  * @param string rule
  *
  * @return string error message
  */
 function error_message($rule)
 {
     if (self::$error_message_cache === null) {
         $defaults = custom_body_class::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];
 }
 /**
  * Execute postupdate hooks on input.
  */
 protected function postupdate($input)
 {
     $defaults = custom_body_class::defaults();
     $plugin_hooks = $this->meta->get('processor', array('preupdate' => array(), 'postupdate' => array()));
     // Calculate hooks
     // ---------------
     $hooks = array();
     // check custom_body_class 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 = custom_body_class::callback($rule, $this->meta);
         call_user_func($callback, $input, $this);
     }
 }
 /**
  * @param string callback key
  *
  * @return string callback function name
  * @throws Exception
  */
 static function callback($key, CustomBodyClassMeta $meta)
 {
     $defaults = custom_body_class::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 . '].');
     }
 }