Core and composer updates
This commit is contained in:
parent
a82634bb98
commit
62cac30480
1118 changed files with 21770 additions and 6306 deletions
|
@ -296,8 +296,10 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s
|
|||
$entity = $form_object->getEntity();
|
||||
$op = $form_object->getOperation();
|
||||
|
||||
// Let the content translation handler alter the content entity edit form.
|
||||
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && ($op == 'edit' || $op == 'default')) {
|
||||
// Let the content translation handler alter the content entity form. This can
|
||||
// be the 'add' or 'edit' form. It also tries a 'default' form in case neither
|
||||
// of the aforementioned forms are defined.
|
||||
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && in_array($op, ['edit', 'add', 'default'], TRUE)) {
|
||||
$controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation');
|
||||
$controller->entityFormAlter($form, $form_state, $entity);
|
||||
|
||||
|
|
|
@ -337,7 +337,9 @@ class ContentTranslationController extends ControllerBase {
|
|||
// @todo Provide a way to figure out the default form operation. Maybe like
|
||||
// $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default';
|
||||
// See https://www.drupal.org/node/2006348.
|
||||
$operation = 'default';
|
||||
|
||||
// Use the add form handler, if available, otherwise default.
|
||||
$operation = $entity->getEntityType()->hasHandlerClass('form', 'add') ? 'add' : 'default';
|
||||
|
||||
$form_state_additions = [];
|
||||
$form_state_additions['langcode'] = $target->getId();
|
||||
|
@ -368,7 +370,9 @@ class ContentTranslationController extends ControllerBase {
|
|||
// @todo Provide a way to figure out the default form operation. Maybe like
|
||||
// $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default';
|
||||
// See https://www.drupal.org/node/2006348.
|
||||
$operation = 'default';
|
||||
|
||||
// Use the edit form handler, if available, otherwise default.
|
||||
$operation = $entity->getEntityType()->hasHandlerClass('form', 'edit') ? 'edit' : 'default';
|
||||
|
||||
$form_state_additions = [];
|
||||
$form_state_additions['langcode'] = $language->getId();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\Tests\content_translation\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Tests\NodeTestBase;
|
||||
use Drupal\Tests\node\Functional\NodeTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\content_translation\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Entity\EntityChangedInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
@ -226,10 +227,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|||
$language = new Language(['id' => $langcode]);
|
||||
$view_url = $entity->url('canonical', ['language' => $language]);
|
||||
$elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]);
|
||||
$this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode]));
|
||||
$this->assertEqual($elements[0]->getText(), $entity->getTranslation($langcode)->label(), new FormattableMarkup('Label correctly shown for %language translation.', ['%language' => $langcode]));
|
||||
$edit_path = $entity->url('edit-form', ['language' => $language]);
|
||||
$elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]);
|
||||
$this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode]));
|
||||
$this->assertEqual($elements[0]->getText(), t('Edit'), new FormattableMarkup('Edit link correct for %language translation.', ['%language' => $langcode]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue