Exemple #1
0
 /**
  * Create input filter specification for integers
  *
  * @param string $name Element name
  * @return array
  */
 protected function _getIntegerFilter($name)
 {
     $validatorChain = new \Zend\Validator\ValidatorChain();
     $validatorChain->attachByName('Callback', array('callback' => array($this, 'validateType'), 'callbackOptions' => 'integer'), true);
     $validatorChain->attachByName('GreaterThan', array('min' => 0));
     return array('name' => $name, 'filters' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'normalize'), 'callback_params' => 'integer'))), 'validators' => $validatorChain);
 }
Exemple #2
0
 /** {@inheritdoc} */
 public function init()
 {
     parent::init();
     $preferences = $this->get('Preferences');
     $inputFilter = new \Zend\InputFilter\InputFilter();
     $trustedNetworksOnly = new \Zend\Form\Element\Checkbox('trustedNetworksOnly');
     $trustedNetworksOnly->setLabel('Limit agent connections to trusted networks');
     $preferences->add($trustedNetworksOnly);
     $inventoryFilter = new \Zend\Form\Element\Checkbox('inventoryFilter');
     $inventoryFilter->setLabel('Limit inventory frequency');
     $preferences->add($inventoryFilter);
     $limitInventoryInterval = new \Zend\Form\Element\Text('limitInventoryInterval');
     $limitInventoryInterval->setLabel('Seconds between inventory processing')->setAttribute('size', 5);
     $preferences->add($limitInventoryInterval);
     $validatorChain = new \Zend\Validator\ValidatorChain();
     $validatorChain->attachByName('Callback', array('callback' => array($this, 'validateType'), 'callbackOptions' => 'integer'), true);
     $validatorChain->attachByName('GreaterThan', array('min' => 0));
     $inputFilter->add(array('name' => 'limitInventoryInterval', 'required' => false, 'filters' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'normalize'), 'callback_params' => 'integer'))), 'validators' => $validatorChain));
     $parentFilter = new \Zend\InputFilter\InputFilter();
     $parentFilter->add($inputFilter, 'Preferences');
     $this->setInputFilter($parentFilter);
 }
