Problem/Motivation

FieldEntryFormController has a protected getFlagging() method to load a single flagging entity from FlagService::getFlaggings().

Proposed resolution

It could be useful to other modules to have this method available in FlagService.

Remaining tasks

Create patch.

User interface changes

None.

API changes

FieldEntryFormController would no longer need the protected getFlagging() method and would instead get the flagging from FlagService. And additional method to load a single flagging would be available on FlagService.

Comments

martin107’s picture

martin107’s picture

Status: Active » Needs review
StatusFileSize
new2.81 KB

Now that #2461549: use entity type hinting in routes things have changed a little

1) The 2 controller functions that call this new service method preload the entity - so it makes sense to pass that entity in rather than the entities id.

2) The guts of the function can be simplified with

\Drupal::service('flag')->

becoming just

$this->

Status: Needs review » Needs work

The last submitted patch, 2: getFlagging-2465875-2.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: getFlagging-2465875-2.patch, failed testing.

martin107’s picture

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

Reroll triggered by #2464995: FieldEntryFormController::getFlagging() change the 'unfound' return type from FALSE to NULL

I also added a minor touch up to the wording of getFlagging()

/**
* Get a flagging that already exists.
*
* @param FlagInterface $flag
* The flag.
* @param mixed $entity_id
* The flaggable ID.
*
* @return FlaggingInterface|null
- * The flagging or NULL.
+ * The flagging or NULL if the flagging is not found.
*/

Status: Needs review » Needs work

The last submitted patch, 6: getFlagging-2465875-6.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new2.67 KB
new577 bytes

A little fix.

Status: Needs review » Needs work

The last submitted patch, 8: getFlagging-2465875-8.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new2.64 KB
new612 bytes

FlagFieldEntryTest now passes locally.

socketwench’s picture

Status: Needs review » Fixed

  • martin107 authored 75e77ce on 8.x-4.x
    Issue #2465875 by martin107: Moved FieldEntryFormController::getFlagging...
socketwench’s picture

Thanks!!!!

Status: Fixed » Closed (fixed)

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