123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace IPv4Bundle\Admin;
- use Base\AdminBundle\Admin\BaseAdmin;
- use Sonata\AdminBundle\Datagrid\DatagridMapper;
- use Sonata\AdminBundle\Datagrid\ListMapper;
- use Sonata\AdminBundle\Form\FormMapper;
- use Sonata\AdminBundle\Show\ShowMapper;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- use HostBundle\Utils\HostStatus;
- class SubNetAdmin extends BaseAdmin
- {
- /**
- * @param DatagridMapper $datagridMapper
- */
- protected function configureDatagridFilters(DatagridMapper $datagridMapper)
- {
- $datagridMapper
- ->add('address')
- ->add('allowedHostType')
- ->add('status')
- ;
- }
- /**
- * @param ListMapper $listMapper
- */
- protected function configureListFields(ListMapper $listMapper)
- {
- $listMapper
- ->add('address')
- ->add('options', null, [
- 'header_style' => 'width: 50%',
- 'template' => 'HostBundle:CRUD:dhcp_options.html.twig',
- ])
- ->add('allowedHostType')
- ->add('status')
- ->add('netGroup')
- ->add('ipPool')
- ->add('_action', null, array(
- 'actions' => array(
- 'show' => array(),
- 'edit' => array(),
- 'delete' => array(),
- ),
- ))
- ;
- }
- /**
- * @param FormMapper $formMapper
- */
- protected function configureFormFields(FormMapper $formMapper)
- {
- $formMapper
- ->tab('SubNet')
- ->with('')
- ->add('address')
- ->add('allowedHostType')
- ->add('status', ChoiceType::class, [
- 'required' => false,
- 'choices' => HostStatus::getChoices(),
- 'translation_domain' => 'IPv4Bundle',
- ])
- ->add('netGroup')
- ->end()
- ->end()
- ;
- }
- /**
- * @param ShowMapper $showMapper
- */
- protected function configureShowFields(ShowMapper $showMapper)
- {
- $showMapper
- ->add('address')
- ->add('allowedHostType')
- ->add('status')
- ->add('netGroup')
- ->add('ipPool')
- ;
- }
- function prePersist($object){
- $object->setOptions(json_encode($object->getDHCPOption()));
- return parent::preUpdate($object);
- }
- function preUpdate($object){
- $object->setOptions(json_encode($object->getDHCPOption()));
- return parent::preUpdate($object);
- }
- }
|