public function Dashboard::loadOverrides in Dashboards with Layout Builder 8
Same name and namespace in other branches
- 2.0.x src/Entity/Dashboard.php \Drupal\dashboards\Entity\Dashboard::loadOverrides()
Loading sections from user data.
File
- src/
Entity/ Dashboard.php, line 213
Class
- Dashboard
- Dashboard.
Namespace
Drupal\dashboards\EntityCode
public function loadOverrides() {
$dataService = \Drupal::service('user.data');
$account = \Drupal::currentUser();
$data = $dataService
->get('dashboards', $account
->id(), $this
->id());
$this
->set('sections', []);
if ($data && !empty($data)) {
try {
$data = unserialize($data);
$sections = array_map([
Section::class,
'fromArray',
], $data);
$this
->set('sections', $sections);
} catch (\Exception $ex) {
$this
->set('sections', []);
}
}
}