public function testAddAndRemoveParameter()
 {
     $instance = new ParserParameterProcessor();
     $instance->addParameter('Foo', 'Bar');
     $this->assertEquals(array('Foo' => array('Bar')), $instance->toArray());
     $instance->removeParameterByKey('Foo');
     $this->assertFalse($instance->hasParameter('Foo'));
 }
 /**
  * @since 1.9
  *
  * @param ParserParameterProcessor $parameters
  *
  * @return string|null
  */
 public function parse(ParserParameterProcessor $parameters)
 {
     $this->initRecurringEvents($parameters->toArray());
     $this->messageFormatter->addFromArray($this->recurringEvents->getErrors());
     foreach ($this->recurringEvents->getDates() as $date_str) {
         // Override existing parameters array with the returned
         // pre-processed parameters array from recurring events
         $parameters->setParameters($this->recurringEvents->getParameters());
         // Add the date string as individual property / value parameter
         $parameters->addParameter($this->recurringEvents->getProperty(), $date_str);
         // @see SubobjectParserFunction::addDataValuesToSubobject
         // Each new $parameters set will add an additional subobject
         // to the instance
         if ($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->addFromArray($this->parserData->getErrors())->getHtml();
 }
 public function testAddParameter()
 {
     $instance = new ParserParameterProcessor();
     $instance->addParameter('Foo', 'Bar');
     $this->assertEquals(array('Foo' => array('Bar')), $instance->toArray());
 }
 private function transformParametersToArray(ParserParameterProcessor $parameters)
 {
     if ($this->useFirstElementForPropertyLabel) {
         $parameters->addParameter($parameters->getFirst(), $this->parserData->getTitle()->getPrefixedText());
     }
     return $parameters->toArray();
 }
 private function doPrepareParameters(ParserParameterProcessor $parserParameterProcessor)
 {
     if ($parserParameterProcessor->hasParameter(self::PARAM_LINKWITH)) {
         $val = $parserParameterProcessor->getParameterValuesByKey(self::PARAM_LINKWITH);
         $parserParameterProcessor->addParameter(end($val), $this->parserData->getTitle()->getPrefixedText());
         $parserParameterProcessor->removeParameterByKey(self::PARAM_LINKWITH);
     }
     if ($this->isEnabledFirstElementAsPropertyLabel) {
         $parserParameterProcessor->addParameter($parserParameterProcessor->getFirst(), $this->parserData->getTitle()->getPrefixedText());
     }
     $parameters = $parserParameterProcessor->toArray();
     // FIXME 3.0 make sorting default by 3.0
     // Only sort for a modified sobj otherwise existing ID will change
     $sort = false;
     // This ensures that an unordered array is ordered and will produce
     // the same ID even if elements are placed differently
     if ($sort) {
         ksort($parameters);
     }
     return $parameters;
 }