diff --git a/app/Shortcodes/Widget.php b/app/Shortcodes/Widget.php index bad16564..ac531540 100644 --- a/app/Shortcodes/Widget.php +++ b/app/Shortcodes/Widget.php @@ -19,6 +19,11 @@ class Widget return call_user_func([$presenter, 'render'], $widget); } + /** + * Load one widget from database + * + * @param $containerId + */ protected function loadWidget($containerId) { $widget = WidgetModel::where('container_id', $containerId) @@ -36,6 +41,11 @@ class Widget self::$widgets[$containerId] = $this->getRenderedWidget($widget); } + /** + * Load all frequently used widgets + * + * Frequency of loaded widgets is counted only using direct loading, widgets displayed in widget areas are omitted + */ protected function initWidgets() { if (self::$initialized) { @@ -53,6 +63,18 @@ class Widget self::$initialized = true; } + /** + * Register new shortcode + * + * Initfrequently used widgets and if not presented yet - load desired widget specified as content of shortcode + * + * @param $shortcode + * @param $containerId + * @param $compiler + * @param $name + * + * @return mixed + */ public function register($shortcode, $containerId, $compiler, $name) { $this->initWidgets();