You are here

private function CacheflushApi::checkError in CacheFlush 8

Check if entity exists and is enabled.

Parameters

\Drupal\cacheflush_entity\Entity\CacheflushEntity $entity: Cacheflush entity.

1 call to CacheflushApi::checkError()
CacheflushApi::clearPresetCache in src/Controller/CacheflushApi.php
Based on settings decide witch clear cache function to be called.

File

src/Controller/CacheflushApi.php, line 253

Class

CacheflushApi
Returns responses for Cacheflush routes.

Namespace

Drupal\cacheflush\Controller

Code

private function checkError(CacheflushEntity $entity) {
  if (!$entity) {
    $this->messenger
      ->addMessage($this
      ->t('Invalid entity ID.'), 'error');
    throw new HttpException('404');
  }
  if ($entity
    ->getStatus() == 0) {
    $this->messenger
      ->addMessage($this
      ->t('This entity is disabled.'), 'error');
    throw new HttpException('403');
  }
}