<?php
namespace App\Controller\Admin;
use App\Entity\AppPushNotification;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
class AppPushNotificationCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return AppPushNotification::class;
}
// public function createEntity(string $entityFqcn)
// {
// $appPushNotification = new AppPushNotification();
// $appPushNotification->setAuthor($this->getUser());
//
// return $article;
// }
// public function configureFilters(Filters $filters): Filters
// {
// return $filters
// ->add('publishedAt');
// }
public function configureCrud(Crud $crud): Crud
{
return $crud
->setEntityLabelInSingular('Notification Push')
->setEntityLabelInPlural('Notifications Push')
->setSearchFields(['code', 'title', 'text']);
}
public function configureFields(string $pageName): iterable
{
$id = IntegerField::new('id', 'ID');
$code = TextField::new('code','Code Unique');
$title = TextField::new('title','Titre');
$text = TextField::new('text','Contenu');
if (Crud::PAGE_INDEX === $pageName) {
return [$id, $code, $title, $text];
}
return [
FormField::addPanel('Informations'),
$code, $title, $text
];
}
}