PHP code example of sherlockode / crud-bundle

1. Go to this page and download the library: Download sherlockode/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/ */

    

sherlockode / crud-bundle example snippets


# src/EventListener/ResourceListener.php

class ResourceListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            ResourceControllerDataEvent::UPDATE => 'update',
        ];
    }

    public function update(ResourceControllerDataEvent $event): void
    {
        // send custom data to the view
        $event->setData([]);
    }
}

# src/EventListener/ResourceListener.php

class ResourceListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            ResourceControllerEvent::BEFORE_UPDATE => 'update',
        ];
    }

    public function update(ResourceControllerDataEvent $event): void
    {
        $event->setCancelProcess(true);
        
        // optional message, by default, a translation key is generated 
        // sherlockode_crud.crud_name.update.cancel
        $event->setMessage('your message');
    }
}