Skip to content

Expose MediaManager's createFrom* methods and/or allow entity modifications before save #31

@Amunak

Description

@Amunak

There's no point in having a customizable Media entity when the createMedia method creates the entity and then immediately persist is and flushes the DB (which, by the way, is a terrible practice as it can cause unexpected flushes in the middle of a request).

For one it'd be nice if all the createFrom* methods were public for more granular control by user.

The save issue could be solved in several ways:

  • Remove the save method from createMedia since it's the programmer's responsibility to manage entities. You don't necessarily want to always immediately persist (and definitely not flush) an entity you create. This is easiest and IMO most correct but breaks BC.
  • Pass an argument to createMedia on whether to save; perhaps just $flush like you have on other methods. This is a simple solution even if it's not very neat.
  • Add some events to the manager logic that fire right after entity creation, right before save, etc. This would add great verstility, is still correct, and allows most customization (especially if you add events for other things too). It's however somewhat harder, though I'd suggest doing this anyway in addition to one of the above options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions