(Novice, my first issue, follow-up from #1832870: Only show source translation column if there are 2 or more source languages (more than n/a and the original language).).

Problem/Motivation

The file content_translation.pages.inc contains a function that is marked as deprecated, and which is to be moved to ContentTranslationController::overview().

The file content_translation.pages.inc contains a function that is marked as deprecated(content_translation_add_page()), and which is to be moved to ContentTranslationController::add()

The file content_translation.pages.inc contains a function that is marked as deprecated(content_translation_edit_page()), and which is to be moved to ContentTranslationController::edit()

Move function _content_translation_get_switch_links() from content_translation.pages.inc to ContentTranslationController::getSwitchLinks()

Move function content_translation_prepare_translation() from content_translation.pages.inc to ContentTranslationController::prepare()

Proposed resolution

Move the code.

Remaining tasks

  1. Move the code

User interface changes

No UI changes.

API changes

No API changes.

Follow-up from #1832870: Only show source translation column if there are 2 or more source languages (more than n/a and the original language)..

Comments

mauzeh’s picture

Issue summary: View changes
mauzeh’s picture

Issue summary: View changes
andrei.dincu’s picture

StatusFileSize
new13.17 KB

move content_translation_overview() body to ContentTranslationController::overview()
remove content_translation_overview()

andrei.dincu’s picture

Status: Active » Needs review
andrei.dincu’s picture

There are already tests created for this at:
Drupal\content_translation\Tests\ContentTranslationUITest

Could not remove: module_load_include('pages.inc', 'content_translation');
because there are other functions from content_translation.pages.inc file that are called in the controller.

andrei.dincu’s picture

andrei.dincu’s picture

I decided to move all functions from content_translation.pages.inc to the Drupal\content_translation\Controller\ContentTranslationController class.
Functions from content_translation.pages.inc are only used in the ContentTranslationController.
Furthermore, I will delete file content_translation.pages.inc.
I will remove @todo from comments for ContentTranslationController

andrei.dincu’s picture

Title: Move content_translation_overview() into ContentTranslationController::overview() » Move all functions from content_translation.pages.inc file to
Issue summary: View changes
Status: Needs review » Needs work
andrei.dincu’s picture

Title: Move all functions from content_translation.pages.inc file to » Move all functions from content_translation.pages.inc file to Drupal\content_translation\Controller\ContentTranslationController class
andrei.dincu’s picture

Assigned: mauzeh » andrei.dincu
andrei.dincu’s picture

StatusFileSize
new20.92 KB

Solve all tasks specified in motivation.

andrei.dincu’s picture

Issue summary: View changes
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: 2224607-remove-pages-inc-11.patch, failed testing.

andrei.dincu’s picture

StatusFileSize
new20.95 KB
andrei.dincu’s picture

Status: Needs work » Needs review
jibran’s picture

Status: Needs review » Needs work
Issue tags: -Quick fix

Thank you for the patch. Here are some minor issues.

  1. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -15,33 +18,222 @@
    +    drupal_set_message($entity->getSystemPath('drupal:content-translation-overview'));
    

    I think this is for debugging. So we can remove it. You can use debug() function in D8 instead of dsm();

  2. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -15,33 +18,222 @@
    +    $administrator = \Drupal::currentUser()->hasPermission('administer languages');
    ...
    +    if (\Drupal::languageManager()->isMultilingual()) {
    ...
    +    $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
    ...
    +    return \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state);
    ...
    +    $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
    ...
    +    return \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state);
    ...
    +    $links = \Drupal::languageManager()->getLanguageSwitchLinks(Language::TYPE_CONTENT, $path);
    ...
    +    $links = \Drupal::languageManager()->getLanguageSwitchLinks(Language::TYPE_INTERFACE, $path);
    

    We can remove \Drupal usage in Controller and use constructor injections.

  3. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -15,33 +18,222 @@
    +          // If the user is allowed to edit the entity we point the edit link to
    

    more then 80 chars.

  4. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -15,33 +18,222 @@
    +  ¶
    ...
    +    return $links; ¶
    ...
    +  ¶
    ...
    +  ¶
    

    Whitespace.

andrei.dincu’s picture

StatusFileSize
new20.91 KB

Small improvements as specified in comment #16.

andrei.dincu’s picture

Status: Needs work » Needs review
jibran’s picture

Status: Needs review » Needs work

