You are here

public static function Link::loadByMachineName in Colossal Menu 8

Same name and namespace in other branches
  1. 2.x src/Entity/Link.php \Drupal\colossal_menu\Entity\Link::loadByMachineName()

Checks that an existing machine name does not already exist.

This is a static mehod so it can be used by a machine name field.

Parameters

string $machine_name: The machine name to load the entity by.

Return value

\Drupal\colossal_menu\Entity\Link|null Loaded Link entity or NULL if not found.

File

src/Entity/Link.php, line 571

Class

Link
Defines the Link entity.

Namespace

Drupal\colossal_menu\Entity

Code

public static function loadByMachineName($machine_name) {
  $storage = \Drupal::service('entity_type.manager')
    ->getStorage('colossal_menu_link');
  $result = $storage
    ->getQuery()
    ->condition('machine_name', $machine_name)
    ->execute();
  return $result ? $storage
    ->loadMultiple($result) : [];
}