Download the PHP package mario-legenda/entity-filter without Composer
On this page you can find all versions of the php package mario-legenda/entity-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mario-legenda/entity-filter
More information about mario-legenda/entity-filter
Files in mario-legenda/entity-filter
Package entity-filter
Short Description Filters collection of entities and transformers them into array
License MIT
Homepage https://github.com/MarioLegenda/entity-filter
Informations about the package entity-filter
Entity filter
Filters Doctrine enitites and transformers them into arrays. Examples speak for themselves, so read on.
Installation
$ composer require mario-legenda/entity-filter
Basic usage
Let's say we have a User
entity that has 25 fields that describe a certain user, like name, lastname,
social security number etc. If you want only 10 of those fields, you would have to manually call each and
every method and place them in some variables. Code is as follows...
This creates some ugly code. If you wish to put the values of those fields in an array, the code is even uglier.
Now, you could say that you can query the database with DQL, but in some cases, you need a clean entity if, for example, you wish to update the User to the database. This is the situtation where this tool comes in handy.
$filtered
is an array that holds id
, name
and other values that you ask from it. EntityFilter::setDataVar()
sets the value of an array key that holds the array with the specified values from the User entity. Default
is data
.
I hope that someone finds this helpfull.