Skip to content
castamir edited this page Oct 16, 2014 · 3 revisions

Description

Convencions

Standard mapper for conventions:

  • underscore separated names of tables and cols
  • PK column name is always [id]
  • FK default column name is [table]
  • entity repository is named [Entity]Repository
  • M:N relations are stored in [table1]_[table2] tables
  • each entity/repository has same namespace prefix (e.g. Default\Namespace\Prefix)
  • getTable: Default\Namespace\Prefix\SomeEntity -> some_entity
  • getTableByRepositoryClass: Default\Namespace\Prefix\Repository\SomeEntityRepository -> some_entity
  • getEntityClass: some_entity -> Default\Namespace\Prefix\SomeEntity
  • getColumn: someField -> some_field
  • getEntityField: some_field -> someField
  • getRelationshipColumn: $targetTable

Package Manager

Package manager is an extension of Joseki\LeanMapper\Mapper thats allows you to have independent namespaces for each entity (repository). To map witch namespace belongs to which table, neon config is used.

For example if you want to have each entity and repository in the same namespace, you can use the following settings:

LeanMapper:
  packages:
    Default:
      Namespace:
        Prefix:
          - table1
          - table2

But this is not recommended (for such settings, it is better to use standard Mapper). What you really can use is like this:

LeanMapper:
  packages:
    Auth:
      - user
      Acl:
        - permission
    Mail:
      - email
      - email_attachment
    Navigation:
      - section
      - restriction
    News:
      - news
    Company:
      Register:
        - company

Note: Since each Entity and Repository can have totally different namespace, it will be hard to maintain changes all by yourself. To prevent this (to autogenerate all Repositories as a service), Package manager expects that you use a CompilerExtension.

Clone this wiki locally