diff --git a/core/lib/Drupal/Core/Controller/HtmlPageController.php b/core/lib/Drupal/Core/Controller/HtmlPageController.php index 4525328..f3358ad 100644 --- a/core/lib/Drupal/Core/Controller/HtmlPageController.php +++ b/core/lib/Drupal/Core/Controller/HtmlPageController.php @@ -84,7 +84,9 @@ public function content(Request $request, $_content) { } if (!is_array($page_content)) { $page_content = array( - '#markup' => $page_content, + 'main' => array( + '#markup' => $page_content, + ), ); } if (!isset($page_content['#title'])) { diff --git a/core/modules/content_translation/content_translation.local_tasks.yml b/core/modules/content_translation/content_translation.local_tasks.yml new file mode 100644 index 0000000..151c584 --- /dev/null +++ b/core/modules/content_translation/content_translation.local_tasks.yml @@ -0,0 +1,3 @@ +content_translation.local_tasks: + derivative: 'Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks' + weight: 100 diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 868b200..f4eba85 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -141,7 +141,7 @@ function content_translation_overview(EntityInterface $entity) { } } - $build['#title'] = t('Translations of %label', array('%label' => $entity->label())); + drupal_set_title(t('Translations of %label', array('%label' => $entity->label())), PASS_THROUGH); // Add metadata to the build render array to let other modules know about // which entity this is. diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php new file mode 100644 index 0000000..764b06a --- /dev/null +++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php @@ -0,0 +1,91 @@ +entityManager = $entity_manager; + $this->routeProvider = $route_provider; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, $base_plugin_id) { + return new static( + $container->get('entity.manager'), + $container->get('router.route_provider') + ); + } + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + // Create tabs for all possible entity types. + foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { + if ($entity_info['translatable'] && isset($entity_info['translation'])) { + $path = '/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']); + $routes = $this->routeProvider->getRoutesByPattern($path)->all(); + if (empty($routes)) { + continue; + } + + $base_route_name = key($routes); + $tab_root = $base_route_name . '_tab'; + $route_name = "content_translation.translation_overview_$entity_type"; + $tab_name = $route_name . '_tab'; + $this->derivatives[$tab_name] = $base_plugin_definition; + $this->derivatives[$tab_name]['title'] = t('Translate'); + $this->derivatives[$tab_name]['route_name'] = $route_name; + $this->derivatives[$tab_name]['tab_root_id'] = $tab_root; + + // @todo Remove after https://drupal.org/node/2095117. + $tab_name = $tab_root; + $this->derivatives[$tab_name] = $base_plugin_definition; + $this->derivatives[$tab_name]['title'] = t('Edit'); + $this->derivatives[$tab_name]['route_name'] = $base_route_name; + $this->derivatives[$tab_name]['tab_root_id'] = $tab_root; + } + } + return parent::getDerivativeDefinitions($base_plugin_definition); + } + +} diff --git a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php index 1affb42..3aad7344 100644 --- a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php @@ -21,9 +21,7 @@ class SystemTestController extends ControllerBase { * The text to display. */ public function mainContentFallback() { - return array( - '#markup' => $this->t('Content to test main content fallback'), - ); + return $this->t('Content to test main content fallback'); } /** diff --git a/core/modules/update/tests/modules/update_test/lib/Drupal/update_test/Controller/UpdateTestController.php b/core/modules/update/tests/modules/update_test/lib/Drupal/update_test/Controller/UpdateTestController.php index 9858aaa..a2b459f 100644 --- a/core/modules/update/tests/modules/update_test/lib/Drupal/update_test/Controller/UpdateTestController.php +++ b/core/modules/update/tests/modules/update_test/lib/Drupal/update_test/Controller/UpdateTestController.php @@ -31,8 +31,8 @@ public function updateError() { /** * @todo Remove update_test_mock_page(). */ - public function updateTest($project_name) { - return update_test_mock_page($project_name); + public function updateTest($project_name, $version) { + return update_test_mock_page($project_name, $version); } } diff --git a/core/modules/update/tests/modules/update_test/update_test.routing.yml b/core/modules/update/tests/modules/update_test/update_test.routing.yml index b44c2f1..708d42f 100644 --- a/core/modules/update/tests/modules/update_test/update_test.routing.yml +++ b/core/modules/update/tests/modules/update_test/update_test.routing.yml @@ -6,9 +6,10 @@ update_test.503: _access: 'TRUE' update_test.update_test: - path: '/update-test/{project_name}' + path: '/update-test/{project_name}/{version}' defaults: _title: 'Update test' _controller: '\Drupal\update_test\Controller\UpdateTestController::updateTest' + version: NULL requirements: _access: 'TRUE'