/** * @param BlockView $view * @param string $attrKey * @param string $encoding */ protected function normalizeClassAttributeWithEncoding(BlockView $view, $attrKey, $encoding) { if (!isset($view->vars[$attrKey])) { return; } if (isset($view->vars[$attrKey]['class']) || array_key_exists('class', $view->vars[$attrKey])) { $class = $view->vars[$attrKey]['class']; if ($class instanceof OptionValueBag) { $class = $this->encoderRegistry->getEncoder($encoding)->encodeActions($class->all()); } if (!empty($class)) { $view->vars[$attrKey]['class'] = $class; } else { unset($view->vars[$attrKey]['class']); } } }
public function testGetEncoderThrowsExceptionIfEncoderDoesNotExist() { $this->encoderRegistry->getEncoder('unknown'); }
/** * @param ExpressionInterface $expr * @param ContextInterface $context * @param DataAccessorInterface $data * @param bool $evaluate * @param string $encoding * * @return mixed|string */ protected function processExpression(ExpressionInterface $expr, ContextInterface $context, DataAccessorInterface $data, $evaluate, $encoding) { return $evaluate ? $expr->evaluate(['context' => $context, 'data' => $data]) : $this->encoderRegistry->getEncoder($encoding)->encodeExpr($expr); }