Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -5,6 +5,8 @@
* Installation functions for Content Translation module.
*/
use \Drupal\Core\Url;
/**
* Implements hook_install().
*/
@ -12,20 +14,19 @@ function content_translation_install() {
// Assign a fairly low weight to ensure our implementation of
// hook_module_implements_alter() is run among the last ones.
module_set_weight('content_translation', 10);
}
/**
* Implements hook_enable().
*/
function content_translation_enable() {
// Translation works when at least two languages are added.
if (count(\Drupal::languageManager()->getLanguages()) < 2) {
$t_args = array(':language_url' => \Drupal::url('entity.configurable_language.collection'));
$message = t('Be sure to <a href=":language_url">add at least two languages</a> to translate content.', $t_args);
$t_args = [
':language_url' => Url::fromRoute('entity.configurable_language.collection')->toString()
];
$message = t('This site has only a single language enabled. <a href=":language_url">Add at least one more language</a> in order to translate content.', $t_args);
drupal_set_message($message, 'warning');
}
// Point the user to the content translation settings.
$t_args = array(':settings_url' => \Drupal::url('language.content_settings_page'));
$t_args = [
':settings_url' => Url::fromRoute('language.content_settings_page')->toString()
];
$message = t('<a href=":settings_url">Enable translation</a> for <em>content types</em>, <em>taxonomy vocabularies</em>, <em>accounts</em>, or any other element you wish to translate.', $t_args);
drupal_set_message($message, 'warning');
}

View file

