コード例 #1
0
 public function render(ElementInterface $element)
 {
     if ($element->getOption('static')) {
         return $this->getView()->formElementStatic($element);
     }
     return parent::render($element);
 }
コード例 #2
0
ファイル: FormCaptcha.php プロジェクト: coolms/common
 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute ' . 'implementing %s; none found', __METHOD__, CaptchaAdapter::class));
     }
     $helper = $captcha->getHelperName();
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         throw new Exception\DomainException(sprintf('%s requires that the renderer implements plugin(); it does not', __METHOD__));
     }
     $helper = $renderer->plugin($helper);
     if ($helper instanceof TranslatorAwareInterface) {
         $rollbackTextDomain = $helper->getTranslatorTextDomain();
         $helper->setTranslatorTextDomain($this->getTranslatorTextDomain());
     }
     $markup = parent::render($element);
     if ($helper instanceof TranslatorAwareInterface) {
         $helper->setTranslatorTextDomain($rollbackTextDomain);
     }
     return $markup;
 }