You are here

public function UserDashboardSectionStorage::save in Dashboards with Layout Builder 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/SectionStorage/UserDashboardSectionStorage.php \Drupal\dashboards\Plugin\SectionStorage\UserDashboardSectionStorage::save()

Saves the sections.

Return value

int SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.

Overrides DashboardSectionStorage::save

File

src/Plugin/SectionStorage/UserDashboardSectionStorage.php, line 122

Class

UserDashboardSectionStorage
Class DashboardSectionStorage.

Namespace

Drupal\dashboards\Plugin\SectionStorage

Code

public function save() {
  $sections = [];
  foreach ($this
    ->getDashboard()
    ->get('sections') as $delta => $section) {
    $sections[$delta] = $section
      ->toArray();
  }
  $this->userData
    ->set('dashboards', $this->account
    ->id(), $this
    ->getDashboard()
    ->id(), serialize($sections));
  return SAVED_UPDATED;
}