You are here

public function BackgroundImageManager::validEntity in Background Image 8

Same name and namespace in other branches
  1. 2.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::validEntity()
  2. 2.0.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::validEntity()

Checks whether an entity can use background images.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An EntityInterface object.

Return value

bool TRUE or FALSE

Overrides BackgroundImageManagerInterface::validEntity

3 calls to BackgroundImageManager::validEntity()
BackgroundImageManager::getEntityBackgroundImage in src/BackgroundImageManager.php
Retrieves a background image that matches a specific entity.
BackgroundImageManager::getEntityFromCurrentRoute in src/BackgroundImageManager.php
Retrieves the current route entity object.
BackgroundImageManager::prepareEntityForm in src/BackgroundImageManager.php
Acts on an entity object about to be shown on an entity form.

File

src/BackgroundImageManager.php, line 721

Class

BackgroundImageManager

Namespace

Drupal\background_image

Code

public function validEntity(EntityInterface $entity) {

  // Check enabled entity bundles.
  if (!in_array($entity
    ->bundle(), array_keys($this
    ->getEnabledEntityTypeBundles($entity
    ->getEntityType())))) {
    return FALSE;
  }

  // Check enabled entity types.
  if (!in_array($entity
    ->getEntityTypeId(), array_keys($this
    ->getEnabledEntityTypes()))) {
    return FALSE;
  }
  return TRUE;
}