Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Annotation\ConfigEntityType.
*/
namespace Drupal\Core\Entity\Annotation;
use Drupal\Core\StringTranslation\TranslatableMarkup;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Annotation\ContentEntityType.
*/
namespace Drupal\Core\Entity\Annotation;
use Drupal\Core\StringTranslation\TranslatableMarkup;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Annotation\EntityReferenceSelection.
*/
namespace Drupal\Core\Entity\Annotation;
use Drupal\Component\Annotation\Plugin;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Annotation\EntityType.
*/
namespace Drupal\Core\Entity\Annotation;
use Drupal\Component\Annotation\Plugin;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\BundleEntityFormBase.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,17 +1,14 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\Plugin\DataType\EntityReference;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\TypedDataInterface;
/**
@ -1114,6 +1111,64 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
return $value;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type->hasKey('id')) {
$fields[$entity_type->getKey('id')] = BaseFieldDefinition::create('integer')
->setLabel(new TranslatableMarkup('ID'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
}
if ($entity_type->hasKey('uuid')) {
$fields[$entity_type->getKey('uuid')] = BaseFieldDefinition::create('uuid')
->setLabel(new TranslatableMarkup('UUID'))
->setReadOnly(TRUE);
}
if ($entity_type->hasKey('revision')) {
$fields[$entity_type->getKey('revision')] = BaseFieldDefinition::create('integer')
->setLabel(new TranslatableMarkup('Revision ID'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
}
if ($entity_type->hasKey('langcode')) {
$fields[$entity_type->getKey('langcode')] = BaseFieldDefinition::create('language')
->setLabel(new TranslatableMarkup('Language'))
->setDisplayOptions('view', [
'type' => 'hidden',
])
->setDisplayOptions('form', [
'type' => 'language_select',
'weight' => 2,
]);
if ($entity_type->isRevisionable()) {
$fields[$entity_type->getKey('langcode')]->setRevisionable(TRUE);
}
if ($entity_type->isTranslatable()) {
$fields[$entity_type->getKey('langcode')]->setTranslatable(TRUE);
}
}
if ($entity_type->hasKey('bundle')) {
if ($bundle_entity_type_id = $entity_type->getBundleEntityType()) {
$fields[$entity_type->getKey('bundle')] = BaseFieldDefinition::create('entity_reference')
->setLabel($entity_type->getBundleLabel())
->setSetting('target_type', $bundle_entity_type_id)
->setRequired(TRUE)
->setReadOnly(TRUE);
}
else {
$fields[$entity_type->getKey('bundle')] = BaseFieldDefinition::create('string')
->setLabel($entity_type->getBundleLabel())
->setRequired(TRUE)
->setReadOnly(TRUE);
}
}
return $fields;
}
/**
* {@inheritdoc}
*/

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityConfirmFormBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Form\ConfirmFormHelper;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityDeleteForm.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Form\FormStateInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityForm.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityFormInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\TypedData\TranslatableInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityNullStorage.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldDefinitionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityStorageBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Cache\Cache;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityStorageInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityType.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityTypeInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentUninstallValidator.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;

View file

