Understanding how a Brick works
In simple words, a Brick is composed of a class that takes the place of the controller and a view. Building a Brick is not so different from implementing an MVC page. The most important exception is that, in this case, we do not have the routing part, as the Brick is added to an existing page (it cannot be run standalone). In the following diagram, we have a schema that explains how Bricks work:
In the previous diagram, we can see that a page (My Page) can host many bricks. Each one is composed of a Class and two templates (edit and view).
In the following sections, we will learn how to implement every single component, including classes and templates.
The class implementation
A brick is an instance of Pimcore\Extension\Document\Areabrick\AreabrickInterface
, but for convenience, we always extend the AbstractTemplateAreabrick
class, which implements the interface and gives us...