PHP code example of okvpn / better-oro-bundle

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

    

okvpn / better-oro-bundle example snippets


class SomeProcessor implements MessageProcessorInterface
{

    /** @var LoggerInterface */
    private $logger;

    /** @var JobRunner */
    private $jobRunner;

    public function __construct(LoggerInterface $logger, JobRunner $jobRunner)
    {
        $this->logger = $logger;
        $this->jobRunner = $jobRunner;
    }
    
    /**
     * {@inheritdoc}
     */
    public function process(MessageInterface $message, SessionInterface $session)
    {
        $body = JSON::decode($message->getBody());

        $result = $this->jobRunner->runDelayed(
            $body['jobId'],
            function () use ($body) {
                try {
                    $this->logger->info('This logs will display in UI on the given root jobs page.')
                } catch (\Throwable $e) {
                    $this->logger->critical(
                        'An error occupies during job execute'
                        ['e' => $e,] // the full stack trace & exception message will display on the job page.
                    );

                    return false;
                }
            }
        );
        
        $this->logger->info('This log will not display, because there isn\'t active job');
        
        return $result ? self::ACK : self::REJECT;
    }
}




namespace Okvpn\Bundle\BetterOroBundle\Event;

final class SendEvents
{
    /**
     * Dispatch before send a message to the producer.
     * Used for modify properties, headers, body or decline sending to producer
     */
    const BEFORE_SEND = 'message_queue.before_send';

    /**
     * Dispatch after send message to producer.
     */
    const AFTER_SEND = 'message_queue.after_send';
}




namespace App\Bundle\AppBundle\Migrations\Schema\v1_0;

use Doctrine\DBAL\Schema\Schema;
use Okvpn\Bundle\BetterOroBundle\Migration\OptimiseDataauditIndexQuery;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class AppBundleMigration implements Migration
{
    /**
     * @inheritDoc
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        $queries->addPostQuery(new OptimiseDataauditIndexQuery());
    }
}

php app/console okvpn:entity-translations:dump "OkvpnAkumaBundle" --skip-translated
okvpn:
    akuma:
       ...