<?php
namespace Moto\Application\Menus\InputFilter; use Moto\InputFilter\ClickAction; use Zend\InputFilter\Exception; use Moto; class SaveMenuItem extends ClickAction { protected $_name = 'menuItem.save'; protected static $_instance = null; public static function getInstance() { if (null == self::$_instance) { self::$_instance = new self; } return self::$_instance; } public function init() { $this->add(array( 'name' => 'id', 'required' => true, 'filters' => array( array('name' => 'Moto\Filter\DefaultFilter'), array('name' => 'Moto\Filter\IntValue'), ), 'validators' => array( array( 'name' => 'Digits', 'break_chain_on_failure' => true ), array( 'name' => 'Db\RecordExists', 'options' => array( 'table' => Moto\Config::get('database.prefix') . 'menu_items', 'field' => 'id', 'adapter' => Moto\Config::get('databaseAdapter'), ) ) ), )); $this->add(array( 'name' => 'menu_id', 'required' => true, 'filters' => array( array('name' => 'Moto\Filter\DefaultFilter'), array('name' => 'Moto\Filter\IntValue'), ), 'validators' => array( array( 'name' => 'Digits', 'break_chain_on_failure' => true ), array( 'name' => 'Db\RecordExists', 'options' => array( 'table' => Moto\Config::get('database.prefix') . 'menus', 'field' => 'id', 'adapter' => Moto\Config::get('databaseAdapter'), ) ) ), )); $this->add(array( 'name' => 'parent_id', 'required' => true, 'filters' => array( array('name' => 'Moto\Filter\DefaultFilter'), ), 'validators' => array( array( 'name' => 'Digits', 'break_chain_on_failure' => true ), array( 'name' => 'Moto\Validator\ParentId', 'options' => array( 'table' => Moto\Config::get('database.prefix') . 'menu_items', 'field' => 'id', 'adapter' => Moto\Config::get('databaseAdapter'), ) ) ), )); $this->add(array( 'name' => 'label', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 1, 'max' => 200, ), ), ), )); parent::init(); $this->add(array( 'name' => 'order', 'required' => true, 'filters' => array( array('name' => 'Moto\Filter\DefaultFilter'), ), 'validators' => array( array( 'name' => 'Digits', ), ), )); } } 