Register macro handler

@param callable|MacroHandlerInterface $handler

@return MacroProcessor
185888
public function addHandler($handler) : MacroProcessor
    {
        if (is_callable($handler)){
            $this->handlers[] = $handler;
        }
        else if ($handler instanceof MacroHandlerInterface){
            $this->handlers[] = array($handler, 'process');
        }
        else if (is_array($handler)){
            $this->handlers[] = function ($keyword) use($handler){
                return $handler[$keyword] ?? null;
            };
        }
        return $this;
    }
1025785
public function setHandler($handler = null)
    {
        $this->handler = null !== $handler ? (string)$handler: $handler;

        return $this;
    }
784689
public function withHandler($handler): self
    {
        return tap($this, function ($request) use ($handler) {
            return $this->handler = $handler;
        });
    }
527459
public function bind($cmd, $handler)
    {
        $cmds = array_map('trim', explode(' ', $cmd));

        foreach ($cmds as $cmd) {
            if ($cmd) {
                if (!isset($this->listeners[$cmd])) {
                    $this->listeners[$cmd] = array();
                }

                if ((is_array($handler) && count($handler) == 2 && is_object($handler[0]) && method_exists($handler[0], $handler[1]))
                || function_exists($handler)) {
                    $this->listeners[$cmd][] = $handler;
                }
            }
        }

        return $this;
    }
127259
public function addMacro(MacroInterface $macro)
	{
		if (!method_exists($macro, 'handle'))
		{
			throw new \LogicException(sprintf('%s does not have a handle method.', get_class($macro)));
		}

		$this->macros[$macro->getMethod()] = $macro;

		return $this;
	}
391632
public function setClassForString(Callable $handler): ColumnInterface
    {
        $this->key = self::ACTION_STRING_TR;
        $this->setHandler($handler);

        return $this;
    }
557529
public function add(string $signal, callable $handler): self
    {
        $this->handlers[$signal] = $handler;

        return $this;
    }
611373
public function setResolverHandler(
        ResolverInterface $handler,
        bool $static = false
    ) {
        if ($static) {
            self::$globalResolverHandler = $handler;
        }

        $this->resolverHandler = $handler;

        return $this;
    }
124895
public function addHandler($handler)
    {
        if ($this->handlerLock) {
            throw new \RuntimeException('Session handlers can’t be added once the stack is dequeuing');
        }
        if (is_null($this->handlers)) {
            $this->seedHandlerStack();
        }

        // DELETE
        $next_delete = $this->stacks['delete']->top();
        $this->stacks['delete'][] = function($session_id) use ($handler, $next_delete) {
            return call_user_func(array( $handler, 'delete'), $session_id, $next_delete);
        };

        // CLEAN
        $next_clean = $this->stacks['clean']->top();
        $this->stacks['clean'][] = function($lifetime) use ($handler, $next_clean) {
            return call_user_func(array( $handler, 'clean'), $lifetime, $next_clean);
        };

        // CREATE
        $next_create = $this->stacks['create']->top();
        $this->stacks['create'][] = function($path, $name) use ($handler, $next_create) {
            return call_user_func(array( $handler, 'create'), $path, $name, $next_create);
        };

        // READ
        $next_read = $this->stacks['read']->top();
        $this->stacks['read'][] = function($session_id) use ($handler, $next_read) {
            return call_user_func(array( $handler, 'read'), $session_id, $next_read);
        };

        // WRITE
        $next_write = $this->stacks['write']->top();
        $this->stacks['write'][] = function($session_id, $session_data) use ($handler, $next_write) {
            return call_user_func(array( $handler, 'write'), $session_id, $session_data, $next_write);
        };

        return $this;
    }
656888
public function create(callable $handler): callable
    {
        foreach ($this->wrappers as $wrapper) {
            $handler = $wrapper->wrap($handler);
        }

        return $handler;
    }
908394
public function setNotFoundHandler($handler) : ClosureAutoBind
    {
        if (!$this->isClosure($handler)) {
            throw new InvalidArgumentException(
                'Handler must be closure'
            );
        }

        $this->notFoundHandler = $handler;

        return $this;
    }
517154
public function handler($handler, $construct = null)
    {
        $this->handler   = $handler;
        $this->construct = $construct;
        return $this;
    }
831516
public function removeHandler($handler)
    {
        if(!is_callable($handler))
            throw new \InvalidArgumentException("Argument 1 of Event->addHandler needs to be a valid callback");

        $i = array_search($handler, $this->_handlers, true);

        if ($i !== false)
            unset($this->_handlers[$i]);

        return $this;
    }
1120504
protected function executeHandler($handler, array $parameters)
	{
		if($handler instanceof Closure)
		{
			return $this->executeClosureHandler($handler, $parameters);
		}

		$handler = $this->resolveHandler($handler);

		return $this->executeClassHandler($handler, $parameters);
	}
668910
protected static function createMigration(HandlerInterface $handler)
    {
        $migrator = static::$migrator;
        $notifier = new Notifier();

        $migration = $migrator->createMigration(
            strtolower($handler->getName()),
            $handler->getTemplate(),
            $handler->getReplace()
        );

        $migrator->logSuccessfulMigration($migration);
        $notifier->newMigration($migration);
    }
60020
public function registerCommand(CommandInterface $commandHandler)
    {
        $command = strtoupper($commandHandler->getCommand());
        $this->commandHandlers[$command] = $commandHandler;
    }
858816
public function instantiate(string $handler) : EventHandler
    {
        if (false === isset($this->handlers[$handler])) {
            throw new InvalidArgumentException(
                sprintf('Handler %s could not be found. Did you register it?', $handler)
            );
        }

        $callable = $this->handlers[$handler];

        return ($callable instanceof \Closure) ? $callable() : new $callable();
    }