Created
February 11, 2014 08:13
-
-
Save pdrosos/8930978 to your computer and use it in GitHub Desktop.
Translatable Doctrine Entity in Typo3 Flow 2.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My\Gallery\Domain\Model; | |
use TYPO3\Flow\Annotations as Flow; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
use Gedmo\Translatable\Translatable; | |
/** | |
* Domain Model of a Gallery | |
* | |
* @Flow\Entity | |
* @ORM\Table(indexes={ | |
* @ORM\Index(name="name_idx", columns={"name"}), | |
* @ORM\Index(name="createdAt_idx", columns={"createdAt"}), | |
* @ORM\Index(name="updatedAt_idx", columns={"updatedAt"}) | |
* }) | |
* @Gedmo\TranslationEntity(class="My\Gallery\Domain\Model\Translation\GalleryTranslation") | |
*/ | |
class Gallery implements Translatable { | |
/** | |
* @Flow\Transient | |
* @Gedmo\Locale | |
* Used locale to override Translation listener`s locale | |
* this is not a mapped field of entity metadata, just a simple property | |
*/ | |
protected $locale; | |
/** | |
* Name | |
* | |
* @var string | |
* @Flow\Validate(type="NotEmpty") | |
* @Flow\Validate(type="StringLength", options={ "minimum"=1, "maximum"=50 }) | |
* @Gedmo\Translatable | |
*/ | |
protected $name; | |
/** | |
* Description | |
* | |
* @var string | |
* @ORM\Column(type="text") | |
* @Gedmo\Translatable | |
*/ | |
protected $description; | |
/** | |
* Create date | |
* | |
* @var \DateTime | |
* @ORM\Column(type="datetime") | |
* @Gedmo\Timestampable(on="create") | |
*/ | |
protected $createdAt; | |
/** | |
* Last update date | |
* | |
* @var \DateTime | |
* @ORM\Column(type="datetime") | |
* @Gedmo\Timestampable(on="update") | |
*/ | |
protected $updatedAt; | |
/** | |
* Set translatable locale | |
* | |
* @param string $locale | |
*/ | |
public function setTranslatableLocale($locale) { | |
$this->locale = $locale; | |
} | |
/** | |
* @return string | |
*/ | |
public function getName() { | |
return $this->name; | |
} | |
/** | |
* @param string $name | |
*/ | |
public function setName($name) { | |
$this->name = $name; | |
} | |
/** | |
* Set description | |
* | |
* @param string $description | |
*/ | |
public function setDescription($description) { | |
$this->description = $description; | |
} | |
/** | |
* Get description | |
* | |
* @return string | |
*/ | |
public function getDescription() { | |
return $this->description; | |
} | |
/** | |
* @return \DateTime | |
*/ | |
public function getCreatedAt() { | |
return $this->createdAt; | |
} | |
/** | |
* @return \DateTime | |
*/ | |
public function getUpdatedAt() { | |
return $this->updatedAt; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment