PHP code example of barthy-koeln / cached-prezent-translation
1. Go to this page and download the library: Download barthy-koeln/cached-prezent-translation library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
barthy-koeln / cached-prezent-translation example snippets
use BarthyKoeln\CachedPrezentTranslation\CachedPrezentTranslationTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Prezent\Doctrine\Translatable\Entity\AbstractTranslatable;
class TranslatedEntity extends AbstractTranslatable
{
use CachedPrezentTranslationTrait;
/**
* @Assert\Valid()
* @Prezent\Translations(targetEntity="App\Entity\TranslatedEntityTranslation")
* @var ArrayCollection
*/
protected $translations;
public function __construct()
{
$this->translations = new ArrayCollection();
}
public function getTitle(?string $locale = null): string
{
return $this->translate($locale)->getTitle();
}
}