Michael Albrecht
Java CAT & PHP Pussy - team neusta
In some situations we have to transform Pimcore Objects into a different world.
Typical example are View objects or Elastic search engine objects.
Jerseys
Vouchers
Soccer School
Other
Merchandising
Articles
ProductView
VoucherView
JerseyView
SoccerSchoolView
In our DSV Project we had:
class SorteView extends BaseSorteView
{
...
/**
* @var TableView[]
*/
private array $tables = [];
/**
* @var LongTextView[]
*/
private array $longTexts = [];
... // Getters & Setters
}
Separating different concerns of representing objects
Being uncoupled from external systems (ERP, Printing, ...)
Separating transformation logic from templates itself
Making transformation much more testable
Keeping high cohesion of transforming attribute-wise by
Populators
"Use this pattern wherever you have to map a typed object from one universe to another"
Entities
Pimcore
DataObjects
Symfony Services
Symfony Controllers
Product
ERPProduct
ProductDTO
ProductView
ProductPrintDTO
ProductEntity
ProductBonus
Each Populator can be implemented quite simple and test-driven.
For setting specific attribute values one can use the whole power of PHP programming
(e.g. instead of Twig functions)
Transformation becomes Backend development task
Supports Open-Closed-Principle
Design by Contract
Code Generation Bundle
Generalization of TableView- and TableRow Population from DSV
Generic (polymorphic) approach
http://www.michael-albrecht.de
@Michael_HB
m.albrecht@neusta.de
Development Amplifier
Java CAT & PHP Pussy
By Michael Albrecht
A short lecture on the pattern "Converter & Populator"