private function getAttachedObjectById($id) { $attachedObject = Disk\AttachedObject::getById($id, array('OBJECT')); if (!$attachedObject || !$attachedObject->getFile()) { throw new RestException("Could not find entity with id '{$id}'.", RestException::ERROR_NOT_FOUND); } return $attachedObject; }
protected static function getIdByFileId($fileId, $ownerId, $entityId, $fieldName) { static::includeDisk(); $currentValue = static::getValue($ownerId, $entityId, $fieldName); foreach ($currentValue as $value) { $attachedObject = AttachedObject::getById($value, array('OBJECT')); if ($attachedObject && $attachedObject->getFile()) { $attachmentFileId = $attachedObject->getObjectId(); if ((int) $attachmentFileId == (int) $fileId) { return $value; } } } return false; }