Notice: You are browsing the documentation for PrestaShop 8, which is currently in development.You might want to read the documentation for the current version, PrestaShop 1.7.
As mentioned in CQRS principles, a
Command is a representation of a single domain use case. To prevent
Command Handlers from duplicating code and depending on each other, it is usually best to avoid implementing the actual logic in the
Command Handler itself, and delegate it to
Domain Services instead. These services are responsible for logic such as:
Here are some principles for implementing a Domain Service:
ObjectModelfor writes, as long as such class exists.
ObjectModelexists, then this query MUST be delegated to the appropriate repository class which must ensure that no legacy exceptions are thrown. If the related
ObjectModelalready implements such method, then the repository must delegate its implementation to the
ObjectModelcontains fields validation, it MUST be validated by a dedicated validator class before persisting to database (e.g. when using
savemethods). It ensures that legacy PrestashopException is not bubbling up and each validation error can be identified by a dedicated exception or exception code.