Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -0,0 +1,30 @@
<?php
/**
* @file
* Install, update and uninstall functions for the block_content module.
*/
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Add 'revision_translation_affected' field to 'block_content' entities.
*/
function block_content_update_8001() {
// Install the definition that this field had in
// \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
// at the time that this update function was written. If/when code is
// deployed that changes that definition, the corresponding module must
// implement an update function that invokes
// \Drupal::entityDefinitionUpdateManager()->updateFieldStorageDefinition()
// with the new definition.
$storage_definition = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))
->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
->setReadOnly(TRUE)
->setRevisionable(TRUE)
->setTranslatable(TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('revision_translation_affected', 'block_content', 'block_content', $storage_definition);
}

View file

@ -8,7 +8,7 @@ id: block_content
label: 'Custom block library'
module: views
description: 'Find and manage custom blocks.'
tag: ''
tag: default
base_table: block_content_field_data
base_field: id
core: 8.x
@ -290,12 +290,14 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: short
custom_date_format: ''
timezone: ''
entity_type: block_content
entity_field: changed
plugin_id: date
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
plugin_id: field
operations:
id: operations
table: block_content

View file

@ -8,7 +8,15 @@
"use strict";
/**
* Sets summaries about revision and translation of block content.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches summary behaviour block content form tabs.
*
* Specifically, it updates summaries to the revision information and the
* translation options.
*/
Drupal.behaviors.blockContentDetailsSummaries = {
attach: function (context) {
@ -17,10 +25,11 @@
var $revisionContext = $(context);
var revisionCheckbox = $revisionContext.find('.form-item-revision input');
// Return 'New revision' if the 'Create new revision' checkbox is checked,
// or if the checkbox doesn't exist, but the revision log does. For users
// without the "Administer content" permission the checkbox won't appear,
// but the revision log will if the content type is set to auto-revision.
// Return 'New revision' if the 'Create new revision' checkbox is
// checked, or if the checkbox doesn't exist, but the revision log does.
// For users without the "Administer content" permission the checkbox
// won't appear, but the revision log will if the content type is set
// to auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.form-item-revision-log textarea').length)) {
return Drupal.t('New revision');
}

View file

@ -220,20 +220,4 @@ class BlockContentForm extends ContentEntityForm {
}
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$entity = parent::validateForm($form, $form_state);
if ($entity->isNew()) {
$exists = $this->blockContentStorage->loadByProperties(array('info' => $form_state->getValue(['info', 0, 'value'])));
if (!empty($exists)) {
$form_state->setErrorByName('info', $this->t('A block with description %name already exists.', array(
'%name' => $form_state->getValue(array('info', 0, 'value')),
)));
}
}
return $entity;
}
}

View file

@ -29,7 +29,7 @@ class BlockContentListBuilder extends EntityListBuilder {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $this->getLabel($entity);
$row['label'] = $entity->label();
return $row + parent::buildRow($entity);
}

View file

@ -10,8 +10,6 @@ namespace Drupal\block_content;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ContentLanguageSettings;
/**

View file

@ -189,7 +189,9 @@ class BlockContent extends ContentEntityBase implements BlockContentInterface {
'type' => 'string_textfield',
'weight' => -5,
))
->setDisplayConfigurable('form', TRUE);
->setDisplayConfigurable('form', TRUE)
->addConstraint('BlockContentInfo', []);
$fields['type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Block type'))

View file

@ -0,0 +1,31 @@
<?php
/**
* @file
* Contains \Drupal\block_content\Plugin\Validation\Constraint\BlockContentInfoConstraint.
*/
namespace Drupal\block_content\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
/**
* Supports validating custom block names.
*
* @Constraint(
* id = "BlockContentInfo",
* label = @Translation("Custom block name", context = "Validation")
* )
*/
class BlockContentInfoConstraint extends Constraint {
public $message = 'A block with description %value already exists.';
/**
* {@inheritdoc}
*/
public function validatedBy() {
return '\Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldValueValidator';
}
}

View file

@ -60,6 +60,7 @@ abstract class BlockContentTestBase extends WebTestBase {
}
$this->adminUser = $this->drupalCreateUser($this->permissions);
$this->drupalPlaceBlock('local_actions_block');
}
/**

View file

@ -30,6 +30,18 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
'block_content'
);
/**
* {@inheritdoc}
*/
protected $defaultCacheContexts = [
'languages:language_interface',
'theme',
'url.path',
'url.query_args',
'user.permissions',
'user.roles:authenticated',
];
/**
* Overrides \Drupal\simpletest\WebTestBase::setUp().
*/

View file

@ -0,0 +1,45 @@
<?php
/**
* @file
* Contains \Drupal\block_content\Tests\BlockContentValidationTest.
*/
namespace Drupal\block_content\Tests;
/**
* Tests block content validation constraints.
*
* @group block_content
*/
class BlockContentValidationTest extends BlockContentTestBase {
/**
* Tests the block content validation constraints.
*/
public function testValidation() {
// Add a block.
$description = $this->randomMachineName();
$block = $this->createBlockContent($description, 'basic');
// Validate the block.
$violations = $block->validate();
// Make sure we have no violations.
$this->assertEqual(count($violations), 0);
// Save the block.
$block->save();
// Add another block with the same description.
$block = $this->createBlockContent($description, 'basic');
// Validate this block.
$violations = $block->validate();
// Make sure we have 1 violation.
$this->assertEqual(count($violations), 1);
// Make sure the violation is on the info property
$this->assertEqual($violations[0]->getPropertyPath(), 'info');
// Make sure the message is correct.
$this->assertEqual($violations[0]->getMessage(), format_string('A block with description %value already exists.', [
'%value' => $block->label(),
]));
}
}

View file

@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade custom blocks.
*
* @group block_content
* @group migrate_drupal_6
*/
class MigrateBlockContentTest extends MigrateDrupal6TestBase {
@ -35,7 +35,6 @@ class MigrateBlockContentTest extends MigrateDrupal6TestBase {
array(array(2), array('full_html'))
)
));
$this->loadDumps(['Boxes.php']);
$this->executeMigration('d6_custom_block');
}

View file

@ -24,8 +24,6 @@ class BoxTest extends MigrateSqlSourceTestCase {
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'test',
// Leave it empty for now.
'idlist' => array(),
'source' => array(
'plugin' => 'd6_boxes',
),