Add handler to elFinder command

@param  string  command name
@param  string|array  callback name or array(object, method)
@return elFinder
@author Dmitry (dio) Levashov
184249
public function bind($cmd, $handler) {
		$allCmds = array_keys($this->commands);
		$cmds = array();
		foreach(explode(' ', $cmd) as $_cmd) {
			if ($_cmd !== '') {
				if ($all = strpos($_cmd, '*') !== false) {
					list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
					if ($sub) {
						$sub = str_replace('\'', '\\\'', $sub);
						$addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');');
						$cmds = array_merge($cmds, array_map($addSub, $allCmds));
					} else {
						$cmds = array_merge($cmds, $allCmds);
					}
				} else {
					$cmds[] = $_cmd;
				}
			}
		}
		$cmds = array_unique($cmds);
		
		foreach ($cmds as $cmd) {
			if (!isset($this->listeners[$cmd])) {
				$this->listeners[$cmd] = array();
			}

			if (is_callable($handler)) {
				$this->listeners[$cmd][] = $handler;
			}
		}

		return $this;
	}
130743
protected function _commandNew($command)
    {
        $name = $this->getController()->getIdentifier()->name;

        $command
        ->append(array('label' => AnTranslator::_('COM-UBSCRIPTIONS-TOOLBAR-'.$name.'-NEW')))
        ->href('#')
        ->setAttribute('data-trigger', 'ReadForm');
    }
688511
def add_command(self, handler, name=None):
        
        if name is None:
            name = docstring_to_subcommand(handler.__doc__)

        # TODO: Prevent overwriting 'help'?
        self._commands[name] = handler
799493
public function getCommand(string $name): AbstractCommand
	{
		$this->initCommands();

		if (!$this->hasCommand($name))
		{
			throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
		}

		// If the command isn't registered, pull it from the loader
		if (!isset($this->commands[$name]))
		{
			$this->addCommand($this->commandLoader->get($name));
		}

		$command = $this->commands[$name];

		// If the user requested help, we'll fetch the help command now and inject the user's command into it
		if ($this->wantsHelp)
		{
			$this->wantsHelp = false;

			/** @var HelpCommand $helpCommand */
			$helpCommand = $this->getCommand('help');
			$helpCommand->setCommand($command);

			return $helpCommand;
		}

		return $command;
	}
853073
protected function runCommand(string $name, $handler, array $options)
    {
        if (\is_object($handler) && \method_exists($handler, '__invoke')) {
            if ($this->input->getSameOpt(['h', 'help'])) {
                $desc = $options['description'] ?? 'No command description message';

                return $this->output->write($desc);
            }

            $result = $handler($this->input, $this->output);
        } else {
            if (!\class_exists($handler)) {
                Helper::throwInvalidArgument("The console command class [$handler] not exists!");
            }

            /** @var Command $object */
            $object = new $handler($this->input, $this->output);

            if (!($object instanceof Command)) {
                Helper::throwInvalidArgument("The console command class [$handler] must instanceof the " . Command::class);
            }

            $object::setName($name);
            $object->setApp($this);
            $result = $object->run();
        }

        return $result;
    }
363873
private function createCurlHandler()
    {
        $handlerOptions = [
            'handle_factory' => new CurlFactory(3),
        ];

        if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
            return Proxy::wrapSync(new CurlMultiHandler($handlerOptions), new CurlHandler($handlerOptions));
        }

        if (\function_exists('curl_exec')) {
            return new CurlHandler($handlerOptions);
        }

        if (\function_exists('curl_multi_exec')) {
            return new CurlMultiHandler($handlerOptions);
        }

        throw new \RuntimeException('Blackfire Player requires cURL.');
    }
362741
public CommandCallback findCommandCallback(String name, ClassLoader cl) {
        synchronized (callbackCache) {
            
            if (!callbackCache.containsKey(name)) {
                try {
                    CommandCallback commandCallbackInstance = (CommandCallback) Class.forName(name, true, cl).newInstance();
                    return commandCallbackInstance;
                    //                            callbackCache.put(name, commandCallbackInstance);
                } catch (Exception ex) {
                    throw new IllegalArgumentException("Unknown Command implementation with name '" + name + "'");
                }

            } else {
                CommandCallback cmdCallback = callbackCache.get(name);
                if (!cmdCallback.getClass().getClassLoader().equals(cl)) {
                    callbackCache.remove(name);
                    try {
                        CommandCallback commandCallbackInstance = (CommandCallback) Class.forName(name, true, cl).newInstance();
                        callbackCache.put(name, commandCallbackInstance);
                    } catch (Exception ex) {
                        throw new IllegalArgumentException("Unknown Command implementation with name '" + name + "'");
                    }
                }
            }

        }
        return callbackCache.get(name);
    }
