/** * {@inheritdoc} */ public function preparePropertyValue(IObject $object, $internalDbValue) { /** * @var IFileProperty $fileProperty */ $fileProperty = $object->getProperty($this->getName()); return new File($fileProperty, $this->sourcePath, $this->sourceURI, $internalDbValue); }
/** * {@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; }
/** * {@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); }
/** * {@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; } }
/** * {@inheritdoc} */ public function calculateDBValue(IObject $object, $localeId = null) { return $object->getProperty($this->getName(), $localeId)->getDbValue(); }
/** * Проверяет правильность пароля для указанного пользователя. * @param IObject $user пользователь * @param string $password пароль * @return bool true, если пароль верный */ public function checkPassword(IObject $user, $password) { return $user->getProperty($this->passwordField)->getValue() === $password; }
/** * Восстанавливает значения полей типа 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); } }