You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
<?php
|
|
|
|
namespace Zitec\RuleEngineBundle\Admin;
|
|
|
|
use Zitec\RuleEngineBundle\Form\Type\RuleEngineType;
|
|
use Sonata\AdminBundle\Admin\AbstractAdmin;
|
|
use Sonata\AdminBundle\Datagrid\ListMapper;
|
|
use Sonata\AdminBundle\Form\FormMapper;
|
|
|
|
/**
|
|
* Class RuleAdmin
|
|
*/
|
|
class RuleAdmin extends AbstractAdmin
|
|
{
|
|
|
|
/**
|
|
* @param FormMapper $formMapper
|
|
*/
|
|
protected function configureFormFields(FormMapper $formMapper)
|
|
{
|
|
$fieldOptions = ['label' => false];
|
|
$parentOptions = $this->getParentFieldDescription()->getOptions();
|
|
if (!isset($parentOptions['rule_manager'])) {
|
|
throw new \RuntimeException('Missing rule manager object!');
|
|
}
|
|
$fieldOptions['rule_manager'] = $parentOptions['rule_manager'];
|
|
$formMapper
|
|
->with('General', ['class' => 'col-md-12'])
|
|
->add('active')
|
|
->add('name')
|
|
->end()
|
|
->with('Reglas', ['class' => 'col-md-12'])
|
|
->add('ruleObject', RuleEngineType::class, $fieldOptions)
|
|
->end()
|
|
->with('Acciones', [
|
|
'class' => 'col-md-12',
|
|
'box_class' => 'box box-solid box-success custom-form-fields',
|
|
'description' => 'Acciones a realizar',
|
|
])
|
|
->add('action','hidden',array('attr'=>array("hidden" => true)))
|
|
->end()
|
|
->end();
|
|
}
|
|
|
|
/**
|
|
* @param ListMapper $list
|
|
*/
|
|
protected function configureListFields(ListMapper $list)
|
|
{
|
|
$list->add('expression')
|
|
->add('json')
|
|
->add('action')
|
|
->add('_action', null, ['actions' => ['edit' => [], 'delete' => []]]);
|
|
}
|
|
}
|