Skip to content

Entities

Albert Juhe Brugué edited this page Nov 10, 2018 · 4 revisions

Entities

Update entities after creation:

php bin/console doctrine:schema:update --force

Entity

namespace App\Domain\Travel\Model;
use App\Domain\Event\DomainEventPublisher;
use App\Domain\Gpx\Model\Gpx;
use App\Domain\Location\Model\Location;
use App\Domain\User\Model\User;
use App\Domain\Travel\ValueObject\GeoLocation;
use App\Domain\Travel\Events\TravelWasPublished;
class Travel
{
    const TRAVEL_DRAFT = 10;
    const TRAVEL_PUBLISHED = 20;
    protected $id;
    /** @var string */
    protected $title;
    /** @var string */
    protected $description;
    /** @var \DateTime */
    protected $createdAt;
    /** @var \DateTime */
    protected $updatedAt;
    /** @var string */
    private $slug;
    /** @var string */
    private $photo;
    /** @var GeoLocation */
    private $geoLocation;
    /** @var \DateTime */
    protected $startAt;
    /** @var \DateTime */
    protected $endAt;
    /** @var int */
    private $starts;
    /** @var int */
    private $watch;
    /** @var Gpx */
    private $gpx;
    /** @var User */
    private $user;
    /** @var Array */
    private $sharedusers;
    /** @var Location */
    private $location;
    /** @var \DateTime */
    private $publishedAt;
    /** @var int */
    private $status;
...

ORM configuration

  App\Domain\Travel\Model\Travel:
    type: entity
    table: travel
    id:
        id:
            type: integer
            scale: 0
            length: null
            unique: false
            nullable: false
            precision: 0
            id: true
            generator:
                strategy: IDENTITY
    fields:
        createdAt:
            type: datetime
            scale: 0
            length: null
            unique: false
            nullable: false
            precision: 0
            column: created_at
        updatedAt:
            type: datetime
            scale: 0
            length: null
            unique: false
            nullable: false
            precision: 0
            column: updated_at
        title:
            type: string
            scale: 0
            length: 255
            unique: false
            nullable: false
            precision: 0
        slug:
           type: string
           length: 500
           gedmo:
              translatable: {}
              slug:
                separator: -
                fields:
                   - title
        photo:
            type: string
            scale: 0
            length: 255
            unique: false
            nullable: true
            precision: 0
        startAt:
            type: datetime
            scale: 0
            length: null
            unique: false
            nullable: false
            precision: 0
            column: start_at
        endAt:
            type: datetime
            scale: 0
            length: null
            unique: false
            nullable: false
            precision: 0
            column: end_at
        description:
            type: text
            scale: 0
            length: null
            unique: false
            nullable: true
            precision: 0
        starts:
            type: integer
            scale: 0
            length: null
            unique: false
            nullable: true
            precision: 0
        watch:
            type: integer
            scale: 0
            length: null
            unique: false
            nullable: true
            precision: 0
        status:
            type: integer
            scale: 0
            length: null
            unique: false
            nullable: true
            precision: 0
    embedded:
        geoLocation:
            class: App\Domain\Travel\ValueObject\GeoLocation
            columnPrefix: false
    manyToOne:
        user:
            targetEntity: App\Domain\User\Model\User
            cascade: {  }
            fetch: LAZY
            mappedBy: null
            inversedBy: travel
            joinColumns:
                user_id:
                    referencedColumnName: id
            orphanRemoval: false
    oneToMany:
        location:
            targetEntity: App\Domain\Location\Model\Location
            cascade:
                - persist
            fetch: LAZY
            mappedBy: travel
            inversedBy: null
            orphanRemoval: false
            orderBy: null
        gpx:
            targetEntity: App\Domain\Gpx\Model\Gpx
            cascade:
                - persist
            fetch: LAZY
            mappedBy: travel
            inversedBy: null
            orphanRemoval: false
            orderBy: null
    manyToMany:
        sharedusers:
            targetEntity: App\Domain\User\Model\User
            cascade:
                - persist
            fetch: LAZY
            mappedBy: travelsshared
            inversedBy: null
            joinTable: {  }

Doctrine mapping

 orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            Travel:
               type: yml
               prefix: App\Domain\Travel\Model
               dir: '%kernel.root_dir%/../src/Infrastructure/TravelBundle/Resources/config/persistence'
               is_bundle: false
Clone this wiki locally