Commit d2ee20c9 authored by rocket.man's avatar rocket.man Committed by woprrr

Issue #2855792 by rocket.man, woprrr: Replace all of deprecated usages

parent 95dd244c
......@@ -32,7 +32,7 @@ function crop_theme() {
*/
function template_preprocess_crop_crop_summary(&$variables) {
if (!empty($variables['data']['crop_type'])) {
$type = \Drupal::entityManager()->getStorage('crop_type')->load($variables['data']['crop_type']);
$type = \Drupal::entityTypeManager()->getStorage('crop_type')->load($variables['data']['crop_type']);
$variables['data']['crop_type'] = $type->label();
}
}
......@@ -47,7 +47,7 @@ function crop_form_media_bundle_form_alter(&$form, FormStateInterface $form_stat
$bundle = $form['#entity'];
$options = [];
$allowed_field_types = ['file', 'image'];
foreach (\Drupal::entityManager()->getFieldDefinitions('media', $bundle->id()) as $field_name => $field) {
foreach (\Drupal::service('entity_field.manager')->getFieldDefinitions('media', $bundle->id()) as $field_name => $field) {
if (in_array($field->getType(), $allowed_field_types) && !$field->getFieldStorageDefinition()->isBaseField()) {
$options[$field_name] = $field->getLabel();
}
......
......@@ -3,7 +3,7 @@
namespace Drupal\crop_media_entity\Plugin\Crop\EntityProvider;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\crop\EntityProviderBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -20,11 +20,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class MediaEntity extends EntityProviderBase implements ContainerFactoryPluginInterface {
/**
* Entity manager service.
* Entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* Constructs media entity integration plugin.
......@@ -35,12 +35,12 @@ class MediaEntity extends EntityProviderBase implements ContainerFactoryPluginIn
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* Entity manager service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager service.
*/
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) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityManager = $entity_manager;
$this->entityTypeManager = $entity_type_manager;
}
/**
......@@ -51,7 +51,7 @@ class MediaEntity extends EntityProviderBase implements ContainerFactoryPluginIn
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity.manager')
$container->get('entity_type.manager')
);
}
......@@ -60,7 +60,7 @@ class MediaEntity extends EntityProviderBase implements ContainerFactoryPluginIn
*/
public function uri(EntityInterface $entity) {
/** @var \Drupal\media_entity\MediaBundleInterface $bundle */
$bundle = $this->entityManager->getStorage('media_bundle')->load($entity->bundle());
$bundle = $this->entityTypeManager->getStorage('media_bundle')->load($entity->bundle());
$image_field = $bundle->getThirdPartySetting('crop', 'image_field');
if ($entity->{$image_field}->first()->isEmpty()) {
......@@ -68,7 +68,7 @@ class MediaEntity extends EntityProviderBase implements ContainerFactoryPluginIn
}
/** @var \Drupal\file\FileInterface $image */
$image = $this->entityManager->getStorage('file')->load($entity->{$image_field}->target_id);
$image = $this->entityTypeManager->getStorage('file')->load($entity->{$image_field}->target_id);
if (strpos($image->getMimeType(), 'image') !== 0) {
return FALSE;
......
......@@ -86,7 +86,7 @@ class CropTypeListBuilder extends ConfigEntityListBuilder {
public function buildRow(EntityInterface $entity) {
$row = [];
$row['name'] = [
'data' => $this->getLabel($entity),
'data' => $entity->label(),
'class' => ['menu-label'],
];
$row['description'] = Xss::filterAdmin($entity->description);
......
......@@ -155,7 +155,7 @@ class Crop extends ContentEntityBase implements CropInterface {
// Try to set URI if not yet defined.
if (empty($this->uri->value) && !empty($this->entity_type->value) && !empty($this->entity_id->value)) {
$entity = \Drupal::entityManager()->getStorage($this->entity_type->value)->load($this->entity_id->value);
$entity = \Drupal::entityTypeManager()->getStorage($this->entity_type->value)->load($this->entity_id->value);
if ($uri = $this->provider()->uri($entity)) {
$this->set('uri', $uri);
}
......
......@@ -132,7 +132,7 @@ class CropType extends ConfigEntityBundleBase implements \IteratorAggregate, Cro
function ($bundle_info) {
return $bundle_info['label'];
},
\Drupal::entityManager()->getBundleInfo('crop')
\Drupal::service('entity_type.bundle.info')->getBundleInfo('crop')
);
}
......
......@@ -4,6 +4,7 @@ namespace Drupal\crop\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Symfony\Component\Validator\ConstraintViolationListInterface;
......@@ -175,7 +176,7 @@ class CropTypeForm extends EntityForm {
}
elseif ($status == SAVED_NEW) {
drupal_set_message($this->t('The crop type %name has been added.', $t_args));
$context = array_merge($t_args, array('link' => $this->l(t('View'), new Url('crop.overview_types'))));
$context = array_merge($t_args, array('link' => Link::createFromRoute($this->t('View'), 'crop.overview_types')));
$this->logger('crop')->notice('Added crop type %name.', $context);
}
......
......@@ -40,7 +40,7 @@ class CropCRUDTest extends CropUnitTestBase {
$loaded = $this->container->get('config.factory')->get('crop.type.' . $values['id'])->get();
foreach ($values as $key => $value) {
$this->assertEqual($loaded[$key], $value, new FormattableMarkup('Correct value for @field found.', ['@field' => $key]));
$this->assertEquals($loaded[$key], $value, new FormattableMarkup('Correct value for @field found.', ['@field' => $key]));
}
}
......@@ -91,11 +91,11 @@ class CropCRUDTest extends CropUnitTestBase {
foreach ($values as $key => $value) {
switch ($key) {
case 'type':
$this->assertEqual($loaded_crop->{$key}->target_id, $value, new FormattableMarkup('Correct value for @field found.', ['@field' => $key]));
$this->assertEquals($loaded_crop->{$key}->target_id, $value, new FormattableMarkup('Correct value for @field found.', ['@field' => $key]));
break;
default:
$this->assertEqual($loaded_crop->{$key}->value, $value, new FormattableMarkup('Correct value for @field found.', ['@field' => $key]));
$this->assertEquals($loaded_crop->{$key}->value, $value, new FormattableMarkup('Correct value for @field found.', ['@field' => $key]));
break;
}
}
......
......@@ -58,7 +58,7 @@ class CropEntityProvidersTest extends CropUnitTestBase {
$this->assertTrue(FALSE, 'File entity provider plugin was found.');
}
$this->assertEqual($provider->uri($file), $file->getFileUri(), 'File provider plugin returned correct URI.');
$this->assertEquals($provider->uri($file), $file->getFileUri(), 'File provider plugin returned correct URI.');
}
}
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