@ -14,7 +14,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\field\FieldConfigInterface;
/**
* Implements hook_help().
@ -283,7 +282,7 @@ function content_translation_translate_access(EntityInterface $entity) {
$condition = $entity instanceof ContentEntityInterface && $entity->access('view') &&
!$entity->getUntranslated()->language()->isLocked() && \Drupal::languageManager()->isMultilingual() && $entity->isTranslatable() &&
($account->hasPermission('create content translations') || $account->hasPermission('update content translations') || $account->hasPermission('delete content translations'));
return AccessResult::allowedIf($condition)->cachePerPermissions()->cacheUntilEntityChanges($entity);
return AccessResult::allowedIf($condition)->cachePerPermissions()->addCacheableDependency($entity);
}
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Access\ContentTranslationManageAccessCheck.
*/
namespace Drupal\content_translation\Access;
use Drupal\Core\Access\AccessResult;
@ -81,7 +76,7 @@ class ContentTranslationManageAccessCheck implements AccessInterface {
// Translation operations cannot be performed on the default
// translation.
if ($language->getId() == $entity->getUntranslated()->language()->getId()) {
return AccessResult::forbidden()->cacheUntilEntityChanges($entity);
return AccessResult::forbidden()->addCacheableDependency($entity);
}
// Editors have no access to the translation operations, as entity
// access already grants them an equal or greater access level.
@ -110,7 +105,7 @@ class ContentTranslationManageAccessCheck implements AccessInterface {
&& isset($languages[$source_language->getId()])
&& isset($languages[$target_language->getId()])
&& !isset($translations[$target_language->getId()]));
return AccessResult::allowedIf($is_new_translation)->cachePerPermissions()->cacheUntilEntityChanges($entity)
return AccessResult::allowedIf($is_new_translation)->cachePerPermissions()->addCacheableDependency($entity)
->andIf($handler->getTranslationAccess($entity, $operation));
case 'delete':
@ -118,7 +113,7 @@ class ContentTranslationManageAccessCheck implements AccessInterface {
$has_translation = isset($languages[$language->getId()])
&& $language->getId() != $entity->getUntranslated()->language()->getId()
&& isset($translations[$language->getId()]);
return AccessResult::allowedIf($has_translation)->cachePerPermissions()->cacheUntilEntityChanges($entity)
return AccessResult::allowedIf($has_translation)->cachePerPermissions()->addCacheableDependency($entity)
->andIf($handler->getTranslationAccess($entity, $operation));
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Access\ContentTranslationOverviewAccess.
*/
namespace Drupal\content_translation\Access;
use Drupal\Core\Access\AccessResult;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationHandler.
*/
namespace Drupal\content_translation;
use Drupal\Core\Access\AccessResult;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationHandlerInterface.
*/
namespace Drupal\content_translation;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationManager.
*/
namespace Drupal\content_translation;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationManagerInterface.
*/
namespace Drupal\content_translation;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationMetadataWrapper.
*/
namespace Drupal\content_translation;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationMetadataWrapperInterface.
*/
namespace Drupal\content_translation;
use Drupal\user\UserInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationPermissions.
*/
namespace Drupal\content_translation;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\ContentTranslationUpdatesManager.
*/
namespace Drupal\content_translation;
use Drupal\Core\Config\ConfigEvents;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Controller\ContentTranslationController.
*/
namespace Drupal\content_translation\Controller;
use Drupal\content_translation\ContentTranslationManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\FieldTranslationSynchronizer.
*/
namespace Drupal\content_translation;
use Drupal\Core\Config\Entity\ThirdPartySettingsInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\FieldTranslationSynchronizerInterface.
*/
namespace Drupal\content_translation;
use Drupal\Core\Entity\ContentEntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Form\ContentTranslationDeleteForm.
*/
namespace Drupal\content_translation\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\Derivative\ContentTranslationContextualLinks.
*/
namespace Drupal\content_translation\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks.
*/
namespace Drupal\content_translation\Plugin\Derivative;
use Drupal\content_translation\ContentTranslationManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\views\field\TranslationLink.
*/
namespace Drupal\content_translation\Plugin\views\field;
use Drupal\views\Plugin\views\field\EntityLink;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Routing\ContentTranslationRouteSubscriber.
*/
namespace Drupal\content_translation\Routing;
use Drupal\content_translation\ContentTranslationManagerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTestTranslationUITest.
*/
namespace Drupal\content_translation\Tests;
/**

View file

@ -1,16 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationContextualLinksTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\Component\Serialization\Json;
use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Tests that contextual links are available for content translation.
@ -29,7 +25,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
/**
* The content type being tested.
*
* @var NodeType
* @var \Drupal\node\Entity\NodeType
*/
protected $contentType;
@ -72,18 +68,18 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
$this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
// Add a field to the content type. The field is not yet translatable.
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => 'field_test_text',
'entity_type' => 'node',
'type' => 'text',
'cardinality' => 1,
))->save();
entity_create('field_config', array(
FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_test_text',
'bundle' => $this->bundle,
'label' => 'Test text-field',
))->save();
])->save();
entity_get_form_display('node', $this->bundle, 'default')
->setComponent('field_test_text', array(
'type' => 'text_textfield',

View file

@ -1,16 +1,11 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationEnableTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Test enabling content translation after other modules.
* Test enabling content translation module.
*
* @group content_translation
*/
@ -34,6 +29,10 @@ class ContentTranslationEnableTest extends WebTestBase {
];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Status messages are shown.
$this->assertText(t('This site has only a single language enabled. Add at least one more language in order to translate content.'));
$this->assertText(t('Enable translation for content types, taxonomy vocabularies, accounts, or any other element you wish to translate.'));
// No pending updates should be available.
$this->drupalGet('admin/reports/status');
$requirement_value = $this->cssSelect("tr.system-status-report__entry th:contains('Entity/field definitions') + td");

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationEntityBundleUITest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\simpletest\WebTestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationMetadataFieldsTest.
*/
namespace Drupal\content_translation\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationOperationsTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\language\Entity\ConfigurableLanguage;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationSettingsTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationStandardFieldsTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\simpletest\WebTestBase;

View file

@ -1,13 +1,11 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationSyncImageTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\Core\Entity\EntityInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\file\Entity\File;
/**
* Tests the field synchronization behavior for the image field.
@ -49,14 +47,14 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$this->fieldName = 'field_test_et_ui_image';
$this->cardinality = 3;
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => $this->fieldName,
'entity_type' => $this->entityTypeId,
'type' => 'image',
'cardinality' => $this->cardinality,
))->save();
entity_create('field_config', array(
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->entityTypeId,
@ -70,7 +68,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
),
),
),
))->save();
])->save();
}
/**
@ -137,7 +135,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
'uid' => \Drupal::currentUser()->id(),
'status' => FILE_STATUS_PERMANENT,
);
$file = entity_create('file', $field_values);
$file = File::create($field_values);
$file->save();
$fid = $file->id();
$this->files[$index]->fid = $fid;

View file

@ -1,15 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationTestBase.
*/
namespace Drupal\content_translation\Tests;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Base class for content translation tests.
@ -183,18 +180,18 @@ abstract class ContentTranslationTestBase extends WebTestBase {
if (empty($this->fieldName)) {
$this->fieldName = 'field_test_et_ui_test';
}
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => $this->fieldName,
'type' => 'string',
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
))->save();
entity_create('field_config', array(
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->bundle,
'label' => 'Test translatable text-field',
))->save();
])->save();
entity_get_form_display($this->entityTypeId, $this->bundle, 'default')
->setComponent($this->fieldName, array(
'type' => 'string_textfield',
@ -232,7 +229,9 @@ abstract class ContentTranslationTestBase extends WebTestBase {
}
}
}
$entity = entity_create($this->entityTypeId, $entity_values);
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->create($entity_values);
$entity->save();
return $entity->id();
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationUISkipTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\simpletest\WebTestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationUITestBase.
*/
namespace Drupal\content_translation\Tests;
use Drupal\Core\Cache\Cache;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationWorkflowsTest.
*/
namespace Drupal\content_translation\Tests;
use Drupal\Component\Utility\SafeMarkup;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\Views\ContentTranslationViewsUITest.
*/
namespace Drupal\content_translation\Tests\Views;
use Drupal\views_ui\Tests\UITestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\Views\TranslationLinkTest.
*/
namespace Drupal\content_translation\Tests\Views;
use Drupal\content_translation\Tests\ContentTranslationTestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation_test\Entity\EntityTestTranslatableNoUISkip.
*/
namespace Drupal\content_translation_test\Entity;
use Drupal\entity_test\Entity\EntityTest;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\content_translation_test\Entity\EntityTestTranslatableUISkip.
*/
namespace Drupal\content_translation_test\Entity;
use Drupal\entity_test\Entity\EntityTest;

View file

@ -1,15 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationConfigImportTest.
*/
namespace Drupal\content_translation\Tests;
namespace Drupal\Tests\content_translation\Kernel;
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\StorageComparer;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests content translation updates performed during config import.

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationSettingsApiTest.
*/
namespace Drupal\Tests\content_translation\Kernel;
namespace Drupal\content_translation\Tests;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the content translation settings API.

View file

@ -1,14 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Tests\ContentTranslationSyncUnitTest.
*/
namespace Drupal\Tests\content_translation\Kernel;
namespace Drupal\content_translation\Tests;
use Drupal\simpletest\KernelTestBase;
use Drupal\content_translation\FieldTranslationSynchronizer;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the field synchronization logic.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\content_translation\Unit\Access\ContentTranslationManageAccessCheckTest.
*/
namespace Drupal\Tests\content_translation\Unit\Access;
use Drupal\content_translation\Access\ContentTranslationManageAccessCheck;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\content_translation\Unit\Menu\ContentTranslationLocalTasksTest.
*/
namespace Drupal\Tests\content_translation\Unit\Menu;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;