123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace MapBundle\EventListener;
- use MapBundle\Entity\Interfaces\LocationInterface;
- use MapBundle\Form\Type\LocationType;
- use Sonata\AdminBundle\Event\ConfigureEvent;
- class LocationListener
- {
- /**
- * @param ConfigureEvent $event
- */
- public function configureFormFields(ConfigureEvent $event)
- {
- $mapper = $event->getMapper();
- $subject = $mapper->getAdmin()->getSubject();
- if ($subject && $subject instanceof LocationInterface) {
- if ($mapper->hasOpenTab()) {
- $mapper
- ->end()
- ->end();
- }
- $options = array(
- 'translation_domain' => 'MapBundle'
- );
- $mapper
- ->tab('Map', $options)
- ->with('Location', $options)
- ->add('location', LocationType::class, array(
- 'label' => false,
- ))
- ->end()
- ->end();
- }
- }
- /**
- * @param ConfigureEvent $event
- */
- public function configureShowFields(ConfigureEvent $event)
- {
- $mapper = $event->getMapper();
- $subject = $mapper->getAdmin()->getSubject();
- if ($subject && $subject instanceof LocationInterface) {
- if ($mapper->hasOpenTab()) {
- $mapper
- ->end()
- ->end();
- }
- $options = array(
- 'translation_domain' => 'MapBundle',
- );
- if (!$mapper->has('location')) {
- $mapper
- ->tab('Map', $options)
- ->with('Location', $options)
- ->add('location', null, array(
- 'template' => 'LeafletBundle:CRUD:map_show_field.html.twig',
- 'translation_domain' => 'MapBundle',
- ))
- ->end()
- ->end();
- }
- }
- }
- }
|