Doctrine Utils
Doctrine Utils
Siteadmin 3 using Doctrine 2 as the ORM of choice. The doctrineUtils
helper encapsulates a collection of functions that preform common operations with a doctrine entity. These operations range from converting an entity to an array to retrieving data store information about an entity.
Convert entity to array
Association Configuration
The $associationConfiguration
parameter in getEntityArray()
is a map of entities which are allowed to be included in the object to array conversion process. This allows you to exclude unwanted data sets from the parsing process.
Example
The code snippet above will parse the user's id
, name
, and followers
fields into an array. The posts
property will be ignored, because it is not included in the association configuration.
Notice the association configuration is a key/value pair, where the key is the name of the associated entity, and the value is its type. The value will almost always be
object
.
Result
You may assume the user's ID is 12
.
Convert entity collection to array
Set entity properties from array
Given a property map with the format [propertyName => value], calls the setters on the given entity with the passed value data.
Example
Get entity meta data
Retrieves information about an entity's methods and properties.
Last updated