PHP code example of jeandanyel / crud-bundle

1. Go to this page and download the library: Download jeandanyel/crud-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeandanyel / crud-bundle example snippets


namespace App\Controller;

use App\Entity\Article;
use App\Form\ArticleType;
use App\List\ArticleListType;
use Jeandanyel\CrudBundle\Attribute\CrudController;
use Jeandanyel\CrudBundle\Controller\AbstractCrudController;

#[CrudController(entityClass: Article::class, formTypeClass: ArticleType::class, listTypeClass: ArticleListType::class)]
class ArticleController extends AbstractCrudController
{
}

namespace App\EventListener;

use App\Entity\Article;
use Jeandanyel\CrudBundle\Event\EntityBeforeSaveEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(EntityBeforeSaveEvent::class)]
class ArticleCrudBeforeSaveListener 
{
    public function __invoke(EntityBeforeSaveEvent $event)
    {
        $entity = $event->getEntity();

        if ($entity instanceof Article) {
            // Perform operations before saving the Article entity.
        }
    }
}