本文整理汇总了PHP中Zend\InputFilter\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createServiceWithName
/**
* Create service with name
*
* @param ServiceLocatorInterface $serviceLocator
* @param $name
* @param $requestedName
* @return mixed
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
$config = $serviceLocator->get('Config');
$zohoConfig = $config['zoho'];
$resourceConfig = $config['zoho']['resources'][$requestedName];
$resource = new Resource($zohoConfig['auth_token'], $zohoConfig['organization_id']);
$resource->setPath($resourceConfig['path']);
$resource->setCollectionName($resourceConfig['collectionName']);
$entityClass = array_key_exists('entityClass', $resourceConfig) ? $resourceConfig['entityClass'] : str_replace('Resource', 'Entity', $requestedName);
$resource->setEntityClass($entityClass);
$resource->setEntityName($resourceConfig['entityName']);
if (isset($resourceConfig['input-filter']) && is_array($resourceConfig['input-filter'])) {
$inputFilterFactory = new InputFilterFactory();
$inputFilter = $inputFilterFactory->createInputFilter($resourceConfig['input-filter']);
$resource->setInputFilter($inputFilter);
}
$hydratorManager = $serviceLocator->get('HydratorManager');
$hydratorName = str_replace('Entity', 'Hydrator', $entityClass);
if ($hydratorManager->has($hydratorName)) {
$hydrator = $hydratorManager->get($hydratorName);
} else {
$hydrator = new ClassMethods();
}
$resource->setHydrator($hydrator);
return $resource;
}
示例2: getInputFilter
public static function getInputFilter()
{
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array('name' => 'status', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 1, 'max' => 65535))))));
return $inputFilter;
}
示例3: getInputFilter
public function getInputFilter()
{
$factory = new Factory;
return $factory->createInputFilter(array(
'type' => 'ZF\Apigility\Admin\InputFilter\Authentication\OAuth2InputFilter',
));
}
示例4: init
/**
* Init Module form
*
* @return void
*/
public function init()
{
$showEmail = new Element\Checkbox('show_email');
$showEmail->setLabel('Show email');
$showEmail->setAttribute('required', 'required')->setAttribute('id', 'show-email');
$username = new Element\Text('username');
$username->setLabel('Username');
$username->setAttribute('required', 'required')->setAttribute('id', 'username');
$email = new Element\Text('email');
$email->setLabel('Email');
$email->setAttribute('required', 'required')->setAttribute('id', 'email');
$message = new Element\Textarea('message');
$message->setLabel('Message');
$message->setAttribute('required', 'required')->setAttribute('id', 'message');
$captchaImage = new CaptchaImage(array('font' => GC_PUBLIC_PATH . '/backend/fonts/arial.ttf', 'width' => 250, 'height' => 50, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3));
$captchaImage->setImgDir(GC_PUBLIC_PATH . '/frontend/tmp');
$captchaImage->setImgUrl('/frontend/tmp');
$captcha = new Element\Captcha('captcha');
$captcha->setLabel('Please verify you are human')->setCaptcha($captchaImage)->setAttribute('required', 'required')->setAttribute('id', 'captcha');
$this->add($showEmail);
$this->add($username);
$this->add($email);
$this->add($message);
$this->add($captcha);
$inputFilterFactory = new InputFilterFactory();
$inputFilter = $inputFilterFactory->createInputFilter(array('show_email' => array('name' => 'show_email', 'required' => false), 'username' => array('name' => 'username', 'required' => true), 'email' => array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'email_address'))), 'message' => array('name' => 'message', 'required' => true), 'captcha' => $captcha->getInputSpecification()));
$this->setInputFilter($inputFilter);
}
示例5: getInputFilter
/**
* (non-PHPdoc)
*
* @see \Zend\InputFilter\InputFilterAwareInterface::getInputFilter()
*/
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array('name' => 'type', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'title', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'first_name', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'last_name', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'gender', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'date_of_birth', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'address1', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'address2', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'email', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'state', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'country', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'town', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'zip', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'phone', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'amount', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'payment', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'passport_number', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$inputFilter->add($factory->createInput(array('name' => 'order_number', 'required' => false, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例6: InputFactory
function __construct()
{
parent::__construct();
$factory = new InputFactory();
$this->add($factory->createInput(array('name' => 'role', 'required' => true, 'validators' => array(array('break_chain_on_failure' => true, 'name' => 'NotEmpty', 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Обязательное поле')))))));
$this->add($factory->createInput(array('name' => 'displayName', 'required' => true, 'validators' => array(array('break_chain_on_failure' => true, 'name' => 'NotEmpty', 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Обязательное поле')))))));
}
示例7: init
public function init()
{
$this->setName('ef');
$this->add(array('name' => 'ef-name', 'type' => 'Text', 'attributes' => array('id' => 'ef-name', 'style' => 'width: 320px'), 'options' => array('label' => 'Name')));
$this->add(array('name' => 'ef-description', 'type' => 'Textarea', 'attributes' => array('id' => 'ef-description', 'class' => 'wysiwyg-editor', 'style' => 'width: 320px; height: 180px;'), 'options' => array('label' => 'Description')));
$this->add(array('name' => 'ef-date-start', 'type' => 'Text', 'attributes' => array('id' => 'ef-date-start', 'class' => 'datepicker', 'style' => 'width: 110px;'), 'options' => array('label' => 'Date (Start)')));
$this->add(array('name' => 'ef-time-start', 'type' => 'Text', 'attributes' => array('id' => 'ef-time-start', 'style' => 'width: 110px;'), 'options' => array('label' => 'Time (Start)')));
$this->add(array('name' => 'ef-date-end', 'type' => 'Text', 'attributes' => array('id' => 'ef-date-end', 'class' => 'datepicker', 'style' => 'width: 110px;'), 'options' => array('label' => 'Date (End)')));
$this->add(array('name' => 'ef-time-end', 'type' => 'Text', 'attributes' => array('id' => 'ef-time-end', 'style' => 'width: 110px;'), 'options' => array('label' => 'Time (End)')));
$squareOptions = array('null' => 'All squares');
foreach ($this->squareManager->getAll() as $sid => $square) {
$squareOptions[$sid] = $square->get('name');
}
$this->add(array('name' => 'ef-sid', 'type' => 'Select', 'attributes' => array('id' => 'ef-sid', 'style' => 'width: 124px'), 'options' => array('label' => 'Square', 'value_options' => $squareOptions)));
$this->add(array('name' => 'ef-capacity', 'type' => 'Text', 'attributes' => array('id' => 'ef-capacity', 'style' => 'width: 110px;'), 'options' => array('label' => 'Capacity', 'notes' => 'How many people can participate?')));
$this->add(array('name' => 'ef-notes', 'type' => 'Textarea', 'attributes' => array('id' => 'ef-notes', 'style' => 'width: 250px; height: 48px;'), 'options' => array('label' => 'Notes', 'notes' => 'These are only visible for administration')));
$this->add(array('name' => 'ef-submit', 'type' => 'Submit', 'attributes' => array('value' => 'Save', 'id' => 'ef-submit', 'class' => 'default-button', 'style' => 'width: 200px;')));
/* Input filters */
$factory = new Factory();
$this->setInputFilter($factory->createInputFilter(array('ef-name' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true))), 'ef-description' => array('required' => false, 'filters' => array(array('name' => 'StringTrim'))), 'ef-date-start' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => function ($value) {
try {
new \DateTime($value);
return true;
} catch (\Exception $e) {
return false;
}
}, 'message' => 'Invalid date')))), 'ef-time-start' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Regex', 'options' => array('pattern' => '/^[0-9]?[0-9]:[0-9][0-9]$/', 'message' => 'Please provide the time in format HH:MM')))), 'ef-date-end' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => function ($value) {
try {
new \DateTime($value);
return true;
} catch (\Exception $e) {
return false;
}
}, 'message' => 'Invalid date')))), 'ef-time-end' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Regex', 'options' => array('pattern' => '/^[0-9]?[0-9]:[0-9][0-9]$/', 'message' => 'Please provide the time in format HH:MM')))), 'ef-capacity' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Digits', 'options' => array('message' => 'Please type a number here')))), 'ef-notes' => array('required' => false, 'filters' => array(array('name' => 'StringTrim'))))));
}
示例8: getInputFilter
public function getInputFilter()
{
if (!$this->filter) {
$factory = new InputFilterFactory();
$inputFilterSpec = array('id' => array('required' => false), 'block_id' => array('required' => false), 'href' => array('required' => false), 'title' => array('required' => true), 'type' => array('required' => true), 'file' => array('required' => false), 'link' => array('required' => false, 'validators' => array(new UrlValidator())), 'page' => array('required' => false), 'entity_id' => array('required' => false), 'position' => array('required' => false));
$data = $this->data;
// if ($this->getName()){
// $name = str_replace(']','', $this->getName());
// $name = explode('[', $name);
// while (!empty($name)){
// $key = array_shift($name);
// $data = $data[$key];
// }
// }
switch ($data['type']) {
case 'link':
$inputFilterSpec['link']['required'] = true;
break;
case 'page':
$inputFilterSpec['page']['required'] = true;
break;
case 'file':
$inputFilterSpec['file']['required'] = true;
break;
}
$this->filter = $factory->createInputFilter($inputFilterSpec);
}
return $this->filter;
}
示例9: init
public function init()
{
$this->setName('bf');
$this->add(array('name' => 'bf-date-start', 'type' => 'Text', 'attributes' => array('id' => 'bf-date-start', 'style' => 'width: 80px;'), 'options' => array('label' => 'Date (Start)')));
$this->add(array('name' => 'bf-date-end', 'type' => 'Text', 'attributes' => array('id' => 'bf-date-end', 'style' => 'width: 80px;'), 'options' => array('label' => 'Date (End)')));
$this->add(array('name' => 'bf-repeat', 'type' => 'Select', 'attributes' => array('id' => 'bf-repeat', 'style' => 'width: 124px'), 'options' => array('label' => 'Repeat', 'value_options' => Booking::$repeatOptions)));
$this->add(array('name' => 'bf-submit', 'type' => 'Submit', 'attributes' => array('value' => 'Save', 'id' => 'bf-submit', 'class' => 'default-button', 'style' => 'width: 125px;')));
/* Input filters */
$factory = new Factory();
$this->setInputFilter($factory->createInputFilter(array('bf-date-start' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => function ($value) {
try {
new \DateTime($value);
return true;
} catch (\Exception $e) {
return false;
}
}, 'message' => 'Invalid date')))), 'bf-date-end' => array('required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type something here'), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => function ($value) {
try {
new \DateTime($value);
return true;
} catch (\Exception $e) {
return false;
}
}, 'message' => 'Invalid date')))))));
}
示例10: init
public function init()
{
$this->setName('eef');
$this->add(array('name' => 'eef-email1', 'type' => 'Text', 'attributes' => array('id' => 'eef-email1', 'style' => 'width: 235px;'), 'options' => array('notes' => 'Please provide your email address')));
$this->add(array('name' => 'eef-email2', 'type' => 'Text', 'attributes' => array('id' => 'eef-email2', 'style' => 'width: 235px;'), 'options' => array('notes' => 'Please type your email address again<br>to prevent typing errors')));
$this->add(array('name' => 'eef-submit', 'type' => 'Submit', 'attributes' => array('value' => 'Update email address', 'class' => 'default-button')));
/* Input filters */
$userManager = $this->userManager;
$factory = new Factory();
$this->setInputFilter($factory->createInputFilter(array('eef-email1' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type your email address here'), 'break_chain_on_failure' => true), array('name' => 'EmailAddress', 'options' => array('useMxCheck' => true, 'message' => 'Please type your correct email address here', 'messages' => array('emailAddressInvalidMxRecord' => 'We could not verify your email provider')), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => function ($value) {
$blacklist = getcwd() . '/data/res/blacklist-emails.txt';
if (is_readable($blacklist)) {
$blacklistContent = file_get_contents($blacklist);
$blacklistDomains = explode("\r\n", $blacklistContent);
foreach ($blacklistDomains as $blacklistDomain) {
$blacklistPattern = str_replace('.', '\\.', $blacklistDomain);
if (preg_match('/' . $blacklistPattern . '$/', $value)) {
return false;
}
}
}
return true;
}, 'message' => 'Trash mail addresses are currently blocked - sorry'), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => function ($value) use($userManager) {
if ($userManager->getBy(array('email' => $value))) {
return false;
} else {
return true;
}
}, 'message' => 'This email address has already been registered')))), 'eef-email2' => array('filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('message' => 'Please type your email address here'), 'break_chain_on_failure' => true), array('name' => 'Identical', 'options' => array('token' => 'eef-email1', 'message' => array('Both email addresses must be identical'))))))));
}
示例11: init
/**
* Init Module form
*
* @return void
*/
public function init()
{
$this->setAttribute('class', 'relative');
$fileInfo = new Info();
$modulesInfos = array();
$options = array('' => 'Select an option');
foreach ($this->getServiceLocator()->get('ModulesList') as $path => $dir) {
$options[$dir] = $dir;
$configFile = $path . '/module.info';
if ($fileInfo->fromFile($configFile) === true) {
$modulesInfos[$dir] = $fileInfo->render();
}
}
$collection = new ModuleCollection();
$modules = $collection->getModules();
foreach ($modules as $module) {
if (in_array($module->getName(), $options)) {
unset($options[$module->getName()]);
unset($modulesInfos[$module->getName()]);
}
}
$module = new Element\Select('module');
$module->setLabel('Module')->setLabelAttributes(array('class' => 'required'));
$module->setAttribute('id', 'module')->setAttribute('class', 'form-control')->setAttribute('modules_info', $modulesInfos)->setValueOptions($options);
$this->add($module);
$inputFilterFactory = new InputFilterFactory();
$inputFilter = $inputFilterFactory->createInputFilter(array('module' => array('name' => 'module', 'required' => true, 'validators' => array(array('name' => 'not_empty')))));
$this->setInputFilter($inputFilter);
}
示例12: loginAction
public function loginAction()
{
$form = new LoginForm('', false, $this->getServiceLocator());
$request = $this->getRequest();
if ($request->isPost()) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array('name' => 'username', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty')))));
$inputFilter->add($factory->createInput(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty')))));
$form->setInputFilter($inputFilter);
$form->setData($request->getPost());
if ($form->isValid()) {
//check authentication...
$this->getAuthService()->getAdapter()->setIdentity('' . $request->getPost('username'))->setCredential('' . $request->getPost('password'));
$result = $this->getAuthService()->authenticate();
foreach ($result->getMessages() as $message) {
//save message temporary into flashmessenger
$this->flashmessenger()->addMessage($message);
}
if ($result->isValid()) {
$this->getAuthService()->getStorage()->write($this->getAuthService()->getAdapter()->getResultRowObject(null));
return $this->redirect()->toRoute('bhome');
}
}
}
return array('form' => $form);
}
示例13: getInputFilter
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
/*
$inputFilter->add($factory->createInput(array(
'name' => 'name',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
)));
*/
$inputFilter->add($factory->createInput(array('name' => 'min_start_range', 'required' => true)));
$inputFilter->add($factory->createInput(array('name' => 'max_start_range', 'required' => true)));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
示例14: InputFactory
function __construct()
{
$factory = new InputFactory();
$this->add($factory->createInput(array('name' => 'title', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('break_chain_on_failure' => true, 'name' => 'NotEmpty', 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Обязательное поле')))))));
$this->add($factory->createInput(array('name' => 'description', 'required' => true, 'validators' => array(array('break_chain_on_failure' => true, 'name' => 'NotEmpty', 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Обязательное поле')))))));
$this->add($factory->createInput(array('name' => 'date', 'required' => true, 'validators' => array(array('break_chain_on_failure' => true, 'name' => 'NotEmpty', 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Обязательное поле')))))));
}
示例15: getInputFilter
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array('name' => 'title', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 5, 'max' => 50))))));
/*
$inputFilter->add($factory->createInput(array(
'name' => 'short_note',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 5,
'max' => 500,
),
),
),
)));
*/
$inputFilter->add($factory->createInput(array('name' => 'field_image', 'required' => false)));
$inputFilter->add($factory->createInput(array('name' => 'external_link', 'required' => true)));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}