Skip to content

Commit

Permalink
Merge pull request #521 from systemli/Adjust-Admin-List-Order
Browse files Browse the repository at this point in the history
  • Loading branch information
0x46616c6b authored Dec 23, 2023
2 parents 46ffea0 + fe3daf2 commit 5004f8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridInterface;
use Symfony\Component\Security\Core\Security;

abstract class Admin extends AbstractAdmin
Expand All @@ -18,6 +19,13 @@ public function __construct(string $code, string $class, string $baseControllerN
parent::__construct($code, $class, $baseControllerName);
}

protected function configureDefaultSortValues(array &$sortValues): void
{
$sortValues[DatagridInterface::PAGE] = 1;
$sortValues[DatagridInterface::SORT_ORDER] = 'DESC';
$sortValues[DatagridInterface::SORT_BY] = 'id';
}

protected function isNewObject(): bool
{
return !$this->getRequest()->get($this->getIdParameter());
Expand Down
8 changes: 2 additions & 6 deletions src/Admin/UserAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ class UserAdmin extends Admin
{
use DomainGuesserAwareTrait;

protected function generateBaseRoutePattern(bool $isChildAdmin = false): string {
protected function generateBaseRoutePattern(bool $isChildAdmin = false): string
{
return 'user';
}

protected array $datagridValues = [
'_page' => 1,
'_sort_order' => 'DESC',
'_sort_by' => 'creationTime',
];
private PasswordUpdater $passwordUpdater;
private MailCryptKeyHandler $mailCryptKeyHandler;
private int $mailCrypt;
Expand Down

0 comments on commit 5004f8a

Please sign in to comment.