51 return [self::TABLE_NAME];
61 return match ($type) {
72 $rid = $identification->serialize();
74 if (isset($this->cache[$rid])) {
75 return $this->cache[$rid];
78 $q =
"SELECT storage_id, rtype FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s";
79 $r = $this->db->queryF(
$q, [
'text'], [$rid]);
80 $d = $this->db->fetchObject(
$r);
83 $resource->setStorageID(
$d->storage_id);
85 $this->cache[$rid] = $resource;
97 if (isset($this->cache[$rid])) {
101 $q =
"SELECT EXISTS(SELECT 1 FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s) AS found";
102 $r = $this->db->queryF(
$q, [
'text'], [$rid]);
103 $d = $this->db->fetchAssoc(
$r);
105 return (
bool)
$d[
'found'];
118 self::IDENTIFICATION => [
'text', $rid]
122 'rtype' => [
'text', $resource->
getType()->value],
126 $this->cache[$rid] = $resource;
135 $this->db->manipulateF(
136 "DELETE FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s",
140 unset($this->cache[$rid]);
151 public function preload(array $identification_strings): void
153 $r = $this->db->query(
154 "SELECT rid, storage_id, rtype FROM " . self::TABLE_NAME .
" WHERE " 155 . $this->db->in(self::IDENTIFICATION, $identification_strings,
false,
'text')
157 while (
$d = $this->db->fetchAssoc(
$r)) {
164 $resource = $this->
blank(
168 $resource->setStorageID($data[
'storage_id']);
169 $this->cache[$data[
'rid']] = $resource;
Interface StorageResource.
__construct(protected \ilDBInterface $db)
Class ResourceDBRepository.
store(StorableResource $resource)
blank(ResourceIdentification $identification, ResourceType $type=ResourceType::SINGLE_FILE)
has(ResourceIdentification $identification)
preload(array $identification_strings)
Class ResourceIdentification.
populateFromArray(array $data)
Interface ResourceRepository.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...