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

This commit is contained in:
Pantheon Automation 2016-01-06 16:31:26 -08:00 committed by Greg Anderson
parent 1a0e9d9fac
commit a6b049dd05
538 changed files with 5247 additions and 1594 deletions

View file

@ -6,15 +6,14 @@
*/
namespace Drupal\Core\Entity\Annotation;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Defines a config entity type annotation object.
*
* Config Entity type plugins use an object-based annotation method, rather than an
* array-type annotation method (as commonly used on other annotation types).
* The annotation properties of entity types are found on
* \Drupal\Core\Entity\ConfigEntityType and are accessed using
* \Drupal\Core\Config\Entity\ConfigEntityType and are accessed using
* get/set methods defined in \Drupal\Core\Entity\EntityTypeInterface.
*
* @ingroup entity_api

View file

@ -10,6 +10,7 @@ namespace Drupal\Core\Entity\Element;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Tags;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\Textfield;
@ -146,6 +147,7 @@ class EntityAutocomplete extends Textfield {
'handler' => $element['#selection_handler'],
'handler_settings' => $element['#selection_settings'],
);
/** @var /Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options);
$autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface;
@ -164,6 +166,7 @@ class EntityAutocomplete extends Textfield {
);
}
elseif ($autocreate) {
/** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */
// Auto-create item. See an example of how this is handled in
// \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave().
$value[] = array(
@ -211,6 +214,7 @@ class EntityAutocomplete extends Textfield {
}
foreach ($invalid_new_entities as $entity) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', array('%type' => $element['#target_type'], '%label' => $entity->label())));
}
}
@ -233,6 +237,8 @@ class EntityAutocomplete extends Textfield {
* The method will return an entity ID if one single entity unambuguously
* matches the incoming input, and sill assign form errors otherwise.
*
* @param \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler
* Entity reference selection plugin.
* @param string $input
* Single string from autocomplete element.
* @param array $element
@ -243,10 +249,10 @@ class EntityAutocomplete extends Textfield {
* Whether to trigger a form error if an element from $input (eg. an entity)
* is not found.
*
* @return integer|null
* @return int|null
* Value of a matching entity ID, or NULL if none.
*/
protected static function matchEntityByTitle($handler, $input, &$element, FormStateInterface $form_state, $strict) {
protected static function matchEntityByTitle(SelectionInterface $handler, $input, array &$element, FormStateInterface $form_state, $strict) {
$entities_by_bundle = $handler->getReferenceableEntities($input, '=', 6);
$entities = array_reduce($entities_by_bundle, function ($flattened, $bundle_entities) {
return $flattened + $bundle_entities;

View file

@ -320,11 +320,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* Returns a list of URI relationships supported by this entity.
*
* @return array
* An array of link relationships supported by this entity.
*/
public function uriRelationships() {
return array_keys($this->linkTemplates());
@ -497,9 +492,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* @return static|null
* The entity object or NULL if there is no entity with the given ID.
*/
public static function load($id) {
$entity_manager = \Drupal::entityManager();
@ -508,10 +500,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* @return static[]
* An array of entity objects indexed by their IDs. Returns an empty array
* if no matching entities are found.
*/
public static function loadMultiple(array $ids = NULL) {
$entity_manager = \Drupal::entityManager();
@ -520,9 +508,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* @return static
* The entity object.
*/
public static function create(array $values = array()) {
$entity_manager = \Drupal::entityManager();

View file

@ -206,6 +206,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE) {
$account = $this->prepareUser($account);
$context += array(
'entity_type_id' => $this->entityTypeId,
'langcode' => LanguageInterface::LANGCODE_DEFAULT,
);

View file

@ -113,7 +113,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
* The URL object.
*
* @deprecated in Drupal 8.0.0, intended to be removed in Drupal 9.0.0
* Use toUrl() instead.
* Use \Drupal\Core\Entity\EntityInterface::toUrl() instead.
*
* @see \Drupal\Core\Entity\EntityInterface::toUrl
*/

View file

@ -41,7 +41,7 @@ class EntityReference extends DataReferenceBase {
/**
* The entity ID.
*
* @var integer|string
* @var int|string
*/
protected $id;

View file

@ -257,7 +257,7 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
$entities = $this->entityManager->getStorage($target_type)->loadMultiple($result);
foreach ($entities as $entity_id => $entity) {
$bundle = $entity->bundle();
$options[$bundle][$entity_id] = Html::escape($entity->label());
$options[$bundle][$entity_id] = Html::escape($this->entityManager->getTranslationFromContext($entity)->label());
}
return $options;

View file

@ -592,7 +592,8 @@ function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $o
* The account trying to access the entity.
* @param array $context
* An associative array of additional context values. By default it contains
* language:
* language and the entity type ID:
* - entity_type_id - the entity type ID.
* - langcode - the current language code.
* @param string $entity_bundle
* The entity bundle name.
@ -1964,7 +1965,7 @@ function hook_ENTITY_TYPE_field_values_init(\Drupal\Core\Entity\FieldableEntityI
*
* @return array
* The array structure is identical to that of the return value of
* \Drupal\Core\Entity\EntityManagerInterface::getExtraFields().
* \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields().
*/
function hook_entity_extra_field_info() {
$extra = array();