You are here

public static function HomeboxPageForm::getLayoutStorageData in Homebox 8

Helper function to get the layout storage data.

Parameters

int $homebox: Current homebox id.

int $user_id: Current user id.

Return value

\Drupal\Core\Entity\EntityInterface|null Layout homebox of current user.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

2 calls to HomeboxPageForm::getLayoutStorageData()
HomeboxPageForm::addBlock in src/Form/HomeboxPageForm.php
Ajax callback to add block.
HomeboxPageForm::buildForm in src/Form/HomeboxPageForm.php
Form constructor.

File

src/Form/HomeboxPageForm.php, line 389

Class

HomeboxPageForm
Class HomeboxPageForm.

Namespace

Drupal\homebox\Form

Code

public static function getLayoutStorageData($homebox, $user_id) {
  $homebox_layout_storage = \Drupal::entityTypeManager()
    ->getStorage('homebox_layout');
  $homebox_layout_id = $homebox_layout_storage
    ->getQuery()
    ->condition('type', $homebox)
    ->condition('user_id', $user_id)
    ->execute();
  if (!empty($homebox_layout_id)) {
    $homebox_layout = $homebox_layout_storage
      ->load(array_shift($homebox_layout_id));
  }
  else {
    $homebox_layout = NULL;
  }
  return $homebox_layout;
}