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