Issue #3023981 by Berdir, larowlan, alexpott, xjm, catch: Add @trigger_error() to deprecated EntityManager->EntityRepository methods
parent
c8dc57eede
commit
e69e249da0
|
|
@ -369,6 +369,7 @@ class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
|
|||
* @see https://www.drupal.org/node/2549139
|
||||
*/
|
||||
public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) {
|
||||
@trigger_error('EntityManagerInterface::getTranslationFromContext() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::getTranslationFromContext() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
return $this->container->get('entity.repository')->getTranslationFromContext($entity, $langcode, $context);
|
||||
}
|
||||
|
||||
|
|
@ -499,6 +500,7 @@ class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
|
|||
* @see https://www.drupal.org/node/2549139
|
||||
*/
|
||||
public function loadEntityByUuid($entity_type_id, $uuid) {
|
||||
@trigger_error('EntityManagerInterface::loadEntityByUuid() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::loadEntityByUuid() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
return $this->container->get('entity.repository')->loadEntityByUuid($entity_type_id, $uuid);
|
||||
}
|
||||
|
||||
|
|
@ -512,6 +514,7 @@ class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
|
|||
* @see https://www.drupal.org/node/2549139
|
||||
*/
|
||||
public function loadEntityByConfigTarget($entity_type_id, $target) {
|
||||
@trigger_error('EntityManagerInterface::loadEntityByConfigTarget() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::loadEntityByConfigTarget() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
return $this->container->get('entity.repository')->loadEntityByConfigTarget($entity_type_id, $target);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
|
|||
use Drupal\Core\Session\AccountInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\SelectionTrait is deprecated in drupal:8.7.0 and will be removed before drupal:9.0.0. A custom constructor must be implemented instead. See https://www.drupal.org/node/3030634', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Provides common methods and injects services for core selection handlers.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Drupal\Core\Entity;
|
|||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Field\FieldItemInterface;
|
||||
|
|
@ -20,6 +21,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* @ingroup entity_api
|
||||
*/
|
||||
class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterface, EntityViewBuilderInterface {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The type of entities for which this view builder is instantiated.
|
||||
|
|
@ -36,11 +43,18 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
|
|||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The entity manager service.
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* The cache bin used to store the render cache.
|
||||
|
|
@ -77,19 +91,26 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository service.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Theme\Registry $theme_registry
|
||||
* The theme registry.
|
||||
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
|
||||
* The entity display repository.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, Registry $theme_registry = NULL) {
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, Registry $theme_registry = NULL, EntityDisplayRepositoryInterface $entity_display_repository = NULL) {
|
||||
$this->entityTypeId = $entity_type->id();
|
||||
$this->entityType = $entity_type;
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityRepository = $entity_repository;
|
||||
$this->languageManager = $language_manager;
|
||||
$this->themeRegistry = $theme_registry ?: \Drupal::service('theme.registry');
|
||||
if (!$entity_display_repository) {
|
||||
@trigger_error('Calling EntityViewBuilder::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_display_repository = \Drupal::service('entity_display.repository');
|
||||
}
|
||||
$this->entityDisplayRepository = $entity_display_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,9 +119,10 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
|
|||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('theme.registry')
|
||||
$container->get('theme.registry'),
|
||||
$container->get('entity_display.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +154,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
|
|||
foreach ($entities as $key => $entity) {
|
||||
// Ensure that from now on we are dealing with the proper translation
|
||||
// object.
|
||||
$entity = $this->entityManager->getTranslationFromContext($entity, $langcode);
|
||||
$entity = $this->entityRepository->getTranslationFromContext($entity, $langcode);
|
||||
|
||||
// Set build defaults.
|
||||
$build_list[$key] = $this->getBuildDefaults($entity, $view_mode);
|
||||
|
|
@ -418,7 +440,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
|
|||
// The 'default' is not an actual view mode.
|
||||
return TRUE;
|
||||
}
|
||||
$view_modes_info = $this->entityManager->getViewModes($this->entityTypeId);
|
||||
$view_modes_info = $this->entityDisplayRepository->getViewModes($this->entityTypeId);
|
||||
return !empty($view_modes_info[$view_mode]['cache']);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@ namespace Drupal\Core\Entity\Plugin\EntityReferenceSelection;
|
|||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Database\Query\AlterableInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||
use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase;
|
||||
use Drupal\Core\Entity\EntityReferenceSelection\SelectionTrait;
|
||||
use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
|
||||
|
|
@ -15,6 +18,7 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\user\EntityOwnerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Default plugin implementation of the Entity Reference Selection plugin.
|
||||
|
|
@ -37,20 +41,118 @@ use Drupal\user\EntityOwnerInterface;
|
|||
* )
|
||||
*/
|
||||
class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPluginInterface, SelectionWithAutocreateInterface {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
use SelectionTrait {
|
||||
// PHP 5.5.9 gets confused between SelectionPluginBase::__construct() and
|
||||
// SelectionTrait::__construct() that's why we are renaming the
|
||||
// SelectionTrait::__construct() to avoid the confusion.
|
||||
// @todo Remove this in https://www.drupal.org/node/2670966.
|
||||
SelectionTrait::__construct as private initialize;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The entity type manager service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity field manager service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
|
||||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* Entity type bundle info service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
|
||||
*/
|
||||
public $entityTypeBundleInfo;
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The module handler service.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* The current user.
|
||||
*
|
||||
* @var \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* Constructs a new DefaultSelection object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler service.
|
||||
* @param \Drupal\Core\Session\AccountInterface $current_user
|
||||
* The current user.
|
||||
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
|
||||
* The entity field manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
|
||||
* The entity type bundle info service.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, EntityFieldManagerInterface $entity_field_manager = NULL, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->currentUser = $current_user;
|
||||
|
||||
if (!$entity_field_manager) {
|
||||
@trigger_error('Calling DefaultSelection::__construct() with the $entity_field_manager argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_field_manager = \Drupal::service('entity_field.manager');
|
||||
}
|
||||
$this->entityFieldManager = $entity_field_manager;
|
||||
|
||||
if (!$entity_type_bundle_info) {
|
||||
@trigger_error('Calling DefaultSelection::__construct() with the $entity_type_bundle_info argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_type_bundle_info = \Drupal::service('entity_type.bundle.info');
|
||||
}
|
||||
$this->entityTypeBundleInfo = $entity_type_bundle_info;
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling DefaultSelection::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user) {
|
||||
$this->initialize($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user);
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('current_user'),
|
||||
$container->get('entity_field.manager'),
|
||||
$container->get('entity_type.bundle.info'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -79,8 +181,8 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
|
|||
|
||||
$configuration = $this->getConfiguration();
|
||||
$entity_type_id = $configuration['target_type'];
|
||||
$entity_type = $this->entityManager->getDefinition($entity_type_id);
|
||||
$bundles = $this->entityManager->getBundleInfo($entity_type_id);
|
||||
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
|
||||
$bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
|
||||
|
||||
if ($entity_type->hasKey('bundle')) {
|
||||
$bundle_options = [];
|
||||
|
|
@ -122,7 +224,7 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
|
|||
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
|
||||
$fields = [];
|
||||
foreach (array_keys($bundles) as $bundle) {
|
||||
$bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
|
||||
$bundle_fields = array_filter($this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
|
||||
return !$field_definition->isComputed();
|
||||
});
|
||||
foreach ($bundle_fields as $field_name => $field_definition) {
|
||||
|
|
@ -245,10 +347,10 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
|
|||
}
|
||||
|
||||
$options = [];
|
||||
$entities = $this->entityManager->getStorage($target_type)->loadMultiple($result);
|
||||
$entities = $this->entityTypeManager->getStorage($target_type)->loadMultiple($result);
|
||||
foreach ($entities as $entity_id => $entity) {
|
||||
$bundle = $entity->bundle();
|
||||
$options[$bundle][$entity_id] = Html::escape($this->entityManager->getTranslationFromContext($entity)->label());
|
||||
$options[$bundle][$entity_id] = Html::escape($this->entityRepository->getTranslationFromContext($entity)->label());
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
|
@ -271,7 +373,7 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
|
|||
$result = [];
|
||||
if ($ids) {
|
||||
$target_type = $this->configuration['target_type'];
|
||||
$entity_type = $this->entityManager->getDefinition($target_type);
|
||||
$entity_type = $this->entityTypeManager->getDefinition($target_type);
|
||||
$query = $this->buildEntityQuery();
|
||||
$result = $query
|
||||
->condition($entity_type->getKey('id'), $ids, 'IN')
|
||||
|
|
@ -285,11 +387,11 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
|
||||
$entity_type = $this->entityManager->getDefinition($entity_type_id);
|
||||
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
|
||||
$bundle_key = $entity_type->getKey('bundle');
|
||||
$label_key = $entity_type->getKey('label');
|
||||
|
||||
$entity = $this->entityManager->getStorage($entity_type_id)->create([
|
||||
$entity = $this->entityTypeManager->getStorage($entity_type_id)->create([
|
||||
$bundle_key => $bundle,
|
||||
$label_key => $label,
|
||||
]);
|
||||
|
|
@ -330,9 +432,9 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
|
|||
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
|
||||
$configuration = $this->getConfiguration();
|
||||
$target_type = $configuration['target_type'];
|
||||
$entity_type = $this->entityManager->getDefinition($target_type);
|
||||
$entity_type = $this->entityTypeManager->getDefinition($target_type);
|
||||
|
||||
$query = $this->entityManager->getStorage($target_type)->getQuery();
|
||||
$query = $this->entityTypeManager->getStorage($target_type)->getQuery();
|
||||
|
||||
// If 'target_bundles' is NULL, all bundles are referenceable, no further
|
||||
// conditions are needed.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ abstract class EntityReferenceFormatterBase extends FormatterBase {
|
|||
|
||||
// Set the entity in the correct language for display.
|
||||
if ($entity instanceof TranslatableInterface) {
|
||||
$entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
|
||||
$entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode);
|
||||
}
|
||||
|
||||
$access = $this->checkAccess($entity);
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
if ($default_value = $field_definition->getDefaultValueLiteral()) {
|
||||
foreach ($default_value as $value) {
|
||||
if (is_array($value) && isset($value['target_uuid'])) {
|
||||
$entity = \Drupal::entityManager()->loadEntityByUuid($target_entity_type->id(), $value['target_uuid']);
|
||||
$entity = \Drupal::service('entity.repository')->loadEntityByUuid($target_entity_type->id(), $value['target_uuid']);
|
||||
// If the entity does not exist do not create the dependency.
|
||||
// @see \Drupal\Core\Field\EntityReferenceFieldItemList::processDefaultValue()
|
||||
if ($entity) {
|
||||
|
|
@ -522,7 +522,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
if ($default_value = $field_definition->getDefaultValueLiteral()) {
|
||||
foreach ($default_value as $key => $value) {
|
||||
if (is_array($value) && isset($value['target_uuid'])) {
|
||||
$entity = $entity_manager->loadEntityByUuid($target_entity_type->id(), $value['target_uuid']);
|
||||
$entity = \Drupal::service('entity.repository')->loadEntityByUuid($target_entity_type->id(), $value['target_uuid']);
|
||||
// @see \Drupal\Core\Field\EntityReferenceFieldItemList::processDefaultValue()
|
||||
if ($entity && isset($dependencies[$entity->getConfigDependencyKey()][$entity->getConfigDependencyName()])) {
|
||||
unset($default_value[$key]);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
namespace Drupal\aggregator;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Entity\EntityViewBuilder;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Theme\Registry;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
|
|
@ -15,21 +18,42 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class FeedViewBuilder extends EntityViewBuilder {
|
||||
|
||||
/**
|
||||
* The 'aggregator.settings' config.
|
||||
*
|
||||
* @var \Drupal\Core\Config\Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* Constructs a new FeedViewBuilder.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository service.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Config\Config $config
|
||||
* The 'aggregator.settings' config.
|
||||
* @param \Drupal\Core\Theme\Registry $theme_registry
|
||||
* The theme registry.
|
||||
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
|
||||
* The entity display repository.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, Config $config) {
|
||||
parent::__construct($entity_type, $entity_manager, $language_manager);
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, Config $config, Registry $theme_registry, EntityDisplayRepositoryInterface $entity_display_repository, EntityTypeManagerInterface $entity_type_manager) {
|
||||
parent::__construct($entity_type, $entity_repository, $language_manager, $theme_registry, $entity_display_repository);
|
||||
$this->config = $config;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,9 +62,12 @@ class FeedViewBuilder extends EntityViewBuilder {
|
|||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('config.factory')->get('aggregator.settings')
|
||||
$container->get('config.factory')->get('aggregator.settings'),
|
||||
$container->get('theme.registry'),
|
||||
$container->get('entity_display.repository'),
|
||||
$container->get('entity_type.manager')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -58,11 +85,11 @@ class FeedViewBuilder extends EntityViewBuilder {
|
|||
// When in summary view mode, respect the list_max setting.
|
||||
$limit = $view_mode == 'summary' ? $this->config->get('source.list_max') : 20;
|
||||
// Retrieve the items attached to this feed.
|
||||
$items = $this->entityManager
|
||||
$items = $this->entityTypeManager
|
||||
->getStorage('aggregator_item')
|
||||
->loadByFeed($entity->id(), $limit);
|
||||
|
||||
$build[$id]['items'] = $this->entityManager
|
||||
$build[$id]['items'] = $this->entityTypeManager
|
||||
->getViewBuilder('aggregator_item')
|
||||
->viewMultiple($items, $view_mode, $entity->language()->getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -6,58 +6,18 @@ use Drupal\Core\Block\MainContentBlockPluginInterface;
|
|||
use Drupal\Core\Block\TitleBlockPluginInterface;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityViewBuilder;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\ContextAwarePluginInterface;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\block\Entity\Block;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides a Block view builder.
|
||||
*/
|
||||
class BlockViewBuilder extends EntityViewBuilder {
|
||||
|
||||
/**
|
||||
* The module handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new BlockViewBuilder.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
|
||||
parent::__construct($entity_type, $entity_manager, $language_manager);
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('module_handler')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class BlockContentEntityReferenceSelectionTest extends KernelTestBase {
|
|||
'target_bundles' => ['spiffy' => 'spiffy'],
|
||||
'sort' => ['field' => '_none'],
|
||||
];
|
||||
$this->selectionHandler = new TestSelection($configuration, '', '', $this->container->get('entity.manager'), $this->container->get('module_handler'), \Drupal::currentUser());
|
||||
$this->selectionHandler = new TestSelection($configuration, '', '', $this->container->get('entity_type.manager'), $this->container->get('module_handler'), \Drupal::currentUser(), \Drupal::service('entity_field.manager'), \Drupal::service('entity_type.bundle.info'), \Drupal::service('entity.repository'));
|
||||
|
||||
// Setup the 3 expectation cases.
|
||||
$this->expectations = [
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
namespace Drupal\comment;
|
||||
|
||||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Entity\EntityViewBuilder;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Theme\Registry;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -23,21 +26,35 @@ class CommentViewBuilder extends EntityViewBuilder {
|
|||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* Constructs a new CommentViewBuilder.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository service.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Session\AccountInterface $current_user
|
||||
* The current user.
|
||||
* @param \Drupal\Core\Theme\Registry $theme_registry
|
||||
* The theme registry.
|
||||
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
|
||||
* The entity display repository.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, AccountInterface $current_user) {
|
||||
parent::__construct($entity_type, $entity_manager, $language_manager);
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, AccountInterface $current_user, Registry $theme_registry, EntityDisplayRepositoryInterface $entity_display_repository, EntityTypeManagerInterface $entity_type_manager) {
|
||||
parent::__construct($entity_type, $entity_repository, $language_manager, $theme_registry, $entity_display_repository);
|
||||
$this->currentUser = $current_user;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,9 +63,12 @@ class CommentViewBuilder extends EntityViewBuilder {
|
|||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('current_user')
|
||||
$container->get('current_user'),
|
||||
$container->get('theme.registry'),
|
||||
$container->get('entity_display.repository'),
|
||||
$container->get('entity_type.manager')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +112,7 @@ class CommentViewBuilder extends EntityViewBuilder {
|
|||
foreach ($entities as $entity) {
|
||||
$uids[] = $entity->getOwnerId();
|
||||
}
|
||||
$this->entityManager->getStorage('user')->loadMultiple(array_unique($uids));
|
||||
$this->entityTypeManager->getStorage('user')->loadMultiple(array_unique($uids));
|
||||
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class CommentedEntity extends EntityField {
|
|||
}
|
||||
|
||||
foreach ($entity_ids_per_type as $type => $ids) {
|
||||
$this->loadedCommentedEntities[$type] = $this->entityManager->getStorage($type)->loadMultiple($ids);
|
||||
$this->loadedCommentedEntities[$type] = $this->entityTypeManager->getStorage($type)->loadMultiple($ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ namespace Drupal\Tests\comment\Unit\Plugin\views\field;
|
|||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\comment\Plugin\views\field\CommentBulkForm;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -46,12 +48,14 @@ class CommentBulkFormTest extends UnitTestCase {
|
|||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
|
||||
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$entity_manager->expects($this->once())
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
|
||||
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
|
||||
|
||||
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
|
||||
|
|
@ -86,7 +90,7 @@ class CommentBulkFormTest extends UnitTestCase {
|
|||
$definition['title'] = '';
|
||||
$options = [];
|
||||
|
||||
$comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_manager, $language_manager, $messenger);
|
||||
$comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
|
||||
$comment_bulk_form->init($executable, $display, $options);
|
||||
|
||||
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $comment_bulk_form);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ trait AssertConfigEntityImportTrait {
|
|||
// should recreate everything as necessary.
|
||||
$entity->delete();
|
||||
$this->configImporter()->reset()->import();
|
||||
$imported_entity = \Drupal::entityManager()->loadEntityByUuid($entity_type_id, $entity_uuid);
|
||||
$imported_entity = \Drupal::service('entity.repository')->loadEntityByUuid($entity_type_id, $entity_uuid);
|
||||
$this->assertIdentical($original_data, $imported_entity->toArray());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ function editor_entity_revision_delete(EntityInterface $entity) {
|
|||
*/
|
||||
function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
|
||||
foreach ($uuids as $uuid) {
|
||||
if ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid)) {
|
||||
if ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid)) {
|
||||
if ($file->status !== FILE_STATUS_PERMANENT) {
|
||||
$file->status = FILE_STATUS_PERMANENT;
|
||||
$file->save();
|
||||
|
|
@ -464,7 +464,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
|
|||
*/
|
||||
function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) {
|
||||
foreach ($uuids as $uuid) {
|
||||
if ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid)) {
|
||||
if ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid)) {
|
||||
\Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class EditorImageDialog extends FormBase {
|
|||
}
|
||||
$max_filesize = min(Bytes::toInt($image_upload['max_size']), file_upload_max_size());
|
||||
|
||||
$existing_file = isset($image_element['data-entity-uuid']) ? \Drupal::entityManager()->loadEntityByUuid('file', $image_element['data-entity-uuid']) : NULL;
|
||||
$existing_file = isset($image_element['data-entity-uuid']) ? \Drupal::service('entity.repository')->loadEntityByUuid('file', $image_element['data-entity-uuid']) : NULL;
|
||||
$fid = $existing_file ? $existing_file->id() : NULL;
|
||||
|
||||
$form['fid'] = [
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
namespace Drupal\editor\Plugin\Filter;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\file\FileInterface;
|
||||
use Drupal\filter\FilterProcessResult;
|
||||
|
|
@ -23,13 +24,19 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* )
|
||||
*/
|
||||
class EditorFileReference extends FilterBase implements ContainerFactoryPluginInterface {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* An entity manager object.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* Constructs a \Drupal\editor\Plugin\Filter\EditorFileReference object.
|
||||
|
|
@ -40,11 +47,11 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* An entity manager object.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
|
||||
$this->entityManager = $entity_manager;
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityRepositoryInterface $entity_repository) {
|
||||
$this->entityRepository = $entity_repository;
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +63,7 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager')
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +83,7 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn
|
|||
// If there is a 'src' attribute, set it to the file entity's current
|
||||
// URL. This ensures the URL works even after the file location changes.
|
||||
if ($node->hasAttribute('src')) {
|
||||
$file = $this->entityManager->loadEntityByUuid('file', $uuid);
|
||||
$file = $this->entityRepository->loadEntityByUuid('file', $uuid);
|
||||
if ($file instanceof FileInterface) {
|
||||
$node->setAttribute('src', $file->createFileUrl());
|
||||
}
|
||||
|
|
@ -86,7 +93,7 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn
|
|||
if (!isset($processed_uuids[$uuid])) {
|
||||
$processed_uuids[$uuid] = TRUE;
|
||||
|
||||
$file = $this->entityManager->loadEntityByUuid('file', $uuid);
|
||||
$file = $this->entityRepository->loadEntityByUuid('file', $uuid);
|
||||
if ($file instanceof FileInterface) {
|
||||
$result->addCacheTags($file->getCacheTags());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
|
|||
$this->assertNoText('Field data will be deleted by this synchronization.');
|
||||
$this->rebuildContainer();
|
||||
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
|
||||
$this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization');
|
||||
$this->assertFalse(\Drupal::service('entity.repository')->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization');
|
||||
$deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
|
||||
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.');
|
||||
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Text field has been completed removed from the system.');
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
|
|||
$entity = unserialize($entity);
|
||||
// And then the entity.
|
||||
$entity->save();
|
||||
$term = \Drupal::entityManager()->loadEntityByUuid($term->getEntityTypeId(), $term->uuid());
|
||||
$term = \Drupal::service('entity.repository')->loadEntityByUuid($term->getEntityTypeId(), $term->uuid());
|
||||
$this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $term->id());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
|
|||
$this->configImporter()->import();
|
||||
|
||||
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
|
||||
$this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization');
|
||||
$this->assertFalse(\Drupal::service('entity.repository')->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization');
|
||||
$deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
|
||||
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.');
|
||||
$this->assertTrue(isset($deleted_storages[$unrelated_field_storage->uuid()]), 'Unrelated field not purged by configuration synchronization.');
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\file\FileInterface;
|
||||
|
||||
/**
|
||||
* Tests \Drupal\file\Entity\File::load().
|
||||
|
|
@ -89,13 +90,11 @@ class LoadTest extends FileManagedUnitTestBase {
|
|||
$file->save();
|
||||
file_test_reset();
|
||||
|
||||
$by_uuid_file = \Drupal::entityManager()->loadEntityByUuid('file', $file->uuid());
|
||||
$by_uuid_file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $file->uuid());
|
||||
$this->assertFileHookCalled('load');
|
||||
$this->assertTrue(is_object($by_uuid_file), '\Drupal::entityManager()->loadEntityByUuid() returned a file object.');
|
||||
if (is_object($by_uuid_file)) {
|
||||
$this->assertInstanceOf(FileInterface::class, $by_uuid_file);
|
||||
$this->assertEqual($by_uuid_file->id(), $file->id(), 'Loading by UUID got the same fid.', 'File');
|
||||
$this->assertTrue($by_uuid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
namespace Drupal\forum\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\taxonomy\Form\OverviewTerms;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
|
@ -18,26 +16,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||
*/
|
||||
class Overview extends OverviewTerms {
|
||||
|
||||
/**
|
||||
* Entity manager Service Object.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* Constructs a \Drupal\forum\Form\OverviewForm object.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler service.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
*/
|
||||
public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($module_handler, $entity_manager);
|
||||
$this->entityManager = $entity_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -51,7 +29,7 @@ class Overview extends OverviewTerms {
|
|||
public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
|
||||
$forum_config = $this->config('forum.settings');
|
||||
$vid = $forum_config->get('vocabulary');
|
||||
$vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
|
||||
$vocabulary = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->load($vid);
|
||||
if (!$vocabulary) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ function image_entity_presave(EntityInterface $entity) {
|
|||
if ($uuid) {
|
||||
$original_uuid = isset($entity->original) ? $entity->original->getSetting('default_image')['uuid'] : NULL;
|
||||
if ($uuid != $original_uuid) {
|
||||
$file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid);
|
||||
$file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid);
|
||||
if ($file) {
|
||||
$image = \Drupal::service('image.factory')->get($file->getFileUri());
|
||||
$default_image['width'] = $image->getWidth();
|
||||
|
|
@ -414,7 +414,7 @@ function image_field_storage_config_update(FieldStorageConfigInterface $field_st
|
|||
$uuid_new = $field_storage->getSetting('default_image')['uuid'];
|
||||
$uuid_old = $prior_field_storage->getSetting('default_image')['uuid'];
|
||||
|
||||
$file_new = $uuid_new ? \Drupal::entityManager()->loadEntityByUuid('file', $uuid_new) : FALSE;
|
||||
$file_new = $uuid_new ? \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid_new) : FALSE;
|
||||
|
||||
if ($uuid_new != $uuid_old) {
|
||||
|
||||
|
|
@ -426,7 +426,7 @@ function image_field_storage_config_update(FieldStorageConfigInterface $field_st
|
|||
}
|
||||
|
||||
// Is there an old file?
|
||||
if ($uuid_old && ($file_old = \Drupal::entityManager()->loadEntityByUuid('file', $uuid_old))) {
|
||||
if ($uuid_old && ($file_old = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid_old))) {
|
||||
\Drupal::service('file.usage')->delete($file_old, 'image', 'default_image', $field_storage->uuid());
|
||||
}
|
||||
}
|
||||
|
|
@ -455,7 +455,7 @@ function image_field_config_update(FieldConfigInterface $field) {
|
|||
$uuid_old = $prior_instance->getSetting('default_image')['uuid'];
|
||||
|
||||
// If the old and new files do not match, update the default accordingly.
|
||||
$file_new = $uuid_new ? \Drupal::entityManager()->loadEntityByUuid('file', $uuid_new) : FALSE;
|
||||
$file_new = $uuid_new ? \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid_new) : FALSE;
|
||||
if ($uuid_new != $uuid_old) {
|
||||
// Save the new file, if present.
|
||||
if ($file_new) {
|
||||
|
|
@ -464,7 +464,7 @@ function image_field_config_update(FieldConfigInterface $field) {
|
|||
\Drupal::service('file.usage')->add($file_new, 'image', 'default_image', $field->uuid());
|
||||
}
|
||||
// Delete the old file, if present.
|
||||
if ($uuid_old && ($file_old = \Drupal::entityManager()->loadEntityByUuid('file', $uuid_old))) {
|
||||
if ($uuid_old && ($file_old = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid_old))) {
|
||||
\Drupal::service('file.usage')->delete($file_old, 'image', 'default_image', $field->uuid());
|
||||
}
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ function image_field_storage_config_delete(FieldStorageConfigInterface $field) {
|
|||
|
||||
// The value of a managed_file element can be an array if #extended == TRUE.
|
||||
$uuid = $field->getSetting('default_image')['uuid'];
|
||||
if ($uuid && ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid))) {
|
||||
if ($uuid && ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid))) {
|
||||
\Drupal::service('file.usage')->delete($file, 'image', 'default_image', $field->uuid());
|
||||
}
|
||||
}
|
||||
|
|
@ -507,7 +507,7 @@ function image_field_config_delete(FieldConfigInterface $field) {
|
|||
$uuid = $field->getSetting('default_image')['uuid'];
|
||||
|
||||
// Remove the default image when the instance is deleted.
|
||||
if ($uuid && ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid))) {
|
||||
if ($uuid && ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid))) {
|
||||
\Drupal::service('file.usage')->delete($file, 'image', 'default_image', $field->uuid());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ abstract class ImageFormatterBase extends FileFormatterBase {
|
|||
if (empty($default_image['uuid']) && $this->fieldDefinition instanceof FieldConfigInterface) {
|
||||
$default_image = $this->fieldDefinition->getFieldStorageDefinition()->getSetting('default_image');
|
||||
}
|
||||
if (!empty($default_image['uuid']) && $file = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid'])) {
|
||||
if (!empty($default_image['uuid']) && $file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid'])) {
|
||||
// Clone the FieldItemList into a runtime-only object for the formatter,
|
||||
// so that the fallback image can be rendered without affecting the
|
||||
// field values in the entity being rendered.
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ class ImageItem extends FileItem {
|
|||
// Convert the stored UUID to a FID.
|
||||
$fids = [];
|
||||
$uuid = $settings['default_image']['uuid'];
|
||||
if ($uuid && ($file = $this->getEntityManager()->loadEntityByUuid('file', $uuid))) {
|
||||
if ($uuid && ($file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $uuid))) {
|
||||
$fids[0] = $file->id();
|
||||
}
|
||||
$element['default_image']['uuid'] = [
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ class ImageWidget extends FileWidget {
|
|||
$default_image = $this->fieldDefinition->getFieldStorageDefinition()->getSetting('default_image');
|
||||
}
|
||||
// Convert the stored UUID into a file ID.
|
||||
if (!empty($default_image['uuid']) && $entity = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid'])) {
|
||||
if (!empty($default_image['uuid']) && $entity = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid'])) {
|
||||
$default_image['fid'] = $entity->id();
|
||||
}
|
||||
$element['#default_image'] = !empty($default_image['fid']) ? $default_image : [];
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
|
|||
\Drupal::entityManager()->clearCachedFieldDefinitions();
|
||||
$field_storage = FieldStorageConfig::loadByName('node', $field_name);
|
||||
$default_image = $field_storage->getSetting('default_image');
|
||||
$file = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid']);
|
||||
$file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid']);
|
||||
$this->assertTrue($file->isPermanent(), 'The default image status is permanent.');
|
||||
$image = [
|
||||
'#theme' => 'image',
|
||||
|
|
@ -448,7 +448,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
|
|||
|
||||
$private_field_storage = FieldStorageConfig::loadByName('node', $private_field_name);
|
||||
$default_image = $private_field_storage->getSetting('default_image');
|
||||
$file = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid']);
|
||||
$file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid']);
|
||||
$this->assertEqual('private', file_uri_scheme($file->getFileUri()), 'Default image uses private:// scheme.');
|
||||
$this->assertTrue($file->isPermanent(), 'The default image status is permanent.');
|
||||
// Create a new node with no image attached and ensure that default private
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
namespace Drupal\menu_link_content\Plugin\Menu;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginException;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Menu\MenuLinkBase;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
@ -13,6 +15,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* Provides the menu link plugin for content menu links.
|
||||
*/
|
||||
class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInterface {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* Entities IDs to load.
|
||||
|
|
@ -48,11 +56,18 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
protected $entity;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
|
|
@ -70,12 +85,14 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
if (!empty($this->pluginDefinition['metadata']['entity_id'])) {
|
||||
|
|
@ -85,8 +102,13 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
static::$entityIdsToLoad[$entity_id] = $entity_id;
|
||||
}
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling MenuLinkContent::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,8 +119,9 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager')
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +137,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
protected function getEntity() {
|
||||
if (empty($this->entity)) {
|
||||
$entity = NULL;
|
||||
$storage = $this->entityManager->getStorage('menu_link_content');
|
||||
$storage = $this->entityTypeManager->getStorage('menu_link_content');
|
||||
if (!empty($this->pluginDefinition['metadata']['entity_id'])) {
|
||||
$entity_id = $this->pluginDefinition['metadata']['entity_id'];
|
||||
// Make sure the current ID is in the list, since each plugin empties
|
||||
|
|
@ -128,15 +151,14 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
if (!$entity) {
|
||||
// Fallback to the loading by the UUID.
|
||||
$uuid = $this->getUuid();
|
||||
$loaded_entities = $storage->loadByProperties(['uuid' => $uuid]);
|
||||
$entity = reset($loaded_entities);
|
||||
$entity = $this->entityRepository->loadEntityByUuid('menu_link_content', $uuid);
|
||||
}
|
||||
if (!$entity) {
|
||||
throw new PluginException("Entity not found through the menu link plugin definition and could not fallback on UUID '$uuid'");
|
||||
}
|
||||
// Clone the entity object to avoid tampering with the static cache.
|
||||
$this->entity = clone $entity;
|
||||
$the_entity = $this->entityManager->getTranslationFromContext($this->entity);
|
||||
$the_entity = $this->entityRepository->getTranslationFromContext($this->entity);
|
||||
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $the_entity */
|
||||
$this->entity = $the_entity;
|
||||
$this->entity->setInsidePlugin();
|
||||
|
|
@ -214,7 +236,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
foreach ($overrides as $key => $value) {
|
||||
$entity->{$key}->value = $value;
|
||||
}
|
||||
$this->entityManager->getStorage('menu_link_content')->save($entity);
|
||||
$entity->save();
|
||||
}
|
||||
|
||||
return $this->pluginDefinition;
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class MenuLinksTest extends KernelTestBase {
|
|||
$this->menuLinkManager->updateDefinition($links['child-1'], ['parent' => $links['child-2']]);
|
||||
// Verify that the entity was updated too.
|
||||
$menu_link_plugin = $this->menuLinkManager->createInstance($links['child-1']);
|
||||
$entity = \Drupal::entityManager()->loadEntityByUuid('menu_link_content', $menu_link_plugin->getDerivativeId());
|
||||
$entity = \Drupal::service('entity.repository')->loadEntityByUuid('menu_link_content', $menu_link_plugin->getDerivativeId());
|
||||
$this->assertEqual($entity->getParentId(), $links['child-2']);
|
||||
|
||||
$expected_hierarchy = [
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
|
|||
|
||||
case 'body':
|
||||
case 'summary':
|
||||
$translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode, ['operation' => 'node_tokens']);
|
||||
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($node, $langcode, ['operation' => 'node_tokens']);
|
||||
if ($translation->hasField('body') && ($items = $translation->get('body')) && !$items->isEmpty()) {
|
||||
$item = $items[0];
|
||||
// If the summary was requested and is not empty, use it.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
namespace Drupal\Tests\node\Unit\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\node\Plugin\views\field\NodeBulkForm;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
|
|
@ -46,12 +48,14 @@ class NodeBulkFormTest extends UnitTestCase {
|
|||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
|
||||
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$entity_manager->expects($this->once())
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
|
||||
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
|
||||
|
||||
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
|
||||
|
|
@ -86,7 +90,7 @@ class NodeBulkFormTest extends UnitTestCase {
|
|||
$definition['title'] = '';
|
||||
$options = [];
|
||||
|
||||
$node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_manager, $language_manager, $messenger);
|
||||
$node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
|
||||
$node_bulk_form->init($executable, $display, $options);
|
||||
|
||||
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityInterface;
|
|||
* Implements hook_quickedit_render_field().
|
||||
*/
|
||||
function quickedit_test_quickedit_render_field(EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
|
||||
$entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
|
||||
$entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode);
|
||||
return [
|
||||
'#prefix' => '<div class="quickedit-test-wrapper">',
|
||||
'field' => $entity->get($field_name)->view($view_mode_id),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace Drupal\rest\Plugin\views\row;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
|
||||
use Drupal\views\Plugin\views\row\RowPluginBase;
|
||||
|
|
@ -23,6 +25,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
class DataEntityRow extends RowPluginBase {
|
||||
|
||||
use EntityTranslationRenderTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -37,11 +45,25 @@ class DataEntityRow extends RowPluginBase {
|
|||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
public $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
|
|
@ -51,25 +73,46 @@ class DataEntityRow extends RowPluginBase {
|
|||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Constructs a new DataEntityRow object.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param array $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling DataEntityRow::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('language_manager'));
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,9 +133,25 @@ class DataEntityRow extends RowPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
// This relies on DeprecatedServicePropertyTrait to trigger a deprecation
|
||||
// message in case it is accessed.
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityTypeManager() {
|
||||
return $this->entityTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
return $this->entityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ function shortcut_renderable_links($shortcut_set = NULL) {
|
|||
|
||||
$cache_tags = [];
|
||||
foreach ($shortcut_set->getShortcuts() as $shortcut) {
|
||||
$shortcut = \Drupal::entityManager()->getTranslationFromContext($shortcut);
|
||||
$shortcut = \Drupal::service('entity.repository')->getTranslationFromContext($shortcut);
|
||||
$url = $shortcut->getUrl();
|
||||
if ($url->access()) {
|
||||
$links[$shortcut->id()] = [
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
namespace Drupal\taxonomy\Form;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
@ -18,6 +20,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* @internal
|
||||
*/
|
||||
class OverviewTerms extends FormBase {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The module handler service.
|
||||
|
|
@ -31,7 +39,7 @@ class OverviewTerms extends FormBase {
|
|||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The term storage handler.
|
||||
|
|
@ -54,22 +62,36 @@ class OverviewTerms extends FormBase {
|
|||
*/
|
||||
protected $renderer;
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* Constructs an OverviewTerms object.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler service.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager service.
|
||||
* @param \Drupal\Core\Render\RendererInterface $renderer
|
||||
* The renderer service.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager, RendererInterface $renderer = NULL) {
|
||||
public function __construct(ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer = NULL, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->storageController = $entity_manager->getStorage('taxonomy_term');
|
||||
$this->termListBuilder = $entity_manager->getListBuilder('taxonomy_term');
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->storageController = $entity_type_manager->getStorage('taxonomy_term');
|
||||
$this->termListBuilder = $entity_type_manager->getListBuilder('taxonomy_term');
|
||||
$this->renderer = $renderer ?: \Drupal::service('renderer');
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling OverviewTerms::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,8 +100,9 @@ class OverviewTerms extends FormBase {
|
|||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('module_handler'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('renderer')
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('renderer'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +254,7 @@ class OverviewTerms extends FormBase {
|
|||
$errors = $form_state->getErrors();
|
||||
$row_position = 0;
|
||||
// Build the actual form.
|
||||
$access_control_handler = $this->entityManager->getAccessControlHandler('taxonomy_term');
|
||||
$access_control_handler = $this->entityTypeManager->getAccessControlHandler('taxonomy_term');
|
||||
$create_access = $access_control_handler->createAccess($taxonomy_vocabulary->id(), NULL, [], TRUE);
|
||||
if ($create_access->isAllowed()) {
|
||||
$empty = $this->t('No terms available. <a href=":link">Add term</a>.', [':link' => Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $taxonomy_vocabulary->id()])->toString()]);
|
||||
|
|
@ -263,7 +286,7 @@ class OverviewTerms extends FormBase {
|
|||
'weight' => [],
|
||||
];
|
||||
/** @var $term \Drupal\Core\Entity\EntityInterface */
|
||||
$term = $this->entityManager->getTranslationFromContext($term);
|
||||
$term = $this->entityRepository->getTranslationFromContext($term);
|
||||
$form['terms'][$key]['#term'] = $term;
|
||||
$indentation = [];
|
||||
if (isset($term->depth) && $term->depth > 0) {
|
||||
|
|
@ -273,7 +296,7 @@ class OverviewTerms extends FormBase {
|
|||
];
|
||||
}
|
||||
$form['terms'][$key]['term'] = [
|
||||
'#prefix' => !empty($indentation) ? \Drupal::service('renderer')->render($indentation) : '',
|
||||
'#prefix' => !empty($indentation) ? $this->renderer->render($indentation) : '',
|
||||
'#type' => 'link',
|
||||
'#title' => $term->getName(),
|
||||
'#url' => $term->toUrl(),
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class TermSelection extends DefaultSelection {
|
|||
|
||||
$options = [];
|
||||
|
||||
$bundles = $this->entityManager->getBundleInfo('taxonomy_term');
|
||||
$bundles = $this->entityTypeBundleInfo->getBundleInfo('taxonomy_term');
|
||||
$bundle_names = $this->getConfiguration()['target_bundles'] ?: array_keys($bundles);
|
||||
|
||||
$has_admin_access = $this->currentUser->hasPermission('administer taxonomy');
|
||||
|
|
@ -64,13 +64,13 @@ class TermSelection extends DefaultSelection {
|
|||
foreach ($bundle_names as $bundle) {
|
||||
if ($vocabulary = Vocabulary::load($bundle)) {
|
||||
/** @var \Drupal\taxonomy\TermInterface[] $terms */
|
||||
if ($terms = $this->entityManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) {
|
||||
if ($terms = $this->entityTypeManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) {
|
||||
foreach ($terms as $term) {
|
||||
if (!$has_admin_access && (!$term->isPublished() || in_array($term->parent->target_id, $unpublished_terms))) {
|
||||
$unpublished_terms[] = $term->id();
|
||||
continue;
|
||||
}
|
||||
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityManager->getTranslationFromContext($term)->label());
|
||||
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityRepository->getTranslationFromContext($term)->label());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class IndexTid extends ManyToOne {
|
|||
$titles = [];
|
||||
$terms = Term::loadMultiple($this->value);
|
||||
foreach ($terms as $term) {
|
||||
$titles[] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
|
||||
$titles[] = \Drupal::service('entity.repository')->getTranslationFromContext($term)->label();
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class TaxonomyIndexTid extends PrerenderList {
|
|||
|
||||
foreach ($result as $node_nid => $data) {
|
||||
foreach ($data as $tid => $term) {
|
||||
$this->items[$node_nid][$tid]['name'] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
|
||||
$this->items[$node_nid][$tid]['name'] = \Drupal::service('entity.repository')->getTranslationFromContext($term)->label();
|
||||
$this->items[$node_nid][$tid]['tid'] = $tid;
|
||||
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->bundle();
|
||||
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->bundle()]->label();
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class TaxonomyIndexTid extends ManyToOne {
|
|||
if ($tree) {
|
||||
foreach ($tree as $term) {
|
||||
$choice = new \stdClass();
|
||||
$choice->option = [$term->id() => str_repeat('-', $term->depth) . \Drupal::entityManager()->getTranslationFromContext($term)->label()];
|
||||
$choice->option = [$term->id() => str_repeat('-', $term->depth) . \Drupal::service('entity.repository')->getTranslationFromContext($term)->label()];
|
||||
$options[] = $choice;
|
||||
}
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ class TaxonomyIndexTid extends ManyToOne {
|
|||
}
|
||||
$terms = Term::loadMultiple($query->execute());
|
||||
foreach ($terms as $term) {
|
||||
$options[$term->id()] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
|
||||
$options[$term->id()] = \Drupal::service('entity.repository')->getTranslationFromContext($term)->label();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ class TaxonomyIndexTid extends ManyToOne {
|
|||
$this->value = array_filter($this->value);
|
||||
$terms = Term::loadMultiple($this->value);
|
||||
foreach ($terms as $term) {
|
||||
$this->valueOptions[$term->id()] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
|
||||
$this->valueOptions[$term->id()] = \Drupal::service('entity.repository')->getTranslationFromContext($term)->label();
|
||||
}
|
||||
}
|
||||
return parent::adminSummary();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ namespace Drupal\user\Plugin\EntityReferenceSelection;
|
|||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
use Drupal\Core\Database\Query\SelectInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
@ -33,13 +36,6 @@ class UserSelection extends DefaultSelection {
|
|||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The user storage.
|
||||
*
|
||||
* @var \Drupal\user\UserStorageInterface
|
||||
*/
|
||||
protected $userStorage;
|
||||
|
||||
/**
|
||||
* Constructs a new UserSelection object.
|
||||
*
|
||||
|
|
@ -49,20 +45,25 @@ class UserSelection extends DefaultSelection {
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager service.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler service.
|
||||
* @param \Drupal\Core\Session\AccountInterface $current_user
|
||||
* The current user.
|
||||
* @param \Drupal\Core\Database\Connection $connection
|
||||
* The database connection.
|
||||
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
|
||||
* The entity field manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
|
||||
* The entity type bundle info service.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, Connection $connection) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user);
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, Connection $connection, EntityFieldManagerInterface $entity_field_manager = NULL, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $module_handler, $current_user, $entity_field_manager, $entity_type_bundle_info, $entity_repository);
|
||||
|
||||
$this->connection = $connection;
|
||||
$this->userStorage = $entity_manager->getStorage('user');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +77,10 @@ class UserSelection extends DefaultSelection {
|
|||
$container->get('entity.manager'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('current_user'),
|
||||
$container->get('database')
|
||||
$container->get('database'),
|
||||
$container->get('entity_field.manager'),
|
||||
$container->get('entity_type.bundle.info'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
namespace Drupal\Tests\user\Unit\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\user\Plugin\views\field\UserBulkForm;
|
||||
|
||||
|
|
@ -46,12 +48,14 @@ class UserBulkFormTest extends UnitTestCase {
|
|||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
|
||||
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$entity_manager->expects($this->once())
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
|
||||
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
|
||||
|
||||
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
|
||||
|
|
@ -86,7 +90,7 @@ class UserBulkFormTest extends UnitTestCase {
|
|||
$definition['title'] = '';
|
||||
$options = [];
|
||||
|
||||
$user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_manager, $language_manager, $messenger);
|
||||
$user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
|
||||
$user_bulk_form->init($executable, $display, $options);
|
||||
|
||||
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
namespace Drupal\views\Entity\Render;
|
||||
|
||||
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\views\Plugin\views\field\EntityField;
|
||||
use Drupal\views\Plugin\views\query\QueryPluginBase;
|
||||
|
|
@ -22,6 +24,12 @@ use Drupal\views\ViewExecutable;
|
|||
class EntityFieldRenderer extends RendererBase {
|
||||
use EntityTranslationRenderTrait;
|
||||
use DependencySerializationTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The relationship being handled.
|
||||
|
|
@ -31,11 +39,18 @@ class EntityFieldRenderer extends RendererBase {
|
|||
protected $relationship;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* A list of indexes of rows whose fields have already been rendered.
|
||||
|
|
@ -55,13 +70,20 @@ class EntityFieldRenderer extends RendererBase {
|
|||
* The language manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(ViewExecutable $view, $relationship, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager) {
|
||||
public function __construct(ViewExecutable $view, $relationship, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type, EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($view, $language_manager, $entity_type);
|
||||
$this->relationship = $relationship;
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling EntityFieldRenderer::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,9 +104,25 @@ class EntityFieldRenderer extends RendererBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
// This relies on DeprecatedServicePropertyTrait to trigger a deprecation
|
||||
// message in case it is accessed.
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityTypeManager() {
|
||||
return $this->entityTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
return $this->entityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ trait EntityTranslationRenderTrait {
|
|||
$renderer = 'ConfigurableLanguageRenderer';
|
||||
}
|
||||
$class = '\Drupal\views\Entity\Render\\' . $renderer;
|
||||
$entity_type = $this->getEntityManager()->getDefinition($this->getEntityTypeId());
|
||||
$entity_type = $this->getEntityTypeManager()->getDefinition($this->getEntityTypeId());
|
||||
$this->entityTranslationRenderer = new $class($view, $this->getLanguageManager(), $entity_type, $langcode);
|
||||
}
|
||||
return $this->entityTranslationRenderer;
|
||||
|
|
@ -74,7 +74,7 @@ trait EntityTranslationRenderTrait {
|
|||
$translation = $entity;
|
||||
if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) {
|
||||
$langcode = $this->getEntityTranslationRenderer()->getLangcode($row);
|
||||
$translation = $this->getEntityManager()->getTranslationFromContext($entity, $langcode);
|
||||
$translation = $this->getEntityRepository()->getTranslationFromContext($entity, $langcode);
|
||||
}
|
||||
return $translation;
|
||||
}
|
||||
|
|
@ -88,12 +88,26 @@ trait EntityTranslationRenderTrait {
|
|||
abstract public function getEntityTypeId();
|
||||
|
||||
/**
|
||||
* Returns the entity manager.
|
||||
* Returns the entity type manager.
|
||||
*
|
||||
* @return \Drupal\Core\Entity\EntityManagerInterface
|
||||
* The entity manager.
|
||||
* @return \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
* The entity type manager.
|
||||
*/
|
||||
abstract protected function getEntityManager();
|
||||
protected function getEntityTypeManager() {
|
||||
@trigger_error('Classes that use EntityTranslationRenderTrait must provide a getEntityTypeManager() method since drupal:8.7.0. This implementation will become abstract before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
return \Drupal::entityTypeManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entity repository.
|
||||
*
|
||||
* @return \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
* The entity repository.
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
@trigger_error('Classes that use EntityTranslationRenderTrait must provide a getEntityRepository() method since drupal:8.7.0. This implementation will become abstract before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
return \Drupal::service('entity.repository');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language manager.
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ abstract class EntityTranslationRendererBase extends RendererBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function preRender(array $result) {
|
||||
$view_builder = $this->view->rowPlugin->entityManager->getViewBuilder($this->entityType->id());
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->entityType->id());
|
||||
|
||||
/** @var \Drupal\views\ResultRow $row */
|
||||
foreach ($result as $row) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class TranslationLanguageRenderer extends EntityTranslationRendererBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function preRender(array $result) {
|
||||
$view_builder = $this->view->rowPlugin->entityManager->getViewBuilder($this->entityType->id());
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->entityType->id());
|
||||
|
||||
/** @var \Drupal\views\ResultRow $row */
|
||||
foreach ($result as $row) {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,16 @@
|
|||
|
||||
namespace Drupal\views\Plugin\EntityReferenceSelection;
|
||||
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase;
|
||||
use Drupal\Core\Entity\EntityReferenceSelection\SelectionTrait;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\views\Views;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Plugin implementation of the 'selection' entity_reference.
|
||||
|
|
@ -20,8 +24,12 @@ use Drupal\views\Views;
|
|||
* )
|
||||
*/
|
||||
class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPluginInterface {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
use SelectionTrait;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The loaded View object.
|
||||
|
|
@ -30,6 +38,65 @@ class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPlug
|
|||
*/
|
||||
protected $view;
|
||||
|
||||
/**
|
||||
* The entity type manager service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The module handler service.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* The current user.
|
||||
*
|
||||
* @var \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* Constructs a new ViewsSelection object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager service.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler service.
|
||||
* @param \Drupal\Core\Session\AccountInterface $current_user
|
||||
* The current user.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->currentUser = $current_user;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('current_user')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -53,8 +120,8 @@ class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPlug
|
|||
$displays = Views::getApplicableViews('entity_reference_display');
|
||||
// Filter views that list the entity type we want, and group the separate
|
||||
// displays by view.
|
||||
$entity_type = $this->entityManager->getDefinition($this->configuration['target_type']);
|
||||
$view_storage = $this->entityManager->getStorage('view');
|
||||
$entity_type = $this->entityTypeManager->getDefinition($this->configuration['target_type']);
|
||||
$view_storage = $this->entityTypeManager->getStorage('view');
|
||||
|
||||
$options = [];
|
||||
foreach ($displays as $data) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\area;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
|
@ -16,6 +19,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* @ViewsArea("entity")
|
||||
*/
|
||||
class Entity extends TokenizeAreaPluginBase {
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* Stores the entity type of the result entities.
|
||||
|
|
@ -25,11 +34,25 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* Constructs a new Entity instance.
|
||||
|
|
@ -40,13 +63,29 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
|
||||
* The entity display repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository = NULL, EntityDisplayRepositoryInterface $entity_display_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling EntityRow::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
|
||||
if (!$entity_display_repository) {
|
||||
@trigger_error('Calling EntityRow::__construct() with the $entity_display_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_display_repository = \Drupal::service('entity_display.repository');
|
||||
}
|
||||
$this->entityDisplayRepository = $entity_display_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +96,9 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager')
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('entity_display.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -95,12 +136,12 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
|
||||
$form['view_mode'] = [
|
||||
'#type' => 'select',
|
||||
'#options' => $this->entityManager->getViewModeOptions($this->entityType),
|
||||
'#options' => $this->entityDisplayRepository->getViewModeOptions($this->entityType),
|
||||
'#title' => $this->t('View mode'),
|
||||
'#default_value' => $this->options['view_mode'],
|
||||
];
|
||||
|
||||
$label = $this->entityManager->getDefinition($this->entityType)->getLabel();
|
||||
$label = $this->entityTypeManager->getDefinition($this->entityType)->getLabel();
|
||||
$target = $this->options['target'];
|
||||
|
||||
// If the target does not contain tokens, try to load the entity and
|
||||
|
|
@ -111,7 +152,7 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
// @todo If the entity does not exist, this will will show the config
|
||||
// target identifier. Decide if this is the correct behavior in
|
||||
// https://www.drupal.org/node/2415391.
|
||||
if ($target_entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
|
||||
if ($target_entity = $this->entityRepository->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
|
||||
$target = $target_entity->id();
|
||||
}
|
||||
}
|
||||
|
|
@ -141,7 +182,7 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
// https://www.drupal.org/node/2396607.
|
||||
$options = $form_state->getValue('options');
|
||||
if (strpos($options['target'], '{{') === FALSE) {
|
||||
if ($entity = $this->entityManager->getStorage($this->entityType)->load($options['target'])) {
|
||||
if ($entity = $this->entityTypeManager->getStorage($this->entityType)->load($options['target'])) {
|
||||
$options['target'] = $entity->getConfigTarget();
|
||||
}
|
||||
$form_state->setValue('options', $options);
|
||||
|
|
@ -159,17 +200,17 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
// We cast as we need the integer/string value provided by the
|
||||
// ::tokenizeValue() call.
|
||||
$target_id = (string) $this->tokenizeValue($this->options['target']);
|
||||
if ($entity = $this->entityManager->getStorage($this->entityType)->load($target_id)) {
|
||||
if ($entity = $this->entityTypeManager->getStorage($this->entityType)->load($target_id)) {
|
||||
$target_entity = $entity;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
|
||||
if ($entity = $this->entityRepository->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
|
||||
$target_entity = $entity;
|
||||
}
|
||||
}
|
||||
if (isset($target_entity) && (!empty($this->options['bypass_access']) || $target_entity->access('view'))) {
|
||||
$view_builder = $this->entityManager->getViewBuilder($this->entityType);
|
||||
$view_builder = $this->entityTypeManager->getViewBuilder($this->entityType);
|
||||
return $view_builder->view($target_entity, $this->options['view_mode']);
|
||||
}
|
||||
}
|
||||
|
|
@ -187,8 +228,8 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
// @todo Use a method to check for tokens in
|
||||
// https://www.drupal.org/node/2396607.
|
||||
if (strpos($this->options['target'], '{{') === FALSE) {
|
||||
if ($entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
|
||||
$dependencies[$this->entityManager->getDefinition($this->entityType)->getConfigDependencyKey()][] = $entity->getConfigDependencyName();
|
||||
if ($entity = $this->entityRepository->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
|
||||
$dependencies[$this->entityTypeManager->getDefinition($this->entityType)->getConfigDependencyKey()][] = $entity->getConfigDependencyName();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
namespace Drupal\views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\RevisionableInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
|
|
@ -28,13 +30,26 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
|||
use RedirectDestinationTrait;
|
||||
use UncacheableFieldHandlerTrait;
|
||||
use EntityTranslationRenderTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The action storage.
|
||||
|
|
@ -73,22 +88,29 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
|||
* The plugin ID for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
|
||||
* The messenger.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, MessengerInterface $messenger) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, MessengerInterface $messenger, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->actionStorage = $entity_manager->getStorage('action');
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->actionStorage = $entity_type_manager->getStorage('action');
|
||||
$this->languageManager = $language_manager;
|
||||
$this->messenger = $messenger;
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling BulkForm::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,7 +123,8 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
|||
$plugin_definition,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('messenger')
|
||||
$container->get('messenger'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -152,9 +175,25 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
// This relies on DeprecatedServicePropertyTrait to trigger a deprecation
|
||||
// message in case it is accessed.
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityTypeManager() {
|
||||
return $this->entityTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
return $this->entityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -499,7 +538,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
|||
$langcode = array_pop($key_parts);
|
||||
|
||||
// Load the entity or a specific revision depending on the given key.
|
||||
$storage = $this->entityManager->getStorage($this->getEntityType());
|
||||
$storage = $this->entityTypeManager->getStorage($this->getEntityType());
|
||||
$entity = $revision_id ? $storage->loadRevision($revision_id) : $storage->load($id);
|
||||
|
||||
if ($entity instanceof TranslatableInterface) {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ use Drupal\Component\Plugin\DependentPluginInterface;
|
|||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldTypePluginManagerInterface;
|
||||
use Drupal\Core\Field\FormatterPluginManager;
|
||||
|
|
@ -39,6 +42,12 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
|
||||
use FieldAPIHandlerTrait;
|
||||
use PluginDependencyTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* An array to store field renderable arrays for use by renderItems().
|
||||
|
|
@ -76,11 +85,25 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
protected $formatterOptions;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity typemanager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity field manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
|
||||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The field formatter plugin manager.
|
||||
|
|
@ -126,8 +149,8 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The field formatter plugin manager.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
* @param \Drupal\Core\Field\FormatterPluginManager $formatter_plugin_manager
|
||||
* The field formatter plugin manager.
|
||||
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager
|
||||
|
|
@ -136,11 +159,15 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
* The language manager.
|
||||
* @param \Drupal\Core\Render\RendererInterface $renderer
|
||||
* The renderer.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
|
||||
* The entity field manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, FormatterPluginManager $formatter_plugin_manager, FieldTypePluginManagerInterface $field_type_plugin_manager, LanguageManagerInterface $language_manager, RendererInterface $renderer) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, FormatterPluginManager $formatter_plugin_manager, FieldTypePluginManagerInterface $field_type_plugin_manager, LanguageManagerInterface $language_manager, RendererInterface $renderer, EntityRepositoryInterface $entity_repository = NULL, EntityFieldManagerInterface $entity_field_manager = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->formatterPluginManager = $formatter_plugin_manager;
|
||||
$this->fieldTypePluginManager = $field_type_plugin_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
|
|
@ -151,6 +178,18 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
if (isset($this->definition['entity field'])) {
|
||||
$this->definition['field_name'] = $this->definition['entity field'];
|
||||
}
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling EntityField::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
|
||||
if (!$entity_field_manager) {
|
||||
@trigger_error('Calling EntityField::__construct() with the $entity_field_manager argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_field_manager = \Drupal::service('entity_field.manager');
|
||||
}
|
||||
$this->entityFieldManager = $entity_field_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -161,11 +200,13 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('plugin.manager.field.formatter'),
|
||||
$container->get('plugin.manager.field.field_type'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('renderer')
|
||||
$container->get('renderer'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('entity_field.manager')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -202,18 +243,11 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access(AccountInterface $account) {
|
||||
$access_control_handler = $this->entityManager->getAccessControlHandler($this->getEntityType());
|
||||
$access_control_handler = $this->entityTypeManager->getAccessControlHandler($this->getEntityType());
|
||||
return $access_control_handler->fieldAccess('view', $this->getFieldDefinition(), $account);
|
||||
}
|
||||
|
||||
|
|
@ -323,7 +357,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
*/
|
||||
protected function getFieldStorageDefinition() {
|
||||
$entity_type_id = $this->definition['entity_type'];
|
||||
$field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
|
||||
$field_storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($entity_type_id);
|
||||
|
||||
// @todo Unify 'entity field'/'field_name' instead of converting back and
|
||||
// forth. https://www.drupal.org/node/2410779
|
||||
|
|
@ -339,7 +373,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
// base fields, so we need to explicitly fetch a list of all base fields in
|
||||
// order to support them.
|
||||
// @see \Drupal\Core\Entity\EntityFieldManager::getFieldStorageDefinitions()
|
||||
$base_fields = $this->entityManager->getBaseFieldDefinitions($entity_type_id);
|
||||
$base_fields = $this->entityFieldManager->getBaseFieldDefinitions($entity_type_id);
|
||||
if (isset($this->definition['field_name']) && isset($base_fields[$this->definition['field_name']])) {
|
||||
return $base_fields[$this->definition['field_name']]->getFieldStorageDefinition();
|
||||
}
|
||||
|
|
@ -798,8 +832,8 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
}
|
||||
}
|
||||
if (!isset($this->entityFieldRenderer)) {
|
||||
$entity_type = $this->entityManager->getDefinition($this->getEntityType());
|
||||
$this->entityFieldRenderer = new EntityFieldRenderer($this->view, $this->relationship, $this->languageManager, $entity_type, $this->entityManager);
|
||||
$entity_type = $this->entityTypeManager->getDefinition($this->getEntityType());
|
||||
$this->entityFieldRenderer = new EntityFieldRenderer($this->view, $this->relationship, $this->languageManager, $entity_type, $this->entityTypeManager, $this->entityRepository);
|
||||
}
|
||||
}
|
||||
return $this->entityFieldRenderer;
|
||||
|
|
@ -1044,7 +1078,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
|
|||
* The table mapping.
|
||||
*/
|
||||
protected function getTableMapping() {
|
||||
return $this->entityManager->getStorage($this->definition['entity_type'])->getTableMapping();
|
||||
return $this->entityTypeManager->getStorage($this->definition['entity_type'])->getTableMapping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Routing\RedirectDestinationTrait;
|
||||
|
|
@ -21,13 +23,33 @@ class EntityOperations extends FieldPluginBase {
|
|||
|
||||
use EntityTranslationRenderTrait;
|
||||
use RedirectDestinationTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
|
|
@ -37,7 +59,7 @@ class EntityOperations extends FieldPluginBase {
|
|||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructs a new EntityOperations object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
|
|
@ -45,16 +67,24 @@ class EntityOperations extends FieldPluginBase {
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param array $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EntityRepositoryInterface $entity_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling EntityOperations::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,8 +95,9 @@ class EntityOperations extends FieldPluginBase {
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager')
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('entity.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +140,7 @@ class EntityOperations extends FieldPluginBase {
|
|||
*/
|
||||
public function render(ResultRow $values) {
|
||||
$entity = $this->getEntityTranslation($this->getEntity($values), $values);
|
||||
$operations = $this->entityManager->getListBuilder($entity->getEntityTypeId())->getOperations($entity);
|
||||
$operations = $this->entityTypeManager->getListBuilder($entity->getEntityTypeId())->getOperations($entity);
|
||||
if ($this->options['destination']) {
|
||||
foreach ($operations as &$operation) {
|
||||
if (!isset($operation['query'])) {
|
||||
|
|
@ -149,9 +180,25 @@ class EntityOperations extends FieldPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
// This relies on DeprecatedServicePropertyTrait to trigger a deprecation
|
||||
// message in case it is accessed.
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityTypeManager() {
|
||||
return $this->entityTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
return $this->entityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
namespace Drupal\views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
|
||||
|
|
@ -21,13 +24,33 @@ use Drupal\Core\Cache\Cache;
|
|||
class RenderedEntity extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
|
||||
use EntityTranslationRenderTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
|
|
@ -45,16 +68,32 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
* The plugin_id for the plugin instance.
|
||||
* @param array $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
|
||||
* The entity display repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EntityRepositoryInterface $entity_repository = NULL, EntityDisplayRepositoryInterface $entity_display_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling RenderedEntity::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
|
||||
if (!$entity_display_repository) {
|
||||
@trigger_error('Calling RenderedEntity::__construct() with the $entity_display_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_display_repository = \Drupal::service('entity_display.repository');
|
||||
}
|
||||
$this->entityDisplayRepository = $entity_display_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,8 +104,10 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager')
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('entity_display.repository')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +136,7 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
|
||||
$form['view_mode'] = [
|
||||
'#type' => 'select',
|
||||
'#options' => $this->entityManager->getViewModeOptions($this->getEntityTypeId()),
|
||||
'#options' => $this->entityDisplayRepository->getViewModeOptions($this->getEntityTypeId()),
|
||||
'#title' => $this->t('View mode'),
|
||||
'#default_value' => $this->options['view_mode'],
|
||||
];
|
||||
|
|
@ -111,7 +152,7 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
$access = $entity->access('view', NULL, TRUE);
|
||||
$build['#access'] = $access;
|
||||
if ($access->isAllowed()) {
|
||||
$view_builder = $this->entityManager->getViewBuilder($this->getEntityTypeId());
|
||||
$view_builder = $this->entityTypeManager->getViewBuilder($this->getEntityTypeId());
|
||||
$build += $view_builder->view($entity, $this->options['view_mode']);
|
||||
}
|
||||
}
|
||||
|
|
@ -129,7 +170,7 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheTags() {
|
||||
$view_display_storage = $this->entityManager->getStorage('entity_view_display');
|
||||
$view_display_storage = $this->entityTypeManager->getStorage('entity_view_display');
|
||||
$view_displays = $view_display_storage->loadMultiple($view_display_storage
|
||||
->getQuery()
|
||||
->condition('targetEntityType', $this->getEntityTypeId())
|
||||
|
|
@ -172,9 +213,25 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
// This relies on DeprecatedServicePropertyTrait to trigger a deprecation
|
||||
// message in case it is accessed.
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityTypeManager() {
|
||||
return $this->entityTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
return $this->entityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -195,7 +252,7 @@ class RenderedEntity extends FieldPluginBase implements CacheableDependencyInter
|
|||
public function calculateDependencies() {
|
||||
$dependencies = parent::calculateDependencies();
|
||||
|
||||
$view_mode = $this->entityManager
|
||||
$view_mode = $this->entityTypeManager
|
||||
->getStorage('entity_view_mode')
|
||||
->load($this->getEntityTypeId() . '.' . $this->options['view_mode']);
|
||||
if ($view_mode) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\row;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
||||
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
|
||||
|
|
@ -20,6 +23,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class EntityRow extends RowPluginBase {
|
||||
use EntityTranslationRenderTrait;
|
||||
use DeprecatedServicePropertyTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
||||
|
||||
/**
|
||||
* The table the entity is using for storage.
|
||||
|
|
@ -50,11 +59,25 @@ class EntityRow extends RowPluginBase {
|
|||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
public $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
|
|
@ -64,18 +87,40 @@ class EntityRow extends RowPluginBase {
|
|||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Constructs a new EntityRow object.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param array $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||
* The entity repository.
|
||||
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
|
||||
* The entity display repository.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EntityRepositoryInterface $entity_repository = NULL, EntityDisplayRepositoryInterface $entity_display_repository = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
|
||||
if (!$entity_repository) {
|
||||
@trigger_error('Calling EntityRow::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_repository = \Drupal::service('entity.repository');
|
||||
}
|
||||
$this->entityRepository = $entity_repository;
|
||||
|
||||
if (!$entity_display_repository) {
|
||||
@trigger_error('Calling EntityRow::__construct() with the $entity_display_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
|
||||
$entity_display_repository = \Drupal::service('entity_display.repository');
|
||||
}
|
||||
$this->entityDisplayRepository = $entity_display_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,7 +130,7 @@ class EntityRow extends RowPluginBase {
|
|||
parent::init($view, $display, $options);
|
||||
|
||||
$this->entityTypeId = $this->definition['entity_type'];
|
||||
$this->entityType = $this->entityManager->getDefinition($this->entityTypeId);
|
||||
$this->entityType = $this->entityTypeManager->getDefinition($this->entityTypeId);
|
||||
$this->base_table = $this->entityType->getDataTable() ?: $this->entityType->getBaseTable();
|
||||
$this->base_field = $this->entityType->getKey('id');
|
||||
}
|
||||
|
|
@ -94,7 +139,15 @@ class EntityRow extends RowPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('language_manager'));
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('entity.repository'),
|
||||
$container->get('entity_display.repository')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -108,9 +161,25 @@ class EntityRow extends RowPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityManager() {
|
||||
// This relies on DeprecatedServicePropertyTrait to trigger a deprecation
|
||||
// message in case it is accessed.
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityTypeManager() {
|
||||
return $this->entityTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntityRepository() {
|
||||
return $this->entityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -142,7 +211,7 @@ class EntityRow extends RowPluginBase {
|
|||
|
||||
$form['view_mode'] = [
|
||||
'#type' => 'select',
|
||||
'#options' => \Drupal::entityManager()->getViewModeOptions($this->entityTypeId),
|
||||
'#options' => $this->entityDisplayRepository->getViewModeOptions($this->entityTypeId),
|
||||
'#title' => $this->t('View mode'),
|
||||
'#default_value' => $this->options['view_mode'],
|
||||
];
|
||||
|
|
@ -152,7 +221,7 @@ class EntityRow extends RowPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function summaryTitle() {
|
||||
$options = \Drupal::entityManager()->getViewModeOptions($this->entityTypeId);
|
||||
$options = $this->entityDisplayRepository->getViewModeOptions($this->entityTypeId);
|
||||
if (isset($options[$this->options['view_mode']])) {
|
||||
return $options[$this->options['view_mode']];
|
||||
}
|
||||
|
|
@ -192,7 +261,7 @@ class EntityRow extends RowPluginBase {
|
|||
public function calculateDependencies() {
|
||||
$dependencies = parent::calculateDependencies();
|
||||
|
||||
$view_mode = $this->entityManager
|
||||
$view_mode = $this->entityTypeManager
|
||||
->getStorage('entity_view_mode')
|
||||
->load($this->entityTypeId . '.' . $this->options['view_mode']);
|
||||
if ($view_mode) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Drupal\Tests\views\Unit\Plugin\area;
|
||||
|
||||
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Plugin\views\area\Entity;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
|
@ -20,11 +23,25 @@ class EntityTest extends UnitTestCase {
|
|||
protected $entityHandler;
|
||||
|
||||
/**
|
||||
* The mocked entity manager.
|
||||
* The mocked entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityDisplayRepository;
|
||||
|
||||
/**
|
||||
* The mocked entity storage.
|
||||
|
|
@ -67,7 +84,9 @@ class EntityTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$this->entityRepository = $this->createMock(EntityRepositoryInterface::class);
|
||||
$this->entityDisplayRepository = $this->createMock(EntityDisplayRepositoryInterface::class);
|
||||
$this->entityStorage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$this->entityViewBuilder = $this->getMock('Drupal\Core\Entity\EntityViewBuilderInterface');
|
||||
|
||||
|
|
@ -82,7 +101,7 @@ class EntityTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->executable->style_plugin = $this->stylePlugin;
|
||||
|
||||
$this->entityHandler = new Entity([], 'entity', ['entity_type' => 'entity_test'], $this->entityManager);
|
||||
$this->entityHandler = new Entity([], 'entity', ['entity_type' => 'entity_test'], $this->entityTypeManager, $this->entityRepository, $this->entityDisplayRepository);
|
||||
|
||||
$this->display->expects($this->any())
|
||||
->method('getPlugin')
|
||||
|
|
@ -107,11 +126,11 @@ class EntityTest extends UnitTestCase {
|
|||
* Ensures that the entity manager returns an entity storage.
|
||||
*/
|
||||
protected function setupEntityManager() {
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('entity_test')
|
||||
->willReturn($this->entityStorage);
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getViewBuilder')
|
||||
->with('entity_test')
|
||||
->willReturn($this->entityViewBuilder);
|
||||
|
|
@ -151,7 +170,7 @@ class EntityTest extends UnitTestCase {
|
|||
|
||||
$this->entityStorage->expects($this->never())
|
||||
->method('loadByProperties');
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityRepository->expects($this->any())
|
||||
->method('loadEntityByConfigTarget')
|
||||
->willReturn($entity);
|
||||
$this->entityViewBuilder->expects($this->once())
|
||||
|
|
@ -225,7 +244,7 @@ class EntityTest extends UnitTestCase {
|
|||
|
||||
$this->entityStorage->expects($this->never())
|
||||
->method('load');
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityRepository->expects($this->once())
|
||||
->method('loadEntityByConfigTarget')
|
||||
->willReturn($entity);
|
||||
$this->entityViewBuilder->expects($this->once())
|
||||
|
|
@ -269,13 +288,13 @@ class EntityTest extends UnitTestCase {
|
|||
->willReturn('entity_test:test-bundle:1d52762e-b9d8-4177-908f-572d1a5845a4');
|
||||
$this->entityStorage->expects($this->never())
|
||||
->method('load');
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityRepository->expects($this->once())
|
||||
->method('loadEntityByConfigTarget')
|
||||
->willReturn($entity);
|
||||
$entity_type->expects($this->once())
|
||||
->method('getConfigDependencyKey')
|
||||
->willReturn('content');
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->willReturn($entity_type);
|
||||
|
||||
|
|
@ -298,7 +317,7 @@ class EntityTest extends UnitTestCase {
|
|||
$entity->expects($this->once())
|
||||
->method('getConfigDependencyName')
|
||||
->willReturn('entity_test:test-bundle:1d52762e-b9d8-4177-908f-572d1a5845a4');
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityRepository->expects($this->once())
|
||||
->method('loadEntityByConfigTarget')
|
||||
->willReturn($entity);
|
||||
$this->entityStorage->expects($this->never())
|
||||
|
|
@ -306,7 +325,7 @@ class EntityTest extends UnitTestCase {
|
|||
$entity_type->expects($this->once())
|
||||
->method('getConfigDependencyKey')
|
||||
->willReturn('content');
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->willReturn($entity_type);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
namespace Drupal\Tests\views\Unit\Plugin\field;
|
||||
|
||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Tests\views\Unit\Plugin\HandlerTestTrait;
|
||||
|
|
@ -23,11 +26,25 @@ class FieldTest extends UnitTestCase {
|
|||
use HandlerTestTrait;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity field manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityFieldManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The mocked formatter plugin manager.
|
||||
|
|
@ -70,7 +87,9 @@ class FieldTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$this->entityFieldManager = $this->createMock(EntityFieldManagerInterface::class);
|
||||
$this->entityRepository = $this->createMock(EntityRepositoryInterface::class);
|
||||
$this->formatterPluginManager = $this->getMockBuilder('Drupal\Core\Field\FormatterPluginManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
@ -107,7 +126,7 @@ class FieldTest extends UnitTestCase {
|
|||
// provides it.
|
||||
'entity field' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
|
||||
$this->assertEquals('title', $handler->definition['field_name']);
|
||||
}
|
||||
|
|
@ -120,12 +139,12 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
|
||||
// Setup the entity manager to allow fetching the storage definitions.
|
||||
$title_storage = $this->getBaseFieldStorage();
|
||||
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -149,12 +168,12 @@ class FieldTest extends UnitTestCase {
|
|||
'default_formatter' => 'test_example',
|
||||
'default_formatter_settings' => ['link_to_entity' => TRUE],
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
|
||||
// Setup the entity manager to allow fetching the storage definitions.
|
||||
$title_storage = $this->getBaseFieldStorage();
|
||||
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -176,12 +195,12 @@ class FieldTest extends UnitTestCase {
|
|||
'field_name' => 'title',
|
||||
'default_formatter_settings' => ['link_to_entity' => TRUE],
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
|
||||
// Setup the entity manager to allow fetching the storage definitions.
|
||||
$title_storage = $this->getBaseFieldStorage();
|
||||
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -202,10 +221,10 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
|
||||
$title_storage = $this->getBaseFieldStorage();
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -224,10 +243,10 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'body',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
|
||||
$body_storage = $this->getConfigFieldStorage();
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -250,7 +269,7 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
$handler->setViewsData($this->viewsData);
|
||||
|
||||
|
|
@ -267,13 +286,13 @@ class FieldTest extends UnitTestCase {
|
|||
]);
|
||||
|
||||
$access_control_handler = $this->getMock('Drupal\Core\Entity\EntityAccessControlHandlerInterface');
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityTypeManager->expects($this->atLeastOnce())
|
||||
->method('getAccessControlHandler')
|
||||
->with('test_entity')
|
||||
->willReturn($access_control_handler);
|
||||
|
||||
$title_storage = $this->getBaseFieldStorage();
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -301,10 +320,10 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
|
||||
$this->entityManager->expects($this->never())
|
||||
$this->entityFieldManager->expects($this->never())
|
||||
->method('getFieldStorageDefinitions');
|
||||
|
||||
$handler->clickSort($order);
|
||||
|
|
@ -323,11 +342,11 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
|
||||
$field_storage = $this->getBaseFieldStorage();
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -344,7 +363,7 @@ class FieldTest extends UnitTestCase {
|
|||
$entity_storage->expects($this->atLeastOnce())
|
||||
->method('getTableMapping')
|
||||
->willReturn($table_mapping);
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityTypeManager->expects($this->atLeastOnce())
|
||||
->method('getStorage')
|
||||
->with('test_entity')
|
||||
->willReturn($entity_storage);
|
||||
|
|
@ -383,11 +402,11 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'body',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
|
||||
$field_storage = $this->getConfigFieldStorage();
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityFieldManager->expects($this->atLeastOnce())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -404,7 +423,7 @@ class FieldTest extends UnitTestCase {
|
|||
$entity_storage->expects($this->atLeastOnce())
|
||||
->method('getTableMapping')
|
||||
->willReturn($table_mapping);
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
$this->entityTypeManager->expects($this->atLeastOnce())
|
||||
->method('getStorage')
|
||||
->with('test_entity')
|
||||
->willReturn($entity_storage);
|
||||
|
|
@ -438,14 +457,14 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'title',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
$handler->view->field = [$handler];
|
||||
|
||||
$this->setupLanguageRenderer($handler, $definition);
|
||||
|
||||
$field_storage = $this->getBaseFieldStorage();
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityFieldManager->expects($this->any())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -462,7 +481,7 @@ class FieldTest extends UnitTestCase {
|
|||
$entity_storage->expects($this->any())
|
||||
->method('getTableMapping')
|
||||
->willReturn($table_mapping);
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('test_entity')
|
||||
->willReturn($entity_storage);
|
||||
|
|
@ -500,14 +519,14 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'body',
|
||||
];
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
$handler->view->field = [$handler];
|
||||
|
||||
$this->setupLanguageRenderer($handler, $definition);
|
||||
|
||||
$field_storage = $this->getConfigFieldStorage();
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityFieldManager->expects($this->any())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -524,7 +543,7 @@ class FieldTest extends UnitTestCase {
|
|||
$entity_storage->expects($this->any())
|
||||
->method('getTableMapping')
|
||||
->willReturn($table_mapping);
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('test_entity')
|
||||
->willReturn($entity_storage);
|
||||
|
|
@ -564,7 +583,7 @@ class FieldTest extends UnitTestCase {
|
|||
'entity_type' => 'test_entity',
|
||||
'field_name' => 'integer',
|
||||
];
|
||||
$handler = new FieldTestEntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
|
||||
$handler = new FieldTestEntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager);
|
||||
$handler->view = $this->executable;
|
||||
$handler->view->field = [$handler];
|
||||
|
||||
|
|
@ -575,7 +594,7 @@ class FieldTest extends UnitTestCase {
|
|||
->method('getCardinality')
|
||||
->willReturn(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
|
||||
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityFieldManager->expects($this->any())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity')
|
||||
->willReturn([
|
||||
|
|
@ -592,7 +611,7 @@ class FieldTest extends UnitTestCase {
|
|||
$entity_storage->expects($this->any())
|
||||
->method('getTableMapping')
|
||||
->willReturn($table_mapping);
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('test_entity')
|
||||
->willReturn($entity_storage);
|
||||
|
|
@ -717,7 +736,7 @@ class FieldTest extends UnitTestCase {
|
|||
->method('id')
|
||||
->willReturn($definition['entity_type']);
|
||||
|
||||
$this->entityManager->expects($this->any())
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->willReturn($entity_type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Drupal\Tests\views\Unit\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Plugin\views\field\EntityOperations;
|
||||
use Drupal\views\ResultRow;
|
||||
|
|
@ -13,11 +15,18 @@ use Drupal\views\ResultRow;
|
|||
class EntityOperationsUnitTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityManager;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
|
|
@ -39,7 +48,8 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
* @covers ::__construct
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$this->entityRepository = $this->createMock(EntityRepositoryInterface::class);
|
||||
$this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$configuration = [];
|
||||
|
|
@ -47,7 +57,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
$plugin_definition = [
|
||||
'title' => $this->randomMachineName(),
|
||||
];
|
||||
$this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager, $this->languageManager);
|
||||
$this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityTypeManager, $this->languageManager, $this->entityRepository);
|
||||
|
||||
$redirect_service = $this->getMock('Drupal\Core\Routing\RedirectDestinationInterface');
|
||||
$redirect_service->expects($this->any())
|
||||
|
|
@ -104,7 +114,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
->with($entity)
|
||||
->will($this->returnValue($operations));
|
||||
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getListBuilder')
|
||||
->with($entity_type_id)
|
||||
->will($this->returnValue($list_builder));
|
||||
|
|
@ -146,7 +156,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
->with($entity)
|
||||
->will($this->returnValue($operations));
|
||||
|
||||
$this->entityManager->expects($this->once())
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getListBuilder')
|
||||
->with($entity_type_id)
|
||||
->will($this->returnValue($list_builder));
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class ConfigEntityUnitTest extends KernelTestBase {
|
|||
$entity->save();
|
||||
|
||||
// Ensure that the configuration entity can be loaded by UUID.
|
||||
$entity_loaded_by_uuid = \Drupal::entityManager()->loadEntityByUuid($entity_type->id(), $entity->uuid());
|
||||
$entity_loaded_by_uuid = \Drupal::service('entity.repository')->loadEntityByUuid($entity_type->id(), $entity->uuid());
|
||||
if (!$entity_loaded_by_uuid) {
|
||||
$this->fail(sprintf("Failed to load '%s' entity ID '%s' by UUID '%s'.", $entity_type->id(), $entity->id(), $entity->uuid()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -632,21 +632,21 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
|
||||
// Check that retrieving the current translation works as expected.
|
||||
$entity = $this->reloadEntity($entity);
|
||||
$translation = $this->entityManager->getTranslationFromContext($entity, $langcode2);
|
||||
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode2);
|
||||
$this->assertEqual($translation->language()->getId(), $default_langcode, 'The current translation language matches the expected one.');
|
||||
|
||||
// Check that language fallback respects language weight by default.
|
||||
$language = ConfigurableLanguage::load($languages[$langcode]->getId());
|
||||
$language->set('weight', -1);
|
||||
$language->save();
|
||||
$translation = $this->entityManager->getTranslationFromContext($entity, $langcode2);
|
||||
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode2);
|
||||
$this->assertEqual($translation->language()->getId(), $langcode, 'The current translation language matches the expected one.');
|
||||
|
||||
// Check that the current translation is properly returned.
|
||||
$translation = $this->entityManager->getTranslationFromContext($entity);
|
||||
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($entity);
|
||||
$this->assertEqual($langcode, $translation->language()->getId(), 'The current translation language matches the topmost language fallback candidate.');
|
||||
$entity->addTranslation($current_langcode, $values[$current_langcode]);
|
||||
$translation = $this->entityManager->getTranslationFromContext($entity);
|
||||
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($entity);
|
||||
$this->assertEqual($current_langcode, $translation->language()->getId(), 'The current translation language matches the current language.');
|
||||
|
||||
// Check that if the entity has no translation no fallback is applied.
|
||||
|
|
@ -655,7 +655,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
$controller = $this->entityManager->getViewBuilder($entity_type);
|
||||
$entity2_build = $controller->view($entity2);
|
||||
$entity2_output = (string) $renderer->renderRoot($entity2_build);
|
||||
$translation = $this->entityManager->getTranslationFromContext($entity2, $default_langcode);
|
||||
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($entity2, $default_langcode);
|
||||
$translation_build = $controller->view($translation);
|
||||
$translation_output = (string) $renderer->renderRoot($translation_build);
|
||||
$this->assertSame($entity2_output, $translation_output, 'When the entity has no translation no fallback is applied.');
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ class EntityUUIDTest extends EntityKernelTestBase {
|
|||
$entity_loaded = $storage->load($entity->id());
|
||||
$this->assertIdentical($entity_loaded->uuid(), $uuid);
|
||||
|
||||
// Verify that \Drupal::entityManager()->loadEntityByUuid() loads the same entity.
|
||||
$entity_loaded_by_uuid = \Drupal::entityManager()->loadEntityByUuid($entity_type, $uuid, TRUE);
|
||||
// Verify that \Drupal::service('entity.repository')->loadEntityByUuid() loads the same entity.
|
||||
$entity_loaded_by_uuid = \Drupal::service('entity.repository')->loadEntityByUuid($entity_type, $uuid, TRUE);
|
||||
$this->assertIdentical($entity_loaded_by_uuid->uuid(), $uuid);
|
||||
$this->assertEqual($entity_loaded_by_uuid->id(), $entity_loaded->id());
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
namespace Drupal\Tests\Core\Entity;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManager;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
|
|
@ -52,6 +54,13 @@ class EntityManagerTest extends UnitTestCase {
|
|||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* The entity display repository.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityRepositoryInterface|\Prophecy\Prophecy\ProphecyInterface
|
||||
*/
|
||||
protected $entityRepository;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -62,12 +71,14 @@ class EntityManagerTest extends UnitTestCase {
|
|||
$this->entityTypeRepository = $this->prophesize(EntityTypeRepositoryInterface::class);
|
||||
$this->entityTypeBundleInfo = $this->prophesize(EntityTypeBundleInfoInterface::class);
|
||||
$this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class);
|
||||
$this->entityRepository = $this->prophesize(EntityRepositoryInterface::class);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('entity_type.manager', $this->entityTypeManager->reveal());
|
||||
$container->set('entity_type.repository', $this->entityTypeRepository->reveal());
|
||||
$container->set('entity_type.bundle.info', $this->entityTypeBundleInfo->reveal());
|
||||
$container->set('entity_field.manager', $this->entityFieldManager->reveal());
|
||||
$container->set('entity.repository', $this->entityRepository->reveal());
|
||||
|
||||
$this->entityManager = new EntityManager();
|
||||
$this->entityManager->setContainer($container);
|
||||
|
|
@ -89,4 +100,46 @@ class EntityManagerTest extends UnitTestCase {
|
|||
$this->entityManager->clearCachedDefinitions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTranslationFromContext() method.
|
||||
*
|
||||
* @covers ::getTranslationFromContext
|
||||
*
|
||||
* @expectedDeprecation EntityManagerInterface::getTranslationFromContext() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::getTranslationFromContext() instead. See https://www.drupal.org/node/2549139.
|
||||
*/
|
||||
public function testGetTranslationFromContext() {
|
||||
$entity = $this->prophesize(EntityInterface::class);
|
||||
$this->entityRepository->getTranslationFromContext($entity->reveal(), 'de', ['example' => 'context'])->shouldBeCalled();
|
||||
|
||||
$this->entityManager->getTranslationFromContext($entity->reveal(), 'de', ['example' => 'context']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the loadEntityByUuid() method.
|
||||
*
|
||||
* @covers ::loadEntityByUuid
|
||||
*
|
||||
* @expectedDeprecation EntityManagerInterface::loadEntityByUuid() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::loadEntityByUuid() instead. See https://www.drupal.org/node/2549139.
|
||||
*/
|
||||
public function testLoadEntityByUuid() {
|
||||
$entity = $this->prophesize(EntityInterface::class);
|
||||
$this->entityRepository->loadEntityByUuid('entity_test', '9a9a3d06-5d27-493b-965d-7f9cb0115817')->shouldBeCalled()->willReturn($entity->reveal());
|
||||
|
||||
$this->assertInstanceOf(EntityInterface::class, $this->entityManager->loadEntityByUuid('entity_test', '9a9a3d06-5d27-493b-965d-7f9cb0115817'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the loadEntityByConfigTarget() method.
|
||||
*
|
||||
* @covers ::loadEntityByConfigTarget
|
||||
*
|
||||
* @expectedDeprecation EntityManagerInterface::loadEntityByConfigTarget() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::loadEntityByConfigTarget() instead. See https://www.drupal.org/node/2549139.
|
||||
*/
|
||||
public function testLoadEntityByConfigTarget() {
|
||||
$entity = $this->prophesize(EntityInterface::class);
|
||||
$this->entityRepository->loadEntityByConfigTarget('config_test', 'test')->shouldBeCalled()->willReturn($entity->reveal());
|
||||
|
||||
$this->assertInstanceOf(EntityInterface::class, $this->entityManager->loadEntityByConfigTarget('config_test', 'test'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue