Update to Drupal 8.1.2. For more information, see https://www.drupal.org/project/drupal/releases/8.1.2

This commit is contained in:
Pantheon Automation 2016-06-02 15:56:09 -07:00 committed by Greg Anderson
parent 9eae24d844
commit 28556d630e
1322 changed files with 6699 additions and 2064 deletions

View file

@ -28,11 +28,11 @@ class ContentEntityType extends EntityType implements ContentEntityTypeInterface
/**
* {@inheritdoc}
*
* @see \Drupal\Core\Entity\ContentEntityStorageInterface.
*
* @throws \InvalidArgumentException
* If the provided class does not implement
* \Drupal\Core\Entity\ContentEntityStorageInterface.
*
* @see \Drupal\Core\Entity\ContentEntityStorageInterface
*/
protected function checkStorageClass($class) {
$required_interface = ContentEntityStorageInterface::class;

View file

@ -57,19 +57,33 @@ class EntityAutocomplete extends Textfield {
if (is_array($element['#default_value']) && $element['#tags'] !== TRUE) {
throw new \InvalidArgumentException('The #default_value property is an array but the form element does not allow multiple values.');
}
elseif (!is_array($element['#default_value'])) {
elseif (!empty($element['#default_value']) && !is_array($element['#default_value'])) {
// Convert the default value into an array for easier processing in
// static::getEntityLabels().
$element['#default_value'] = array($element['#default_value']);
}
if ($element['#default_value'] && !(reset($element['#default_value']) instanceof EntityInterface)) {
throw new \InvalidArgumentException('The #default_value property has to be an entity object or an array of entity objects.');
}
if ($element['#default_value']) {
if (!(reset($element['#default_value']) instanceof EntityInterface)) {
throw new \InvalidArgumentException('The #default_value property has to be an entity object or an array of entity objects.');
}
// Extract the labels from the passed-in entity objects, taking access
// checks into account.
return static::getEntityLabels($element['#default_value']);
// Extract the labels from the passed-in entity objects, taking access
// checks into account.
return static::getEntityLabels($element['#default_value']);
}
}
// Potentially the #value is set directly, so it contains the 'target_id'
// array structure instead of a string.
if ($input !== FALSE && is_array($input)) {
$entity_ids = array_map(function(array $item) {
return $item['target_id'];
}, $input);
$entities = \Drupal::entityTypeManager()->getStorage($element['#target_type'])->loadMultiple($entity_ids);
return static::getEntityLabels($entities);
}
}
@ -136,6 +150,7 @@ class EntityAutocomplete extends Textfield {
*/
public static function validateEntityAutocomplete(array &$element, FormStateInterface $form_state, array &$complete_form) {
$value = NULL;
if (!empty($element['#value'])) {
$options = array(
'target_type' => $element['#target_type'],
@ -146,27 +161,35 @@ class EntityAutocomplete extends Textfield {
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options);
$autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface;
$input_values = $element['#tags'] ? Tags::explode($element['#value']) : array($element['#value']);
foreach ($input_values as $input) {
$match = static::extractEntityIdFromAutocompleteInput($input);
if ($match === NULL) {
// Try to get a match from the input string when the user didn't use
// the autocomplete but filled in a value manually.
$match = static::matchEntityByTitle($handler, $input, $element, $form_state, !$autocreate);
}
// GET forms might pass the validated data around on the next request, in
// which case it will already be in the expected format.
if (is_array($element['#value'])) {
$value = $element['#value'];
}
else {
$input_values = $element['#tags'] ? Tags::explode($element['#value']) : array($element['#value']);
if ($match !== NULL) {
$value[] = array(
'target_id' => $match,
);
}
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(
'entity' => $handler->createNewEntity($element['#target_type'], $element['#autocreate']['bundle'], $input, $element['#autocreate']['uid']),
);
foreach ($input_values as $input) {
$match = static::extractEntityIdFromAutocompleteInput($input);
if ($match === NULL) {
// Try to get a match from the input string when the user didn't use
// the autocomplete but filled in a value manually.
$match = static::matchEntityByTitle($handler, $input, $element, $form_state, !$autocreate);
}
if ($match !== NULL) {
$value[] = array(
'target_id' => $match,
);
}
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(
'entity' => $handler->createNewEntity($element['#target_type'], $element['#autocreate']['bundle'], $input, $element['#autocreate']['uid']),
);
}
}
}

View file

@ -301,4 +301,5 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
'formatters' => new EntityDisplayPluginCollection($this->pluginManager, $configurations)
);
}
}

View file

@ -42,4 +42,5 @@ interface EntityChangedInterface {
* translations.
*/
public function getChangedTimeAcrossTranslations();
}

View file

@ -45,4 +45,5 @@ trait EntityChangedTrait {
$this->set('changed', $timestamp);
return $this;
}
}

View file

@ -26,4 +26,5 @@ interface EntityDisplayModeInterface extends ConfigEntityInterface {
* @return $this
*/
public function setTargetType($target_entity_type);
}

View file

@ -159,7 +159,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* @param string $hook
* One of 'presave', 'insert', 'update', 'predelete', 'delete', or
* 'revision_delete'.
* @param \Drupal\Core\Entity\EntityInterface $entity
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
*/
protected function invokeHook($hook, EntityInterface $entity) {

View file

@ -28,7 +28,6 @@ class QueryFactory implements QueryFactoryInterface {
/**
* Constructs a QueryFactory object.
*
*/
public function __construct(KeyValueFactoryInterface $key_value_factory) {
$this->keyValueFactory = $key_value_factory;

View file

@ -93,4 +93,5 @@ class EntityDeriver implements ContainerDeriverInterface {
}
return $this->derivatives;
}
}

View file

@ -121,4 +121,5 @@ class EntityReference extends DataReferenceBase {
}
return '';
}
}

View file

@ -55,4 +55,5 @@ class BundleConstraint extends Constraint {
public function getRequiredOptions() {
return array('bundle');
}
}

View file

@ -16,4 +16,5 @@ use Symfony\Component\Validator\Constraint;
class EntityChangedConstraint extends Constraint {
public $message = 'The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.';
}

View file

@ -42,4 +42,5 @@ class EntityTypeConstraint extends Constraint {
public function getRequiredOptions() {
return array('type');
}
}

View file

@ -47,4 +47,5 @@ class ReferenceAccessConstraintValidator extends ConstraintValidator {
}
}
}
}

View file

@ -20,4 +20,5 @@ abstract class ConditionBase extends ConditionFundamentals implements ConditionI
return $this;
}
}

View file

@ -72,4 +72,5 @@ interface ConditionInterface {
* The query object this conditional clause belongs to.
*/
public function compile($query);
}

View file

@ -42,4 +42,5 @@ class Query extends QueryBase implements QueryInterface, QueryAggregateInterface
public function conditionAggregateGroupFactory($conjunction = 'AND') {
return new ConditionAggregate($conjunction, $this);
}
}

View file

@ -48,7 +48,6 @@ interface QueryAggregateInterface extends QueryInterface {
* The aggregation function, for example COUNT or MIN.
* @param mixed $value
* The actual value of the field.
*
* @param $operator
* Possible values:
* - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS',
@ -58,14 +57,13 @@ interface QueryAggregateInterface extends QueryInterface {
* literals of the same type as the column.
* - 'BETWEEN': This operator expects $value to be an array of two literals
* of the same type as the column.
*
* @param string $langcode
* (optional) The language code.
*
* @return \Drupal\Core\Entity\Query\QueryAggregateInterface
* The called object.
*
* @see \Drupal\Core\Entity\Query\QueryInterface::condition().
* @see \Drupal\Core\Entity\Query\QueryInterface::condition()
*/
public function conditionAggregate($field, $function = NULL, $value = NULL, $operator = '=', $langcode = NULL);

View file

@ -442,7 +442,7 @@ abstract class QueryBase implements QueryInterface {
* The alias for the field.
*/
protected function getAggregationAlias($field, $function) {
return strtolower($field . '_'. $function);
return strtolower($field . '_' . $function);
}
/**

View file

@ -118,7 +118,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
* Returns the called object.
*/
protected function addSortAggregate() {
if(!$this->count) {
if (!$this->count) {
foreach ($this->sortAggregate as $alias => $sort) {
$this->sqlQuery->orderBy($alias, $sort['direction']);
}

View file

@ -33,4 +33,5 @@ class Condition extends BaseCondition {
}
parent::translateCondition($condition, $sql_query, $case_sensitive);
}
}

View file

@ -185,7 +185,7 @@ class DefaultTableMapping implements TableMappingInterface {
public function getColumnNames($field_name) {
if (!isset($this->columnMapping[$field_name])) {
$this->columnMapping[$field_name] = array();
if (isset($this->fieldStorageDefinitions[$field_name])) {
if (isset($this->fieldStorageDefinitions[$field_name]) && !$this->fieldStorageDefinitions[$field_name]->hasCustomStorage()) {
foreach (array_keys($this->fieldStorageDefinitions[$field_name]->getColumns()) as $property_name) {
$this->columnMapping[$field_name][$property_name] = $this->getFieldColumnName($this->fieldStorageDefinitions[$field_name], $property_name);
}

View file

@ -36,7 +36,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*
* @ingroup entity_api
*/
class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEntityStorageInterface, DynamicallyFieldableEntityStorageSchemaInterface, EntityBundleListenerInterface {
class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEntityStorageInterface, DynamicallyFieldableEntityStorageSchemaInterface, EntityBundleListenerInterface {
/**
* The mapping of field columns to SQL tables.

View file

@ -44,4 +44,5 @@ interface EntityDataDefinitionInterface extends ComplexDataDefinitionInterface {
* @return $this
*/
public function setBundles(array $bundles = NULL);
}

View file

@ -883,6 +883,9 @@ function hook_ENTITY_TYPE_storage_load(array $entities) {
/**
* Act on an entity before it is created or updated.
*
* You can get the original entity object from $entity->original when it is an
* update of the entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
*
@ -899,6 +902,9 @@ function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
/**
* Act on a specific type of entity before it is created or updated.
*
* You can get the original entity object from $entity->original when it is an
* update of the entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
*
@ -963,7 +969,8 @@ function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
* Respond to updates to an entity.
*
* This hook runs once the entity storage has been updated. Note that hook
* implementations may not alter the stored entity data.
* implementations may not alter the stored entity data. Get the original entity
* object from $entity->original.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
@ -986,7 +993,8 @@ function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
* Respond to updates to an entity of a particular type.
*
* This hook runs once the entity storage has been updated. Note that hook
* implementations may not alter the stored entity data.
* implementations may not alter the stored entity data. Get the original entity
* object from $entity->original.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.