ILIAS  release_7 Revision v7.30-3-g800a261c036
DBRepositoryPreloader.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
4
9
16{
20 protected $db;
21
22 protected $preloaded = [];
23
24 public function __construct(
30 ) {
31 $this->db = $db;
37 );
38 }
39
40 public function preload(array $identification_strings) : void
41 {
42 $requested = array_diff($identification_strings, $this->preloaded);
43 if (count($requested) === 0) {
44 return;
45 }
46 try {
47 $r = $this->db->query(
48 "SELECT *, il_resource_revision.title AS revision_title
49FROM il_resource_revision
50JOIN il_resource_info ON il_resource_revision.rid = il_resource_info.rid AND il_resource_info.version_number = il_resource_revision.version_number
51JOIN il_resource ON il_resource_revision.rid = il_resource.rid
52JOIN il_resource_stkh_u ON il_resource_stkh_u.rid = il_resource.rid
53JOIN il_resource_stkh ON il_resource_stkh_u.stakeholder_id = il_resource_stkh.id
54WHERE " . $this->db->in('il_resource_revision.rid', $requested, false, 'text')
55 );
56 while ($d = $this->db->fetchAssoc($r)) {
57 $this->resource_repository->populateFromArray($d);
58 $this->revision_repository->populateFromArray($d);
59 $this->information_repository->populateFromArray($d);
60 $this->stakeholder_repository->populateFromArray($d);
61 }
62 $this->preloaded = array_merge($this->preloaded, $identification_strings);
63 $this->preloaded = array_unique($this->preloaded);
64 } catch (\Throwable $t) {
65 // preloading failed, fallback will be loading one by one
66 }
67 }
68}
An exception for terminatinating execution or to throw for unit testing.
__construct(\ilDBInterface $db, ResourceRepository $resource_repository, RevisionRepository $revision_repository, InformationRepository $information_repository, StakeholderRepository $stakeholder_repository)
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc