You are here

protected function OgMenuTrait::getOgMenuInstance in Organic Groups Menu (OG Menu) 8

Retrieves an OG Menu instance from the database.

Parameters

string $group_id: The group id of the parent entity.

string $type: The OG Menu bundle.

Return value

\Drupal\og_menu\OgMenuInstanceInterface|null The menu instance as retrieved from the database, or NULL if no instance is found.

1 call to OgMenuTrait::getOgMenuInstance()
OgMenuSubContext::assertMenuItemCount in ./og_menu.behat.inc
Checks that the given OG Menu instance has the expected number of items.

File

src/Tests/Traits/OgMenuTrait.php, line 27

Class

OgMenuTrait
Helper methods to use in OG Menu tests.

Namespace

Drupal\og_menu\Tests\Traits

Code

protected function getOgMenuInstance($group_id, $type) {
  $values = [
    'type' => $type,
    OgGroupAudienceHelperInterface::DEFAULT_FIELD => $group_id,
  ];
  $instances = \Drupal::entityTypeManager()
    ->getStorage('ogmenu_instance')
    ->loadByProperties($values);
  return !empty($instances) ? array_pop($instances) : NULL;
}