<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface PageInterface | |||||
{ | |||||
} |
*/ | */ | ||||
protected $image; | protected $image; | ||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $devAlias; | |||||
public function getTitle(): ?string | public function getTitle(): ?string | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getDevAlias(): ?string | |||||
{ | |||||
return $this->devAlias; | |||||
} | |||||
public function setDevAlias(?string $devAlias): self | |||||
{ | |||||
$this->devAlias = $devAlias; | |||||
return $this; | |||||
} | |||||
} | } |
namespace Lc\ShopBundle\Model; | namespace Lc\ShopBundle\Model; | ||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
/** | /** |
<?php | |||||
namespace Lc\ShopBundle\Model; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Page extends AbstractDocumentEntity | |||||
{ | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $content; | |||||
public function __toString() | |||||
{ | |||||
return $this->getTitle() ; | |||||
} | |||||
public function getContent(): ?string | |||||
{ | |||||
return $this->content; | |||||
} | |||||
public function setContent(?string $content): self | |||||
{ | |||||
$this->content = $content; | |||||
return $this; | |||||
} | |||||
} |
} | } | ||||
public function findOneByDevAlias($devAlias) | |||||
{ | |||||
return $this->createQueryBuilder('e') | |||||
->where('e.devAlias = :devAlias') | |||||
->andWhere('object.status = 1') | |||||
->setParameter('devAlias', $devAlias) | |||||
->getQuery() | |||||
->getResult(); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Repository; | |||||
use App\Entity\Page; | |||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | |||||
use Doctrine\Common\Persistence\ManagerRegistry; | |||||
use Lc\ShopBundle\Repository\BaseRepository; | |||||
/** | |||||
* @method Page|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method Page|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method Page[] findAll() | |||||
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class PageRepository extends BaseRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, Page::class); | |||||
} | |||||
// /** | |||||
// * @return Page[] Returns an array of Page objects | |||||
// */ | |||||
/* | |||||
public function findByExampleField($value) | |||||
{ | |||||
return $this->createQueryBuilder('p') | |||||
->andWhere('p.exampleField = :val') | |||||
->setParameter('val', $value) | |||||
->orderBy('p.id', 'ASC') | |||||
->setMaxResults(10) | |||||
->getQuery() | |||||
->getResult() | |||||
; | |||||
} | |||||
*/ | |||||
/* | |||||
public function findOneBySomeField($value): ?Page | |||||
{ | |||||
return $this->createQueryBuilder('p') | |||||
->andWhere('p.exampleField = :val') | |||||
->setParameter('val', $value) | |||||
->getQuery() | |||||
->getOneOrNullResult() | |||||
; | |||||
} | |||||
*/ | |||||
} |
var elements = $( '.lc-ckeditor' ); | var elements = $( '.lc-ckeditor' ); | ||||
for ( var i = 0; i < elements.length; ++i ) { | for ( var i = 0; i < elements.length; ++i ) { | ||||
CKEDITOR.replace( elements[ i ], {"toolbar":[{"name":"styles","items":["Bold","Italic","BulletedList","Link","imageUpload","ckfinder"]}],"language":"fr"} ); | |||||
var editor = CKEDITOR.replace( elements[ i ], {"toolbar":[ | |||||
{name:"styles",items:["Format",'Bold', 'Italic', 'Underline', 'Strike',"Link","BulletedList"]}, | |||||
{name: 'paragraph', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] }, | |||||
{name: 'insert', items: [ 'Image','SpecialChar'] }, | |||||
{name:"document",items:["Source"]}, | |||||
], | |||||
"language":"fr"} ); | |||||
CKFinder.setupCKEditor(editor); | |||||
} | } | ||||
} | } | ||||
namespace Lc\ShopBundle\Services; | namespace Lc\ShopBundle\Services; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\ShopBundle\Context\PageInterface; | |||||
class Utils | class Utils | ||||
{ | { | ||||
protected $em ; | |||||
protected $unitsArray = [ | protected $unitsArray = [ | ||||
'piece' => [ | 'piece' => [ | ||||
'unit' => 'piece', | 'unit' => 'piece', | ||||
], | ], | ||||
]; | ]; | ||||
public function __construct(EntityManagerInterface $em) | |||||
{ | |||||
$this->em = $em ; | |||||
} | |||||
public static function getDayByNumber($number) | public static function getDayByNumber($number) | ||||
{ | { | ||||
$daysArray = [ | $daysArray = [ | ||||
1 => 'Lundu', | |||||
1 => 'Lundi', | |||||
2 => 'Mardi', | 2 => 'Mardi', | ||||
3 => 'Mercredi', | 3 => 'Mercredi', | ||||
4 => 'Jeudi', | 4 => 'Jeudi', | ||||
return '' ; | return '' ; | ||||
} | } | ||||
public function getUnitsListFormatedForType(){ | |||||
public function getUnitsListFormatedForType() { | |||||
foreach ($this->unitsArray as $unit=>$unitInfo){ | foreach ($this->unitsArray as $unit=>$unitInfo){ | ||||
$choices[$unitInfo['wording_unit']] = $unit; | $choices[$unitInfo['wording_unit']] = $unit; | ||||
}; | }; | ||||
return $choices; | return $choices; | ||||
} | } | ||||
public function getUnitsList(){ | |||||
public function getUnitsList() { | |||||
return $this->unitsArray; | return $this->unitsArray; | ||||
} | } | ||||
public function getElementByDevAlias($devAlias, $class = PageInterface::class) | |||||
{ | |||||
$class = $this->em->getClassMetadata($class)->getName(); | |||||
return $this->em->getRepository($class)->findOneByDevAlias($devAlias) ; | |||||
} | |||||
} | } |
namespace Lc\ShopBundle\Twig; | namespace Lc\ShopBundle\Twig; | ||||
use Lc\ShopBundle\Context\PageInterface; | |||||
use Lc\ShopBundle\Services\Utils; | use Lc\ShopBundle\Services\Utils; | ||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFilter; | |||||
use Twig\TwigFunction; | use Twig\TwigFunction; | ||||
class BridgeTwigExtension extends AbstractExtension | class BridgeTwigExtension extends AbstractExtension | ||||
return array( | return array( | ||||
new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']), | new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']), | ||||
new TwigFunction('getUnitsList', [$this, 'getUnitsList']), | new TwigFunction('getUnitsList', [$this, 'getUnitsList']), | ||||
new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']), | |||||
); | ); | ||||
} | } | ||||
return $this->utils->getUnitsList() ; | return $this->utils->getUnitsList() ; | ||||
} | } | ||||
public function getElementByDevAlias($devAlias, $class = PageInterface::class) | |||||
{ | |||||
return $this->utils->getElementByDevAlias($devAlias, $class) ; | |||||
} | |||||
} | } |