예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function preparePropertyValue(IObject $object, $internalDbValue)
 {
     /**
      * @var IFileProperty $fileProperty
      */
     $fileProperty = $object->getProperty($this->getName());
     return new File($fileProperty, $this->sourcePath, $this->sourceURI, $internalDbValue);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function calculateDBValue(IObject $object, $localeId = null)
 {
     if (!$object instanceof IHierarchicObject) {
         throw new RuntimeException($this->translate('Cannot calculate order value for nonhierarchical object.'));
     }
     if (null != ($order = $object->getProperty($this->getName())->getDbValue())) {
         return $order;
     }
     return $object->getCollection()->getMaxOrder($object->getParent()) + 1;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function calculateDBValue(IObject $object, $localeId = null)
 {
     if (!$object instanceof IHierarchicObject) {
         throw new RuntimeException($this->translate('Cannot calculate level value for nonhierarchical object.'));
     }
     /**
      * @var MaterializedPathField $mpathField
      */
     $mpathField = $object->getProperty(IHierarchicObject::FIELD_MPATH)->getField();
     $mpath = $mpathField->calculateDBValue($object);
     return substr_count($mpath, MaterializedPathField::MPATH_SEPARATOR);
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function calculateDBValue(IObject $object, $localeId = null)
 {
     if (!$object instanceof IHierarchicObject) {
         throw new RuntimeException($this->translate('Cannot calculate URI value for nonhierarchical object.'));
     }
     /**
      * @var SlugField $slugField
      */
     $slugField = $object->getProperty(IHierarchicObject::FIELD_SLUG)->getField();
     $slug = $slugField->calculateDBValue($object, $localeId);
     if ($parent = $object->getParent()) {
         return $parent->getURI() . '/' . $slug;
     } else {
         return self::URI_START_SYMBOL . '/' . $slug;
     }
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function calculateDBValue(IObject $object, $localeId = null)
 {
     return $object->getProperty($this->getName(), $localeId)->getDbValue();
 }
예제 #6
0
 /**
  * Проверяет правильность пароля для указанного пользователя.
  * @param IObject $user пользователь
  * @param string $password пароль
  * @return bool true, если пароль верный
  */
 public function checkPassword(IObject $user, $password)
 {
     return $user->getProperty($this->passwordField)->getValue() === $password;
 }
예제 #7
0
 /**
  * Восстанавливает значения полей типа relation
  * @param IObject $object
  * @param array $relatedValues
  */
 protected function restoreObjectRelations(IObject $object, array $relatedValues)
 {
     foreach ($relatedValues as $propertyName => $value) {
         $property = $object->getProperty($propertyName);
         $property->setInitialValue(null);
         $property->setValue($value);
     }
 }