Ejemplo n.º 1
0
 /**
  * Test the validity of a model
  * @final
  * @param Cognosys\Model $model
  * @return bool
  */
 protected final function valid(Model $model)
 {
     $model->validate();
     $errors = Validator::get();
     AlertManager::import($errors);
     $metadata = $this->getClassMetadata(get_class($model));
     foreach ($metadata->associationMappings as $assoc) {
         $method = TextUtil::camelize($assoc['fieldName']);
         if (is_numeric($model->{$method}()) && $model->{$method}() > 0) {
             // transform the identifier to the entity
             $model->{$method}($this->getReference($assoc['targetEntity'], $model->{$method}()));
             $this->persist($model->{$method}());
         }
     }
     return empty($errors);
 }
Ejemplo n.º 2
0
 /**
  * Renames controller and action
  * @return void
  */
 private function _renameProperties()
 {
     $this->_original_controller = $this->_controller;
     $this->_controller = $this->_controller === null ? 'IndexController' : ucfirst(TextUtil::camelize($this->_controller)) . 'Controller';
     $this->_action = $this->_action === null ? 'index' : TextUtil::camelize($this->_action);
 }