PHP code example of chrzanek98 / pimcore-object-event-listeners-bundle

1. Go to this page and download the library: Download chrzanek98/pimcore-object-event-listeners-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/ */

    

chrzanek98 / pimcore-object-event-listeners-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \Chrzanek98\PimcoreObjectEventListenersBundle\Chrzanek98PimcoreObjectEventListenersBundle(),
        );

        // ...
    }

    // ...
}



namespace AppBundle\EventListeners;

use Chrzanek98\PimcoreObjectEventListenersBundle\EventListeners\Providers\AbstractHandler;
use Pimcore\Event\Model\DataObjectEvent;

class AcmeEventListener extends AbstractHandler
{
    // ...
}



namespace AppBundle\EventListeners;

// ...

class AcmeEventListener extends AbstractHandler
{
    public function canHandle(DataObjectEvent $element)
    {
        return $element->getObject() instanceof Acme;
    }
}



namespace AppBundle\EventListeners;

// ...

class AcmeEventListener extends AbstractHandler
{
    public function preUpdate(DataObjectEvent $element)
    {
        throw new NotFoundHttpException('Lorem ipsum dolor sit amet');
    }

    public function canHandle(DataObjectEvent $element)
    {
        return $element->getObject() instanceof Acme;
    }
}