Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
|
@ -117,7 +117,9 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParentId() {
|
||||
return $this->get('parent')->value;
|
||||
// Cast the parent ID to a string, only an empty string means no parent,
|
||||
// NULL keeps the existing parent.
|
||||
return (string) $this->get('parent')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,23 +235,20 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
||||
$fields['id'] = BaseFieldDefinition::create('integer')
|
||||
->setLabel(t('Entity ID'))
|
||||
->setDescription(t('The entity ID for this menu link content entity.'))
|
||||
->setReadOnly(TRUE)
|
||||
->setSetting('unsigned', TRUE);
|
||||
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
|
||||
$fields = parent::baseFieldDefinitions($entity_type);
|
||||
|
||||
$fields['uuid'] = BaseFieldDefinition::create('uuid')
|
||||
->setLabel(t('UUID'))
|
||||
->setDescription(t('The content menu link UUID.'))
|
||||
->setReadOnly(TRUE);
|
||||
$fields['id']->setLabel(t('Entity ID'))
|
||||
->setDescription(t('The entity ID for this menu link content entity.'));
|
||||
|
||||
$fields['bundle'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Bundle'))
|
||||
$fields['uuid']->setDescription(t('The content menu link UUID.'));
|
||||
|
||||
$fields['langcode']->setDescription(t('The menu link language code.'));
|
||||
|
||||
$fields['bundle']
|
||||
->setDescription(t('The content menu link bundle.'))
|
||||
->setSetting('max_length', EntityTypeInterface::BUNDLE_MAX_LENGTH)
|
||||
->setSetting('is_ascii', TRUE)
|
||||
->setReadOnly(TRUE);
|
||||
->setSetting('is_ascii', TRUE);
|
||||
|
||||
$fields['title'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Menu link title'))
|
||||
|
@ -334,7 +333,7 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
|
|||
'type' => 'boolean',
|
||||
'weight' => 0,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
->setDisplayOptions('form', array(
|
||||
'settings' => array('display_label' => TRUE),
|
||||
'weight' => 0,
|
||||
));
|
||||
|
@ -353,18 +352,6 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
|
|||
'weight' => -1,
|
||||
));
|
||||
|
||||
$fields['langcode'] = BaseFieldDefinition::create('language')
|
||||
->setLabel(t('Language'))
|
||||
->setDescription(t('The menu link language code.'))
|
||||
->setTranslatable(TRUE)
|
||||
->setDisplayOptions('view', array(
|
||||
'type' => 'hidden',
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'language_select',
|
||||
'weight' => 2,
|
||||
));
|
||||
|
||||
$fields['parent'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Parent plugin ID'))
|
||||
->setDescription(t('The ID of the parent menu link plugin, or empty string when at the top level of the hierarchy.'));
|
||||
|
|
|
@ -188,6 +188,20 @@ class LinksTest extends WebTestBase {
|
|||
);
|
||||
$this->assertMenuLinkParents($links, $expected_hierarchy);
|
||||
|
||||
// Try changing the parent at the entity level.
|
||||
$definition = $this->menuLinkManager->getDefinition($links['child-1-2']);
|
||||
$entity = MenuLinkContent::load($definition['metadata']['entity_id']);
|
||||
$entity->parent->value = '';
|
||||
$entity->save();
|
||||
|
||||
$expected_hierarchy = array(
|
||||
'parent' => '',
|
||||
'child-1-1' => 'parent',
|
||||
'child-1-2' => '',
|
||||
'child-2' => 'parent',
|
||||
);
|
||||
$this->assertMenuLinkParents($links, $expected_hierarchy);
|
||||
|
||||
// @todo Figure out what makes sense to test in terms of automatic
|
||||
// re-parenting. https://www.drupal.org/node/2309531
|
||||
}
|
||||
|
|
|
@ -98,7 +98,10 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doTestTranslationEdit() {
|
||||
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
||||
$storage = $this->container->get('entity_type.manager')
|
||||
->getStorage($this->entityTypeId);
|
||||
$storage->resetCache([$this->entityId]);
|
||||
$entity = $storage->load($this->entityId);
|
||||
$languages = $this->container->get('language_manager')->getLanguages();
|
||||
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
|
|
Reference in a new issue