Download the PHP package cscfa_tool_division/csr3-dto without Composer
On this page you can find all versions of the php package cscfa_tool_division/csr3-dto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cscfa_tool_division/csr3-dto
More information about cscfa_tool_division/csr3-dto
Files in cscfa_tool_division/csr3-dto
Package csr3-dto
Short Description The CSCFA csr Division PHP implementation
License MIT
Informations about the package csr3-dto
CSR3 Data Transfer Object
This project is the PHP implementation of the csr3 specification.
The data transfer objects are elements used to encapsulate the data when they must go through multiple elements of an application. The DTO acts as a container.
Basic usage
The CSR3 project define a generic DTO object :
The CSR3GenericDTO is an instance that implement CSR3DTOInterface. This interface extend ArrayAccess and Iterator interfaces.
The ArrayAccess iplementation
By using the ArrayAccess interface, the CSR3GenericDTO allow to be used as an array.
The Iterator iplementation
By using the Iterator interface, the CSR3GenericDTO allow to be used as an iterator.
The CSR3DTOInterface iplementation
The CSR3DTOInterface is the default access feature of the CSR3 DTOs. It allow to set and get attributes.
Adding custom methods
The CSR3GenericDTO is a final class and cannot be extended as it. But it extend an abstract class : the AbstractCSR3DTO that define all the logic needed to implement the CSR3DTOInterface.
Imagine you want to create a DTO that store a specific context and you want to be able to retreive this by a method call. You can create a DTO class as the following :
Using custom class properties
As seen in the custom method addition, you'll must create your own class :
The problem yu will discover by using this custom class is that the ArrayAccess and iterator property are not able to handle the $context
property. To avoid this issue, you'll need to extend the AbstractCSR3PropertyDTO
instead of the AbstractCSR3DTO
.
:anger: Note the AbstractCSR3PropertyDTO is not able to process private properties as it. This is in fact the POO structure of the PHP.
Using private properties
To be able to manage the private properties of your DTO's, you'll must override three methods of the AbstractCSR3PropertyDTO
:
:grey_exclamation: These three methods work in cooperation and cannot be override without the other to enable the fully private property support.
Internal key-words and how to override them
The AbstractCSR3DTO
and AbstractCSR3PropertyDTO
defines an attributes and traversingPosition properties. The first one store the attributes of the DTO, the second store the internal iteration pointer. It is possible to override them by setting a attributeContainer and a positionContainer properties that store the attributes names to use instead of the two initial properties.
:anger: The attributeContainer and positionContainer properties are key-words and cannot be overrides.
Using logic without CSR3 interfaces
The complete logic of this implementation is encapsulated inside a CSR3DTOTrait
and a CSR3PropertyDTOTrait
.