BundleEntityStorage.php in Lightning Core 8.4
File
src/BundleEntityStorage.php
View source
<?php
namespace Drupal\lightning_core;
use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\Core\Entity\EntityAccessControlHandlerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BundleEntityStorage extends ConfigEntityStorage {
protected $accessHandler;
public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityAccessControlHandlerInterface $access_handler, MemoryCacheInterface $memory_cache) {
parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache);
$this->accessHandler = $access_handler;
}
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('config.factory'), $container
->get('uuid'), $container
->get('language_manager'), $container
->get('entity_type.manager')
->getAccessControlHandler($entity_type
->getBundleOf()), $container
->get('entity.memory_cache'));
}
public function loadMultiple(array $ids = NULL, $check_access = FALSE) {
if ($check_access) {
$ids = array_filter($ids ?: $this
->getQuery()
->execute(), [
$this->accessHandler,
'createAccess',
]);
}
return parent::loadMultiple($ids);
}
}