Esempio n. 1
0
 /**
  * Validation data
  * 
  * @param array $data
  * @return mixed
  * @throws FormValidationException
  */
 public function validate(array $data)
 {
     $this->validation = $this->validator->make($data, $this->rules(), $this->messages());
     if ($this->validation->fails()) {
         throw new FormValidationException("Validation Failed", $this->errors());
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Validate the form data
  *
  * @throws FormValidationException
  *         whenever the validation fails
  *
  * @param mixed $formData
  *
  * @return bool
  */
 public function validate($formData)
 {
     $formData = $this->normalizeFormData($formData);
     $this->validation = $this->factory->make($formData, $this->getValidationRules(), $this->getValidationMessages());
     if ($this->validation->fails()) {
         throw new FormValidationException('Validation failed', $this->getValidationErrors());
     }
     return true;
 }
Esempio n. 3
0
 public function addChild($child, array $options = array())
 {
     if (!$child instanceof ItemInterface) {
         $child = $this->factory->createItem($child, $options);
     } elseif (null !== $child->getParent()) {
         throw new \InvalidArgumentException('Cannot add menu item as child, it already belongs to another menu (e.g. has a parent).');
     }
     $child->setParent($this);
     $this->children[$child->getName()] = $child;
     return $child;
 }
Esempio n. 4
0
 /**
  * Builds validator using validation factory.
  *
  * @param array $data
  * @param array $rules
  * @param array $messages
  *
  * @return ValidatorInterface
  */
 public function makeValidator(array $data, array $rules, array $messages = [])
 {
     return $this->validationFactory->make($data, $rules, $messages);
 }
 /**
  * Get template
  *
  * @return \Magento\Framework\Mail\TemplateInterface
  */
 protected function getTemplate()
 {
     return $this->templateFactory->get($this->templateIdentifier)->setVars($this->templateVars)->setOptions($this->templateOptions);
 }