function UpdateProject::toArray
Same name and namespace in other branches
- main core/modules/update/src/UpdateProject.php \Drupal\update\UpdateProject::toArray()
Creates an array from UpdateProject object.
Return value
array The array representation on the object.
File
-
core/
modules/ update/ src/ UpdateProject.php, line 173
Class
- UpdateProject
- Update project information.
Namespace
Drupal\updateCode
public function toArray() : array {
$projectData = [];
// Convert to snake case from properties.
foreach (get_object_vars($this) as $property => $value) {
switch ($property) {
case 'fetchStatus':
if ($value) {
$projectData['fetch_status'] = $value;
}
break;
case 'installType':
if ($value) {
$projectData['install_type'] = $value;
}
break;
case 'latestDev':
if ($value) {
$projectData['latest_dev'] = $value;
}
break;
case 'latestVersion':
if ($value) {
$projectData['latest_version'] = $value;
}
break;
case 'projectType':
if ($value) {
$projectData['project_type'] = $value;
}
break;
case 'existingMajor':
if ($value) {
$projectData['existing_major'] = $value;
}
break;
case 'projectStatus':
if ($value) {
$projectData['project_status'] = $value;
}
break;
case 'securityUpdates':
if ($value) {
$projectData['security updates'] = $value;
}
break;
case 'existingVersion':
// Ensure we do not get a property that is pascal case set as a key.
break;
default:
if ($value) {
$projectData[$property] = $value;
}
break;
}
}
// This key must always exist even if the prop does not.
$projectData['existing_version'] = $this->existingVersion;
return $projectData;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.