Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
||||
}
|
|
@ -60,6 +60,7 @@ abstract class BlockContentTestBase extends WebTestBase {
|
|||
}
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser($this->permissions);
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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().
|
||||
*/
|
||||
|
|
|
@ -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(),
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue