Commit dbdef799 authored by Tino Goratsch's avatar Tino Goratsch

extracted the adding of the data grid columns into a separate method so that...

extracted the adding of the data grid columns into a separate method so that the data grid can be extended more easily
parent f8b3dc8c
......@@ -24,13 +24,13 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Articles\Model\Repository\DataGridRepository $dataGridRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Articles\Model\Repository\DataGridRepository $dataGridRepository)
{
Articles\Model\Repository\DataGridRepository $dataGridRepository
) {
parent::__construct($context);
$this->dataGridRepository = $dataGridRepository;
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/articles/index/delete')
->setResourcePathEdit('admin/articles/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'publication_period'),
......@@ -68,10 +81,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -24,13 +24,13 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Categories\Model\Repository\DataGridRepository $dataGridRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Categories\Model\Repository\DataGridRepository $dataGridRepository)
{
Categories\Model\Repository\DataGridRepository $dataGridRepository
) {
parent::__construct($context);
$this->dataGridRepository = $dataGridRepository;
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/categories/index/delete')
->setResourcePathEdit('admin/categories/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('categories', 'title'),
......@@ -73,10 +86,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -67,34 +67,7 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/comments/details/delete/id_' . $id)
->setResourcePathEdit('admin/comments/details/edit');
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'date'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\DateColumnRenderer::class,
'fields' => ['date'],
'default_sort' => true
], 50)
->addColumn([
'label' => $this->translator->t('system', 'name'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\TextColumnRenderer::class,
'fields' => ['name'],
], 40)
->addColumn([
'label' => $this->translator->t('system', 'message'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\Nl2pColumnRenderer::class,
'fields' => ['message'],
], 30)
->addColumn([
'label' => $this->translator->t('comments', 'ip'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\TextColumnRenderer::class,
'fields' => ['ip'],
], 20)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'fields' => ['id'],
'primary' => true
], 10);
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
......@@ -105,4 +78,39 @@ class Index extends Core\Controller\AbstractAdminAction
throw new Core\Controller\Exception\ResultNotExistsException();
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'date'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\DateColumnRenderer::class,
'fields' => ['date'],
'default_sort' => true
], 50)
->addColumn([
'label' => $this->translator->t('system', 'name'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\TextColumnRenderer::class,
'fields' => ['name'],
], 40)
->addColumn([
'label' => $this->translator->t('system', 'message'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\Nl2pColumnRenderer::class,
'fields' => ['message'],
], 30)
->addColumn([
'label' => $this->translator->t('comments', 'ip'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\TextColumnRenderer::class,
'fields' => ['ip'],
], 20)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\Helpers\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'fields' => ['id'],
'primary' => true
], 10);
}
}
......@@ -24,13 +24,13 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Comments\Model\Repository\CommentRepository $commentRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Comments\Model\Repository\CommentRepository $commentRepository)
{
Comments\Model\Repository\CommentRepository $commentRepository
) {
parent::__construct($context);
$this->commentRepository = $commentRepository;
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/comments/index/delete')
->setResourcePathEdit('admin/comments/details/index');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('comments', 'module'),
......@@ -66,10 +79,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['module_id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -47,6 +47,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/emoticons/index/delete')
->setResourcePathEdit('admin/emoticons/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'description'),
......@@ -73,10 +86,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/files/index/delete')
->setResourcePathEdit('admin/files/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'publication_period'),
......@@ -82,10 +95,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -90,6 +90,25 @@ class Edit extends Core\Controller\AbstractAdminAction
throw new Core\Controller\Exception\ResultNotExistsException();
}
/**
* @param array $formData
* @param int $galleryId
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function executePost(array $formData, $galleryId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $galleryId) {
$this->galleryFormValidation
->setUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId))
->validate($formData);
$formData['user_id'] = $this->user->getUserId();
return $this->galleryModel->save($formData, $galleryId);
});
}
/**
* @param int $id
*
......@@ -108,6 +127,19 @@ class Edit extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/gallery/pictures/delete/id_' . $id)
->setResourcePathEdit('admin/gallery/pictures/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid$dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('gallery', 'picture'),
......@@ -143,29 +175,5 @@ class Edit extends Core\Controller\AbstractAdminAction
]
], 20);
}
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param array $formData
* @param int $galleryId
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function executePost(array $formData, $galleryId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $galleryId) {
$this->galleryFormValidation
->setUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId))
->validate($formData);
$formData['user_id'] = $this->user->getUserId();
return $this->galleryModel->save($formData, $galleryId);
});
}
}
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/gallery/index/delete')
->setResourcePathEdit('admin/gallery/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'publication_period'),
......@@ -73,10 +86,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -24,7 +24,7 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Guestbook\Model\Repository\DataGridRepository $dataGridRepository
*/
public function __construct(
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/guestbook/index/delete')
->setResourcePathEdit('admin/guestbook/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'date'),
......@@ -79,10 +92,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -24,13 +24,13 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\News\Model\Repository\DataGridRepository $dataGridRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
News\Model\Repository\DataGridRepository $dataGridRepository)
{
News\Model\Repository\DataGridRepository $dataGridRepository
) {
parent::__construct($context);
$this->dataGridRepository = $dataGridRepository;
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/news/index/delete')
->setResourcePathEdit('admin/news/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'publication_period'),
......@@ -74,10 +87,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -24,13 +24,13 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Newsletter\Model\Repository\AccountDataGridRepository $dataGridRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Newsletter\Model\Repository\AccountDataGridRepository $dataGridRepository)
{
Newsletter\Model\Repository\AccountDataGridRepository $dataGridRepository
) {
parent::__construct($context);
$this->dataGridRepository = $dataGridRepository;
......@@ -49,6 +49,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setIdentifier('#acp-table')
->setResourcePathDelete('admin/newsletter/accounts/delete');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'email_address'),
......@@ -90,10 +103,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -24,13 +24,13 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Newsletter\Model\Repository\NewsletterDataGridRepository $dataGridRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Newsletter\Model\Repository\NewsletterDataGridRepository $dataGridRepository)
{
Newsletter\Model\Repository\NewsletterDataGridRepository $dataGridRepository
) {
parent::__construct($context);
$this->dataGridRepository = $dataGridRepository;
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathEdit('admin/newsletter/index/edit')
->setResourcePathDelete('admin/newsletter/index/delete');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'date'),
......@@ -81,10 +94,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/polls/index/delete')
->setResourcePathEdit('admin/polls/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('system', 'publication_period'),
......@@ -69,10 +82,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -57,6 +57,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/seo/index/delete')
->setResourcePathEdit('admin/seo/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('seo', 'uri'),
......@@ -104,10 +117,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
......@@ -24,7 +24,7 @@ class Index extends Core\Controller\AbstractAdminAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Users\Model\Repository\DataGridRepository $dataGridRepository
*/
public function __construct(
......@@ -50,6 +50,19 @@ class Index extends Core\Controller\AbstractAdminAction
->setResourcePathDelete('admin/users/index/delete')
->setResourcePathEdit('admin/users/index/edit');
$this->addDataGridColumns($dataGrid);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
/**
* @param Core\Helpers\DataGrid $dataGrid
*/
protected function addDataGridColumns(Core\Helpers\DataGrid $dataGrid)
{
$dataGrid
->addColumn([
'label' => $this->translator->t('users', 'nickname'),
......@@ -73,10 +86,5 @@ class Index extends Core\Controller\AbstractAdminAction
'fields' => ['id'],
'primary' => true
], 10);
return [
'grid' => $dataGrid->render(),
'show_mass_delete_button' => $dataGrid->countDbResults() > 0
];
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment