Add click handler on button, that will execute callback. Similar to
onClick, however output from callback execution will appear in a
dialog window with a console.

@param callable $callback
@param string $title
435725
public function onClickConsole($callback, $title = null)
    {
        if (is_null($title)) {
            $title = $this->template->get('Content');
        }

        $this->virtual_page = $this->add('VirtualPage', ['type' => 'frameURL']);
        /** @type VirtualPage $this->virtual_page */
        $this->virtual_page
            ->bindEvent($title)
            ->set(function ($p) use ($callback) {
                /** @type View_Console $console */
                $console = $p->add('View_Console');
                $console->set($callback);
            });
    }
804147
public static function listen(string $event, callable $callback) {
		if (!isset(self::$events[$event])) {
			self::$events[$event] = [];
		}
		self::$events[$event][] = $callback;
	}
602300
public static function capture( $callback = null, $key = null, $attr = null ) 
	{	
		// we got some dynamics in the parameters here so in case
		// of this shift stuff
		if ( is_callable( $attr ) && !is_callable( $callback ) )
		{
			$new_attr = $key;
			$key = $callback;
			$callback = $attr;
			$attr = $new_attr;
		}

		$form = new static;

		if ( is_null( $callback ) )
		{
			throw new Exception( 'Cannot use capture without a callback or string given.' );
		}

		// fix no array given
		if ( !is_array( $attr ) )
		{
			$attr = array();
		} 

		return static::start( $key, $attr ).\CCStr::capture( $callback, array( $form ) ).static::end();
	}
489929
public function add(string $name, callable $callback): self
    {
        call_user_func($this->addCallback, $name, $callback);
        return $this;
    }
48133
public function setCallback($callback = null)
    {
        if (!is_null($callback) && !is_callable($callback)) {
            throw new Exception("callback must be of type callable or null");
        }

        $this->callback = $callback;

        return $this;
    }
514228
protected function afterResolvingCallback(Closure $callback)
    {
        $abstract = $this->getFunctionHint($callback);

        if ($abstract) {
            $this->afterResolvingCallbacks[$abstract][] = $callback;
        } else {
            $this->globalAfterResolvingCallbacks[] = $callback;
        }
    }
817563
public function listen($event, $callback)
    {
        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }

        $this->events[$event][] = $callback;
        return true;
    }
185438
public function listen($eventName, $callback)
    {
        if (is_array($eventName)) {
            foreach ($eventName as $evnt) {
                $this["dispatcher"]->addListener($evnt, $callback);
            }
        } else {
            $this["dispatcher"]->addListener($eventName, $callback);
        }
    }
137092
public function addModal($button, $title, $callback, $owner = null)
    {
        if (!$owner) {
            $modal = $this->owner->owner->add(['Modal', 'title'=>$title]);
        } else {
            $modal = $owner->add(['Modal', 'title'=>$title]);
        }
        $modal->observeChanges(); // adds scrollbar if needed

        $modal->set(function ($t) use ($callback) {
            call_user_func($callback, $t, $this->app->stickyGet($this->name));
        });

        return $this->addAction($button, $modal->show([$this->name=>$this->owner->jsRow()->data('id')]));
    }
453191
public function open(callable $callback)
    {
        $sessionHandleList = $this->getSessionWindowHandles();
        $callback($this->driver);
        for ($i = 0; $i < 10; $i++) {
            $handle = $this->getNewWindow($sessionHandleList);
            if ($handle === null) {
                sleep(1);
            } else {
                $this->setWindowHandle($handle);
                return $this;
            }
        }
        throw new WebDriver_Exception("The expected window didn't open.");
    }
256812
public static function listen($event, $callback)
	{
		if (!isset(self::$events[$event])) {
			self::$events[$event] = array();
		}
		
		self::$events[$event][] = $callback;
		return true;
	}
874494
public function onClick($callback, $confirm_msg = null)
    {
        if ($this->isClicked($confirm_msg)) {

            // TODO: add try catch here
            $ret = call_user_func($callback, $this, $_POST);

            // if callback response is JS, then execute it
            if ($ret instanceof jQuery_Chain) {
                $ret->execute();
            }

            // blank chain otherwise
            $this->js()->univ()->successMessage(is_string($ret) ? $ret : 'Success')->execute();
        }

        return $this;
    }
458680
public function execute(callable $callback)
    {
        $commands = $this->commands;
        $command  = $this->client->createCommand('EXEC');

        $this->client->executeCommand($command, function ($responses, $client) use ($commands, $callback) {
            $size = count($responses);
            $processed = [];

            for ($i = 0; $i < $size; $i++) {
                $command  = $commands->dequeue();
                $response = $responses[$i];

                unset($responses[$i]);

                if (!$response instanceof ResponseInterface) {
                    $response = $command->parseResponse($response);
                }

                $processed[$i] = $response;
            }

            call_user_func($callback, $processed, $client);
        });
    }
1166220
public function when(string $name, callable $callback) : Event
    {
        if ($this->matchEventName($name, $this)){
            ($callback)($this);
            $this->consumed = true;
        }
        return $this;
    }
1204994
function beforeAction(callable $callback, $subtype = false)
    {
        $this->addHook(self::HOOK_BEFORE_ACTION, $callback, false, $subtype);
    }
452077
public function listen(Closure $callback)
    {
        if (isset($this->events)) {
            $this->events->listen(Events\QueryExecuted::class, $callback);
        }
    }
89656
public static function apply($title = null)
    {
        $toolbar = Toolbar::getInstance(self::$_toolbar);
        $title   = (empty($title)) ? __d('core', 'Apply') : $title;

        $toolbar->appendButton('Core.action', $title, self::ACTION_APPLY, [
            'class'  => 'jsFormButton',
            'icon'   => 'check-square-o',
            'button' => 'green lighten-2',
        ]);
    }