Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Entity/Entity.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
87 protected function entityTypeManager() { | 87 protected function entityTypeManager() { |
88 return \Drupal::entityTypeManager(); | 88 return \Drupal::entityTypeManager(); |
89 } | 89 } |
90 | 90 |
91 /** | 91 /** |
92 * Gets the entity type bundle info service. | |
93 * | |
94 * @return \Drupal\Core\Entity\EntityTypeBundleInfoInterface | |
95 */ | |
96 protected function entityTypeBundleInfo() { | |
97 return \Drupal::service('entity_type.bundle.info'); | |
98 } | |
99 | |
100 /** | |
92 * Gets the language manager. | 101 * Gets the language manager. |
93 * | 102 * |
94 * @return \Drupal\Core\Language\LanguageManagerInterface | 103 * @return \Drupal\Core\Language\LanguageManagerInterface |
95 */ | 104 */ |
96 protected function languageManager() { | 105 protected function languageManager() { |
196 } | 205 } |
197 else { | 206 else { |
198 $bundle = $this->bundle(); | 207 $bundle = $this->bundle(); |
199 // A bundle-specific callback takes precedence over the generic one for | 208 // A bundle-specific callback takes precedence over the generic one for |
200 // the entity type. | 209 // the entity type. |
201 $bundles = $this->entityManager()->getBundleInfo($this->getEntityTypeId()); | 210 $bundles = $this->entityTypeBundleInfo()->getBundleInfo($this->getEntityTypeId()); |
202 if (isset($bundles[$bundle]['uri_callback'])) { | 211 if (isset($bundles[$bundle]['uri_callback'])) { |
203 $uri_callback = $bundles[$bundle]['uri_callback']; | 212 $uri_callback = $bundles[$bundle]['uri_callback']; |
204 } | 213 } |
205 elseif ($entity_uri_callback = $this->getEntityType()->getUriCallback()) { | 214 elseif ($entity_uri_callback = $this->getEntityType()->getUriCallback()) { |
206 $uri_callback = $entity_uri_callback; | 215 $uri_callback = $entity_uri_callback; |
342 /** | 351 /** |
343 * {@inheritdoc} | 352 * {@inheritdoc} |
344 */ | 353 */ |
345 public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { | 354 public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { |
346 if ($operation == 'create') { | 355 if ($operation == 'create') { |
347 return $this->entityManager() | 356 return $this->entityTypeManager() |
348 ->getAccessControlHandler($this->entityTypeId) | 357 ->getAccessControlHandler($this->entityTypeId) |
349 ->createAccess($this->bundle(), $account, [], $return_as_object); | 358 ->createAccess($this->bundle(), $account, [], $return_as_object); |
350 } | 359 } |
351 return $this->entityManager() | 360 return $this->entityTypeManager() |
352 ->getAccessControlHandler($this->entityTypeId) | 361 ->getAccessControlHandler($this->entityTypeId) |
353 ->access($this, $operation, $account, $return_as_object); | 362 ->access($this, $operation, $account, $return_as_object); |
354 } | 363 } |
355 | 364 |
356 /** | 365 /** |
372 | 381 |
373 /** | 382 /** |
374 * {@inheritdoc} | 383 * {@inheritdoc} |
375 */ | 384 */ |
376 public function save() { | 385 public function save() { |
377 return $this->entityManager()->getStorage($this->entityTypeId)->save($this); | 386 $storage = $this->entityTypeManager()->getStorage($this->entityTypeId); |
387 return $storage->save($this); | |
378 } | 388 } |
379 | 389 |
380 /** | 390 /** |
381 * {@inheritdoc} | 391 * {@inheritdoc} |
382 */ | 392 */ |
383 public function delete() { | 393 public function delete() { |
384 if (!$this->isNew()) { | 394 if (!$this->isNew()) { |
385 $this->entityManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]); | 395 $this->entityTypeManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]); |
386 } | 396 } |
387 } | 397 } |
388 | 398 |
389 /** | 399 /** |
390 * {@inheritdoc} | 400 * {@inheritdoc} |
405 | 415 |
406 /** | 416 /** |
407 * {@inheritdoc} | 417 * {@inheritdoc} |
408 */ | 418 */ |
409 public function getEntityType() { | 419 public function getEntityType() { |
410 return $this->entityManager()->getDefinition($this->getEntityTypeId()); | 420 return $this->entityTypeManager()->getDefinition($this->getEntityTypeId()); |
411 } | 421 } |
412 | 422 |
413 /** | 423 /** |
414 * {@inheritdoc} | 424 * {@inheritdoc} |
415 */ | 425 */ |
506 | 516 |
507 /** | 517 /** |
508 * {@inheritdoc} | 518 * {@inheritdoc} |
509 */ | 519 */ |
510 public static function load($id) { | 520 public static function load($id) { |
511 $entity_manager = \Drupal::entityManager(); | 521 $entity_type_repository = \Drupal::service('entity_type.repository'); |
512 return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->load($id); | 522 $entity_type_manager = \Drupal::entityTypeManager(); |
523 $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(get_called_class())); | |
524 return $storage->load($id); | |
513 } | 525 } |
514 | 526 |
515 /** | 527 /** |
516 * {@inheritdoc} | 528 * {@inheritdoc} |
517 */ | 529 */ |
518 public static function loadMultiple(array $ids = NULL) { | 530 public static function loadMultiple(array $ids = NULL) { |
519 $entity_manager = \Drupal::entityManager(); | 531 $entity_type_repository = \Drupal::service('entity_type.repository'); |
520 return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->loadMultiple($ids); | 532 $entity_type_manager = \Drupal::entityTypeManager(); |
533 $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(get_called_class())); | |
534 return $storage->loadMultiple($ids); | |
521 } | 535 } |
522 | 536 |
523 /** | 537 /** |
524 * {@inheritdoc} | 538 * {@inheritdoc} |
525 */ | 539 */ |
526 public static function create(array $values = []) { | 540 public static function create(array $values = []) { |
527 $entity_manager = \Drupal::entityManager(); | 541 $entity_type_repository = \Drupal::service('entity_type.repository'); |
528 return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->create($values); | 542 $entity_type_manager = \Drupal::entityTypeManager(); |
543 $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(get_called_class())); | |
544 return $storage->create($values); | |
529 } | 545 } |
530 | 546 |
531 /** | 547 /** |
532 * Invalidates an entity's cache tags upon save. | 548 * Invalidates an entity's cache tags upon save. |
533 * | 549 * |