PHP code example of stevecohenfr / legacy-publish-handler-bundle

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

    

stevecohenfr / legacy-publish-handler-bundle example snippets



    
    // app/AppKernel.php

    // ...
    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            $bundles = array(
                // ...

                new SteveCohenFr\LegacyPublishHandlerBundle\SteveCohenFrLegacyPublishHandlerBundle(),
            );

            // ...
        }

        // ...
    }

namespace ACME\ACMEBundle\Handlers;

use eZ\Publish\API\Repository\Values\Content\Content;
use SteveCohenFr\LegacyPublishHandlerBundle\Classes\LegacyPublishHandlerInterface;

class OnPublishHandler implements LegacyPublishHandlerInterface
{
    /**
     * This function is called from legacy part before an object publication (called by workflow)
     * You must link the "before publish" trigger to the custom workflow
     *
     * @param Content $content              The legacy object
     * @param int     $version              The object version
     *
     */
    function beforePublish(Content $content, $version)
    {
        //TODO this function will be called before the content is published
    }

    /**
     * This function is called from legacy part after an object publication (called by workflow)
     * You must link the "after publish" trigger to the custom workflow
     *
     * @param Content $content              The legacy object
     * @param int     $version              The object version
     *
     */
    function afterPublish(Content $content, $version)
    {
       //TODO this function will be called after the content is published
    }
}
bash
php bin/console ezpublish:legacybundles:install_extensions --relative