You are here

protected function DeveloperAppFormTrait::apiProductList in Apigee Edge 8

1 method overrides DeveloperAppFormTrait::apiProductList()
DeveloperAppEditForm::apiProductList in src/Entity/Form/DeveloperAppEditForm.php
Returns the list of API product that the user can see on the form.

File

src/Entity/Form/DeveloperAppFormTrait.php, line 127

Class

DeveloperAppFormTrait
Helper trait that contains developer app (create/edit) form specific tweaks.

Namespace

Drupal\apigee_edge\Entity\Form

Code

protected function apiProductList(array $form, FormStateInterface $form_state) : array {
  $email = $form_state
    ->getValue('owner') ?? $form['owner']['#value'] ?? $form['owner']['#default_value'];

  /** @var \Drupal\user\UserInterface|null $account */
  $account = user_load_by_mail($email);
  return array_filter(\Drupal::entityTypeManager()
    ->getStorage('api_product')
    ->loadMultiple(), function (ApiProductInterface $product) use ($account) {
    return $product
      ->access('assign', $account);
  });
}