Register a new theme.

@param string $id The theme ID.
@param callable $callback A function to define theme parameters.
@return self Returns a reference to itself.
421927
public function register(string $id, callable $callback): self
    {
        Internal\Themes::$registrations[$id] = $callback;

        if (Config::$initialized) { // Initialize to add asset dirs
            $currentThemeID = Internal\CurrentTheme::getID();
            if ($currentThemeID === $id) {
                Internal\Themes::initialize($currentThemeID);
            }
        }

        return $this;
    }
137406
public function add(string $id): self
    {
        $app = App::get();
        if (\BearFramework\Addons::exists($id)) {
            $app->addons->add($id);
            if (isset(Internal\Data\Addons::$registrations[$id])) {
                $addon = new \BearCMS\Addons\Addon($id);
                call_user_func(Internal\Data\Addons::$registrations[$id], $addon);
                if (is_callable($addon->initialize)) {
                    call_user_func($addon->initialize);
                }
            }
        }
        return $this;
    }
795764
public function callback(string $name, callable $callback): self
    {
        $this->callbacks[$name] = $callback;
        return $this;
    }
242589
protected static function registerModelEvent($event, $callback)
    {
        $event = self::makeModelEventName($event);

        event()->listen($event, $callback);
    }
445925
public function on(String $parameter, $callback)
    {
        $this->settings['attr']['on']         = $parameter;
        $this->settings['attr']['onCallback'] = $this->stringOrCallback($callback);

        return $this;
    }
768352
public function reanimateCallback($callback)
    {
        $key = $this->getCallbackKey($callback);

        self::$_baseRealCallbacks[$key] = $callback;

        return $this;
    }
1100860
public function registerClientScript($id)
	{
        $booster = Booster::getBooster();
        $booster->registerAssetJs('bootstrap-modalmanager.js', CClientScript::POS_HEAD);
        $booster->registerAssetCss('bootstrap-modalmanager.css');

		$options = !empty($this->format) ? CJavaScript::encode(array('format' => $this->format)) : '';

		ob_start();
		echo "jQuery('#{$id}').modalmanager({$options})";
		foreach ($this->events as $event => $handler) {
			echo ".on('{$event}', " . CJavaScript::encode($handler) . ")";
		}

		Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';');

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			Yii::app()->getClientScript()->registerScript(
				__CLASS__ . '#' . $id . '_' . $name,
				"jQuery('#{$id}').on('{$name}', {$handler});"
			);
		}
	}
107374
public function save($callback)
    {
        foreach ($this as $object) {
            call_user_func($callback, $object);
            if($object->changes()) $object->save();
        }

        return $this;
    }
762522
public function register($name, Closure $callback)
    {
        $this->checkCallbackName($name);

        $this->callbacks[$name] = $callback;

        return $this;
    }
1136831
public function actionIndex($callback, $id)
    {
        $model = NavItemPageBlockItem::findOne($id);
        
        if (!$model) {
            throw new Exception("Unable to find item id.");
        }
        
        $block = $model->block->getObject($model->id, 'callback');

        if (!$block) {
            throw new Exception("Unable to find block object.");
        }
        
        return ObjectHelper::callMethodSanitizeArguments($block, $this->callbackToMethod($callback), Yii::$app->request->get());
    }
781261
public function addIndex(string $id, callable $callback): self
    {
        $index = new MapIndex($callback);

        foreach ($this->elements as $key => $element) {
            $index->add($key, $element);
        }

        $this->indexes[$id] = $index;

        return $this;
    }
370864
public final function hook($hookId, callable $callback = null)
	{
		if (null === $callback) {
			//触发
			if (isset($this->hooks[$hookId])) {
				return ($this->hooks[$hookId])($this);
			}
		} else {
			//绑定
			$id = 1;
			while ($hookId > 0) {
				if ($hookId & 1 == 1) {
					$this->hooks[$id] = $callback;
				}
				$id *= 2;
				$hookId >>= 1;
			}
		}
	}
921190
protected function attachEvent(EventManagerInterface $events, $id, $event, $callback)
    {
        /** @var \Zend\EventManager\SharedEventManager $sharedEvents */
        $sharedEvents = $events->getSharedManager();

        $this->listeners[] = $sharedEvents->attach($id, $event, array($this, $callback), 100);
    }
304951
public function addCallback(string $name, $callback)
    {
        if (!is_object($callback)) {
            throw new \InvalidArgumentException('Given callback must be an object');
        }

        $this->callbacks[$name] = $callback;
    }
1277341
public function customize($callback)
    {
        foreach ($this->requestDataSetGenerators as $requestDataSetGenerator) {
            $callback($requestDataSetGenerator, $requestDataSetGenerator->getRouteInfo());
        }

        return $this;
    }
1180721
public function register($event, $callback)
	{
		// check if this is a valid event type
		if ( ! isset($this->callbacks[$event]))
		{
			throw new \InvalidArgumentException($event.' is not a valid event');
		}

		// check if the callback is acually callable
		if ( ! is_callable($callback))
		{
			throw new \InvalidArgumentException('Callback passed is not callable');
		}

		// store it
		$this->callbacks[$event][] = $callback;
	}
422861
public function setEditableCallback($callback)
    {
        $this->isEditable() ?: $this->setEditable();
        $this->editableCallback = $callback;

        return $this;
    }