| Current Path : /var/www/v3.cesa.co.za/src/CoreBundle/Admin/ |
| Current File : /var/www/v3.cesa.co.za/src/CoreBundle/Admin/BatchJobsAdmin.php |
<?php
namespace App\CoreBundle\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Sonata\AdminBundle\Show\ShowMapper;
/**
* Batch job queue admin (read-only except delete).
*/
class BatchJobsAdmin extends AbstractAdmin
{
protected function generateBaseRouteName(bool $isChildAdmin = false): string
{
return 'batch_jobs';
}
protected function generateBaseRoutePattern(bool $isChildAdmin = false): string
{
return 'batch_jobs';
}
protected function configureListFields(ListMapper $listMapper): void
{
$listMapper
->add('id', null, ['label' => 'ID'])
->add('site_host', null, ['label' => 'Host'])
->add('php_script', null, [
'label' => 'Script',
'template' => '@CoreBundle/Admin/truncate_text.html.twig',
'property' => 'php_script',
])
->add('success', null, ['label' => 'Success'])
->add('failed', null, ['label' => 'Failed'])
->add('fail_count', null, ['label' => 'Fail count'])
->add('in_progress', null, ['label' => 'In progress'])
->add('is_locked', null, ['label' => 'Locked'])
->add('created_by', null, ['label' => 'Created by'])
->add('created_at', null, [
'label' => 'Created at',
'format' => 'Y-m-d H:i:s',
])
->add('execution_started', null, [
'label' => 'Started',
'format' => 'Y-m-d H:i:s',
])
->add('execution_ended', null, [
'label' => 'Ended',
'format' => 'Y-m-d H:i:s',
])
->add('_action', 'actions', [
'actions' => [
'show' => [],
'delete' => [],
],
])
;
}
protected function configureShowFields(ShowMapper $showMapper): void
{
$showMapper
->add('id', null, ['label' => 'ID'])
->add('site_host', null, ['label' => 'Host'])
->add('php_script', null, ['label' => 'Script'])
->add('success', null, ['label' => 'Success'])
->add('failed', null, ['label' => 'Failed'])
->add('fail_count', null, ['label' => 'Fail count'])
->add('in_progress', null, ['label' => 'In progress'])
->add('is_locked', null, ['label' => 'Locked'])
->add('job_priority', null, ['label' => 'Priority'])
->add('created_by', null, ['label' => 'Created by'])
->add('created_at', null, [
'label' => 'Created at',
'format' => 'Y-m-d H:i:s',
])
->add('updated_at', null, [
'label' => 'Updated at',
'format' => 'Y-m-d H:i:s',
])
->add('execution_started', null, [
'label' => 'Execution started',
'format' => 'Y-m-d H:i:s',
])
->add('execution_ended', null, [
'label' => 'Execution ended',
'format' => 'Y-m-d H:i:s',
])
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('site_host', null, ['label' => 'Host'])
->add('php_script', null, ['label' => 'Script'])
->add('success', null, ['label' => 'Success'])
->add('failed', null, ['label' => 'Failed'])
->add('fail_count', null, ['label' => 'Fail count'])
->add('in_progress', null, ['label' => 'In progress'])
->add('is_locked', null, ['label' => 'Locked'])
->add('created_by', null, ['label' => 'Created by'])
->add('created_at', null, ['label' => 'Created at'])
;
}
protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface
{
$query->orderBy($query->getRootAlias() . '.created_at', 'DESC');
return parent::configureQuery($query);
}
protected function configureRoutes(RouteCollectionInterface $collection): void
{
$collection
->remove('create')
->remove('edit')
;
}
}