/**
  * {@inheritdoc}
  */
 public function persistProperty(IObject $object, IProperty $property, IQueryBuilder $builder)
 {
     if ($builder instanceof IUpdateBuilder) {
         $increment = $property->getDbValue() - $property->getPersistedDbValue();
         if ($increment !== 0) {
             $incrementExpression = $builder->getConnection()->quoteIdentifier($this->getColumnName()) . ' + (' . $increment . ')';
             $builder->set($this->getColumnName(), ':new' . $this->getColumnName())->bindExpression(':new' . $this->getColumnName(), $incrementExpression);
         }
     }
     return $this;
 }
 /**
  * @see IField::persistProperty()
  */
 public function persistProperty(IObject $object, IProperty $property, IQueryBuilder $builder)
 {
     if ($builder instanceof IUpdateBuilder) {
         $localeId = $property->getLocaleId();
         if ($localeId && !$this->hasLocale($localeId)) {
             return $this;
         }
         $builder->set($this->getColumnName($localeId));
         $value = $this->calculateDBValue($object, $localeId);
         $builder->bindValue(':' . $this->getColumnName($localeId), $value, $this->getDataType());
         $property->setValue($value);
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function persistProperty(IObject $object, IProperty $property, IQueryBuilder $builder)
 {
     $localeId = $property->getLocaleId();
     if ($localeId && !$this->hasLocale($localeId)) {
         return $this;
     }
     /**
      * @var IUpdateBuilder $builder
      */
     if ($builder instanceof IUpdateBuilder) {
         $increment = $property->getDbValue() - $property->getPersistedDbValue();
         if ($increment !== 0) {
             $incrementExpression = $builder->getConnection()->quoteIdentifier($this->getColumnName()) . ' + (' . $increment . ')';
             $builder->set($this->getColumnName($localeId), ':new' . $this->getColumnName($localeId))->bindExpression(':new' . $this->getColumnName($localeId), $incrementExpression);
         }
     } elseif ($builder instanceof IInsertBuilder) {
         $builder->set($this->getColumnName($localeId));
         $builder->bindValue(':' . $this->getColumnName($localeId), $this->calculateDBValue($object, $localeId), $this->getDataType());
     }
     return $this;
 }
Exemple #4
0
 /**
  * Возвращает значение локализованого свойства. <br/>
  * Если поле локализовано, и значение в текущей локали отсутствует, возвращается значение дефолтной локали.
  * @param IProperty $property
  * @param string $localeId идентификатор локали
  * @return mixed
  */
 protected function getLocalizedValue(IProperty $property, $localeId)
 {
     if ($localeId || !is_null($property->getValue()) || $property->getLocaleId() === $this->getDefaultDataLocale()) {
         return $property->getValue();
     }
     $defaultProperty = $this->getProperty($property->getName(), $this->getDefaultDataLocale());
     return $defaultProperty->getValue();
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public function persistProperty(IObject $object, IProperty $property, IQueryBuilder $builder)
 {
     /**
      * @var IUpdateBuilder $builder
      */
     if ($builder instanceof IInsertBuilder || $builder instanceof IUpdateBuilder) {
         $localeId = $property->getLocaleId();
         if ($localeId && !$this->hasLocale($localeId)) {
             return $this;
         }
         $builder->set($this->getColumnName($localeId));
         $builder->bindValue(':' . $this->getColumnName($localeId), $property->getDbValue(), $this->getDataType());
     }
     return $this;
 }