/** * Add a step callback * * Step callbacks, are callbacks that executed when the API reaches * a certain step, multiple callbacks can be set for the same step. * @param string $step * @param function $callback * @since 0.1.1 * @throws Exception When callback is not not callable * @throws Phramework\Exceptions\IncorrectParametersException */ public function add($step, $callback) { //Check if step is allowed (new \Phramework\Validate\EnumValidator([self::STEP_BEFORE_AUTHENTICATION_CHECK, self::STEP_AFTER_AUTHENTICATION_CHECK, self::STEP_AFTER_CALL_URISTRATEGY, self::STEP_BEFORE_CALL_URISTRATEGY, self::STEP_BEFORE_CLOSE, self::STEP_FINALLY, self::STEP_ERROR]))->parse($step); if (!is_callable($callback)) { throw new \Exception(Phramework::getTranslated('Callback is not callable')); } //If stepCallback list is empty if (!isset($this->stepCallback[$step])) { //Initialize list $this->stepCallback[$step] = []; } //Push $this->stepCallback[$step][] = $callback; }