X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FContentEntityForm.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FContentEntityForm.php;h=75bde9fe3502b48148d9e7d14dafabf72e888df2;hp=92bbbae42f98ac98acef95ae7d4de75ce8441033;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php index 92bbbae42..75bde9fe3 100644 --- a/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -15,13 +15,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; */ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface { - /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - /** * The entity being used by this form. * @@ -43,19 +36,29 @@ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface */ protected $time; + /** + * The entity repository service. + * + * @var \Drupal\Core\Entity\EntityRepositoryInterface + */ + protected $entityRepository; + /** * Constructs a ContentEntityForm object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository service. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * The entity type bundle service. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. */ - public function __construct(EntityManagerInterface $entity_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) { - $this->entityManager = $entity_manager; - + public function __construct(EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) { + if ($entity_repository instanceof EntityManagerInterface) { + @trigger_error('Passing the entity.manager service to ContentEntityForm::__construct() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Pass the entity.repository service instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED); + $this->entityManager = $entity_repository; + } + $this->entityRepository = $entity_repository; $this->entityTypeBundleInfo = $entity_type_bundle_info ?: \Drupal::service('entity_type.bundle.info'); $this->time = $time ?: \Drupal::service('datetime.time'); } @@ -65,7 +68,7 @@ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity.repository'), $container->get('entity_type.bundle.info'), $container->get('datetime.time') ); @@ -131,7 +134,7 @@ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface '#type' => 'container', '#weight' => 99, '#attributes' => [ - 'class' => ['entity-content-form-footer'] + 'class' => ['entity-content-form-footer'], ], '#optional' => TRUE, ]; @@ -307,7 +310,7 @@ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface // Imply a 'view' operation to ensure users edit entities in the same // language they are displayed. This allows to keep contextual editing // working also for multilingual entities. - $form_state->set('langcode', $this->entityManager->getTranslationFromContext($this->entity)->language()->getId()); + $form_state->set('langcode', $this->entityRepository->getTranslationFromContext($this->entity)->language()->getId()); } }