Coder Social home page Coder Social logo

redefine ENUMs with enumType about admin HOT 2 OPEN

arhimede avatar arhimede commented on June 26, 2024
redefine ENUMs with enumType

from admin.

Comments (2)

arhimede avatar arhimede commented on June 26, 2024 1

@kakapiciu will try to implement a proof of concept
solution 2, variant #2

from admin.

alexmerlin avatar alexmerlin commented on June 26, 2024

Solution 1: Mapping to Varchars is what we're currently using and as we know, it has it's own flaws (showing unnecessary modifications in each migration).

Solution 2: Defining a Type seems to be the preferred approach in most frameworks.
In addition to the method described in the article, there should be either:

  1. An abstract type that then could be extended by each custom enumType

    abstract class AbstractEnumType extends Type containing all the methods defined in the article (getSQLDeclaration, convertToPHPValue etc)
    Then custom enumTypes extending AbstractEnumType that have only one purpose, providing the values (which can be defined as constants in the custom enumType and also used in the $values array - this way the values are defined only once and constants can also be reused outside the class)

  2. One single enumType that when added to a property, can be configured (if needed, the values parameter's name can be changed to a more suitable one):

    #[ORM\Column(name: "status", type: EnumType::class, values: ["pending", "active"])]
    If this can be implemented, it would be the easisest solution both to write and to use.

Note:
Both solutions (the abstract / generic enumTypes) are theoretical, I did not try them in practice. Their purpose is only to give an idea on where to start implementing these types.

from admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.