@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface PageInterface | |||
{ | |||
} |
@@ -38,6 +38,11 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn | |||
*/ | |||
protected $image; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $devAlias; | |||
public function getTitle(): ?string | |||
{ | |||
@@ -87,5 +92,16 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn | |||
return $this; | |||
} | |||
public function getDevAlias(): ?string | |||
{ | |||
return $this->devAlias; | |||
} | |||
public function setDevAlias(?string $devAlias): self | |||
{ | |||
$this->devAlias = $devAlias; | |||
return $this; | |||
} | |||
} |
@@ -2,8 +2,6 @@ | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
/** |
@@ -0,0 +1,33 @@ | |||
<?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; | |||
} | |||
} |
@@ -36,5 +36,15 @@ class BaseRepository extends EntityRepository implements ServiceEntityRepository | |||
} | |||
public function findOneByDevAlias($devAlias) | |||
{ | |||
return $this->createQueryBuilder('e') | |||
->where('e.devAlias = :devAlias') | |||
->andWhere('object.status = 1') | |||
->setParameter('devAlias', $devAlias) | |||
->getQuery() | |||
->getResult(); | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
<?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() | |||
; | |||
} | |||
*/ | |||
} |
@@ -45,7 +45,14 @@ function initLcCkEditor(){ | |||
var elements = $( '.lc-ckeditor' ); | |||
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); | |||
} | |||
} | |||
@@ -2,8 +2,13 @@ | |||
namespace Lc\ShopBundle\Services; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\ShopBundle\Context\PageInterface; | |||
class Utils | |||
{ | |||
protected $em ; | |||
protected $unitsArray = [ | |||
'piece' => [ | |||
'unit' => 'piece', | |||
@@ -55,10 +60,15 @@ class Utils | |||
], | |||
]; | |||
public function __construct(EntityManagerInterface $em) | |||
{ | |||
$this->em = $em ; | |||
} | |||
public static function getDayByNumber($number) | |||
{ | |||
$daysArray = [ | |||
1 => 'Lundu', | |||
1 => 'Lundi', | |||
2 => 'Mardi', | |||
3 => 'Mercredi', | |||
4 => 'Jeudi', | |||
@@ -74,17 +84,20 @@ class Utils | |||
return '' ; | |||
} | |||
public function getUnitsListFormatedForType(){ | |||
public function getUnitsListFormatedForType() { | |||
foreach ($this->unitsArray as $unit=>$unitInfo){ | |||
$choices[$unitInfo['wording_unit']] = $unit; | |||
}; | |||
return $choices; | |||
} | |||
public function getUnitsList(){ | |||
public function getUnitsList() { | |||
return $this->unitsArray; | |||
} | |||
public function getElementByDevAlias($devAlias, $class = PageInterface::class) | |||
{ | |||
$class = $this->em->getClassMetadata($class)->getName(); | |||
return $this->em->getRepository($class)->findOneByDevAlias($devAlias) ; | |||
} | |||
} |
@@ -2,9 +2,9 @@ | |||
namespace Lc\ShopBundle\Twig; | |||
use Lc\ShopBundle\Context\PageInterface; | |||
use Lc\ShopBundle\Services\Utils; | |||
use Twig\Extension\AbstractExtension; | |||
use Twig\TwigFilter; | |||
use Twig\TwigFunction; | |||
class BridgeTwigExtension extends AbstractExtension | |||
@@ -21,6 +21,7 @@ class BridgeTwigExtension extends AbstractExtension | |||
return array( | |||
new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']), | |||
new TwigFunction('getUnitsList', [$this, 'getUnitsList']), | |||
new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']), | |||
); | |||
} | |||
@@ -40,4 +41,8 @@ class BridgeTwigExtension extends AbstractExtension | |||
return $this->utils->getUnitsList() ; | |||
} | |||
public function getElementByDevAlias($devAlias, $class = PageInterface::class) | |||
{ | |||
return $this->utils->getElementByDevAlias($devAlias, $class) ; | |||
} | |||
} |