Please post the interdiff.

  1. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,232 @@
    +    $header = array(t('Language'), t('Translation'), t('Source language'), t('Status'), t('Operations'));
    

    We can use $this->t instead of t.

  2. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,232 @@
    +          // If the user is allowed to edit the entity we point the edit link to
    

    more then 80 chars.

andrei.dincu’s picture

StatusFileSize
new21.04 KB
new5.11 KB

Solved issues from comment #19.
Provide interdiff.
Waiting for feedback.

andrei.dincu’s picture

Status: Needs work » Needs review
penyaskito’s picture

Status: Needs review » Needs work

Wow! This looks really awesome. Thanks for working on this, Andrei. Some small nitpicks:

  1. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,233 @@
    +use \Drupal\Core\Controller\ControllerBase;
    

    Remove the trailing backslash.

  2. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,233 @@
    +   * @param EntityInterface $entity
    +   *   The entity being translated.
    ...
       public function add(Request $request, $source, $target) {
    

    The phpdoc first argument says that this is an entity, but it is not.

    Add typehinting: add(Request $request, Language $source, Language $target). This way IDEs can help autocompleting.

  3. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,233 @@
    +   * @param Language $source
    ...
    +   * @param Language $target
    

    We should use here fully-qualified namespaces, as the other methods' phpdoc. See https://drupal.org/coding-standards/docs#types

  4. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,233 @@
    +    $links = $this->languageManager()->getLanguageSwitchLinks(Language::TYPE_INTERFACE, $path);
    

    Wrong indentation.

  5. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,233 @@
    +   *   The entitiy being translated.
    

    Typo: entitiy => entity.

andrei.dincu’s picture

Status: Needs work » Needs review
StatusFileSize
new21.41 KB
new3.79 KB

Thank you penyaskito for you review.
I've fixed documentation.
Providin interdiff.
Waiting for you review again please.

Status: Needs review » Needs work

The last submitted patch, 23: 2224607-23.patch, failed testing.

andrei.dincu’s picture

Status: Needs work » Needs review
StatusFileSize
new21.11 KB
new3.85 KB
znerol’s picture

Great progress, thank you very much andrei. Overall the patch looks great, some minor issues:

  1. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,236 @@
    +   * @param \Symfony\Component\HttpFoundation\Request $request
    +   *   The request obkect.
    

    object is misspelled in several places.

  2. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,236 @@
        */
    -  public function add(Request $request, $source, $target) {
    +  public function add(Request $request,$source,$target) {
         $entity = $request->attributes->get($request->attributes->get('_entity_type_id'));
    

    A comma should be followed by a space in the argument list (also several places).

  3. +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php
    @@ -8,40 +8,236 @@
    +   * @param \Drupal\Core\Language\Language $source
    +   *   The language to be used as source.
    +   * @param \Drupal\Core\Language\Language $target
    +   *   The language to be used as target.
    +   */
    +  public function prepareTranslation(EntityInterface $entity, Language $source, Language $target) {
    +    if ($entity instanceof ContentEntityInterface) {
    

    When type hinting, use an interface when possible. I.e. LanguageInterface instead of Language. A notable exception to this rule is the Request class, there is no interface for it.

andrei.dincu’s picture

StatusFileSize
new21.08 KB
new3.14 KB

Solved issues from the previous comment.
Providing interdiff.

znerol’s picture

Status: Needs review » Reviewed & tested by the community

This looks okay now. Let's get it in and move on. Thank you andrei.

andrei.dincu’s picture

Thank you for your review.

penyaskito’s picture

Issue tags: +sprint

Adding to sprint

penyaskito’s picture

Issue tags: +language-content

And tagging.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 27: 2224607-27.patch, failed testing.

andrei.dincu’s picture

Status: Needs work » Needs review
StatusFileSize
new21.12 KB

Patch rerolled

znerol’s picture

Status: Needs review » Reviewed & tested by the community
Anonymous’s picture

Status: Reviewed & tested by the community » Needs work

It duplicates this one https://drupal.org/node/1987882. We need an authorized person who is able to take a right decision.

penyaskito’s picture

Status: Needs work » Postponed

Let's postpone this one on the other one. When #1987882: Convert content_translation routes to a new style controller is done we can get back here and ensure that content_translation.pages.inc has been removed.

andypost’s picture

Status: Postponed » Closed (duplicate)
gábor hojtsy’s picture

Issue tags: -sprint

Off of the sprint then.