Ejemplo n.º 1
0
 private function getActionImplementationMap()
 {
     if ($this->actionMap === null) {
         // We can't use PhutilClassMapQuery here because action expansion
         // depends on the adapter and object.
         $object = $this->getObject();
         $map = array();
         $all = HeraldAction::getAllActions();
         foreach ($all as $key => $action) {
             $action = id(clone $action)->setAdapter($this);
             if (!$action->supportsObject($object)) {
                 continue;
             }
             $subactions = $action->getActionsForObject($object);
             foreach ($subactions as $subkey => $subaction) {
                 if (isset($map[$subkey])) {
                     throw new Exception(pht('Two HeraldActions (of classes "%s" and "%s") have the same ' . 'action key ("%s") after expansion for an object of class ' . '"%s" inside adapter "%s". Each action must have a unique ' . 'action key.', get_class($subaction), get_class($map[$subkey]), $subkey, get_class($object), get_class($this)));
                 }
                 $subaction = id(clone $subaction)->setAdapter($this);
                 $map[$subkey] = $subaction;
             }
         }
         $this->actionMap = $map;
     }
     return $this->actionMap;
 }