/** * Extend an action by appending additional logic * * Note that this modifies the original action as opposed to creating a new action. * The action returned will be the same one you called `extend()` on but will have a * modified operation and dependencies. * * @access public * @param ActionInterface $action The action with which to extend this one * @return Action the extended action */ public function extend(ActionInterface $action) { $principal = $this->getOperation(); $extension = $action->getOperation(); $this->dependencies = array_unique(array_merge($this->getDependencies(), $action->getDependencies())); $this->operation = function () use($principal, $extension) { call_user_func_array($principal, func_get_args()); call_user_func_array($extension, func_get_args()); }; return $this; }