<?php
namespace Moto\Application\Settings\InputFilter; use Moto\InputFilter\AbstractInputFilter; use Moto; class MailClassParameters extends AbstractInputFilter { protected $_name = 'settingsWebsite.mailClassParameters'; public function init() { $this->add(array( 'name' => 'host', 'required' => true, 'allow_empty' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), array( 'name' => 'Moto\Filter\DefaultFilter', 'options' => array( 'value' => 'localhost' ) ), ), 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 0, 'max' => 256, ), ), ), )); $this->add(array( 'name' => 'port', 'required' => false, 'allow_empty' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'continue_if_empty' => false, 'validators' => array( array( 'name' => 'Digits', ), array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 1, 'max' => 9, ), ), ), )); $this->add(array( 'name' => 'connection_class', 'required' => false, 'allow_empty' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array('', 'none', 'smtp', 'plain', 'login', 'crammd5') ) ), ), )); $this->add(new MailConnectionConfig(), 'connection_config'); } public function getValues($keys = null, $ignoreDefault = false) { $values = parent::getValues($keys, $ignoreDefault); if (empty($values['connection_class'])) { unset($values['connection_config']); } return $values; } }