Beispiel #1
0
 /**
  * Register a Hook (predefined class) to be called at certain events.
  * Can drill down the hook to only execute during a certain scope (controller, action).
  *
  * @access public
  * @param HookInterface $Hook
  * @param array $scope
  * @return void
  * @static
  */
 public static function register(HookInterface $Hook, array $scope = array())
 {
     if ($Hook) {
         $class = App::toDotNotation(get_class($Hook));
         self::$__objectMap[$class] = $Hook;
         foreach (self::$__events as $event) {
             self::$__hooks[$event][$class] = array('executed' => false);
             if (!empty($scope)) {
                 self::$__scopes[$event][$class] = $scope + array('container' => '*', 'controller' => '*', 'action' => '*');
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Manually store an object into registry, and store the object name to the $__mapping array.
  * The property $__registered contains the object where as $__mapping is just the class name.
  *
  * @access public
  * @param object $object
  * @param string $slug
  * @return object
  * @static
  */
 public static function store($object, $slug = null)
 {
     if (!is_object($object)) {
         throw new Exception('The object passed must be instantiated.');
     }
     $namespace = get_class($object);
     $className = App::baseClass($namespace);
     if (!$slug) {
         $slug = App::toDotNotation($namespace);
     }
     static::$__registered[$slug] = $object;
     static::$__mapping = Set::insert(static::$__mapping, $slug, $className);
     return $object;
 }