Replace the entity manager with the entity type manager and remove unused imports in code base.

Comments

heykarthikwithu created an issue. See original summary.

heykarthikwithu’s picture

Assigned: heykarthikwithu » Unassigned
Status: Active » Needs review
StatusFileSize
new6.81 KB

replaced the entity manager with the entity type manager and remove unused imports in code base.

slashrsm’s picture

Status: Needs review » Needs work
Issue tags: +D8Media, +Novice

There are some more places where we inject entity.manager via create() method. We should probably convert that too.

heykarthikwithu’s picture

Status: Needs work » Needs review
StatusFileSize
new11.92 KB
new4.52 KB

checked in the whole code and replaced.

slashrsm’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php
@@ -80,7 +80,7 @@ class ImageThumbnail extends FieldWidgetDisplayBase implements ContainerFactoryP
+    foreach (\Drupal::entityTypeManager()->getStorage('image_style')->loadMultiple() as $id => $image_style) {

This is not the right approach. Instead of using static way we should inject entity type manager instead of entity manager and use that.

heykarthikwithu’s picture

Status: Needs work » Needs review

> Instead of using static way we should inject entity type manager instead of entity manager and use that.

currenlty this patch has entity type manager.
\Drupal::entityTypeManager()->getStorage('image_style')->loadMultiple()

correct me i am wrong :).

slashrsm’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php
@@ -80,7 +80,7 @@ class ImageThumbnail extends FieldWidgetDisplayBase implements ContainerFactoryP
-    foreach ($this->entityManager->getStorage('image_style')->loadMultiple() as $id => $image_style) {
+    foreach (\Drupal::entityTypeManager()->getStorage('image_style')->loadMultiple() as $id => $image_style) {
       $options[$id] = $image_style->label();

This was using injected entity manager and is not any more. There are few changes like this in the patch.

marvin_b8’s picture

Status: Needs work » Needs review
StatusFileSize
new17.52 KB
killua99’s picture

I don't see any major issue with this patch.

For me could be a RTBC but I've no idea if I could change the status (in core you can't).

Also It apply well too so it could be merged as it.

borisson_’s picture

StatusFileSize
new18.6 KB
new35.87 KB

#8 looks great, however a couple of instances were still remaining.

slashrsm’s picture

Status: Needs review » Reviewed & tested by the community

Looks OK. Would be great to prepare patch that would update entity browser widgets that DropzoneJS ships. This way we can commit everything in one step and prevent fatals from appearing for people.

slashrsm’s picture

Status: Reviewed & tested by the community » Needs work

Needs reroll.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new38.67 KB

Reroll.

slashrsm’s picture

Status: Needs review » Needs work

The last submitted patch, 13: 2639706_13.patch, failed testing.

The last submitted patch, 13: 2639706_13.patch, failed testing.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new38.34 KB
slashrsm’s picture

Status: Needs review » Fixed

Committed. Thanks!

  • slashrsm committed d4c3a03 on 8.x-1.x
    Issue #2639706 by heykarthikwithu, slashrsm, borisson_, marvin_B8,...
samuel.mortenson’s picture

Can we do a hotfix? Looks like these instances of Entity Manager were missed, breaking both widgets:

$ grep entityManager -R .
./src/Plugin/EntityBrowser/Widget/Upload.php:      $files[] = $this->entityManager->getStorage('file')->load($fid);
./src/Plugin/EntityBrowser/Widget/View.php:      $view = $this->entityManager->getStorage('view')->load($view_id);

  • slashrsm committed 26018b3 on 8.x-1.x
    Issue #2639706 by slashrsm, samuel.mortenson: Use entity type manager pt...
slashrsm’s picture

Fixed view. Upload seems to be ok in HEAD. Rebase problem?

Status: Fixed » Closed (fixed)

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