<?php
namespace Moto\Application\Users; use Moto\InputFilter\AbstractInputFilter; use Traversable; class DeleteUserFilter extends AbstractInputFilter { protected $_name = 'users.delete'; public function init() { $this->add(array( 'name' => 'user_id', 'type' => 'Zend\InputFilter\ArrayInput', 'required' => true, 'validators' => array( array( "name" => "NotEmpty" ), array( "name" => "Digits" ) ) )); $this->add(array( 'name' => 'action', 'required' => true, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array('remove', 'reassign') ) ), ) )); $this->add(array( 'name' => 'reassign_to', 'required' => true, 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'Moto\Application\Users\DeleteUserValidator' ) ) )); } public function setData($data) { if (!is_array($data) && !$data instanceof Traversable) { throw new \Zend\InputFilter\Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received %s', __METHOD__, (is_object($data) ? get_class($data) : gettype($data)) )); } if (array_key_exists('user_id', $data)) { $data['user_id'] = is_array($data['user_id']) ? $data['user_id'] : array($data['user_id']); } else { $data['user_id'] = array(null); } if (!array_key_exists('action', $data)) { $data['action'] = ''; } parent::setData($data); } } 