ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NewTypeAddedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Setup;
25
27{
28 protected string $type;
29 protected string $type_title;
30
31 public function __construct(string $type, string $type_title)
32 {
33 $this->type = $type;
34 $this->type_title = $type_title;
35 }
36
37 public function getHash(): string
38 {
39 return hash("sha256", self::class . "::" . $this->type);
40 }
41
42 public function getLabel(): string
43 {
44 return "Add new type $this->type to object data";
45 }
46
47 public function isNotable(): bool
48 {
49 return true;
50 }
51
55 public function getPreconditions(Environment $environment): array
56 {
57 return [
59 ];
60 }
61
62 public function achieve(Environment $environment): Environment
63 {
65
66 $id = $db->nextId("object_data");
67
68 $values = [
69 'obj_id' => ['integer', $id],
70 'type' => ['text', 'typ'],
71 'title' => ['text', $this->type],
72 'description' => ['text', $this->type_title],
73 'owner' => ['integer', -1],
74 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
75 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
76 ];
77
78 $db->insert("object_data", $values);
79
80 return $environment;
81 }
82
83 public function isApplicable(Environment $environment): bool
84 {
86 if (is_null(ilObject::_getObjectTypeIdByTitle($this->type, $db))) {
87 return true;
88 }
89 return false;
90 }
91}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
isApplicable(Environment $environment)
Get to know whether the objective is applicable.
getLabel()
Get a label that describes this objective.
isNotable()
Get to know if this is an interesting objective for a human.
__construct(string $type, string $type_title)
achieve(Environment $environment)
Objectives can be achieved.
static _getObjectTypeIdByTitle(string $type, ?\ilDBInterface $ilDB=null)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Agent.php:19
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...