@ -1,24 +1,29 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Controller\EntityController.
*/
namespace Drupal\Core\Entity\Controller;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Routing\UrlGeneratorTrait;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides generic entity title callbacks for use in routing.
* Provides the add-page and title callbacks for entities.
*
* It provides:
* - The add-page callback.
* - An add title callback for entity types.
* - An add title callback for entity types with bundles.
* - A view title callback.
* - An edit title callback.
* - A delete title callback.
@ -26,25 +31,59 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class EntityController implements ContainerInjectionInterface {
use StringTranslationTrait;
use UrlGeneratorTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* The entity type bundle info.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityRepository;
/**
* The renderer.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/**
* Constructs a new EntityController.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation.
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
* The url generator.
*/
public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation) {
$this->entityManager = $entity_manager;
public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityRepositoryInterface $entity_repository, RendererInterface $renderer, TranslationInterface $string_translation, UrlGeneratorInterface $url_generator) {
$this->entityTypeManager = $entity_type_manager;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->entityRepository = $entity_repository;
$this->renderer = $renderer;
$this->stringTranslation = $string_translation;
$this->urlGenerator = $url_generator;
}
/**
@ -52,11 +91,127 @@ class EntityController implements ContainerInjectionInterface {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('string_translation')
$container->get('entity_type.manager'),
$container->get('entity_type.bundle.info'),
$container->get('entity.repository'),
$container->get('renderer'),
$container->get('string_translation'),
$container->get('url_generator')
);
}
/**
* Displays add links for the available bundles.
*
* Redirects to the add form if there's only one bundle available.
*
* @param string $entity_type_id
* The entity type ID.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|array
* If there's only one available bundle, a redirect response.
* Otherwise, a render array with the add links for each bundle.
*/
public function addPage($entity_type_id) {
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
$bundle_key = $entity_type->getKey('bundle');
$bundle_entity_type_id = $entity_type->getBundleEntityType();
$build = [
'#theme' => 'entity_add_list',
'#bundles' => [],
];
if ($bundle_entity_type_id) {
$bundle_argument = $bundle_entity_type_id;
$bundle_entity_type = $this->entityTypeManager->getDefinition($bundle_entity_type_id);
$bundle_entity_type_label = $bundle_entity_type->getLowercaseLabel();
$build['#cache']['tags'] = $bundle_entity_type->getListCacheTags();
// Build the message shown when there are no bundles.
$link_text = $this->t('Add a new @entity_type.', ['@entity_type' => $bundle_entity_type_label]);
$link_route_name = 'entity.' . $bundle_entity_type->id() . '.add_form';
$build['#add_bundle_message'] = $this->t('There is no @entity_type yet. @add_link', [
'@entity_type' => $bundle_entity_type_label,
'@add_link' => Link::createFromRoute($link_text, $link_route_name)->toString(),
]);
// Filter out the bundles the user doesn't have access to.
$access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type_id);
foreach ($bundles as $bundle_name => $bundle_info) {
$access = $access_control_handler->createAccess($bundle_name, NULL, [], TRUE);
if (!$access->isAllowed()) {
unset($bundles[$bundle_name]);
}
$this->renderer->addCacheableDependency($build, $access);
}
// Add descriptions from the bundle entities.
$bundles = $this->loadBundleDescriptions($bundles, $bundle_entity_type);
}
else {
$bundle_argument = $bundle_key;
}
$form_route_name = 'entity.' . $entity_type_id . '.add_form';
// Redirect if there's only one bundle available.
if (count($bundles) == 1) {
$bundle_names = array_keys($bundles);
$bundle_name = reset($bundle_names);
return $this->redirect($form_route_name, [$bundle_argument => $bundle_name]);
}
// Prepare the #bundles array for the template.
foreach ($bundles as $bundle_name => $bundle_info) {
$build['#bundles'][$bundle_name] = [
'label' => $bundle_info['label'],
'description' => isset($bundle_info['description']) ? $bundle_info['description'] : '',
'add_link' => Link::createFromRoute($bundle_info['label'], $form_route_name, [$bundle_argument => $bundle_name]),
];
}
return $build;
}
/**
* Provides a generic add title callback for an entity type.
*
* @param string $entity_type_id
* The entity type ID.
*
* @return string
* The title for the entity add page.
*/
public function addTitle($entity_type_id) {
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
return $this->t('Add @entity-type', ['@entity-type' => $entity_type->getLowercaseLabel()]);
}
/**
* Provides a generic add title callback for entities with bundles.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match.
* @param string $entity_type_id
* The entity type ID.
* @param string $bundle_parameter
* The name of the route parameter that holds the bundle.
*
* @return string
* The title for the entity add page, if the bundle was found.
*/
public function addBundleTitle(RouteMatchInterface $route_match, $entity_type_id, $bundle_parameter) {
$bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
// If the entity has bundle entities, the parameter might have been upcasted
// so fetch the raw parameter.
$bundle = $route_match->getRawParameter($bundle_parameter);
if ((count($bundles) > 1) && isset($bundles[$bundle])) {
return $this->t('Add @bundle', ['@bundle' => $bundles[$bundle]['label']]);
}
// If the entity supports bundles generally, but only has a single bundle,
// the bundle is probably something like 'Default' so that it preferable to
// use the entity type label.
else {
return $this->addTitle($entity_type_id);
}
}
/**
* Provides a generic title callback for a single entity.
*
@ -65,8 +220,8 @@ class EntityController implements ContainerInjectionInterface {
* @param \Drupal\Core\Entity\EntityInterface $_entity
* (optional) An entity, passed in directly from the request attributes.
*
* @return string
* The title for the entity view page.
* @return string|null
* The title for the entity view page, if an entity was found.
*/
public function title(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
if ($entity = $this->doGetEntity($route_match, $_entity)) {
@ -82,8 +237,8 @@ class EntityController implements ContainerInjectionInterface {
* @param \Drupal\Core\Entity\EntityInterface $_entity
* (optional) An entity, passed in directly from the request attributes.
*
* @return string
* The title for the entity edit page.
* @return string|null
* The title for the entity edit page, if an entity was found.
*/
public function editTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
if ($entity = $this->doGetEntity($route_match, $_entity)) {
@ -101,7 +256,7 @@ class EntityController implements ContainerInjectionInterface {
* set in \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer.
*
* @return string
* The title for the delete entity page.
* The title for the entity delete page.
*/
public function deleteTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
if ($entity = $this->doGetEntity($route_match, $_entity)) {
@ -135,9 +290,37 @@ class EntityController implements ContainerInjectionInterface {
}
}
}
if ($entity) {
return $this->entityManager->getTranslationFromContext($entity);
if (isset($entity)) {
return $this->entityRepository->getTranslationFromContext($entity);
}
}
/**
* Expands the bundle information with descriptions, if known.
*
* @param array $bundles
* An array of bundle information.
* @param \Drupal\Core\Entity\EntityTypeInterface $bundle_entity_type
* The ID of the bundle entity type.
*
* @return array
* The expanded array of bundle information.
*/
protected function loadBundleDescriptions(array $bundles, EntityTypeInterface $bundle_entity_type) {
if (!$bundle_entity_type->isSubclassOf('\Drupal\Core\Entity\EntityDescriptionInterface')) {
return $bundles;
}
$bundle_names = array_keys($bundles);
$storage = $this->entityTypeManager->getStorage($bundle_entity_type->id());
/** @var \Drupal\Core\Entity\EntityDescriptionInterface[] $bundle_entities */
$bundle_entities = $storage->loadMultiple($bundle_names);
foreach ($bundles as $bundle_name => &$bundle_info) {
if (isset($bundle_entities[$bundle_name])) {
$bundle_info['description'] = $bundle_entities[$bundle_name]->getDescription();
}
}
return $bundles;
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Controller\EntityListController.
*/
namespace Drupal\Core\Entity\Controller;
use Drupal\Core\Controller\ControllerBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Controller\EntityViewController.
*/
namespace Drupal\Core\Entity\Controller;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
@ -104,8 +99,25 @@ class EntityViewController implements ContainerInjectionInterface {
$page['#entity_type'] = $_entity->getEntityTypeId();
$page['#' . $page['#entity_type']] = $_entity;
return $page;
}
/**
* Provides a page to render a single entity revision.
*
* @param \Drupal\Core\Entity\EntityInterface $_entity_revision
* The Entity to be rendered. Note this variable is named $_entity_revision
* rather than $entity to prevent collisions with other named placeholders
* in the route.
* @param string $view_mode
* (optional) The view mode that should be used to display the entity.
* Defaults to 'full'.
*
* @return array
* A render array.
*/
public function viewRevision(EntityInterface $_entity_revision, $view_mode = 'full') {
return $this->view($_entity_revision, $view_mode);
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\DependencyTrait.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Display\EntityDisplayInterface.
*/
namespace Drupal\Core\Entity\Display;
use Drupal\Core\Config\Entity\ConfigEntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Display\EntityFormDisplayInterface.
*/
namespace Drupal\Core\Entity\Display;
use Drupal\Core\Entity\EntityConstraintViolationListInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Display\EntityViewDisplayInterface.
*/
namespace Drupal\Core\Entity\Display;
use Drupal\Core\Entity\FieldableEntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldDefinitionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Element\EntityAutocomplete.
*/
namespace Drupal\Core\Entity\Element;
use Drupal\Component\Utility\Crypt;
@ -290,7 +285,7 @@ class EntityAutocomplete extends Textfield {
/**
* Converts an array of entity objects into a string of entity labels.
*
* This method is also responsible for checking the 'view' access on the
* This method is also responsible for checking the 'view label' access on the
* passed-in entities.
*
* @param \Drupal\Core\Entity\EntityInterface[] $entities
@ -302,7 +297,9 @@ class EntityAutocomplete extends Textfield {
public static function getEntityLabels(array $entities) {
$entity_labels = array();
foreach ($entities as $entity) {
$label = ($entity->access('view')) ? $entity->label() : t('- Restricted access -');
// Use the special view label, since some entities allow the label to be
// viewed, even if the entity is not allowed to be viewed.
$label = ($entity->access('view label')) ? $entity->label() : t('- Restricted access -');
// Take into account "autocreated" entities.
if (!$entity->isNew()) {

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer.
*/
namespace Drupal\Core\Entity\Enhancer;
use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Entity.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Cache\Cache;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Entity\EntityFormDisplay.
*/
namespace Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\EntityConstraintViolationListInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Entity\EntityFormMode.
*/
namespace Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\EntityDisplayModeBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Entity\EntityViewDisplay.
*/
namespace Drupal\Core\Entity\Entity;
use Drupal\Component\Utility\NestedArray;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Entity\EntityViewMode.
*/
namespace Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\EntityDisplayModeBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityAccessCheck.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Access\AccessResult;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityAccessControlHandler.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Access\AccessResult;
@ -39,6 +34,16 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
*/
protected $entityType;
/**
* Allows to grant access to just the labels.
*
* By default, the "view label" operation falls back to "view". Set this to
* TRUE to allow returning different access when just listing entity labels.
*
* @var bool
*/
protected $viewLabelOperation = FALSE;
/**
* Constructs an access control handler instance.
*
@ -57,6 +62,10 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
$account = $this->prepareUser($account);
$langcode = $entity->language()->getId();
if ($operation === 'view label' && $this->viewLabelOperation == FALSE) {
$operation = 'view';
}
if (($return = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) {
// Cache hit, no work necessary.
return $return_as_object ? $return : $return->isAllowed();
@ -124,7 +133,8 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity for which to check access.
* @param string $operation
* The entity operation. Usually one of 'view', 'update' or 'delete'.
* The entity operation. Usually one of 'view', 'view label', 'update' or
* 'delete'.
* @param \Drupal\Core\Session\AccountInterface $account
* The user for which to check access.
*
@ -133,7 +143,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'delete' && $entity->isNew()) {
return AccessResult::forbidden()->cacheUntilEntityChanges($entity);
return AccessResult::forbidden()->addCacheableDependency($entity);
}
if ($admin_permission = $this->entityType->getAdminPermission()) {
return AccessResult::allowedIfHasPermission($account, $this->entityType->getAdminPermission());

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityAccessControlHandlerInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldItemListInterface;
@ -27,7 +22,7 @@ interface EntityAccessControlHandlerInterface {
* The entity for which to check access.
* @param string $operation
* The operation access should be checked for.
* Usually one of "view", "update" or "delete".
* Usually one of "view", "view label", "update" or "delete".
* @param \Drupal\Core\Session\AccountInterface $account
* (optional) The user session for which to check access, or NULL to check
* access for the current user. Defaults to NULL.
@ -96,7 +91,7 @@ interface EntityAccessControlHandlerInterface {
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The field definition.
* @param \Drupal\Core\Session\AccountInterface $account
* (optional) The user session for which to check access, or NULL to check
* (optional) The user session for which to check access, or NULL to check
* access for the current user. Defaults to NULL.
* @param \Drupal\Core\Field\FieldItemListInterface $items
* (optional) The field values for which to check access, or NULL if access

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityAutocompleteMatcher.
*/
namespace Drupal\Core\Entity;
use Drupal\Component\Utility\Html;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityBundleListener.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Extension\ModuleHandlerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityBundleListenerInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityChangedInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityChangedTrait.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityConfirmFormBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Form\ConfirmFormHelper;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityConstraintViolationList.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Plugin\Validation\Constraint\CompositeConstraintBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityConstraintViolationListInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Session\AccountInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityCreateAccessCheck.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Access\AccessResult;

View file

@ -0,0 +1,104 @@
<?php
namespace Drupal\Core\Entity;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\Routing\Route;
/**
* Defines an access checker for creating an entity of any bundle.
*/
class EntityCreateAnyAccessCheck implements AccessInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The entity type bundle info.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;
/**
* The key used by the routing requirement.
*
* @var string
*/
protected $requirementsKey = '_entity_create_any_access';
/**
* Constructs a EntityCreateAnyAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
$this->entityTypeManager = $entity_type_manager;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
}
/**
* Checks access to create an entity of any bundle for the given route.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The parameterized route.
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
$entity_type_id = $route->getRequirement($this->requirementsKey);
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type_id);
// In case there is no "bundle" entity key, check create access with no
// bundle specified.
if (!$entity_type->hasKey('bundle')) {
return $access_control_handler->createAccess(NULL, $account, [], TRUE);
}
$access = AccessResult::neutral();
$bundles = array_keys($this->entityTypeBundleInfo->getBundleInfo($entity_type_id));
// Include list cache tag as access might change if more bundles are added.
if ($entity_type->getBundleEntityType()) {
$access->addCacheTags($this->entityTypeManager->getDefinition($entity_type->getBundleEntityType())->getListCacheTags());
// Check if the user is allowed to create new bundles. If so, allow
// access, so the add page can show a link to create one.
// @see \Drupal\Core\Entity\Controller\EntityController::addPage()
$bundle_access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type->getBundleEntityType());
$access = $access->orIf($bundle_access_control_handler->createAccess(NULL, $account, [], TRUE));
if ($access->isAllowed()) {
return $access;
}
}
// Check whether an entity of any bundle may be created.
foreach ($bundles as $bundle) {
$access = $access->orIf($access_control_handler->createAccess($bundle, $account, [], TRUE));
// In case there is a least one bundle user can create entities for,
// access is allowed.
if ($access->isAllowed()) {
break;
}
}
return $access;
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDefinitionUpdateManager.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Schema\DynamicallyFieldableEntityStorageSchemaInterface;
@ -53,15 +48,14 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte
// Process entity type definition changes.
if (!empty($change_list['entity_type'])) {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$t_args = array('%entity_type' => $entity_type->getLabel());
switch ($change_list['entity_type']) {
case static::DEFINITION_CREATED:
$summary[$entity_type_id][] = $this->t('Create the %entity_type entity type.', $t_args);
$summary[$entity_type_id][] = $this->t('The %entity_type entity type needs to be installed.', ['%entity_type' => $entity_type->getLabel()]);
break;
case static::DEFINITION_UPDATED:
$summary[$entity_type_id][] = $this->t('Update the %entity_type entity type.', $t_args);
$summary[$entity_type_id][] = $this->t('The %entity_type entity type needs to be updated.', ['%entity_type' => $entity_type->getLabel()]);
break;
}
}
@ -74,15 +68,15 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte
foreach ($change_list['field_storage_definitions'] as $field_name => $change) {
switch ($change) {
case static::DEFINITION_CREATED:
$summary[$entity_type_id][] = $this->t('Create the %field_name field.', array('%field_name' => $storage_definitions[$field_name]->getLabel()));
$summary[$entity_type_id][] = $this->t('The %field_name field needs to be installed.', ['%field_name' => $storage_definitions[$field_name]->getLabel()]);
break;
case static::DEFINITION_UPDATED:
$summary[$entity_type_id][] = $this->t('Update the %field_name field.', array('%field_name' => $storage_definitions[$field_name]->getLabel()));
$summary[$entity_type_id][] = $this->t('The %field_name field needs to be updated.', ['%field_name' => $storage_definitions[$field_name]->getLabel()]);
break;
case static::DEFINITION_DELETED:
$summary[$entity_type_id][] = $this->t('Delete the %field_name field.', array('%field_name' => $original_storage_definitions[$field_name]->getLabel()));
$summary[$entity_type_id][] = $this->t('The %field_name field needs to be uninstalled.', ['%field_name' => $original_storage_definitions[$field_name]->getLabel()]);
break;
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldStorageDefinitionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDeleteForm.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDeleteFormTrait.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait;

View file

@ -0,0 +1,28 @@
<?php
namespace Drupal\Core\Entity;
/**
* Defines the interface for entities that have a description.
*/
interface EntityDescriptionInterface {
/**
* Gets the entity description.
*
* @return string
* The entity description.
*/
public function getDescription();
/**
* Sets the entity description.
*
* @param string $description
* The entity description.
*
* @return $this
*/
public function setDescription($description);
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDisplayBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDisplayModeBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDisplayModeInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDisplayPluginCollection.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Plugin\DefaultLazyPluginCollection;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDisplayRepository.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Cache\CacheBackendInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityDisplayRepositoryInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFieldManager.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Cache\Cache;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFieldManagerInterface.
*/
namespace Drupal\Core\Entity;
/**
@ -73,7 +68,8 @@ interface EntityFieldManagerInterface {
* An array keyed by entity type. Each value is an array which keys are
* field names and value is an array with two entries:
* - type: The field type.
* - bundles: The bundles in which the field appears.
* - bundles: An associative array of the bundles in which the field
* appears, where the keys and values are both the bundle's machine name.
*/
public function getFieldMap();
@ -97,7 +93,8 @@ interface EntityFieldManagerInterface {
* An array keyed by entity type. Each value is an array which keys are
* field names and value is an array with two entries:
* - type: The field type.
* - bundles: The bundles in which the field appears.
* - bundles: An associative array of the bundles in which the field
* appears, where the keys and values are both the bundle's machine name.
*/
public function getFieldMapByFieldType($field_type);

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityForm.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Form\FormBase;
@ -358,7 +353,19 @@ class EntityForm extends FormBase implements EntityFormInterface {
$entity = $route_match->getParameter($entity_type_id);
}
else {
$entity = $this->entityManager->getStorage($entity_type_id)->create([]);
$values = [];
// If the entity has bundles, fetch it from the route match.
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
if ($bundle_key = $entity_type->getKey('bundle')) {
if (($bundle_entity_type_id = $entity_type->getBundleEntityType()) && $route_match->getRawParameter($bundle_entity_type_id)) {
$values[$bundle_key] = $route_match->getParameter($bundle_entity_type_id)->id();
}
elseif ($route_match->getRawParameter($bundle_key)) {
$values[$bundle_key] = $route_match->getParameter($bundle_key);
}
}
$entity = $this->entityTypeManager->getStorage($entity_type_id)->create($values);
}
return $entity;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFormBuilder.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Form\FormBuilderInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFormBuilderInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFormInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Extension\ModuleHandlerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFormModeInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityHandlerBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityHandlerInterface.
*/
namespace Drupal\Core\Entity;
use Symfony\Component\DependencyInjection\ContainerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Access\AccessibleInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityLastInstalledSchemaRepository.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldStorageDefinitionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldStorageDefinitionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityListBuilder.
*/
namespace Drupal\Core\Entity;
use Symfony\Component\DependencyInjection\ContainerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityListBuilderInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityMalformedException.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityManager.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldDefinitionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityManagerInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldDefinitionListenerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface.
*/
namespace Drupal\Core\Entity\EntityReferenceSelection;
use Drupal\Core\Database\Query\SelectInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager.
*/
namespace Drupal\Core\Entity\EntityReferenceSelection;
use Drupal\Component\Plugin\FallbackPluginManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface.
*/
namespace Drupal\Core\Entity\EntityReferenceSelection;
use Drupal\Component\Plugin\PluginManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface.
*/
namespace Drupal\Core\Entity\EntityReferenceSelection;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityRepository.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityTypeInterface;
@ -56,7 +51,7 @@ class EntityRepository implements EntityRepositoryInterface {
$entities = $this->entityTypeManager->getStorage($entity_type_id)->loadByProperties([$uuid_key => $uuid]);
return reset($entities);
return ($entities) ? reset($entities) : NULL;
}
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityRepositoryInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityResolverManager.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\ClassResolverInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityStorageBase.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Query\QueryInterface;
@ -163,7 +158,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
*
* @param string $hook
* One of 'presave', 'insert', 'update', 'predelete', 'delete', or
* 'revision_delete'.
* 'revision_delete'.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
*/

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityStorageException.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityStorageInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,15 +1,11 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityType.
*/
namespace Drupal\Core\Entity;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Exception\EntityTypeIdLengthException;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Provides an implementation of an entity type and its metadata.
@ -185,6 +181,29 @@ class EntityType implements EntityTypeInterface {
*/
protected $label = '';
/**
* The indefinite singular name of the type.
*
* @var string
*/
protected $label_singular = '';
/**
* The indefinite plural name of the type.
*
* @var string
*/
protected $label_plural = '';
/**
* A definite singular/plural name of the type.
*
* Needed keys: "singular" and "plural".
*
* @var string[]
*/
protected $label_count = [];
/**
* A callable that can be used to provide the entity URI.
*
@ -290,7 +309,6 @@ class EntityType implements EntityTypeInterface {
if (empty($this->list_cache_tags)) {
$this->list_cache_tags = [$definition['id'] . '_list'];
}
}
/**
@ -720,6 +738,39 @@ class EntityType implements EntityTypeInterface {
return Unicode::strtolower($this->getLabel());
}
/**
* {@inheritdoc}
*/
public function getSingularLabel() {
if (empty($this->label_singular)) {
$lowercase_label = $this->getLowercaseLabel();
$this->label_singular = $lowercase_label;
}
return $this->label_singular;
}
/**
* {@inheritdoc}
*/
public function getPluralLabel() {
if (empty($this->label_plural)) {
$lowercase_label = $this->getLowercaseLabel();
$this->label_plural = new TranslatableMarkup('@label entities', ['@label' => $lowercase_label], [], $this->getStringTranslation());
}
return $this->label_plural;
}
/**
* {@inheritdoc}
*/
public function getCountLabel($count) {
if (empty($this->label_count)) {
return $this->formatPlural($count, '@count @label', '@count @label entities', ['@label' => $this->getLowercaseLabel()], ['context' => 'Entity type label']);
}
$context = isset($this->label_count['context']) ? $this->label_count['context'] : 'Entity type label';
return $this->formatPlural($count, $this->label_count['singular'], $this->label_count['plural'], ['context' => $context]);
}
/**
* {@inheritdoc}
*/

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeBundleInfo.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Cache\Cache;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeBundleInfoInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeEvent.
*/
namespace Drupal\Core\Entity;
use Symfony\Component\EventDispatcher\GenericEvent;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeEventSubscriberTrait.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeEvents.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\Definition\PluginDefinitionInterface;
@ -630,6 +625,33 @@ interface EntityTypeInterface extends PluginDefinitionInterface {
*/
public function getLowercaseLabel();
/**
* Gets the singular label of the entity type.
*
* @return string
* The singular label.
*/
public function getSingularLabel();
/**
* Gets the plural label of the entity type.
*
* @return string
* The plural label.
*/
public function getPluralLabel();
/**
* Gets the count label of the entity type
*
* @param int $count
* The item count to display if the plural form was requested.
*
* @return string
* The count label.
*/
public function getCountLabel($count);
/**
* Gets a callable that can be used to provide the entity URI.
*

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeListener.
*/
namespace Drupal\Core\Entity;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeListenerInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeManager.
*/
namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeManagerInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeRepository.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Exception\AmbiguousEntityClassException;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityTypeRepositoryInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityViewBuilder.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Cache\Cache;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityViewBuilderInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Field\FieldItemInterface;
@ -104,7 +99,7 @@ interface EntityViewBuilderInterface {
* @param \Drupal\Core\Field\FieldItemListInterface $items
* FieldItemList containing the values to be displayed.
* @param string|array $display_options
* Can be either:
* Can be either:
* - The name of a view mode. The field will be displayed according to the
* display settings specified for this view mode in the $field
* definition for the field in the entity's bundle. If no display settings

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityViewModeInterface.
*/
namespace Drupal\Core\Entity;
/**

View file

@ -1,12 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityWithPluginCollectionInterface.
*/
namespace Drupal\Core\Entity;
use Drupal\Core\Plugin\ObjectWithPluginCollectionInterface;
/**
* Provides an interface for an object using a plugin collection.
*
@ -14,15 +11,6 @@ namespace Drupal\Core\Entity;
*
* @ingroup plugin_api
*/
interface EntityWithPluginCollectionInterface extends EntityInterface {
/**
* Gets the plugin collections used by this entity.
*
* @return \Drupal\Component\Plugin\LazyPluginCollection[]
* An array of plugin collections, keyed by the property name they use to
* store their configuration.
*/
public function getPluginCollections();
interface EntityWithPluginCollectionInterface extends EntityInterface, ObjectWithPluginCollectionInterface {
}

Some files were not shown because too many files have changed in this diff Show more