41 protected \ilDBInterface
$db;
53 return [self::TABLE_NAME];
63 return match ($type) {
74 $rid = $identification->serialize();
76 if (isset($this->cache[$rid])) {
77 return $this->cache[$rid];
80 $q =
"SELECT storage_id, rtype FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s";
81 $r = $this->db->queryF(
$q, [
'text'], [$rid]);
82 $d = $this->db->fetchObject(
$r);
85 $resource->setStorageID(
$d->storage_id);
87 $this->cache[$rid] = $resource;
99 if (isset($this->cache[$rid])) {
103 $q =
"SELECT EXISTS(SELECT 1 FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s) AS found";
104 $r = $this->db->queryF(
$q, [
'text'], [$rid]);
105 $d = $this->db->fetchAssoc(
$r);
107 return (
bool)
$d[
'found'];
120 self::IDENTIFICATION => [
'text', $rid]
124 'rtype' => [
'text', $resource->
getType()->value],
128 $this->cache[$rid] = $resource;
137 $this->db->manipulateF(
138 "DELETE FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s",
142 unset($this->cache[$rid]);
153 public function preload(array $identification_strings): void
155 $r = $this->db->query(
156 "SELECT rid, storage_id, rtype FROM " . self::TABLE_NAME .
" WHERE " 157 . $this->db->in(self::IDENTIFICATION, $identification_strings,
false,
'text')
159 while (
$d = $this->db->fetchAssoc(
$r)) {
166 $resource = $this->
blank(
170 $resource->setStorageID($data[
'storage_id']);
171 $this->cache[$data[
'rid']] = $resource;
Interface StorageResource.
__construct(\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...