lib/composer/LisaBundle/src/VisualMedia/LisaBundle/Component/DataTable/Column/HiddenColumn.php line 60

Open in your IDE?
  1. <?php
  2. /**
  3. * Hidden Column
  4. *
  5. * Could be used for adding data attributes to a row but not show as an visible column
  6. *
  7. * @author Bertin van den Ham <b.vandenham@visualmedia.nl>
  8. */
  9. namespace VisualMedia\LisaBundle\Component\DataTable\Column;
  10. use Closure;
  11. use VisualMedia\LisaBundle\Helper\EntityHelper;
  12. use VisualMedia\LisaBundle\Helper\Helper;
  13. use VisualMedia\LisaBundle\Component\Interfaces\ColumnInterface;
  14. use VisualMedia\LisaBundle\Component\Interfaces\DataTableInterface;
  15. use VisualMedia\LisaBundle\Component\Interfaces\EntityInterface;
  16. /**
  17. * Hidden Column
  18. */
  19. class HiddenColumn extends Column
  20. {
  21. public const DEFAULT_BODY_TEMPLATE = '@VisualMediaLisa/DataTable/HiddenColumn/body.html.twig';
  22. public const DEFAULT_HEADER_TEMPLATE = '@VisualMediaLisa/DataTable/HiddenColumn/header.html.twig';
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public $bodyTemplate = self::DEFAULT_BODY_TEMPLATE;
  27. public $headerTemplate = self::DEFAULT_HEADER_TEMPLATE;
  28. /**
  29. * DataAttributeClosuere
  30. * Could be use to set data attributes to an hidden column
  31. *
  32. * @var Closure|null
  33. */
  34. public $dataAttributeClosure = null;
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function initialize(DataTableInterface $datatable, $title = null, $content = null, $orderBy = false, $dataAttributeClosure = null): ColumnInterface
  39. {
  40. $this->dataAttributeClosure = $dataAttributeClosure;
  41. parent::initialize($datatable, $title, $content, $orderBy, $dataAttributeClosure);
  42. return $this;
  43. }
  44. /**
  45. * GetdataAttributeClosure
  46. *
  47. * @param EntityInterface|null $row
  48. *
  49. * @return Closure|mixed|string|array|null
  50. */
  51. public function getdataAttributeClosure(EntityInterface $row = null)
  52. {
  53. $dataAttributeClosure = $this->dataAttributeClosure;
  54. if ($row !== null) {
  55. if ($dataAttributeClosure === null) {
  56. return null;
  57. } else if ($dataAttributeClosure instanceof Closure) {
  58. return $dataAttributeClosure($row);
  59. }
  60. }
  61. return $dataAttributeClosure;
  62. }
  63. }