add documentation
This commit is contained in:
parent
3043f1ef1d
commit
bd4bc81e9d
|
@ -28,16 +28,129 @@ core:
|
|||
name: 'Your page'
|
||||
templates:
|
||||
- {name: "Template 1", file: "page/your_page/template1.html.twig"}
|
||||
App\Entity\Page\SimplePage:
|
||||
name: 'Page simple'
|
||||
templates:
|
||||
- {name: "Template", file: "page/simple/template.html.twig"}
|
||||
App\Entity\Page\SimplePage:
|
||||
name: 'Page simple'
|
||||
templates:
|
||||
- {name: "Template", file: "page/simple/template.html.twig"}
|
||||
App\Entity\Page\SimplePage:
|
||||
name: 'Page simple'
|
||||
templates:
|
||||
- {name: "Template", file: "page/simple/template.html.twig"}
|
||||
App\Entity\Page\SimplePage:
|
||||
name: 'Page simple'
|
||||
templates:
|
||||
- {name: "Template", file: "page/simple/template.html.twig"}
|
||||
- {name: "Template 2", file: "page/your_page/template2.html.twig"}
|
||||
```
|
||||
|
||||
### Page
|
||||
|
||||
A page is a doctrine entity that contains blocks and a way to edit them. For each element defined in `buildForm`, you must add a getter and a setter. See the example below.
|
||||
|
||||
```
|
||||
// src/Entity/Page/YourPage.php
|
||||
namespace App\Entity\Page;
|
||||
|
||||
use App\Core\Entity\Site\Page\Block;
|
||||
use App\Core\Entity\Site\Page\Page;
|
||||
use App\Core\Form\Site\Page\TextBlockType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class YourPage extends Page
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add(
|
||||
'myBlock',
|
||||
TextBlockType::class,
|
||||
[
|
||||
'label' => 'My block',
|
||||
'options' => [
|
||||
// options given to the sub form
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function setTitle(Block $block)
|
||||
{
|
||||
return $this->setBlock($block);
|
||||
}
|
||||
|
||||
public function getTitle(): Block
|
||||
{
|
||||
return $this->getBlock('myBlock');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### TextBlockType
|
||||
|
||||
`App\Core\Form\Site\Page\TextBlockType` will render a symfony `TextType`.
|
||||
|
||||
#### TextareaBlockType
|
||||
|
||||
`App\Core\Form\Site\Page\TextareaBlockType` will render a symfony `TextareaType`.
|
||||
|
||||
#### FileBlockType
|
||||
|
||||
`App\Core\Form\Site\Page\FileBlockType` will render a symfony `FileType` with a download link.
|
||||
|
||||
In the getter, you must specify the block:
|
||||
|
||||
```
|
||||
use App\Core\Entity\Site\Page\FileBlock;
|
||||
|
||||
public function getMyBlock(): Block
|
||||
{
|
||||
return $this->getBlock('myBlock', FileBlock::class);
|
||||
}
|
||||
```
|
||||
|
||||
#### ImageBlockType
|
||||
|
||||
`App\Core\Form\Site\Page\ImageBlockType` will render a symfony `FileType` with a preview of the image.
|
||||
|
||||
In the getter, you must specify the block:
|
||||
|
||||
```
|
||||
use App\Core\Entity\Site\Page\FileBlock;
|
||||
|
||||
public function getMyBlock(): Block
|
||||
{
|
||||
return $this->getBlock('myBlock', FileBlock::class);
|
||||
}
|
||||
```
|
||||
|
||||
#### CollectionBlockType
|
||||
|
||||
`App\Core\Form\Site\Page\CollectionBlockType` will a render a symfony `CollectionType ` with availabity to add and remove elements.
|
||||
|
||||
```
|
||||
use App\Core\Entity\Site\Page\CollectionBlock;
|
||||
|
||||
public function getMyBlock(): Block
|
||||
{
|
||||
return $this->getBlock('myBlock', CollectionBlock::class);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Routing
|
||||
|
||||
The routing tab is very important. It allows you to define all parameters related to:
|
||||
|
||||
* The routing (obviously):
|
||||
* An optional URL with parameters
|
||||
* A route name generated using the code
|
||||
* An optional URL with parameters
|
||||
* A route name generated using the field `code`
|
||||
* A custom content-type of the response (eg: 'text/plain')
|
||||
* A custom controller called when the node is requested
|
||||
|
||||
|
|
Loading…
Reference in a new issue