2017 © Pedro PelĆ”ez
 

library doctrine-sortable

Doctrine sortable entities for Nette framework.

image

librette/doctrine-sortable

Doctrine sortable entities for Nette framework.

  • Wednesday, February 21, 2018
  • by matej21
  • Repository
  • 4 Watchers
  • 2 Stars
  • 2,752 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

doctrine-sortable

Sooner or later you will have to implement sorting of your entities. For example categories, products on main page and so on. And why you should do this by yourself when everything you have to do is to copy & paste?, (*1)

Installation

The best way to install librette/doctrine-sortable is using Composer:, (*2)

$ composer require librette/doctrine-sortable

and enable librette extension in your `config.neon ````yml extensions: # add this line at the end of your extensions list librette.doctrine.sortable: Librette\Doctrine\Sortable\DI\SortableExtension, (*3)


Simplest entity --------------- ```php namespace App; use Kdyby\Doctrine\Entities\BaseEntity; use Librette\Doctrine\Sortable\ISortable; use Librette\Doctrine\Sortable\TSortable; /** * @ORM\Entity */ class Category extends BaseEntity implements ISortable { use TSortable; /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue */ protected $id; }

Trait TSortable

There is trait TSortable that implements basic sorting methods to your entity. Everything you need is to call those methods in your service / presenter., (*4)

// you can move your entity up or down
$entity->moveUp();
$entity->moveDown();
// or you can put it before / after another one
$entity->moveBefore($anotherEntity);
$entity->moveAfter($anotherEntity);
// also you can set position directly
$entity->setPosition(21);

Don't forget to persist and flush after you finish with sorting!, (*5)

$this->em->persist($entity);
$this->em->flush();

The Versions

21/02 2018

dev-master

9999999-dev

Doctrine sortable entities for Nette framework.

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

doctrine nette sortable librette

21/02 2018

v0.3.0

0.3.0.0

Doctrine sortable entities for Nette framework.

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

doctrine nette sortable librette

27/02 2015

v0.2.0

0.2.0.0

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

doctrine nette sortable librette