/** * {@inheritdoc} */ public function isApplicable(ContextInterface $context, array $processorAttributes) { if (empty($processorAttributes['group']) || !$context->hasSkippedGroups()) { return self::ABSTAIN; } return in_array($processorAttributes['group'], $context->getSkippedGroups(), true) ? self::NOT_APPLICABLE : self::ABSTAIN; }
/** * {@inheritdoc} */ public function rewind() { $this->action = $this->context->getAction(); $this->index = -1; $this->maxIndex = isset($this->processors[$this->action]) ? count($this->processors[$this->action]) - 1 : -1; $this->nextApplicable(); }
/** * {@inheritdoc} */ public function isApplicable(ContextInterface $context, array $processorAttributes) { $result = self::APPLICABLE; foreach ($processorAttributes as $key => $value) { if ($key === 'group' || !is_scalar($value) && !is_array($value)) { continue; } if (!$context->has($key)) { $result = self::ABSTAIN; } elseif (!$this->isMatch($value, $context->get($key))) { $result = self::NOT_APPLICABLE; break; } } return $result; }
/** * {@inheritdoc} */ public function getPath() { $result = ''; $result = $this->join($result, $this->context->getPath()); $result = $this->join($result, $this->module); $result = $this->join($result, $this->filePath); return $result; }
/** * @param string $name The name of the data provider * * @return mixed The returned values: * DataProviderInterface if the data provider is loaded * mixed if data should be loaded from the layout context * false if the requested data cannot be loaded */ protected function getDataProvider($name) { if (isset($this->dataProviders[$name])) { return $this->dataProviders[$name]; } $dataProvider = $this->registry->findDataProvider($name); if ($dataProvider === null) { $dataProvider = $this->context->data()->has($name) ? $this->context->data()->getIdentifier($name) : false; } $this->dataProviders[$name] = $dataProvider; return $dataProvider; }
/** * {@inheritdoc} */ public function getRelativeSourceFilePath() { $path = $this->filePath; if (strpos($this->source->findRelativeSourceFilePath($this), 'less')) { $path = str_replace('.css', '.less', $this->filePath); } $result = ''; $result = $this->join($result, $this->context->getPath()); $result = $this->join($result, $this->module); $result = $this->join($result, $path); return $result; }
/** * {@inheritdoc} */ public function getRelativeSourceFilePath() { $path = $this->filePath; $sourcePath = $this->source->findRelativeSourceFilePath($this); if ($sourcePath) { $origExt = pathinfo($path, PATHINFO_EXTENSION); $ext = pathinfo($sourcePath, PATHINFO_EXTENSION); $path = str_replace('.' . $origExt, '.' . $ext, $this->filePath); } $result = ''; $result = $this->join($result, $this->context->getPath()); $result = $this->join($result, $this->module); $result = $this->join($result, $path); return $result; }
/** * {@inheritdoc} */ public function isApplicable(ContextInterface $context, array $processorAttributes) { if (null === $this->processorBag || empty($processorAttributes['group']) || !$context->getFirstGroup() && !$context->getLastGroup()) { return self::ABSTAIN; } $this->ensureGroupsLoaded($context->getAction()); $group = $processorAttributes['group']; if (isset($this->groups[$group])) { $groupIndex = $this->groups[$group]; $firstGroup = $context->getFirstGroup(); if ($firstGroup && isset($this->groups[$firstGroup]) && $groupIndex < $this->groups[$firstGroup]) { return self::NOT_APPLICABLE; } $lastGroup = $context->getLastGroup(); if ($lastGroup && isset($this->groups[$lastGroup]) && $groupIndex > $this->groups[$lastGroup]) { return self::NOT_APPLICABLE; } } return self::ABSTAIN; }
/** * @param $value * * @return array */ public function run($value) { return $this->context->run($value); }
/** * {@inheritdoc} */ public function getLayout(ContextInterface $context, $rootId = null) { if (!$context->isResolved()) { $this->registry->configureContext($context); $context->resolve(); } $this->layoutManipulator->applyChanges($context); $rawLayout = $this->rawLayoutBuilder->getRawLayout(); $rootView = $this->blockFactory->createBlockView($rawLayout, $context, $rootId); $layout = $this->createLayout($rootView); $rootBlockId = $rawLayout->getRootId(); $blockThemes = $rawLayout->getBlockThemes(); foreach ($blockThemes as $blockId => $themes) { $layout->setBlockTheme($themes, $blockId !== $rootBlockId ? $blockId : null); } return $layout; }
/** * @param ContextInterface $context * @param int $hour */ public function doClock(ContextInterface $context, $hour) { if (!self::isDay($hour)) { $context->changeState(NightState::getInstance()); } }
/** * Fetch context content * * @return mixed */ public function fetch() { return $this->context->fetch(); }