<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
heimrichhannot / contao-progress-bar-widget-bundle example snippets
'importProgress' => [
'inputType' => 'huhProgressBar',
'eval' => [
// an introduction text for the widget (mandatory)
'description' => $GLOBALS['TL_LANG']['tl_entity_import_config']['reference']['importProgressDescription'],
// only show the progress bar but not the numbers below (optional, default false)
'hideNumbers' => false,
// hide skipped items from the numbers section (optional, default false)
'hideSkippedItems' => false
]
],
use HeimrichHannot\ProgressBarWidgetBundle\Event\LoadProgressEvent;
use HeimrichHannot\ProgressBarWidgetBundle\Widget\ProgressBar;
use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;
/**
* @ServiceTag("kernel.event_listener", event="huh.progress_bar_widget.event.load_progress")
*/
class LoadProgressListener
{
public function __invoke(LoadProgressEvent $event) {
if (null === ($record = MyModel::findByPk($event->getId()))) {
return;
}
// map the record's state field to the progress bar's expectations
// of course you can decide yourself in which cases you'd like to pass which state
switch ($record->state) {
case 'success':
$state = ProgressBar::STATE_SUCCESS;
$class = 'tl_confirm';
break;
case 'error':
$state = ProgressBar::STATE_FAILED;
$class = 'tl_error';
break;
default:
$state = ProgressBar::STATE_IN_PROGRESS;
$class = '';
}
$data = [
'state' => $state,
'currentProgress' => $record->importProgressCurrent, // field name depends on your dca
'totalCount' => $record->importProgressTotal, // field name depends on your dca
'skippedCount' => $record->importProgressSkipped, // field name depends on your dca
];
// add messages if some are available
if ($record->importProgressResult) {
$data['messages'] = [[
'class' => $class,
'text' => str_replace("\n", '<br>', $record->importProgressResult),
]];
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.