public function onBeforeChange(ModelAbstract $model) { if ($model instanceof ModelAbstractPlusSymfony) { $model->ensureValid(); } $this->eventDispatcher->dispatch('recordChange', new RecordChangeEvent($model, self::BEFORE_CHANGE)); }
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; }
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; }