• Как заменить стандартный escapeHtmlHelper в форме (элемент textarea) в zf2?

    27cm
    @27cm
    TODO: Написать статус
    namespace Application\View\Helper;
    
    use Zend\View\Helper\AbstractHelper;
    use Zend\Form\View\Helper\FormTextarea;
    use Zend\Form\ElementInterface;
    
    use HTMLPurifier;
    use HTMLPurifier_Config;
    use HTMLPurifier_ConfigSchema;
    use Soflomo\Purifier\View\Helper\Purifier;
    
    use Zend\ServiceManager\ServiceLocatorAwareInterface;
    use Zend\ServiceManager\ServiceLocatorAwareTrait;
    use Zend\ServiceManager\ServiceLocatorInterface;
    use Zend\ServiceManager\AbstractPluginManager;
    
    class PurefierFormTextarea extends FormTextarea implements ServiceLocatorAwareInterface
    {
        protected $serviceLocator = null;
    
        public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
        {
            $this->serviceLocator = $serviceLocator;
            return $this;
        }
    
        public function getServiceLocator()
        {
            return $this->serviceLocator;
        }
    
        public function getMainServiceLocator()
        {
            if ($this->serviceLocator instanceof AbstractPluginManager) {
                return $this->serviceLocator->getServiceLocator();
            }
            return $this->serviceLocator;
        }
    
        public function render(ElementInterface $element)
        {
            // ...
    
            $this->getMainServiceLocator()->get('HTMLPurifier'); 
    
            // ...
        }
    }
    Ответ написан
    Комментировать