symfony-cmf/resource

Doctrine ORM "sharded" repository.

dantleech opened this issue · 6 comments

We could support the Doctrine ORM by using "sharding" based on table fields to provide a hierarchy.

By providing a list of SQL field specifications we should be able to emulate a
hierarchy.

cmf_repository:
    repositories:
        invoices_by_date:
            # e.g. /2016/06/SYMCMF-01
            type: doctrine_orm_sharded
            class: AppBundle\Entity\Invoice
            name: {{ clientRef }}-{{ invoiceNo }} # property access

            # in SQL
            shards:
                - "DATE(date)"
                - "MONTH(date)"
        invoices_by_client:
            # e.g. /SYMCMF/00001
            type: doctrine_orm_sharded
            class: AppBundle\Entity\Invoice
            name: {{ invoiceNo }}

            # in SQL
            shards:
                - "clientRef"

        default:
            # mount in a composite e.g.
            #
            #   articles/
            #      ...
            #   invoices/
            #     date/
            #       2016/
            #         06/
            #           SYMCMF-0001
            #     client/
            #       SYMCMF/
            #         0001
            #  
            ty: composite
            mount:
                - 
                    repository: invoices_by_date
                    mountpoint: "/invoices/bydate"
                -
                    repository: invoices_by_client
                    mountpoint: "/invoices/byclient"
                -
                    repository: articles # f.e.
                    mountpoint: "/articles"

/cc @symfony-cmf/core

dbu commented

there are also doctrine extensions to make manifest trees on doctrine orm. not sure how much those could be useful instead.

i have nothing against doing these things, but don't see them as a priority for the cmf.

@dbu this isn't about making a tree (i.e. nested set, materialized path) in Doctrine ORM, its about taking an existing Entity and representing it as a resource, using fields as path elements, creating a virtual hierarchy. (though is that what you meant by manfest tree?)

dbu commented

👍 Except that I would replace property access + sql with Symfony ExpressionLanguage instead:

name: 'model.clientRef ~ '-' ~ model.invoiceNo'
shards: ['year(date)', 'month(date)']

property access + sql with Symfony ExpressionLanguage instead:

Also replace the SQL? Was thinking this would be just DBAL SQL. If we replaced SQL with expression language it would be lots of work I would think.