/** * Embeds output of widgets in view as configured. * * @param string $stage marks stage of view manager when calling this function */ protected function processConfiguredWidgets($stage) { foreach (config::getList('view.widget') as $spec) { // filter by stage if (array_key_exists('stage', $spec)) { $stages = $spec['stage']; if (!is_array($stages)) { $stages = preg_split('/[,\\s]+/', $stages); } if (!in_array($stage, $stages)) { continue; } } else { // provide backwards compatible behaviour // -> w/o marking stage process on load-stage, only if ($stage !== "load") { continue; } } if (array_key_exists('viewport', $spec)) { $viewport = $spec['viewport']; } else { $viewport = $spec['target']; } if (trim($viewport) === '') { $viewport = 'main'; } $provider = array($spec['provider']['class'], $spec['provider']['method']); if (is_callable($provider)) { $args = $spec['provider']['selector']; if (!is_array($args)) { $args = array($args); } $widget = call_user_func_array($provider, $args); $this->writeInViewport($viewport, data::asString($widget), !$spec['prepend']); } } }