Skip to content

Instantly share code, notes, and snippets.

@alihammad-gist
Created October 12, 2014 19:45
Show Gist options
  • Save alihammad-gist/1adb10868eddef3049fb to your computer and use it in GitHub Desktop.
Save alihammad-gist/1adb10868eddef3049fb to your computer and use it in GitHub Desktop.
<?php
namespace Staff\Entity;
class Member
{
const IMAGE_BASE_PATH = '/img/staff';
protected $id;
protected $name;
protected $imagePath;
protected $description;
protected $rank;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function getImagePath()
{
return $this->imagePath;
}
public function getFullImagePath()
{
if (!$this->imagePath) {
return null;
}
return static::IMAGE_BASE_PATH . '/' . $this->imagePath;
}
public function getDescription()
{
return $this->description;
}
public function getRank()
{
return $this->rank;
}
public function setId($id)
{
$this->id = $id;
}
public function setName($name)
{
$this->name = $name;
}
public function setImagePath($path)
{
$this->imagePath = $path;
}
public function setDescription($description)
{
$this->description = $description;
}
public function setRank(Rank $rank)
{
$this->rank = $rank;
}
}
<?php
namespace Staff\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
class Rank
{
protected $id;
protected $title;
protected $members;
public function __construct()
{
$this->members = new ArrayCollection;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
public function getMembers()
{
return $this->members;
}
public function setMembers(Collection $members)
{
$this->members = $members;
}
}
Staff\Entity\Member:
type: entity
repositoryClass: Staff\Repository\Member
id:
id:
type: integer
generator: { strategy: AUTO }
indexes:
rank_index:
columns: [ name ]
fields:
name:
type: string
length: 150
imagePath:
type: string
length: 350
nullable: true
description:
type: text
manyToOne:
rank:
targetEntity: Staff\Entity\Rank
inversedBy: members
joinColumn:
name: rank_id
referencedColumnName: id
Staff\Entity\Rank:
type: entity
repositoryClass: Staff\Repository\Rank
id:
id:
type: integer
generator: { strategy: AUTO }
indexes:
title_id:
columns: [ title, id ]
fields:
title:
type: string
length: 200
oneToMany:
members:
targetEntity: Staff\Entity\Member
mappedBy: rank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment