Skip to content

Instantly share code, notes, and snippets.

@woutsanders
Forked from mnapoli/reference.yml
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save woutsanders/2f43a08fcd10061dbda0 to your computer and use it in GitHub Desktop.

Select an option

Save woutsanders/2f43a08fcd10061dbda0 to your computer and use it in GitHub Desktop.
Holds common Doctrine relation and field definitions
# Inspired from http://blog.hio.fr/2011/09/17/doctrine2-yaml-mapping-example.html
myEntity:
type: entity
repositoryClass: myRepositoryClass
table: my_entity
namedQueries:
all: SELECT u FROM __CLASS__ u
id:
id:
type: integer
generator:
strategy: AUTO
sequenceGenerator:
sequenceName: tablename_seq
allocationSize: 100
initialValue: 1
fields:
name:
type: string
length: 50
nullable: true
unique: true
email:
type: string
column: user_email
columnDefinition: CHAR(32) NOT NULL
oneToOne:
address:
targetEntity: Address
inversedBy: user
joinColumn:
name: address_id
referencedColumnName: id
onDelete: CASCADE
onUpdate: CASCADE
cascade: [ remove ]
oneToMany:
phonenumbers:
targetEntity: PhoneNumber
orphanRemoval: true
mappedBy: user
orderBy:
number: ASC
cascade: [ persist ]
manyToMany:
groups:
targetEntity: Group
joinTable:
name: users_groups
joinColumns:
user_id:
referencedColumnName: id
nullable: false
unique: false
inverseJoinColumns:
group_id:
referencedColumnName: id
columnDefinition: INT NULL
cascade:
- all
manyToOne:
securityLevel:
targetEntity: SecurityLevel
inversedBy: users
joinColumn:
name: securitylevel_id
referencedColumnName: id
nullable: false
lifecycleCallbacks:
prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ]
postPersist: [ doStuffOnPostPersist ]
uniqueConstraints:
search_idx:
columns: name,user_email
indexes:
name_idx:
columns: name
0:
columns: user_email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment