30 private $requiredProperties = [
43 parent::initializeAttributes();
45 $this->attributes[
'subtype'] =
'elgg_upgrade';
48 $this->attributes[
'container_guid'] = 0;
49 $this->attributes[
'owner_guid'] = 0;
60 $this->is_completed =
true;
71 return (
bool) $this->is_completed;
99 return !is_subclass_of($this->
class, \
Elgg\Upgrade\SystemUpgrade::class);
112 $loglevel = $this->
isCompleted() ?
'INFO' :
'ERROR';
113 elgg_log($ex->getMessage(), $loglevel);
123 elgg_log(
"Upgrade $this->class returned an invalid version: $version");
138 if (!is_int(
$time)) {
142 return $this->completed_time =
$time;
151 return $this->completed_time;
160 unset($this->is_completed);
161 unset($this->completed_time);
162 unset($this->processed);
163 unset($this->offset);
164 unset($this->start_time);
176 if (!is_int(
$time)) {
180 if (isset($this->start_time)) {
181 return $this->start_time;
184 return $this->start_time =
$time;
193 return (
int) $this->start_time;
200 public function save() : bool {
201 if (!isset($this->is_completed)) {
202 $this->is_completed =
false;
205 foreach ($this->requiredProperties as $prop) {
207 throw new ElggUnexpectedValueException(
"ElggUpgrade objects must have a value for the {$prop} property.");
211 return parent::save();
224 if (array_key_exists(
$name, $this->attributes)) {
239 if (array_key_exists(
$name, $this->attributes)) {
240 return parent::__get(
$name);
251 if (array_key_exists(
$name, $this->attributes)) {
252 return parent::__isset(
$name);
256 return !is_null($private_setting);
isCompleted()
Has this upgrade completed?
__get($name)
Get an attribute or private setting value.
if(!$user||!$user->canDelete()) $name
setPrivateSetting($name, $value)
Adds a private setting to this entity.
getPrivateSetting($name)
Returns a private setting value.
if(!$annotation instanceof ElggAnnotation) $time
getStartTime()
Gets the time when the upgrade completed.
isAsynchronous()
Check if the upgrade should be run asynchronously.
trait TimeUsing
Adds methods for setting the current time (for testing)
initializeAttributes()
Set subtype to upgrade.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
getCurrentTime($modifier= '')
Get the (cloned) time.
getCompletedTime()
Gets the time when the upgrade completed.
getBatch()
Return instance of the class that processes the data.
setID($id)
Sets an unique id for the upgrade.
Represents an upgrade that runs outside of the upgrade.php script.
Exception thrown if a value does not match with a set of values.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
__set($name, $value)
Set a value as private setting or attribute.
setCompleted()
Mark this upgrade as completed.
setCompletedTime($time=null)
Sets the timestamp for when the upgrade completed.
setClass($class)
Sets a class for the upgrade.
reset()
Resets the update in order to be able to run it again.
_elgg_services()
Get the global service provider.
setStartTime($time=null)
Sets the timestamp for when the upgrade started.
elgg_trigger_event($event, $object_type, $object=null)
$id
Generic annotation delete action.