fsi / admin-positionable-bundle
FSi admin positionable bundle.
Installs: 13 710
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 7
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.1
- fsi/admin-bundle: ^2.0|^3.0
- symfony/config: ^3.4|^4.0
- symfony/dependency-injection: ^3.4|^4.0
- symfony/event-dispatcher: ^3.4|^4.0
- symfony/framework-bundle: ^3.4|^4.0
- symfony/http-foundation: ^3.4|^4.0
- symfony/http-kernel: ^3.4|^4.0
- symfony/routing: ^3.4|^4.0
Requires (Dev)
- phpspec/phpspec: ^5.0
- phpspec/prophecy: ^1.7
README
This bundle provides way to change position of item on the list gradually. This mean that position will be changed by 1.
FSiAdminPositionableBundle
works with conjunction with Sortable behavior extension for Doctrine2
Usage
Add to AppKernel.php
:
new FSi\Bundle\AdminPositionableBundle\FSiAdminPositionableBundle(),
Add routes to /app/config/routing.yml
:
_fsi_positionable: resource: "@FSiAdminPositionableBundle/Resources/config/routing/positionable.xml" prefix: /admin
Sample entity:
Note: @Gedmo\Mapping\Annotation\SortablePosition points column to store position index
use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use FSi\Bundle\AdminPositionableBundle\Model\PositionableInterface; class Promotion implements PositionableInterface { /** * @Gedmo\SortablePosition * @ORM\Column(type="integer") */ protected $position; /** * {@inheritdoc} */ public function increasePosition() { $this->position++; } /** * {@inheritdoc} */ public function decreasePosition() { $this->position--; } }
Note: that PositionableInterface
implementation is required
Sample datagrid definition:
columns: title: type: text options: display_order: 1 label: "backend.promotions.datagrid.title.label" actions: type: action options: display_order: 2 label: "backend.promotions.datagrid.actions.label" field_mapping: [ id ] actions: move_up: route_name: "fsi_admin_positionable_decrease_position" additional_parameters: { element: "promotions" } parameters_field_mapping: { id: id } content: <span class="glyphicon glyphicon-arrow-up icon-white"></span> url_attr: { class: "btn btn-warning btn-sm" } move_down: route_name: "fsi_admin_positionable_increase_position" additional_parameters: { element: "promotions" } parameters_field_mapping: { id: id } content: <span class="glyphicon glyphicon-arrow-down icon-white"></span> url_attr: { class: "btn btn-warning btn-sm" }