Browse Source

add text page

develop
Simon Vieille 3 weeks ago
parent
commit
36487fe685
  1. 4
      config/packages/app.yaml
  2. 19
      src/Controller/TextController.php
  3. 44
      src/Entity/Page/TextPage.php
  4. 1
      templates/page/text/default.txt.twig

4
config/packages/app.yaml

@ -23,6 +23,10 @@ core:
name: 'RSS'
templates:
- {name: "Par défaut", file: "page/rss/default.xml.twig"}
App\Entity\Page\TextPage:
name: 'Texte'
templates:
- {name: "Par défaut", file: "page/text/default.txt.twig"}
fos_js_routing:
routes_to_expose:

19
src/Controller/TextController.php

@ -0,0 +1,19 @@
<?php
namespace App\Controller;
use App\Api\TTRssClient;
use App\Core\Controller\Site\PageController;
use App\Markdown\Parser\Post as PostParser;
use Symfony\Component\HttpFoundation\Response;
class TextController extends PageController
{
public function text(): Response
{
$response = new Response();
$response->headers->set('Content-Type', 'text/plain');
return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [], $response);
}
}

44
src/Entity/Page/TextPage.php

@ -0,0 +1,44 @@
<?php
namespace App\Entity\Page;
use App\Core\Entity\Site\Page\Block;
use App\Core\Entity\Site\Page\FileBlock;
use App\Core\Form\Site\Page\TextareaBlockType;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Form\FormBuilderInterface;
use App\Core\Entity\Site\Page\Page;
/**
* @ORM\Entity
*/
class TextPage extends Page
{
public function buildForm(FormBuilderInterface $builder)
{
$builder->add(
'content',
TextareaBlockType::class,
[
'label' => 'Contenu',
'options' => [
'attr' => [
'rows' => '50',
],
'constraints' => [
],
],
]
);
}
public function setContent(Block $block)
{
return $this->setBlock($block);
}
public function getContent()
{
return $this->getBlock('content');
}
}

1
templates/page/text/default.txt.twig

@ -0,0 +1 @@
{{ _page.content.value|raw }}
Loading…
Cancel
Save