예제 #1
0
 public function onBeforeChange(ModelAbstract $model)
 {
     if ($model instanceof ModelAbstractPlusSymfony) {
         $model->ensureValid();
     }
     $this->eventDispatcher->dispatch('recordChange', new RecordChangeEvent($model, self::BEFORE_CHANGE));
 }
예제 #2
0
 public function setProperty($name, $value)
 {
     try {
         parent::setProperty($name, $value);
     } catch (ConversionImpossibleException $e) {
         $this->conversionViolations[] = new ConstraintViolation($e->getMessage(), array(), $this, $name, $value);
     }
     return $this;
 }
예제 #3
0
 protected function convertModelToDbChangesArray(ModelAbstract $model)
 {
     $modelArray = $model->getProperties();
     $modelArrayDefaults = $model->getOriginalProperties();
     $dbChangesArray = array();
     foreach ($this->orm->config->models[$this->baseClass]->properties as $propertyName => $propertyConfig) {
         if ($modelArray[$propertyName] == $modelArrayDefaults[$propertyName]) {
             continue;
         }
         if (!$propertyConfig->isLocalInDb) {
             continue;
         }
         $dbChangesArray[$propertyName] = $this->orm->typeConverter->convertPhpToDb($propertyConfig->type, $modelArray[$propertyName], $propertyConfig->isNullable);
     }
     return $dbChangesArray;
 }