29 private $requiredProperties = [
42 parent::initializeAttributes();
44 $this->attributes[
'subtype'] =
'elgg_upgrade';
47 $this->attributes[
'container_guid'] = 0;
48 $this->attributes[
'owner_guid'] = 0;
59 $this->is_completed =
true;
70 return (
bool) $this->is_completed;
98 return !is_subclass_of($this->
class, \
Elgg\Upgrade\SystemUpgrade::class);
111 $loglevel = $this->
isCompleted() ?
'INFO' :
'ERROR';
112 elgg_log($ex->getMessage(), $loglevel);
122 elgg_log(
"Upgrade $this->class returned an invalid version: $version");
137 if (!is_int(
$time)) {
141 return $this->completed_time =
$time;
150 return $this->completed_time;
159 unset($this->is_completed);
160 unset($this->completed_time);
161 unset($this->processed);
162 unset($this->offset);
163 unset($this->start_time);
175 if (!is_int(
$time)) {
179 if (isset($this->start_time)) {
180 return $this->start_time;
183 return $this->start_time =
$time;
192 return (
int) $this->start_time;
199 public function save() : bool {
200 if (!isset($this->is_completed)) {
201 $this->is_completed =
false;
204 foreach ($this->requiredProperties as $prop) {
206 throw new UnexpectedValueException(
"ElggUpgrade objects must have a value for the {$prop} property.");
210 return parent::save();
223 if (array_key_exists(
$name, $this->attributes)) {
238 if (array_key_exists(
$name, $this->attributes)) {
239 return parent::__get(
$name);
250 if (array_key_exists(
$name, $this->attributes)) {
251 return parent::__isset(
$name);
255 return !is_null($private_setting);
if(!$user||!$user->canDelete()) $name
isCompleted()
Has this upgrade completed?
__get($name)
Get an attribute or private setting value.
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.
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.