/** * @inheritdoc */ public function decorate($content, ViewInterface $view = null, $beginMarker = null, $endMarker = null) { $beginMarker = $beginMarker ?: self::DEFAULT_BEGIN_MARKER; $endMarker = $endMarker ?: self::DEFAULT_END_MARKER; // Only output the comments in development environments if (!$view->getEngine()->getEnvironmentInfo()->isDevMode()) { return $content; } // Determine the spec, which is printed at the beginning and end $spec = array('view'); for ($i = 0, $len = $view->getTargetCount(); $i < $len; ++$i) { $spec[] = $view->getTarget($i); } $spec = implode('.', $spec); // Render and return the result return sprintf('<!-- %s [[ %s ]] --> %s%s<!-- %s [[ %s ]] -->%s', $beginMarker, $spec, PHP_EOL, $content, $endMarker, $spec, PHP_EOL); }
/** * @inheritdoc */ public function buildViewContext(ViewInterface $view, Request $request) { LoggerRegistry::debug('SitegearViewFactory::buildViewContext()'); // Check for special targets at the module level switch ($view->getTarget(View::TARGET_LEVEL_MODULE)) { // $view->template()->{templateName}() case self::SPECIAL_TARGET_MODULE_TEMPLATE: $context = new TemplateViewContext($view, $request); break; // $view->section()->{sectionName}() // $view->section()->{sectionName}() case self::SPECIAL_TARGET_MODULE_SECTION: $index = $this->getIndexSectionName(); $fallback = $this->getFallbackSectionName(); $context = new SectionViewContext($view, $request, $index, $fallback); break; // $view->component()->{componentName}() // $view->component()->{componentName}() case self::SPECIAL_TARGET_MODULE_COMPONENT: $context = new ComponentViewContext($view, $request, true); break; // $view->resources()->{resourceTypeName}() // $view->resources()->{resourceTypeName}() case self::SPECIAL_TARGET_MODULE_RESOURCES: $context = new ResourcesViewContext($view, $request); break; // $view->strings()->{stringName}() // $view->strings()->{stringName}() case self::SPECIAL_TARGET_MODULE_STRINGS: $context = new StringsViewContext($view, $request); break; // $view->{moduleName}()... // $view->{moduleName}()... default: // No special target at the module level, check at the method level switch ($view->getTarget(View::TARGET_LEVEL_METHOD)) { // $view->{moduleName}()->item() case self::SPECIAL_TARGET_METHOD_ITEM: $context = new ModuleItemViewContext($view, $request); break; // $view->{moduleName}()->{componentName}() // $view->{moduleName}()->{componentName}() default: $context = new ComponentViewContext($view, $request, false); } } return $context; }