Commit d06f753b authored by willzyx's avatar willzyx

Issue #2783055 by chaitanya17, willzyx: Deprecated \Drupal::entityManager() function

parent 2b865e37
......@@ -64,9 +64,10 @@ function drush_phpstorm_metadata() {
}
// Entity Manager - getStorage
foreach (\Drupal::entityManager()->getDefinitions() as $type => $definition) {
$class = Drupal::entityManager()->getStorage($type);
foreach (\Drupal::entityTypeManager()->getDefinitions() as $type => $definition) {
$class = Drupal::entityTypeManager()->getStorage($type);
$map["\\Drupal::entityManager()->getStorage('')"][$type] = '\\' . get_class($class);
$map["\\Drupal::entityTypeManager()->getStorage('')"][$type] = '\\' . get_class($class);
}
$content = _drush_phpstorm_metadata_phpstorm_metadata_template($map);
......
......@@ -100,7 +100,7 @@ class DevelController extends ControllerBase {
ksort($field_instances);
$output['instances'] = array('#markup' => kprint_r($field_instances, TRUE, $this->t('Instances')));
$bundles = $this->entityManager()->getAllBundleInfo();
$bundles = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo();
ksort($bundles);
$output['bundles'] = array('#markup' => kprint_r($bundles, TRUE, $this->t('Bundles')));
......@@ -126,11 +126,10 @@ class DevelController extends ControllerBase {
* Array of page elements to render.
*/
public function entityInfoPage() {
$types = $this->entityManager()->getEntityTypeLabels();
$types = $this->entityTypeManager()->getDefinitions();
ksort($types);
$result = array();
foreach (array_keys($types) as $type) {
$definition = $this->entityManager()->getDefinition($type);
foreach ($types as $id => $definition) {
$reflected_definition = new \ReflectionClass($definition);
$props = array();
foreach ($reflected_definition->getProperties() as $property) {
......@@ -138,7 +137,7 @@ class DevelController extends ControllerBase {
$value = $property->getValue($definition);
$props[$property->name] = $value;
}
$result[$type] = $props;
$result[$id] = $props;
}
return array('#markup' => kprint_r($result, TRUE));
......@@ -301,8 +300,8 @@ class DevelController extends ControllerBase {
$build = $view_hook($entity);
}
// If entity has view_builder handler
elseif ($this->entityManager()->hasHandler($entity_type_id, 'view_builder')) {
$build = $this->entityManager()->getViewBuilder($entity_type_id)->view($entity);
elseif ($this->entityTypeManager()->hasHandler($entity_type_id, 'view_builder')) {
$build = $this->entityTypeManager()->getViewBuilder($entity_type_id)->view($entity);
}
$output = array('#markup' => kdevel_print_object($build));
......
......@@ -3,7 +3,7 @@
namespace Drupal\devel\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -19,20 +19,20 @@ class DevelLocalTask extends DeriverBase implements ContainerDeriverInterface {
/**
* The entity manager
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* Creates an DevelLocalTask object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The translation manager.
*/
public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation) {
$this->entityManager = $entity_manager;
public function __construct(EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
$this->entityTypeManager = $entity_type_manager;
$this->stringTranslation = $string_translation;
}
......@@ -41,7 +41,7 @@ class DevelLocalTask extends DeriverBase implements ContainerDeriverInterface {
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('string_translation')
);
}
......@@ -52,7 +52,7 @@ class DevelLocalTask extends DeriverBase implements ContainerDeriverInterface {
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = array();
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
$has_edit_path = $entity_type->hasLinkTemplate('devel-load');
$has_canonical_path = $entity_type->hasLinkTemplate('devel-render');
......
......@@ -9,7 +9,7 @@
* Implements hook_entity_view_mode_info_alter().
*/
function devel_entity_test_entity_view_mode_info_alter(&$view_modes) {
$entity_info = \Drupal::entityManager()->getDefinitions();
$entity_info = \Drupal::entityTypeManager()->getDefinitions();
foreach ($entity_info as $entity_type => $info) {
if ($entity_info[$entity_type]->getProvider() == 'devel_entity_test_canonical' && !isset($view_modes[$entity_type])) {
$view_modes[$entity_type] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment