<?php
namespace Moto\Application\RobotsTxt\InputFilter; use Moto\InputFilter\AbstractInputFilter; use Moto; class SaveSettings extends AbstractInputFilter { protected $_name = 'RobotsTxt.settings'; protected $_defaultsValue = [ 'system' => [ 'enabled' => 1, 'indexing' => 1, ], 'custom' => [ 'enabled' => 1, ], ]; public function init() { $system = new AbstractInputFilter(); $this->add($system, 'system'); $system->add(array( 'name' => 'enabled', 'required' => false, 'filters' => array( array('name' => Moto\Filter\IntValue::class), array('name' => 'Boolean'), ), )); $system->add(array( 'name' => 'indexing', 'required' => false, 'filters' => array( array('name' => Moto\Filter\IntValue::class), array('name' => 'Boolean'), ), )); $system->add(array( 'name' => 'sitemapType', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array('none', 'system', 'custom',), ), ), ), )); $system->add(array( 'name' => 'sitemapUrl', 'required' => false, 'allow_empty' => true, 'filters' => array( array('name' => Moto\Filter\StringValue::class), array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 1, 'max' => 1024, ), ), ), )); $custom = new AbstractInputFilter(); $this->add($custom, 'custom'); $custom->add(array( 'name' => 'enabled', 'required' => false, 'filters' => array( array('name' => Moto\Filter\IntValue::class), array('name' => 'Boolean'), ), )); $custom->add(array( 'name' => 'content', 'required' => false, 'allow_empty' => true, 'filters' => array( array('name' => Moto\Filter\StringValue::class), array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 1, 'max' => 10240, ), ), ), )); } } 