Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (59 sloc) 1.95 KB
<?php
/**
* Created by PhpStorm.
* User: vincent.foulon
* Date: 04/09/2017
* Time: 13:44
*/
namespace VFou\CmsBundle\Type;
use Doctrine\ORM\EntityManagerInterface;
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use VFou\CmsBundle\Entity\Draft;
use VFou\CmsBundle\Entity\Page;
use VFou\CmsBundle\Service\CacheService;
class PageType extends AbstractType
{
public function initialize($name = "Page", $icon = "/bundles/vfoucms/icons/page.svg")
{
parent::initialize($name, $icon);
}
public function display(Page $page, $options = []){
return $page->getData();
}
public function addForm(FormBuilderInterface $fb, Page $page){
$fb->add("html", CKEditorType::class, [
"config_name" => "custom",
'label' => "page.html",
"input_sync" => true,
'data' => $page->getData(),
'mapped' => false,
"required" => false,
"translation_domain" => "forms"
]);
return $fb;
}
public function handleRequest(Request $request, Page &$page){
$html = $request->request->get("vfou_cmsbundle_page")["html"];
$page->setData($html);
}
public function frontendEditing(FormBuilderInterface $fb, Page $page, Draft $draft, &$options)
{
$fb->add("html", CKEditorType::class, [
"inline" => true,
"label_attr" => ["style"=>"display:none;"],
"input_sync" => true,
"data" => $draft->getData(),
]);
return $fb;
}
public function fEditingHandle(Request $request, Page &$page, Draft &$draft)
{
$html = $request->request->get("form")["html"];
$draft->setData($html);
}
public function getCacheLevel() {return CacheService::PERMANENT;}
}
You can’t perform that action at this time.