You are here

public function UserDashboardSectionStorage::save in Dashboards with Layout Builder 2.0.x

Same name and namespace in other branches
  1. 8 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 90

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;
}