Skip to content
Snippets Groups Projects
Commit a5e3956c authored by Jess's avatar Jess
Browse files

Revert "Issue #2939909 by plach, Wim Leers: Ensure that...

Revert "Issue #2939909 by plach, Wim Leers: Ensure that hook_bundle_info_alter() implementations know whether bundles are translatable"

This reverts commit c9392bb3.
parent f9365a0a
No related branches found
No related tags found
No related merge requests found
......@@ -60,14 +60,6 @@ function content_translation_module_implements_alter(&$implementations, $hook) {
unset($implementations['content_translation']);
$implementations['content_translation'] = $group;
break;
// Move our hook_entity_bundle_info_alter() implementation to the top of the
// list, so that any other hook implementation can rely on bundles being
// correctly marked as translatable.
case 'entity_bundle_info_alter':
$group = $implementations['content_translation'];
$implementations = ['content_translation' => $group] + $implementations;
break;
}
}
......
name: 'A content translation test module'
type: module
description: 'Helper module to test hook invocation order.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- content_translation
- entity_test
<?php
/**
* @file
* Helper module for the Content Translation tests.
*/
/**
* Implements hook_entity_bundle_info_alter().
*/
function a_content_translation_test_entity_bundle_info_alter(&$bundles) {
\Drupal::state()->set('a_content_translation_test.translatable', !empty($bundles['entity_test_mul']['entity_test_mul']['translatable']));
}
<?php
namespace Drupal\Tests\content_translation\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the Content Translation bundle info logic.
*
* @group content_translation
*/
class ContentTranslationEntityBundleInfoTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['user', 'language', 'a_content_translation_test', 'content_translation', 'entity_test'];
/**
* The content translation manager.
*
* @var \Drupal\content_translation\ContentTranslationManagerInterface
*/
protected $contentTranslationManager;
/**
* The bundle info service.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfo
*/
protected $bundleInfo;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->contentTranslationManager = $this->container->get('content_translation.manager');
$this->bundleInfo = $this->container->get('entity_type.bundle.info');
$this->installEntitySchema('entity_test_mul');
}
/**
* Tests that modules can know whether bundles are translatable.
*/
public function testHookInvocationOrder() {
$this->contentTranslationManager->setEnabled('entity_test_mul', 'entity_test_mul', TRUE);
$this->bundleInfo->clearCachedBundles();
$this->bundleInfo->getAllBundleInfo();
// Check that, although the "a_content_translation_test" hook implementation
// by default would be invoked first, it still has access to the
// "translatable" bundle info property.
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this->container->get('state');
$this->assertTrue($state->get('a_content_translation_test.translatable'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment