From 777e9472ec89c84611e818483fb5f2a811558c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wr=C3=B3blewski?= Date: Fri, 9 Feb 2024 22:00:59 +0100 Subject: [PATCH] feat: Change data table factory aware trait factory to protected, change exceptions to bundle-specific ones --- src/DataTableFactoryAwareTrait.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DataTableFactoryAwareTrait.php b/src/DataTableFactoryAwareTrait.php index 9bed95ac..ee8a2576 100755 --- a/src/DataTableFactoryAwareTrait.php +++ b/src/DataTableFactoryAwareTrait.php @@ -4,13 +4,14 @@ namespace Kreyu\Bundle\DataTableBundle; +use Kreyu\Bundle\DataTableBundle\Exception\LogicException; use Kreyu\Bundle\DataTableBundle\Type\DataTableType; use Kreyu\Bundle\DataTableBundle\Type\DataTableTypeInterface; use Symfony\Contracts\Service\Attribute\Required; trait DataTableFactoryAwareTrait { - private null|DataTableFactoryInterface $dataTableFactory = null; + protected ?DataTableFactoryInterface $dataTableFactory = null; #[Required] public function setDataTableFactory(?DataTableFactoryInterface $dataTableFactory): void @@ -24,7 +25,7 @@ public function setDataTableFactory(?DataTableFactoryInterface $dataTableFactory protected function createDataTable(string $type, mixed $query = null, array $options = []): DataTableInterface { if (null === $this->dataTableFactory) { - throw new \LogicException(sprintf('You cannot use the "%s" method on controller without data table factory.', __METHOD__)); + throw new LogicException(sprintf('You cannot use the "%s" method on controller without data table factory.', __METHOD__)); } return $this->dataTableFactory->create($type, $query, $options); @@ -36,7 +37,7 @@ protected function createDataTable(string $type, mixed $query = null, array $opt protected function createNamedDataTable(string $name, string $type, mixed $query = null, array $options = []): DataTableInterface { if (null === $this->dataTableFactory) { - throw new \LogicException(sprintf('You cannot use the "%s" method on controller without data table factory.', __METHOD__)); + throw new LogicException(sprintf('You cannot use the "%s" method on controller without data table factory.', __METHOD__)); } return $this->dataTableFactory->createNamed($name, $type, $query, $options); @@ -45,7 +46,7 @@ protected function createNamedDataTable(string $name, string $type, mixed $query protected function createDataTableBuilder(mixed $query = null, array $options = []): DataTableBuilderInterface { if (null === $this->dataTableFactory) { - throw new \LogicException(sprintf('You cannot use the "%s" method on controller without data table factory.', __METHOD__)); + throw new LogicException(sprintf('You cannot use the "%s" method on controller without data table factory.', __METHOD__)); } return $this->dataTableFactory->createBuilder(DataTableType::class, $query, $options);