Skip to content

Commit

Permalink
add Easyadmin
Browse files Browse the repository at this point in the history
  • Loading branch information
pyatnitsev committed Dec 4, 2023
1 parent 8a91efe commit 01ef6f5
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
.idea/
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.16",
"easycorp/easyadmin-bundle": "^4.8",
"pagerfanta/doctrine-orm-adapter": "^4.2",
"pagerfanta/twig": "^4.2",
"phpdocumentor/reflection-docblock": "^5.3",
Expand Down
252 changes: 251 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
];
4 changes: 4 additions & 0 deletions config/packages/uid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
uid:
default_uuid_version: 4
time_based_uuid_version: 7
2 changes: 1 addition & 1 deletion src/Controller/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

#[Route('/admin', name: "admin.")]
#[Route('/admin-simple', name: "admin.")]
class AdminController extends AbstractController
{
#[Route('/', name: 'index')]
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

#[Route('/admin/article')]
#[Route('/admin-simple/article')]
class ArticleController extends AbstractController
{
#[Route('/', name: 'app_article_index', methods: ['GET'])]
Expand Down
31 changes: 31 additions & 0 deletions src/Controller/EasyAdmin/ArticleCrudController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Controller\EasyAdmin;

use App\Entity\Article;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

class ArticleCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Article::class;
}

public function configureFields(string $pageName): iterable
{
return [
IdField::new('id', 'ID'),
TextField::new('title', 'Заголовок статьи'),
TextEditorField::new('body', 'Текст поста'),
AssociationField::new('author', 'Автор')->hideOnForm(),
DateTimeField::new('createdAt', 'Дата создания')->hideOnForm()
];
}

}
Loading

0 comments on commit 01ef6f5

Please sign in to comment.