PHP code example of dpfaffenbauer / process-manager

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

    

dpfaffenbauer / process-manager example snippets


$processFactory = $container->get('process_manager.factory.process');
$process = $processFactory->createProcess(
    sprintf(
        'Process (%s): %s',
        $date->formatLocalized('%A %d %B %Y'),
        'Special Long Running Task'
    ),                                                  //Name
    'special_task',                                     //Type
    'Message',                                          //Message Text
    100,                                                //Total Steps
    0                                                   //Current Step
);
$process->save();                                       //Save

$process->progress();
$process->save();

$process->setProgress($process->getTotal());
$process->save();

$logger = $container->get('process_manager.logger');

//Logs a emergency message
$logger->emergency($process, 'Total of 100 entries found');

//Logs a alert message
$logger->alert($process, 'Total of 100 entries found');

//Logs a critical message
$logger->critical($process, 'Total of 100 entries found');

//Logs a error message
$logger->error($process, 'Total of 100 entries found');

//Logs a warning message
$logger->warning($process, 'Total of 100 entries found');

//Logs a notice message
$logger->notice($process, 'Total of 100 entries found');

//Logs a info message
$logger->info($process, 'Total of 100 entries found');

//Logs a debug message
$logger->debug($process, 'Total of 100 entries found');

$process = $this->processRepository->find($processId);
if ($process->getStatus() == ProcessManagerBundle::STATUS_STOPPING) {
    // Here goes your process stop and cleanup logic
    ...
    
    $process->setStatus(ProcessManagerBundle::STATUS_STOPPED); // remember to set the status to stopped.
    $process->save();    
}