You are here

public function FlagService::getFlagById in Flag 8.4

Load the flag entity given the ID.

$flag = \Drupal::service('flag')
  ->getFlagById('bookmark');

Parameters

string $flag_id: The identifier of the flag to load.

Return value

\Drupal\flag\FlagInterface|null The flag entity.

Overrides FlagServiceInterface::getFlagById

File

src/FlagService.php, line 194

Class

FlagService
Flag service.

Namespace

Drupal\flag

Code

public function getFlagById($flag_id) {
  return $this->entityTypeManager
    ->getStorage('flag')
    ->load($flag_id);
}