Recent efforts to restore author access functionality has drawn focus to a unnecessary redundancy.

from

https://www.drupal.org/node/2716613#comment-11674285

a) FlagTypeBase looks like a good place for common code WITHOUT assuming the implementation is based on entities.

b) FlagEntityType is a good place for common code based on the assumption that the implementation IS based on entities.

but as Berdir questions

Clearly flag only works for entities as we store an entity type and ID, so those two classes could be merge together?

I agree lets reduce complexity and merge.

As a side note to a side note ... in this light should we find a better place in the namespace tree for FlagTypePluginInterface and FlagTypePLuginManager ?

The issue from which this stems in an alpha blocker... don't know what that makes this issue!

Comments

martin107 created an issue. See original summary.

martin107’s picture

Status: Active » Postponed
joachim’s picture

> Clearly flag only works for entities as we store an entity type and ID

That wasn't the case on D7, but honestly, I've not heard of anyone flagging non-entities on D7, and on D8 there's no reason to not make something an entity.

Berdir’s picture

flagging in 7.x-3.0 also has an entity_type and entity_id column, how would you reference something else? Sure, you could stuff in there whatever you want but I doubt that's going to work well?

joachim’s picture

The name and description don't agree on D7:

      'entity_type' => array(
        'description' => 'The flag type, for example "node", "comment", or "user".',

You could argue that's the flag type name, and a badly named column ;)

But I'm happy to say that only entities can be flagged is a design decision we already made for 7.x-3.x.

martin107’s picture

Issue tags: +alpha blocker

@joachim

can I tentatively declare this an alpha blocker.

The code refactoring is maybe minor, but the

Where to put FlagTypePluginInterface

that strikes me as a potentially disruptive change ( disruptive to other contrib modules )

so something best done early when nothing is set in concrete.

This is my preferred directory structure - just to start the ball moving

flag
  src
    FlagTypePluginInterface
    FlagTypePluginManager
Berdir’s picture

Seems to me that moving the interfaces is a separate task?

If we do what the title says (merge flagtypebase into EntityFlagType) then the impact should be minimal as I assume that eventually existing subclasses subclass EntityFlagType and then nothing changes for them.

martin107’s picture

A perfectly reasonable thing to say.

joachim’s picture

> That wasn't the case on D7, but honestly, I've not heard of anyone flagging non-entities on D7, and on D8 there's no reason to not make something an entity.

I take that back.

Someone just got in touch with me about flagging repeated dates... which are going to be field items maybe?

I have *no idea* how that would even be possible. We've probably gone too far down the route of only working with entities by our use of an entity reference field on Flaggings -- though there's per-bundle base fields overrides IIRC?

socketwench’s picture

Issue tags: +Flag 5.x

Might be a good 5.x feature?