ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObject2.php
Go to the documentation of this file.
1<?php
2
23abstract class ilObject2 extends ilObject
24{
31 public function __construct(int $a_id = 0, bool $a_reference = true)
32 {
33 $this->initType();
34 parent::__construct($a_id, $a_reference);
35 }
36
37 abstract protected function initType(): void;
38
39 final public function read(): void
40 {
41 parent::read();
42 $this->doRead();
43 }
44
45 protected function doRead(): void
46 {
47 }
48
49
50 final public function create(bool $a_clone_mode = false): int
51 {
52 if ($this->beforeCreate()) {
53 $id = parent::create();
54 if ($id) {
55 $this->doCreate($a_clone_mode);
56 return $id;
57 }
58 }
59 return 0;
60 }
61
62 protected function doCreate(bool $clone_mode = false): void
63 {
64 }
65
72 protected function beforeCreate(): bool
73 {
74 return true;
75 }
76
77 public function update(): bool
78 {
79 if ($this->beforeUpdate()) {
80 if (!parent::update()) {
81 return false;
82 }
83 $this->doUpdate();
84
85 return true;
86 }
87
88 return false;
89 }
90
91 protected function doUpdate(): void
92 {
93 }
94
95 protected function beforeUpdate(): bool
96 {
97 return true;
98 }
99
100 final public function delete(): bool
101 {
102 if ($this->beforeDelete()) {
103 if (parent::delete()) {
104 $this->doDelete();
105 $this->id = 0;
106 return true;
107 }
108 }
109 return false;
110 }
111
112 protected function doDelete(): void
113 {
114 }
115
116 protected function beforeDelete(): bool
117 {
118 return true;
119 }
120
121 final public function cloneMetaData(ilObject $target_obj): bool
122 {
123 return parent::cloneMetaData($target_obj);
124 }
125
126 final public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ?ilObject
127 {
128 if ($this->beforeCloneObject()) {
129 $new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);
130 if ($new_obj instanceof ilObject2) {
131 $this->doCloneObject($new_obj, $target_id, $copy_id);
132 return $new_obj;
133 }
134 }
135 return null;
136 }
137
138 protected function doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id = null): void
139 {
140 }
141
142 protected function beforeCloneObject(): bool
143 {
144 return true;
145 }
146}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
beforeCreate()
If overwritten this method should return true, there is currently no "abort" handling for cases where...
doCreate(bool $clone_mode=false)
doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
cloneObject(int $target_id, int $copy_id=0, bool $omit_tree=false)
__construct(int $a_id=0, bool $a_reference=true)
Constructor.
cloneMetaData(ilObject $target_obj)
Copy meta data.
create(bool $a_clone_mode=false)
Class ilObject Basic functions for all objects.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc