Download the PHP package xepozz/entity-sorter-bundle without Composer
On this page you can find all versions of the php package xepozz/entity-sorter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xepozz/entity-sorter-bundle
More information about xepozz/entity-sorter-bundle
Files in xepozz/entity-sorter-bundle
Package entity-sorter-bundle
Short Description Adds sorting functionality to entities
License MIT
Informations about the package entity-sorter-bundle
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Add it to an entity
Add the Doctrine entity listener to your entitiy and don't forget to include all the use statements. Then extend your Entity with BaseSort as shown as in the example below.
After this changes the sort value is already being set automatically for new database entries and is also correctly modified when you delete or update entries.
Step 3: Move items up and down
To move your items up or down in the sort order use the entity functions and . You can, for example, call these functions in your controller. Your controller class has to extend the Symfony controller:
(Optional) Step 4: Sorting within a supercategory
If your entity is a subcategory of another entity and should be sorted only within its own supercategory, you need to overwrite the function in your entity.
In the example below we have a product sub category that needs to be sorted within the product category.
An entity can have several supercategories. The array returned in getSuperCategories
just has to contain the values from them. The order of the supercategories has no influence on the sorting: