public function Dashboard::loadOverrides in Dashboards with Layout Builder 2.0.x
Same name and namespace in other branches
- 8 src/Entity/Dashboard.php \Drupal\dashboards\Entity\Dashboard::loadOverrides()
Loading sections from user data.
File
- src/
Entity/ Dashboard.php, line 217
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', []);
}
}
}