/** * Render the placeholders. * * @todo Implement data presenter as a better alternative. * @return AbstractPropertyInput Chainable */ protected function renderPlaceholder() { if ($this->placeholder instanceof TranslationString) { foreach ($this->placeholder->all() as $lang => $value) { if ($value && $this instanceof ViewableInterface && $this->view() !== null) { $this->placeholder[$lang] = $this->view()->render($value, $this->viewController()); } } $this->placeholder->isRendered = true; } return $this; }
/** * Assign the current translation value(s). * * @param TranslationStringInterface|array|string $val The translation value(s). * Add one or more translation values. * * Accept 3 types of arguments: * - object (TranslationStringInterface): The data will be copied from the object's. * - array: All languages available in the array. The format of the array should * be a hash in the `lang` => `string` format. * - string: The value will be assigned to the current language. * @return self * @throws InvalidArgumentException If value is invalid. */ public function setVal($val) { if ($val instanceof TranslationStringInterface) { $this->val = $val->all(); } elseif (is_array($val) || is_a($val, 'Traversable')) { $this->val = []; foreach ($val as $lang => $l10n) { $this->addVal($lang, (string) $l10n); } } elseif (is_string($val)) { $lang = $this->currentLanguage(); $this->val[$lang] = $val; } else { throw new InvalidArgumentException('Invalid localized value.'); } return $this; }