Skip to content

Instantly share code, notes, and snippets.

@rande
Created March 8, 2014 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rande/9439778 to your computer and use it in GitHub Desktop.
Save rande/9439778 to your computer and use it in GitHub Desktop.
<?php
namespace Sonata\Bundle\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Acl\Model\DomainObjectInterface;
/**
* @ORM\Entity
* @ORM\Table(name="test_color")
*/
class Color implements DomainObjectInterface
{
/**
* @ORM\Id
* @ORM\Column(type="string")
* @ORM\GeneratedValue(strategy="NONE")
*/
protected $r;
/**
* @ORM\Id
* @ORM\Column(type="string")
* @ORM\GeneratedValue(strategy="NONE")
*/
protected $g;
/**
* @ORM\Id
* @ORM\Column(type="string")
* @ORM\GeneratedValue(strategy="NONE")
*/
protected $b;
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\ManyToOne(targetEntity="Material", cascade={"persist"}, fetch="EAGER")
*/
protected $material;
/**
* @param mixed $b
*/
public function setB($b)
{
$this->b = $b;
}
/**
* @return mixed
*/
public function getB()
{
return $this->b;
}
/**
* @param mixed $material
*/
public function setMaterial(Material $material)
{
$this->material = $material;
}
/**
* @return mixed
*/
public function getMaterial()
{
return $this->material;
}
/**
* @param mixed $g
*/
public function setG($g)
{
$this->g = $g;
}
/**
* @return mixed
*/
public function getG()
{
return $this->g;
}
/**
* @param mixed $r
*/
public function setR($r)
{
$this->r = $r;
}
/**
* @return mixed
*/
public function getR()
{
return $this->r;
}
/**
* Returns a unique identifier for this domain object.
*
* @return string
*/
public function getObjectIdentifier()
{
return sprintf("%d-%d-%d-%d", $this->getR(), $this->getG(), $this->getB(), $this->getMaterial() ? $this->getMaterial()->getId() : null);
}
/**
* @return string
*/
public function __toString()
{
return $this->getObjectIdentifier() ?: "n/a";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment