Ejemplo n.º 1
0
 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @return bool
  * @throws Exception\RuntimeException If validation of $value is impossible
  */
 public function isValid($value)
 {
     $company = $this->companyService->getBySsn($value);
     if ($company && $company->id != $this->id) {
         $this->error(self::SSN_IN_USE);
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 public function __construct(Company $company)
 {
     $companies = $company->fetchAll(['Einstaklingur', 'Háskóli']);
     $options = array();
     foreach ($companies as $item) {
         $options[$item->id] = $item->name;
     }
     parent::__construct(strtolower(str_replace('\\', '-', get_class($this))));
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'company-select', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('placeholder' => 'Nafn...', 'required' => 'required'), 'options' => array('label' => 'Fyrirtæki', 'empty_option' => 'Veldu fyrirtæki', 'value_options' => $options)));
     $this->add(array('name' => 'submit-company-select', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('value' => 'Submit'), 'options' => array('label' => 'Submit')));
 }
Ejemplo n.º 3
0
 public function __construct(Company $company)
 {
     parent::__construct(strtolower(str_replace('\\', '-', get_class($this))));
     $companies = $company->fetchType(['Háskóli']);
     $options = array();
     foreach ($companies as $item) {
         $options[$item->id] = $item->name;
     }
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'university-select', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('placeholder' => 'Háskólar'), 'options' => array('label' => 'Háskólar', 'empty_option' => 'Veldu háskóla', 'value_options' => $options)));
     $this->add(array('name' => 'submit-university-select', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('value' => 'Submit'), 'options' => array('label' => 'Submit')));
 }
Ejemplo n.º 4
0
 /**
  * Delete company with no storage connection.
  * @expectedException Exception
  */
 public function testDeleteException()
 {
     $service = new Company();
     $service->setDataSource(new PDOMock());
     $service->delete(1);
 }