19 declare(strict_types=1);
31 return "PollImagesMigration";
52 $this->db = $environment->
getResource(Environment::RESOURCE_DATABASE);
58 $res = $this->db->query(
"SELECT id, image FROM il_poll WHERE migrated = 0 LIMIT 1");
59 $row =
$res->fetchAssoc();
60 $image = $row[
"image"] ??
"";
71 $stakeholder = (
new ilPollImageRepositoryStakeholder())->withUserId(6);
73 $rid = $irss_helper->movePathToStorage($file_path, 6,
null,
null,
false);
74 $rid_thumbnail = $irss_helper->movePathToStorage($thumbnail_path, 6,
null,
null,
false);
75 $org_thumbnail = $irss_helper->movePathToStorage($org_path, 6,
null,
null,
false);
77 $res_existing = $this->db->query(
"SELECT * FROM il_poll_image WHERE object_id = " . $this->db->quote(
$id,
ilDBConstants::T_INTEGER));
78 $row_existing = $res_existing->fetchAssoc();
79 if (is_null($row_existing)) {
80 $this->db->manipulate(
81 "INSERT INTO il_poll_image (object_id, rid) VALUES " 87 if (!is_null($row_existing)) {
88 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($rid), $stakeholder);
90 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($rid_thumbnail), $stakeholder);
91 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($org_thumbnail), $stakeholder);
98 $res = $this->db->query(
99 'SELECT COUNT(*) AS count FROM il_poll WHERE migrated = 0' 101 $row = $this->db->fetchAssoc(
$res);
102 return (
int) $row[
'count'];
A migration is a potentially long lasting operation that can be broken into discrete steps...
getThumbnailImagePath(string $img, int $id)
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
step(Environment $environment)
Run one step of the migration.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static createPathFromId(int $a_container_id, string $a_name)
getOrgImagePath(string $img, int $id)
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getImageFullPath(string $img, int $id)
An environment holds resources to be used in the setup process.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
prepare(Environment $environment)
Prepare the migration by means of some environment.