Comments

tshivasrikanth created an issue. See original summary.

miro_dietiker’s picture

I do prefer to commit deprecated and other non-functional clean-up fixes as a combined patch.

We should preferrably work through all the positive reports at "PHPStorm Code - Inspect Code" in this issue.

johnchque’s picture

Status: Needs review » Needs work
shiva srikanth t’s picture

@miro_dietiker
I will update the patch for deprecated and other non-functional clean-up fixes as a combined patch soon.

shiva srikanth t’s picture

StatusFileSize
new16.48 KB
shiva srikanth t’s picture

Status: Needs work » Needs review
shiva srikanth t’s picture

@miro_dietiker
I have attached new patch with all deprecated and other non-functional clean-up fixes as a combined patch.
Please review the code.

tduong’s picture

Status: Needs review » Needs work

Good job! But after going to admin/help/entity_reference_revisions there were some errors/exceptions, so you need to fix (+ small refactoring) as follow:

  1. +++ b/entity_reference_revisions.module
    @@ -21,11 +21,11 @@ function entity_reference_revisions_help($route_name, RouteMatchInterface $route
    +      $output .= '<p>' . t('The Entity Reference Revisions module allows you to create fields that contain links to other entities (such as content items, taxonomy terms, etc.) within the site. This allows you, for example, to include a link to a user within a content item. For more information, see <a href="!er_do">the online documentation for the Entity Reference Revisions module</a> and the <a href="!field_help">Field module help page</a>.', array('!field_help' => Url::fromRoute('help.page', array('name' => 'field')), '!er_do' => 'https://drupal.org/documentation/modules/entity_reference_revisions')) . '</p>';
    

    Call ->toString() after Url::formRoute() (like Url::fromRoute(...)->toString()), and replace the " ! " with " : ", for :field_help, :er_do and ...

  2. +++ b/entity_reference_revisions.module
    @@ -21,11 +21,11 @@ function entity_reference_revisions_help($route_name, RouteMatchInterface $route
    +      $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the entity reference field can be configured separately. See the <a href="!field_ui">Field UI help</a> for more information on how to manage fields and their display.', array('!field_ui' => Url::fromRoute('help.page', array('name' => 'field_ui')))) . '</dd>';
    

    ... for :field_ui, also call ->toString() here as well.
    And add the Drupal\Core\Url import.

  1. +++ b/entity_reference_revisions.views.inc
    @@ -12,7 +12,7 @@ use Drupal\field\FieldStorageConfigInterface;
    diff --git a/src/EntityReferenceRevisionsFieldItemList.php b/src/EntityReferenceRevisionsFieldItemList.php
    

    Saw an unused import in this class (use Drupal\Core\Field\FieldItemList).

  2. +++ b/src/Plugin/views/style/EntityReferenceRevisions.php
    @@ -92,7 +92,7 @@ class EntityReferenceRevisions extends StylePluginBase {
    diff --git a/src/Tests/EntityReferenceRevisionsAutocompleteTest.php b/src/Tests/EntityReferenceRevisionsAutocompleteTest.php
    

    Please fix the path of the class docblock (missing Tests subclass).

Otherwise looks fine to me! :)

shiva srikanth t’s picture

@tduong

I have done with all changes except following

+++ b/src/Plugin/views/style/EntityReferenceRevisions.php
@@ -92,7 +92,7 @@ class EntityReferenceRevisions extends StylePluginBase {
diff --git a/src/Tests/EntityReferenceRevisionsAutocompleteTest.php b/src/Tests/EntityReferenceRevisionsAutocompleteTest.php

Please fix the path of the class docblock (missing Tests subclass).

could you let me know what's need to be add.

miro_dietiker’s picture

@sskt please also upload intermediate patches to make tests run.

tduong’s picture

@sskt just do "\Drupal\entity_reference_revisions\Tests\EntityReferenceRevisionsAutocompleteTest."
And yes, please add also the interdiff file to easily review your changes between two patches (if you wonder how to do that, see https://www.drupal.org/documentation/git/interdiff).

shiva srikanth t’s picture

StatusFileSize
new4.37 KB
new17.66 KB

Updated patch with changes.

shiva srikanth t’s picture

Status: Needs work » Needs review
tduong’s picture

Status: Needs review » Needs work

Great! Just a small standard coding:

+++ b/src/Plugin/views/style/EntityReferenceRevisions.php
@@ -2,7 +2,7 @@
+ * Contains \Drupal\entity_reference_revisions\src\Plugin\views\style\EntityReferenceRevisions.

This was fine. Usually you don't write src in the path/namespace.
Here you can find the @file Documenting files and Namespaces standard coding documentations. Just revert this line.

Otherwise everything is fine for me! :)

shiva srikanth t’s picture

StatusFileSize
new517 bytes
new17.38 KB

Thanks @tduong,
I have make the changes.

shiva srikanth t’s picture

Status: Needs work » Needs review
tduong’s picture

Status: Needs review » Reviewed & tested by the community

Yep, looks good to me!

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests
  1. +++ b/src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsEntityFormatter.php
    @@ -92,7 +92,7 @@ class EntityReferenceRevisionsEntityFormatter extends EntityReferenceRevisionsFo
    +      '#options' => \Drupal::entityTypeManager()->getViewModeOptions($this->getFieldSetting('target_type')),
    
    @@ -107,7 +107,7 @@ class EntityReferenceRevisionsEntityFormatter extends EntityReferenceRevisionsFo
    +    $view_modes = \Drupal::entityTypeManager()->getViewModeOptions($this->getFieldSetting('target_type'));
    
    +++ b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php
    @@ -252,10 +252,10 @@ class EntityReferenceRevisionsItem extends EntityReferenceItem implements Option
    +          $entity = \Drupal::entityTypeManager()->loadEntityByUuid($target_entity_type->id(), $default_value['target_uuid']);
    

    These things are wrongly converted. The methods have been moved to different managers...

    It also means there is no test coverage for that, and we want to fix this.

tduong’s picture

Status: Needs work » Needs review
StatusFileSize
new4.42 KB
new16.49 KB

Just rerolled, solved a merge conflict.
Not sure how the conversions mentioned in should be fixed...

tduong’s picture

StatusFileSize
new1.04 KB
new17.29 KB

Don't know what happened with the previous interdiff... Anyway, reverted too much, set back "entity_view" in EntityReferenceRevisionsEntityFormatter::viewElements().

shiva srikanth t’s picture

Assigned: shiva srikanth t » Unassigned
miro_dietiker’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsEntityFormatter.php
@@ -107,7 +107,7 @@ class EntityReferenceRevisionsEntityFormatter extends EntityReferenceRevisionsFo
+    $view_modes = \Drupal::entityTypeManager()->getViewModeOptions($this->getFieldSetting('target_type'));

Fatal: This is not provided by EntityTypeManager. Newly only on EntityDisplayRepository provided by getViewModeOptions on EntityManagerWrapper.

Also i still see no new tests.

tduong’s picture

Status: Needs work » Needs review
StatusFileSize
new11.03 KB
new25.61 KB

Replaced the wrong conversions:
- injected $entityDisplayRepository in EntityReferenceRevisionsEntityFormatter
- used \Drupal::getContainer()->get('entity.repository') in EntityReferenceRevisionsItem

I've just learnt something new and dropped all @file comments for classes / interfaces / traits according to the @file doc standard coding.

I think the test for the view mode options (called by EntityDisplayRepositoryInterface) is already covered in EntityReferenceRevisionsAdminTest.
Not sure about the other one: what is the good approach to test the new conversion in EntityReferenceRevisionsItem to check loading entity by uuid ?

miro_dietiker’s picture

Status: Needs review » Needs work

Unrelated code cleanups are not accepted. :-)
File a separate issue. It makes reviewing hard and if you have multiple issues like that the patches conflict!

The test can not have been covered - otherwise it would have failed.

miro_dietiker’s picture

loadEntityByUuid() is about the default value. Create a field and check config if the dependencies are properly created.

tduong’s picture

Status: Needs work » Needs review
Related issues: +#2709241: Drop @file path documentation according to standard coding
StatusFileSize
new6.23 KB
new21.43 KB

Interdiff against patch #20:
- fix wrong manager conversions
- test checking the configuration dependencies

Created follow-up #2709241: Drop @file path documentation according to standard coding

tduong’s picture

Need to think how to get a failing test_only patch.

tduong’s picture

StatusFileSize
new21.14 KB

Rerolled. @Berdir said he will take a look for this test as soon as he has time.

berdir’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Ok, this is a bit more complicated. Lets go back to just do the fix without changing the test here, and open a new issue to test entity reference revisions default values and configuration dependencies.

Basically, what you need to do is the following:

'default_value' => [
[
'target_id' => $composite->id(),
'revision_id' => $composite->getRevisionId(),
]
]

To the field config, so it uses that reference as the default. When you try that, you'll notice that you get an invalid config schema error, we are missing schema for the field type value. The new issue can do that.

tduong’s picture

Title: Entity Reference Revisions remove drupal_render deprecated method » Remove drupal_render deprecated method and refactor non-functional cleanups
Status: Needs work » Needs review
Related issues: +#2711429: Test ERR default values and configuration dependencies
StatusFileSize
new6.68 KB
new20.78 KB

Dropped test and shortened the "array syntax" according to the array standard coding (just in entity_reference_revisions.module for now). This is not *that* important, but since this issue is about "deprecated and other non-functional clean-up fixes" it may make sense to edit them here for the whole ERR module, but sure it will conflict with a lot of other issues...

Created follow-up: #2711429: Test ERR default values and configuration dependencies.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

We should definitely be careful with mixing so many changes. However, only one case seems to touch code that doesn't already change, so that's pretty OK.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

Committing this, changes also look fine for me.

  • miro_dietiker committed 7426116 on 8.x-1.x authored by tduong
    Issue #2690007 by tduong, sskt: Remove drupal_render deprecated method...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.