Skip to content
ritalin edited this page Sep 5, 2011 · 1 revision

Introduction

このページは、Doctrine2 2.0.2の頃に、YAML Mappingに用いられる属性(アノテーション)を調べた際のメモです。 テンプレートとしてそのまま使用出来るよう、*.dcm.yml形式で作成されています。 各属性には、Doctrine2のリファレンスから抜いてきた説明文を付けています。

Sample

Models\User:
  # A Mapping type. Either entity or mappedSuperclass (required)
  type: entity
  
  # The fully qualified class-name of 
  # an alternative Doctrine\ORM\EntityRepository 
  # implementation to be used with this entity. (optional)
#  repositoryClass: 
  
  # The Table-Name to be used for this entity. (optional)
  # Otherwise the Unqualified Class-Name is used by default.
  table: m_user
  
  # A more detailed description (optional)
  # Following in the [Defining Inheritance Mappings] section.
#  inheritanceType: 
  
  # The change trackng policy. (optional)
  # One of deferred_explicit or deferred_explicit or notify
#  changeTrackingPolicy: 
  
  # identify field (required)
  id:
    # A property name on php class (required)
    name: userId
    
    # The Doctrine\DBAL\Types\Type name (required), 
    # preferably “string” or “integer”
    type: integer
    
    # max field size (required for string type)
#    length:
    
    # Name of the column in the database, (optional)
    # defaults to the field name.
    # Using the simplified definition 
    # above Doctrine will use no identifier strategy for this entity. 
    # That means you have to manually set the identifier before calling EntityManager#persist($entity). 
    # This is the so called ASSIGNED strategy.
    column: user_id
    
    # Switch the identifier generation strategy (optional)
#    generator:
    # Strategy is one of
    #   AUTO
    #     Automatic detection of the identifier strategy 
    #     based on the preferred solution of the database vendor.
    #   IDENTITY
    #     Use of a IDENTIFY strategy such as Auto-Increment IDs available to Doctrine 
    #     AFTER the INSERT statement has been executed.
    #   SEQUENCE
    #     Use of a database sequence to retrieve the entity-ids. 
    #     This is possible before the INSERT statement is executed.
#      strategy: 
    
    # required if you are using the SEQUENCE strategy
#    sequenceGenerator:
#      sequenceName: user_seq 
      # By how much steps should the sequence be incremented when a value is retrieved. 
      # Defaults to 1
      # (optional)
#      allocationSize: 5 
      # The initial value of the sequence be.
#      initialValue: 30
    
  fields:
    # property on php class (required)
    userName: 
      type: string # Alternative expression is string(50)
      length: 50 # (optional)
      # Name of the column in the database (optional)
      column: user_name
      # Should this field contain a unique value across the table (optional)
      # Defaults to false.
      unique: false
      # Should this field allow NULL as a value? (optional)
      # Defaults to false.
      nullable: false
      # Should this field be used for optimistic locking? (optional)
      # Only works on fields with type integer or datetime.
      version: false
      
      # Scale of a decimal type. (optional)
#        scale: 
      # Precision of a decimal type. (optional)
#        precision:
      
      # Alternative SQL representation for this column. 
      # This definition begin after the field-name and has to specify the complete column definition. Using this feature 
      # will turn this field dirty for Schema-Tool update commands at all times.
#        columnDefinition: ??
      
    password:
      type: string;
      length: 30
      column: password
      unique: false
      nullable: false
        
    email:
      type: sting
      length: 100
      column: email
      unique: true
      nullable: true
          
  # Defining additional indexes (optional)
#  indexes:
    # Alternative expression is "index-name-value": [ "column-value", ... ]

    # index name (requird)
#    name:
    
    # column names. (required)
    # This is array or comma-separated-string
#    columns: [ ]
  
  # Defining additional unique constraints (optional)
#  uniqueConstraints:
    # Alternative expression is "constraint-name-value": [ "column-value", ... ]

    # constraint name (required)
#    name:

    # constraint columns. (required)
    # This is array or comma-separated-string 
#    columns: [ ]

  # oneToOne relationships (optional)
#    oneToOne:
    # property on php class (required)
#      member: 
      # The class name of the target entity. If it is fully-qualified it is used as is.
      # If it is a simple, unqualified class name the namespace is assumed to be the same
      # as the namespace of the source entity.
      # IMPORTANT: No leading backslash!
      targetEntity: Member
      
      # For bidirectional association. (optional)
      # property on php class on inverse side table
#        mappedBy: user

      # For bidirectional association. (optional)
      # property on php class on owning side table
      inversedBy: user
      
      # makes only sense on the owning side, 
      # the inverse side ALWAYS has to use the FETCH strategy.
      # defaults to LAZY
#        fetch:
      
      # The names of persistence operations to cascade on the association. 
      # The set of possible values are: 
      #   "persist", "remove", "detach", "merge", "refresh", "all" (implies all others).
#        cascade: [ ]
      
      joinColumn:
        name: member_id
        referencedColumnName: member_id
        fieldName: 
        unique:
        nullable:
        columnDefinition:
        onDelete:
        onUpdate:
        
#        joinColumns:
        # see oneToOne/joinColumn
#          joinColumn:
      
    # oneToMany relationships (optional)
  oneToMany:
    phoneNumbers:
      targetEntity: Phone
      mappedBy: User
      # see oneToOne/cascade
#      cascade: [ ]
      # undocumented
#      orderBy: { }
#      fetch: 
      
  # manyToOne relationships (optional)
#    manyToOne:
    
  
  # manyToMany relationships (optional)
#    manyToMany:
  
  # "event-name": [callback-function-name, ...] (optional)
  # lifeCycleCallbacks event are
  #   preRemove 
  #     The preRemove event occurs for a given entity 
  #     before the respective EntityManager remove operation for that entity is executed. 
  #     It is not called for a DQL DELETE statement.
  #   postRemove
  #     The postRemove event occurs for an entity after the entity has been deleted. 
  #     It will be invoked after the database delete operations. 
  #     It is not called for a DQL DELETE statement.
  #   prePersist 
  #     The prePersist event occurs for a given entity 
  #     before the respective EntityManager persist operation 
  #     for that entity is executed.
  #   postPersist 
  #     The postPersist event occurs for an entity after the entity 
  #     has been made persistent. 
  #     It will be invoked after the database insert operations. 
  #     Generated primary key values are available in the postPersist event.
  #   preUpdate 
  #     The preUpdate event occurs before the database update operations to entity data. 
  #     It is not called for a DQL UPDATE statement.
  #   postUpdate 
  #     The postUpdate event occurs after the database update operations to entity data. 
  #     It is not called for a DQL UPDATE statement.
  #   postLoad 
  #     The postLoad event occurs for an entity 
  #     after the entity has been loaded into the current EntityManager 
  #     from the database or after the refresh operation has been applied to it.
  #   loadClassMetadata 
  #     The loadClassMetadata event occurs 
  #     after the mapping metadata for a class has been loaded from a mapping source 
  #     (annotations/xml/yaml).
  #   onFlush 
  #     The onFlush event occurs 
  #     after the change-sets of all managed entities are computed. 
  #     This event is not a lifecycle callback.
  lifeCycleCallbacks: [  ]
Clone this wiki locally