Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -110,12 +110,12 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
throw new FieldException('Attempt to create a field without a field_name.');
|
||||
}
|
||||
if (empty($values['entity_type'])) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name without an entity_type.', array('@field_name' => $values['field_name'])));
|
||||
throw new FieldException("Attempt to create a field '{$values['field_name']}' without an entity_type.");
|
||||
}
|
||||
}
|
||||
// 'bundle' is required in either case.
|
||||
if (empty($values['bundle'])) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name without a bundle.', array('@field_name' => $values['field_name'])));
|
||||
throw new FieldException("Attempt to create a field '{$values['field_name']}' without a bundle.");
|
||||
}
|
||||
|
||||
parent::__construct($values, $entity_type);
|
||||
|
@ -288,9 +288,10 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
if (!$this->fieldStorage) {
|
||||
$fields = $this->entityManager()->getFieldStorageDefinitions($this->entity_type);
|
||||
if (!isset($fields[$this->field_name])) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); }
|
||||
throw new FieldException('Attempt to create a field {$this->field_name} that does not exist on entity type {$this->entity_type}.');
|
||||
}
|
||||
if (!$fields[$this->field_name] instanceof FieldStorageConfigInterface) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a configurable field of non-configurable field storage @field_name.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));
|
||||
throw new FieldException("Attempt to create a configurable field of non-configurable field storage {$this->field_name}.");
|
||||
}
|
||||
$this->fieldStorage = $fields[$this->field_name];
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\field\Entity;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
@ -242,13 +241,13 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
|
|||
throw new FieldException('Attempt to create a field storage without a field name.');
|
||||
}
|
||||
if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['field_name'])) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character', array('@field_name' => $values['field_name'])));
|
||||
throw new FieldException("Attempt to create a field storage {$values['field_name']} with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character");
|
||||
}
|
||||
if (empty($values['type'])) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with no type.', array('@field_name' => $values['field_name'])));
|
||||
throw new FieldException("Attempt to create a field storage {$values['field_name']} with no type.");
|
||||
}
|
||||
if (empty($values['entity_type'])) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field storage @field_name with no entity_type.', array('@field_name' => $values['field_name'])));
|
||||
throw new FieldException("Attempt to create a field storage {$values['field_name']} with no entity_type.");
|
||||
}
|
||||
|
||||
parent::__construct($values, $entity_type);
|
||||
|
@ -309,24 +308,19 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
|
|||
// We use Unicode::strlen() because the DB layer assumes that column widths
|
||||
// are given in characters rather than bytes.
|
||||
if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) {
|
||||
throw new FieldException(SafeMarkup::format(
|
||||
'Attempt to create a field storage with an name longer than @max characters: %name', array(
|
||||
'@max' => static::NAME_MAX_LENGTH,
|
||||
'%name' => $this->getName(),
|
||||
)
|
||||
));
|
||||
throw new FieldException('Attempt to create a field storage with an name longer than ' . static::NAME_MAX_LENGTH . ' characters: ' . $this->getName());
|
||||
}
|
||||
|
||||
// Disallow reserved field names.
|
||||
$disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId()));
|
||||
if (in_array($this->getName(), $disallowed_field_names)) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->getName(), '%type' => $this->getTargetEntityTypeId())));
|
||||
throw new FieldException("Attempt to create field storage {$this->getName()} which is reserved by entity type {$this->getTargetEntityTypeId()}.");
|
||||
}
|
||||
|
||||
// Check that the field type is known.
|
||||
$field_type = $field_type_manager->getDefinition($this->getType(), FALSE);
|
||||
if (!$field_type) {
|
||||
throw new FieldException(SafeMarkup::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->getType())));
|
||||
throw new FieldException("Attempt to create a field storage of unknown type {$this->getType()}.");
|
||||
}
|
||||
$this->module = $field_type['provider'];
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains Drupal\field\ProxyClass\FieldUninstallValidator.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file was generated via php core/scripts/generate-proxy-class.php 'Drupal\field\FieldUninstallValidator' "core/modules/field/src".
|
||||
*/
|
||||
|
||||
namespace Drupal\field\ProxyClass {
|
||||
|
||||
/**
|
||||
* Provides a proxy class for \Drupal\field\FieldUninstallValidator.
|
||||
*
|
||||
* @see \Drupal\Component\ProxyBuilder
|
||||
*/
|
||||
class FieldUninstallValidator implements \Drupal\Core\Extension\ModuleUninstallValidatorInterface
|
||||
{
|
||||
|
||||
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
||||
/**
|
||||
* The id of the original proxied service.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $drupalProxyOriginalServiceId;
|
||||
|
||||
/**
|
||||
* The real proxied service, after it was lazy loaded.
|
||||
*
|
||||
* @var \Drupal\field\FieldUninstallValidator
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
/**
|
||||
* The service container.
|
||||
*
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructs a ProxyClass Drupal proxy object.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
* The container.
|
||||
* @param string $drupal_proxy_original_service_id
|
||||
* The service ID of the original service.
|
||||
*/
|
||||
public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy loads the real service from the container.
|
||||
*
|
||||
* @return object
|
||||
* Returns the constructed real service.
|
||||
*/
|
||||
protected function lazyLoadItself()
|
||||
{
|
||||
if (!isset($this->service)) {
|
||||
$this->service = $this->container->get($this->drupalProxyOriginalServiceId);
|
||||
}
|
||||
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate($module)
|
||||
{
|
||||
return $this->lazyLoadItself()->validate($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setStringTranslation(\Drupal\Core\StringTranslation\TranslationInterface $translation)
|
||||
{
|
||||
return $this->lazyLoadItself()->setStringTranslation($translation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -200,11 +200,8 @@ class EntityReferenceFormatterTest extends EntityUnitTestBase {
|
|||
';
|
||||
$renderer->renderRoot($build[0]);
|
||||
$this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
|
||||
$expected_cache_tags = Cache::mergeTags(
|
||||
\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(),
|
||||
$this->referencedEntity->getCacheTags(),
|
||||
FilterFormat::load('full_html')->getCacheTags()
|
||||
);
|
||||
$expected_cache_tags = Cache::mergeTags(\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags());
|
||||
$expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags());
|
||||
$this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));
|
||||
|
||||
// Test the second field item.
|
||||
|
|
|
@ -29,6 +29,11 @@ class FieldDataCountTest extends FieldUnitTestBase {
|
|||
*/
|
||||
protected $storageRev;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface
|
||||
*/
|
||||
protected $storageUser;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -37,6 +42,7 @@ class FieldDataCountTest extends FieldUnitTestBase {
|
|||
$this->installEntitySchema('entity_test_rev');
|
||||
$this->storage = \Drupal::entityManager()->getStorage('entity_test');
|
||||
$this->storageRev = \Drupal::entityManager()->getStorage('entity_test_rev');
|
||||
$this->storageUser = \Drupal::entityManager()->getStorage('user');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,4 +142,22 @@ class FieldDataCountTest extends FieldUnitTestBase {
|
|||
$this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $first_revision)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that we can count a table that contains an entry with index 0.
|
||||
*/
|
||||
public function testCountWithIndex0() {
|
||||
// Create an entry for the anonymous user, who has user ID 0.
|
||||
$user = $this->storageUser
|
||||
->create(array(
|
||||
'uid' => 0,
|
||||
'name' => 'anonymous',
|
||||
'mail' => NULL,
|
||||
'status' => FALSE,
|
||||
));
|
||||
$user->save();
|
||||
|
||||
$storage = $user->getFieldDefinition('name')->getFieldStorageDefinition();
|
||||
$this->assertIdentical(TRUE, $this->storageUser->countFieldData($storage, TRUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,9 @@ field.storage_settings.test_field:
|
|||
config_data_from_storage_setting:
|
||||
type: boolean
|
||||
label: 'Test FieldItemInterface::storageSettingsToConfigData()'
|
||||
translatable_storage_setting:
|
||||
type: label
|
||||
label: 'Translatable storage setting'
|
||||
|
||||
field.storage_settings.test_field_with_dependencies:
|
||||
type: field.storage_settings.test_field
|
||||
|
@ -88,6 +91,9 @@ field.field_settings.test_field:
|
|||
config_data_from_field_setting:
|
||||
type: boolean
|
||||
label: 'Test FieldItemInterface::fieldSettingsToConfigData()'
|
||||
translatable_field_setting:
|
||||
type: label
|
||||
label: 'Translatable field setting'
|
||||
|
||||
field.field_settings.test_field_with_dependencies:
|
||||
type: field.field_settings.test_field
|
||||
|
|
|
@ -33,6 +33,7 @@ class TestItem extends FieldItemBase {
|
|||
'test_field_storage_setting' => 'dummy test string',
|
||||
'changeable' => 'a changeable field storage setting',
|
||||
'unchangeable' => 'an unchangeable field storage setting',
|
||||
'translatable_storage_setting' => 'a translatable field storage setting',
|
||||
) + parent::defaultStorageSettings();
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,7 @@ class TestItem extends FieldItemBase {
|
|||
public static function defaultFieldSettings() {
|
||||
return array(
|
||||
'test_field_setting' => 'dummy test string',
|
||||
'translatable_field_setting' => 'a translatable field setting',
|
||||
) + parent::defaultFieldSettings();
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
* Test that invalid bundles are handled.
|
||||
*
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Missing bundle entity, entity type <em class="placeholder">bundle_entity_type</em>, entity id <em class="placeholder">test_bundle_not_exists</em>.
|
||||
* @expectedExceptionMessage Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.
|
||||
*/
|
||||
public function testCalculateDependenciesIncorrectBundle() {
|
||||
$storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
|
||||
|
|
Reference in a new issue