/** * @since 1.9 * * @param ArrayFormatter $parameters * * @return string|null */ public function parse(ArrayFormatter $parameters) { $subject = $this->parserData->getSemanticData()->getSubject(); foreach ($parameters->toArray() as $property => $values) { foreach ($values as $value) { $dataValue = DataValueFactory::getInstance()->newPropertyValue($property, $value, false, $subject); $this->parserData->addDataValue($dataValue); } } $this->parserData->pushSemanticDataToParserOutput(); return $this->messageFormatter->addFromArray($this->parserData->getErrors())->addFromArray($parameters->getErrors())->getHtml(); }
/** * @since 1.9 * * @param ArrayFormatter $parameters * * @return string|null */ public function parse(ArrayFormatter $parameters) { $count = 0; $template = ''; $subject = $this->parserData->getSemanticData()->getSubject(); $parametersToArray = $parameters->toArray(); if (isset($parametersToArray['template'])) { $template = $parametersToArray['template'][0]; unset($parametersToArray['template']); } foreach ($parametersToArray as $property => $values) { foreach ($values as $value) { $dataValue = DataValueFactory::getInstance()->newPropertyValue($property, $value, false, $subject); $this->parserData->addDataValue($dataValue); $this->messageFormatter->addFromArray($dataValue->getErrors()); $this->addFieldsToTemplate($template, $dataValue, $property, $value, $count); } } $this->parserData->pushSemanticDataToParserOutput(); $html = $this->templateRenderer->render() . $this->messageFormatter->addFromArray($parameters->getErrors())->getHtml(); return array($html, 'noparse' => true, 'isHTML' => true); }
/** * Parse parameters, and update the ParserOutput with data from the * RecurringEvents object * * @since 1.9 * * @param ArrayFormatter $parameters * * @return string|null */ public function parse(ArrayFormatter $parameters) { $this->setFirstElementForPropertyLabel(true); // Get recurring events $this->events = new RecurringEvents($parameters->toArray(), $this->settings); $this->messageFormatter->addFromArray($this->events->getErrors()); foreach ($this->events->getDates() as $date_str) { // Override existing parameters array with the returned // pre-processed parameters array from recurring events $parameters->setParameters($this->events->getParameters()); // Add the date string as individual property / value parameter $parameters->addParameter($this->events->getProperty(), $date_str); // @see SubobjectParserFunction::addDataValuesToSubobject // Each new $parameters set will add an additional subobject // to the instance $this->addDataValuesToSubobject($parameters); $this->parserData->getSemanticData()->addSubobject($this->subobject); // Collect errors that occurred during processing $this->messageFormatter->addFromArray($this->subobject->getErrors()); } // Update ParserOutput $this->parserData->pushSemanticDataToParserOutput(); return $this->messageFormatter->getHtml(); }
private function transformParametersToArray(ArrayFormatter $parameters) { if ($this->useFirstElementForPropertyLabel) { $parameters->addParameter($parameters->getFirst(), $this->parserData->getTitle()->getPrefixedText()); } return $parameters->toArray(); }