266649
public function addCallbackCommand($command)
    {
        if (!is_object($command)) {
            if (!class_exists($command)) {
                throw new TelegramSDKException(
                    sprintf(
                        'Command class "%s" not found! Please make sure the class exists.',
                        $command
                    )
                );
            }

            if ($this->telegram->hasContainer()) {
                $command = $this->buildDependencyInjectedAnswer($command);
            } else {
                $command = new $command();
            }
        }

        if ($command instanceof CallbackCommandInterface) {

            /*
             * At this stage we definitely have a proper command to use.
             *
             * @var CallbackCommand $command
             */
            $this->commands[$command->getName()] = $command;

            return $this;
        }

        throw new TelegramSDKException(
            sprintf(
                'Command class "%s" should be an instance of "Telegram\Bot\Callback\CallbackCommandInterface"',
                get_class($command)
            )
        );
    }
156738
function (command, callback) {

    var self = this;
    var callbacked = false;

    function handleError (err) {
      debug(err);

      if (_.isString(err)) {
        if (_.isEmpty(err)) {
          err = self.description;
        }
        err = new BusinessRuleError(err);
      } else if (err instanceof BusinessRuleError) {
        // do nothing
      } else {
        err = new BusinessRuleError(err.message || self.description);
      }

      callbacked = true;
      callback(err);
    }

    var payload;
    if (!this.payload || this.payload === '') {
      payload = command;
    } else {
      payload = dotty.get(command, this.payload);
    }

    try {
      if (this.preLoadConditionFn.length === 2) {
        this.preLoadConditionFn(_.cloneDeep(payload), function (err) {
          if (err) {
            return handleError(err);
          }
          callbacked = true;
          callback(null);
        });
      } else {
        var err = this.preLoadConditionFn(_.cloneDeep(payload));
        if (err) {
          return handleError(err);
        }
        callbacked = true;
        callback(null);
      }
    } catch (err) {
      if (!callbacked) {
        return handleError(err);
      }
      throw err;
    }
  }
101889
public function addDirective($name, Aoe_ExtendedFilter_Model_Directive_Interface $handler)
    {
        $name = strtolower(trim($name));
        $this->directives[$name] = $handler;
        return $this;
    }
424137
public static function tooManyCommandHandler(AbstractCommand $command, array $commandHandlers)
    {
        $handlerClassNames = array_map(
            function (CommandHandlerInterface $commandHandler) {
                return get_class($commandHandler);
            },
            $commandHandlers
        );

        return new self(
            sprintf(
                'There are too many command handler for the command type %s. Candidates are %s.',
                get_class($command),
                implode(', ', $handlerClassNames)
            )
        );
    }
1296568
public function toHandler($command)
    {
        $class = get_class($command);
        $offset = ($this->positionAt('Command', $class)) ?: $this->positionAt('Request', $class);
        $handlerClass = substr_replace($class, 'Handler', $offset);

        if (!class_exists($handlerClass)) {
            $message = "Command handler [$handlerClass] does not exist.";
            throw new HandlerNotRegisteredException($message);
        }

        return $handlerClass;
    }
934569
function(name, handler) {
		if (typeof handler === 'string')
			handler = listenerParser.parseListener(handler);
		return this.exec('on', [name, handler]);
	}
1130097
public function addCommand($command)
    {
        if (is_string($command)) {
            $command = $this->app->make($command);
        }

        if ($command instanceof Command) {
            $command->setLaravel($this->app);
        }

        $this->console->add($command);
    }
818778
public function of($name, Closure $callback = null): Handler
    {
        if ($name instanceof Closure) {
            $callback = $name;
            $name = $this->getDefaultDriver();
        }

        $instance = $this->make($name);

        if ($instance instanceof Handler && ! \is_null($callback)) {
            $callback($instance);
        }

        return $instance;
    }
245240
public function addHandler($commandClassName, $handler)
    {
        if (!is_string($commandClassName)) {
            throw new \InvalidArgumentException('The command name should be a string');
        }

        $this->handlers[$commandClassName] = $handler;
    }
1035836
function (cmd, callback) {
    if (!cmd || !_.isObject(cmd)) {
      var err = new Error('Please pass a valid command!');
      debug(err);
      throw err;
    }

    if (!callback || !_.isFunction(callback)) {
      var err = new Error('Please pass a valid callback!');
      debug(err);
      throw err;
    }

    var target = this.getTargetInformation(cmd);

    var commandHandler = this.tree.getCommandHandler(target);

    // if (!commandHandler) {
    //   commandHandler = this.tree.getCommandHandlerByOldTarget(target);
    // }

    if (!commandHandler) {
      var err = new Error('No command handler found for ' + target.name);
      debug(err);
      return callback(err);
    }

    if (!this.commandBumper) {
      return commandHandler.handle(cmd, callback);
    }

    var key = target.context + target.aggregate + target.aggregateId + dotty.get(cmd, this.definition.id);

    this.commandBumper.add(key, function (err, added) {
      if (err) {
        return callback(err);
      }

      if (!added) {
        return callback(new DuplicateCommandError('Command already seen!'));
      }

      commandHandler.handle(cmd, callback);
    });
  }