Exemple #3
0
 /** {@inheritdoc} */
 public function init()
 {
     parent::init();
     $preferences = $this->get('Preferences');
     $inputFilter = new \Zend\InputFilter\InputFilter();
     $integerFilter = array('name' => 'Callback', 'options' => array('callback' => array($this, 'normalize'), 'callback_params' => 'integer'));
     $validatorChain = new \Zend\Validator\ValidatorChain();
     $validatorChain->attachByName('Callback', array('callback' => array($this, 'validateType'), 'callbackOptions' => 'integer'), true);
     $validatorChain->attachByName('GreaterThan', array('min' => 0));
     $groupCacheExpirationInterval = new \Zend\Form\Element\Text('groupCacheExpirationInterval');
     $groupCacheExpirationInterval->setLabel('Minimum seconds between group cache rebuilds')->setAttribute('size', 5);
     $preferences->add($groupCacheExpirationInterval);
     $inputFilter->add(array('name' => 'groupCacheExpirationInterval', 'filters' => array($integerFilter), 'validators' => $validatorChain));
     $groupCacheExpirationFuzz = new \Zend\Form\Element\Text('groupCacheExpirationFuzz');
     $groupCacheExpirationFuzz->setLabel('Maximum seconds added to above value')->setAttribute('size', 5);
     $preferences->add($groupCacheExpirationFuzz);
     $inputFilter->add(array('name' => 'groupCacheExpirationFuzz', 'filters' => array($integerFilter), 'validators' => $validatorChain));
     $setGroupPackageStatus = new \Zend\Form\Element\Checkbox('setGroupPackageStatus');
     $setGroupPackageStatus->setLabel('Set package status on clients for group-assigned packages');
     $preferences->add($setGroupPackageStatus);
     $parentFilter = new \Zend\InputFilter\InputFilter();
     $parentFilter->add($inputFilter, 'Preferences');
     $this->setInputFilter($parentFilter);
 }
}, 'Acl\\Import\\User\\Validator' => function ($sm) {
    $validator = new \Acl\Model\Import\ImportValidator();
    $validator->addColumnDefinition($sm->get('Acl\\Import\\ColumnDefinition\\UniqueIdentity'))->addColumnDefinition($sm->get('Acl\\Import\\ColumnDefinition\\Credential'));
    return $validator;
}, 'Acl\\Import\\User' => function ($sm) {
    $manager = $sm->get('Acl\\Entity\\Manager');
    $factory = $sm->get('Acl\\Factory\\User');
    $wrapper = $sm->get('Acl\\Wrapper\\User');
    $adapter = $sm->get('Acl\\Import\\Adapter\\CsvFile');
    $validator = $sm->get('Acl\\Import\\User\\Validator');
    $import = new \Acl\Model\Import\EntityImport();
    $import->setManager($manager)->setFactory($factory)->setWrapper($wrapper)->setAdapter($adapter)->setValidator($validator);
    return $import;
}, 'Acl\\Import\\ColumDefinition\\AttributeName\\ValidatorChain' => function ($sm) {
    $chain = new \Zend\Validator\ValidatorChain();
    $chain->attachByName('NotEmpty', array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Value for [name] column is required and cannot be empty')), true);
    return $chain;
}, 'Acl\\Import\\ColumnDefinition\\AttributeName' => function ($sm) {
    $validator = $sm->get('Acl\\Import\\ColumDefinition\\AttributeName\\ValidatorChain');
    $factory = $sm->get('Acl\\Factory\\ColumnDefinition');
    return $factory->createInstance(array('name' => 'name', 'validator' => $validator, 'required' => true));
}, 'Acl\\Import\\Attribute\\Validator' => function ($sm) {
    $validator = new \Acl\Model\Import\ImportValidator();
    $validator->addColumnDefinition($sm->get('Acl\\Import\\ColumnDefinition\\Identity'))->addColumnDefinition($sm->get('Acl\\Import\\ColumnDefinition\\AttributeName'));
    return $validator;
}, 'Acl\\Import\\Attribute' => function ($sm) {
    $manager = $sm->get('Acl\\Entity\\Manager');
    $factory = $sm->get('Acl\\Factory\\Attribute');
    $wrapper = $sm->get('Acl\\Wrapper\\Attribute');
    $adapter = $sm->get('Acl\\Import\\Adapter\\CsvFile');
    $validator = $sm->get('Acl\\Import\\Attribute\\Validator');
Exemple #5
0
 /**
  * Get input filter specification for an integer field
  *
  * @param string $name Field name
  * @param integer $min Allowed minimum value
  * @return array
  */
 protected function _getIntegerFilter($name, $min)
 {
     $validatorChain = new \Zend\Validator\ValidatorChain();
     $validatorChain->attachByName('Callback', array('callback' => array($this, 'validateInteger')), true);
     // Callback validators do not support message variables. For
     // translatable messages with a parameter, do translation and
     // substitution here and disable further translation.
     $message = "The input is not greater or equal than '%min%'";
     // Prevent extraction by xgettext
     $minValueValidator = new \Zend\Validator\Callback();
     $minValueValidator->setCallback(array($this, 'validateMinValue'))->setCallbackOptions($min)->setMessage(str_replace('%min%', $min, $minValueValidator->getTranslator()->translate($message)))->setTranslatorEnabled(false);
     $validatorChain->attach($minValueValidator);
     return array('name' => $name, 'required' => false, 'filters' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'filterInteger')))), 'validators' => $validatorChain);
 }
 /**
  * Get input filter specification for an integer field
  *
  * @param string $name Field name
  * @param integer $min Allowed minimum value
  * @return array
  */
 protected function _getIntegerFilter($name, $min)
 {
     $validatorChain = new \Zend\Validator\ValidatorChain();
     $validatorChain->attachByName('Callback', array('callback' => array($this, 'validateInteger')), true);
     $minValueValidator = new \Zend\Validator\Callback();
     $minValueValidator->setCallback(array($this, 'validateMinValue'))->setCallbackOptions($min)->setMessage("The input is not greater or equal than '{$min}'");
     $validatorChain->attach($minValueValidator);
     return array('name' => $name, 'required' => false, 'filters' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'filterInteger')))), 'validators' => $validatorChain);
 }