use ChamberOrchestra\DoctrineSortBundle\Mapping\Attribute\Sort;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class TodoItem
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'integer', options: ['unsigned' => true, 'default' => 0])]
#[Sort]
private int $sortOrder = 0;
// Setting sortOrder to 0 appends the item to the end of the list.
// Setting sortOrder to 1 moves it to the beginning.
// Any value in between inserts at that position; surrounding items shift automatically.
}
use ChamberOrchestra\DoctrineSortBundle\Mapping\Attribute\Sort;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Task
{
#[ORM\ManyToOne]
private ?Project $project = null;
#[ORM\Column(type: 'integer', options: ['unsigned' => true, 'default' => 0])]
#[Sort(groupBy: ['project'])]
private int $sortOrder = 0;
// Each project has its own independent sort sequence.
// Moving a task to a different project removes it from the old sequence
// and inserts it into the new one.
}
use ChamberOrchestra\DoctrineSortBundle\Contracts\Entity\SortInterface;
use ChamberOrchestra\DoctrineSortBundle\Entity\SortTrait;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class TodoItem implements SortInterface
{
use SortTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
}
#[Sort(
groupBy: ['parent'], // Fields that define independent sort groups
evictCollections: [ // Second-level cache collections to evict on change
[ParentEntity::class, 'children'],
],
evictRegions: ['my_query_region'], // Query cache regions to evict on change
)]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.