41 protected \ilDBInterface
$db;
53 return [self::TABLE_NAME];
63 return match ($type) {
74 if (isset($this->cache[$identification->serialize()])) {
75 return $this->cache[$identification->serialize()];
78 $q =
"SELECT " . self::IDENTIFICATION .
", storage_id, rtype FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s";
79 $r = $this->db->queryF(
$q, [
'text'], [$identification->serialize()]);
80 $d = $this->db->fetchObject(
$r);
83 $resource->setStorageID(
$d->storage_id);
85 $this->cache[$identification->serialize()] = $resource;
95 if (isset($this->cache[$identification->
serialize()])) {
98 $q =
"SELECT " . self::IDENTIFICATION .
" FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s";
99 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
101 return (
bool)
$r->numRows() > 0;
115 self::IDENTIFICATION => [
'text', $rid],
117 'rtype' => [
'text', $resource->
getType()->value],
120 self::IDENTIFICATION => [
'text', $rid],
128 self::IDENTIFICATION => [
'text', $rid],
130 'rtype' => [
'text', $resource->
getType()->value],
134 $this->cache[$rid] = $resource;
143 $this->db->manipulateF(
144 "DELETE FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s",
148 unset($this->cache[$rid]);
159 public function preload(array $identification_strings): void
161 $r = $this->db->query(
162 "SELECT rid, storage_id, rtype FROM " . self::TABLE_NAME .
" WHERE " 163 . $this->db->in(self::IDENTIFICATION, $identification_strings,
false,
'text')
165 while (
$d = $this->db->fetchAssoc(
$r)) {
172 $resource = $this->
blank(
176 $resource->setStorageID($data[
'storage_id']);
177 $this->cache[$data[
'rid']] = $resource;
Interface StorageResource.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__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...