updrade with rector
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Blog;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\SlugField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
/**
|
||||
* Class BlogCrudController
|
||||
* @package App\Controller\Admin
|
||||
*/
|
||||
class BlogCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Blog::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
AssociationField::new('author')
|
||||
->autocomplete(),
|
||||
TextField::new('title'),
|
||||
SlugField::new('slug')
|
||||
->setTargetFieldName('title'),
|
||||
TextEditorField::new('teaser'),
|
||||
TextEditorField::new('content'),
|
||||
DateTimeField::new('createdAt'),
|
||||
AssociationField::new('editedBy')
|
||||
->autocomplete()
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Comment;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
/**
|
||||
* Class CommentCrudController
|
||||
* @package App\Controller\Admin
|
||||
*/
|
||||
class CommentCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Comment::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
AssociationField::new('author')
|
||||
->autocomplete(),
|
||||
AssociationField::new('blog')
|
||||
->autocomplete(),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('content'),
|
||||
DateTimeField::new('createdAt'),
|
||||
AssociationField::new('editedBy')
|
||||
->autocomplete(),
|
||||
DateTimeField::new('editedAt'),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Pages;
|
||||
use App\Entity\Projects;
|
||||
use App\Entity\Quotes;
|
||||
use App\Entity\User;
|
||||
@@ -18,50 +19,45 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DashboardController extends AbstractDashboardController
|
||||
{
|
||||
#[isGranted(data: 'ROLE_ADMIN')]
|
||||
#[Route(path: '/admin', name: 'admin')]
|
||||
public function index(): Response
|
||||
{
|
||||
//return parent::index();
|
||||
return $this->render(view: 'admin/index.html.twig');
|
||||
}
|
||||
|
||||
public function configureDashboard(): Dashboard
|
||||
{
|
||||
return Dashboard::new()
|
||||
->setTitle(title: '24unix Admin');
|
||||
}
|
||||
|
||||
public function configureMenuItems(): iterable
|
||||
{
|
||||
yield MenuItem::linkToUrl(label: 'Homepage', icon: 'fa fa-home', url: $this->generateUrl(route: 'app_main'));
|
||||
yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard');
|
||||
yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class);
|
||||
yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class);
|
||||
yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class);
|
||||
}
|
||||
|
||||
public function configureUserMenu(UserInterface $user): UserMenu
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new Exception(message: 'Wrong User!');
|
||||
}
|
||||
|
||||
return parent::configureUserMenu(user: $user)
|
||||
->setAvatarUrl(url: $user->getAvatar());
|
||||
}
|
||||
|
||||
|
||||
public function configureActions(): Actions
|
||||
{
|
||||
return parent::configureActions()
|
||||
->add(pageName: Crud::PAGE_INDEX, actionNameOrObject: Action::DETAIL);
|
||||
}
|
||||
|
||||
|
||||
#[isGranted(data: 'ROLE_ADMIN')]
|
||||
#[Route(path: '/admin', name: 'admin')]
|
||||
public function index(): Response
|
||||
{
|
||||
// return parent::index();
|
||||
return $this->render(view: 'admin/index.html.twig');
|
||||
}
|
||||
|
||||
public function configureDashboard(): Dashboard
|
||||
{
|
||||
return Dashboard::new()
|
||||
->setTitle(title: '24unix Admin');
|
||||
}
|
||||
|
||||
public function configureMenuItems(): iterable
|
||||
{
|
||||
yield MenuItem::linkToUrl(label: 'Homepage', icon: 'fa fa-home', url: $this->generateUrl(route: 'app_main'));
|
||||
yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard');
|
||||
yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class);
|
||||
yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class);
|
||||
yield MenuItem::linkToCrud(label: 'Pages', icon: 'fa fa-newspaper-o', entityFqcn: Pages::class);
|
||||
yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class);
|
||||
}
|
||||
|
||||
public function configureUserMenu(UserInterface $user): UserMenu
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new Exception(message: 'Wrong User!');
|
||||
}
|
||||
|
||||
return parent::configureUserMenu(user: $user)
|
||||
->setAvatarUrl(url: 'build/images/'.$user->getAvatar());
|
||||
}
|
||||
|
||||
public function configureActions(): Actions
|
||||
{
|
||||
return parent::configureActions()
|
||||
->add(pageName: Crud::PAGE_INDEX, actionNameOrObject: Action::DETAIL);
|
||||
}
|
||||
}
|
||||
|
||||
30
src/Controller/Admin/PagesCrudController.php
Normal file
30
src/Controller/Admin/PagesCrudController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Pages;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\CodeEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class PagesCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Pages::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'name');
|
||||
yield AssociationField::new(propertyName: 'owner');
|
||||
// yield CodeEditorField::new(propertyName: 'content')
|
||||
yield TextareaField::new(propertyName: 'content')
|
||||
->onlyOnForms();
|
||||
}
|
||||
}
|
||||
@@ -8,27 +8,23 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ProjectsCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Projects::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'name');
|
||||
yield TextField::new(propertyName: 'description');
|
||||
yield TextField::new(propertyName: 'description');
|
||||
yield ImageField::new(propertyName: 'teaserImage')
|
||||
->setBasePath(path: 'uploads/projects')
|
||||
->setUploadDir(uploadDirPath: 'public/uploads/projects')
|
||||
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
|
||||
|
||||
}
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Projects::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'name');
|
||||
yield TextField::new(propertyName: 'description');
|
||||
yield TextField::new(propertyName: 'description');
|
||||
yield ImageField::new(propertyName: 'teaserImage')
|
||||
->setBasePath(path: 'uploads/projects')
|
||||
->setUploadDir(uploadDirPath: 'public/uploads/projects')
|
||||
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,20 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class QuotesCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Quotes::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'quote')
|
||||
->onlyOnIndex();
|
||||
yield TextEditorField::new(propertyName: 'quote')
|
||||
->onlyOnForms();
|
||||
}
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Quotes::class;
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'quote')
|
||||
->onlyOnIndex();
|
||||
yield TextEditorField::new(propertyName: 'quote')
|
||||
->onlyOnForms();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Section;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
|
||||
/**
|
||||
* Class SectionCrudController
|
||||
* @package App\Controller\Admin
|
||||
*/
|
||||
class SectionCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
{
|
||||
return Section::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -10,9 +10,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class UserCrudController extends AbstractCrudController
|
||||
{
|
||||
public static function getEntityFqcn(): string
|
||||
@@ -22,20 +19,20 @@ class UserCrudController extends AbstractCrudController
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'firstName');
|
||||
yield TextField::new(propertyName: 'lastName');
|
||||
yield EmailField::new(propertyName: 'email');
|
||||
yield ImageField::new(propertyName: 'avatar')
|
||||
->setBasePath(path: 'uploads/avatars')
|
||||
->setUploadDir(uploadDirPath: 'public/uploads/avatars')
|
||||
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
|
||||
$roles = ['ROLE_FOUNDER', 'ROLE_ADMIN', 'ROLE_MODERATOR', 'ROLE_USER'];
|
||||
yield ChoiceField::new(propertyName: 'roles')
|
||||
->setChoices(choiceGenerator: array_combine(keys: $roles, values: $roles))
|
||||
->allowMultipleChoices()
|
||||
->renderExpanded()
|
||||
->renderAsBadges();
|
||||
yield IdField::new(propertyName: 'id')
|
||||
->onlyOnIndex();
|
||||
yield TextField::new(propertyName: 'firstName');
|
||||
yield TextField::new(propertyName: 'lastName');
|
||||
yield EmailField::new(propertyName: 'email');
|
||||
yield ImageField::new(propertyName: 'avatar')
|
||||
->setBasePath(path: 'uploads/avatars')
|
||||
->setUploadDir(uploadDirPath: 'public/uploads/avatars')
|
||||
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
|
||||
$roles = ['ROLE_FOUNDER', 'ROLE_ADMIN', 'ROLE_MODERATOR', 'ROLE_USER'];
|
||||
yield ChoiceField::new(propertyName: 'roles')
|
||||
->setChoices(choiceGenerator: array_combine(keys: $roles, values: $roles))
|
||||
->allowMultipleChoices()
|
||||
->renderExpanded()
|
||||
->renderAsBadges();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user