<?php
namespace Moto\Application\Fonts\InputFilter; use Moto; use Moto\InputFilter\AbstractInputFilter; class StoreFont extends AbstractInputFilter { protected $_name = 'fonts.store'; public function init() { $this->add([ 'name' => 'name', 'required' => true, 'filters' => [ ['name' => 'StripTags'], ['name' => 'StringTrim'], ], 'validators' => [ array( 'name' => 'Regex', 'break_chain_on_failure' => true, 'options' => array( 'pattern' => '/^([a-z][a-z0-9\_\-\s]{0,31})$/i', ) ), [ 'name' => 'Db\NoRecordExists', 'options' => [ 'table' => Moto\Config::get('database.prefix') . 'fonts', 'field' => 'name', 'adapter' => Moto\System::getDatabaseAdapter(), ], ], ], ]); $this->add([ 'name' => 'category', 'required' => true, 'filters' => [ ['name' => 'StripTags'], ['name' => 'StringTrim'], ], 'validators' => [ [ 'name' => 'InArray', 'options' => [ 'haystack' => [ 'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', ], ], ], ], ]); $this->add([ 'name' => 'family', 'required' => false, 'filters' => [ [ 'name' => 'Callback', 'options' => array( 'callback' => function () { $form = $this; $family = trim((string) $form->getValue('name')); $family = '\'' . $family . '\''; $category = trim((string) $form->getValue('category')); if ($category !== '') { $family .= ', ' . $category; } return $family; }, ) ], ], ]); $this->add([ 'name' => 'provider', 'required' => true, 'filters' => [ ['name' => 'StripTags'], ['name' => 'StringTrim'], ], 'validators' => [ [ 'name' => 'InArray', 'options' => [ 'haystack' => ['custom',], ], ], ], ]); } } 