Skip to content

Commit

Permalink
removed unneeded grid services from grid.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Jan 5, 2024
1 parent f8251b8 commit 64df23b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
8 changes: 1 addition & 7 deletions config/admin/grid.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
services:

oksydan.is_imageslider.grid.definition.factory.image_sliders:
class: 'Oksydan\IsImageslider\Grid\Definition\Factory\ImageSliderGridDefinitionFactory'
parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'
public: true

oksydan.is_imageslider.grid.image_slider_grid_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory'
arguments:
- '@oksydan.is_imageslider.grid.definition.factory.image_sliders'
- '@Oksydan\IsImageslider\Grid\Definition\Factory\ImageSliderGridDefinitionFactory'
- '@oksydan.is_imageslider.grid.data.factory.image_slider_decorator'
- '@prestashop.core.grid.filter.form_factory'
- '@prestashop.core.hook.dispatcher'
Expand All @@ -22,7 +17,6 @@ services:
- '@prestashop.core.grid.query.doctrine_query_parser'
- 'is_imageslider'


oksydan.is_imageslider.grid.data.factory.image_slider_decorator:
class: 'Oksydan\IsImageslider\Grid\Data\Factory\ImageSliderGridDataFactory'
arguments:
Expand Down
30 changes: 21 additions & 9 deletions src/Grid/Definition/Factory/ImageSliderGridDefinitionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory;
use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection;
use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class ImageSliderGridDefinitionFactory extends AbstractGridDefinitionFactory
{
private TranslatorInterface $trans;

public const GRID_ID = 'is_imageslider';

public function __construct(
HookDispatcherInterface $hookDispatcher = null,
TranslatorInterface $trans
) {
parent::__construct($hookDispatcher);
$this->trans = $trans;
}

/**
* {@inheritdoc}
*/
Expand All @@ -35,7 +47,7 @@ protected function getId()
*/
protected function getName()
{
return $this->trans('Image slider', [], TranslationDomains::TRANSLATION_DOMAIN_ADMIN);
return $this->trans->trans('Image slider', [], TranslationDomains::TRANSLATION_DOMAIN_ADMIN);
}

/**
Expand All @@ -46,7 +58,7 @@ protected function getColumns()
return (new ColumnCollection())
->add(
(new PositionColumn('position'))
->setName($this->trans('Position', [], 'Admin.Global'))
->setName($this->trans->trans('Position', [], 'Admin.Global'))
->setOptions([
'id_field' => 'id_slide',
'position_field' => 'position',
Expand All @@ -56,35 +68,35 @@ protected function getColumns()
)
->add(
(new ImageColumn('image'))
->setName($this->trans('Image', [], 'Admin.Global'))
->setName($this->trans->trans('Image', [], 'Admin.Global'))
->setOptions([
'src_field' => 'image',
])
)
->add(
(new DataColumn('title'))
->setName($this->trans('Title', [], 'Admin.Global'))
->setName($this->trans->trans('Title', [], 'Admin.Global'))
->setOptions([
'field' => 'title',
])
)
->add(
(new DataColumn('id_slide'))
->setName($this->trans('ID', [], 'Admin.Global'))
->setName($this->trans->trans('ID', [], 'Admin.Global'))
->setOptions([
'field' => 'id_slide',
])
)
->add(
(new DataColumn('title'))
->setName($this->trans('Title', [], 'Admin.Global'))
->setName($this->trans->trans('Title', [], 'Admin.Global'))
->setOptions([
'field' => 'title',
])
)
->add(
(new ToggleColumn('active'))
->setName($this->trans('Displayed', [], 'Admin.Global'))
->setName($this->trans->trans('Displayed', [], 'Admin.Global'))
->setOptions([
'field' => 'active',
'primary_field' => 'id_slide',
Expand All @@ -107,13 +119,13 @@ protected function getColumns()
)
->add(
(new LinkRowAction('delete'))
->setName($this->trans('Delete', [], 'Admin.Actions'))
->setName($this->trans->trans('Delete', [], 'Admin.Actions'))
->setIcon('delete')
->setOptions([
'route' => 'is_imageslider_controller_delete',
'route_param_name' => 'slideId',
'route_param_field' => 'id_slide',
'confirm_message' => $this->trans(
'confirm_message' => $this->trans->trans(
'Delete selected item?',
[],
'Admin.Notifications.Warning'
Expand Down

0 comments on commit 64df23b

Please sign in to comment.