lib/composer/LisaBundle/src/VisualMedia/LisaBundle/Component/DataTable/Column/OrderingColumn.php line 52

Open in your IDE?
  1. <?php
  2. /**
  3. * Ordering Column
  4. *
  5. * @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
  6. */
  7. namespace VisualMedia\LisaBundle\Component\DataTable\Column;
  8. use VisualMedia\LisaBundle\Component\Interfaces\ColumnInterface;
  9. use VisualMedia\LisaBundle\Component\Interfaces\DataTableInterface;
  10. use VisualMedia\LisaBundle\Component\Interfaces\EntityInterface;
  11. /**
  12. * Ordering Column
  13. */
  14. class OrderingColumn extends ActionsColumn
  15. {
  16. const ORDERING_UP = 'up';
  17. const ORDERING_DOWN = 'down';
  18. const DEFAULT_BODY_TEMPLATE = '@VisualMediaLisa/DataTable/OrderingColumn/body.html.twig';
  19. /**
  20. * Order By
  21. * @var string
  22. */
  23. protected $orderBy;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public $bodyTemplate = self::DEFAULT_BODY_TEMPLATE;
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function initialize(DataTableInterface $datatable, $title = null, $content = null, $ordering = false, $actions = array()): ColumnInterface
  32. {
  33. $this->orderBy = $content;
  34. $actions[static::ORDERING_UP] = $actions[static::ORDERING_UP] ?? null;
  35. $actions[static::ORDERING_DOWN] = $actions[static::ORDERING_DOWN] ?? null;
  36. parent::initialize($datatable, $title, $actions, true);
  37. return $this;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function getContent(EntityInterface $row = null)
  43. {
  44. if ($row !== null) {
  45. return parent::getContent($row);
  46. }
  47. return $this->orderBy;
  48. }
  49. }