コード例 #1
0
 /**
  * Takes care of validation and rendering, and returns the output.
  *
  * @since 0.4
  *
  * @param array $arguments
  * @param integer $type Item of the ParserHook::TYPE_ enum
  *
  * @return string
  */
 public function validateAndRender(array $arguments, $type)
 {
     $names = $this->getNames();
     $this->validator = Processor::newDefault();
     $this->validator->getOptions()->setName($names[0]);
     if ($type === self::TYPE_FUNCTION) {
         $this->validator->setFunctionParams($arguments, $this->getParameterInfo($type), $this->getDefaultParameters($type));
     } else {
         $this->validator->setParameters($arguments, $this->getParameterInfo($type));
     }
     $this->validator->validateParameters();
     $fatalError = $this->validator->hasFatalError();
     if ($fatalError === false) {
         $output = $this->render($this->validator->getParameterValues());
     } else {
         $output = $this->renderFatalError($fatalError);
     }
     return $output;
 }