| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file is part of the Sonata Project package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * (c) Thomas Rabaix <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace Sonata\NotificationBundle\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Sonata\AdminBundle\Admin\AbstractAdmin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sonata\AdminBundle\Datagrid\DatagridMapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sonata\AdminBundle\Datagrid\ListMapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sonata\AdminBundle\Route\RouteCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Sonata\AdminBundle\Show\ShowMapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class MessageAdmin extends AbstractAdmin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected $classnameLabel = 'Message'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     public function configureRoutes(RouteCollection $collection): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $collection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             ->remove('edit') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             ->remove('create') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             ->remove('history') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     public function getBatchActions() | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         $actions = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |         $actions['publish'] = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |             'label' => $this->getLabelTranslatorStrategy()->getLabel('publish', 'batch', 'message'), | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             'translation_domain' => $this->getTranslationDomain(), | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |             'ask_confirmation' => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         $actions['cancelled'] = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |             'label' => $this->getLabelTranslatorStrategy()->getLabel('cancelled', 'batch', 'message'), | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |             'translation_domain' => $this->getTranslationDomain(), | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |             'ask_confirmation' => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         return $actions; | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     protected function configureShowFields(ShowMapper $showMapper): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $showMapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             ->add('id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             ->add('type') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             ->add('createdAt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             ->add('startedAt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             ->add('completedAt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             ->add('getStateName') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             ->add('body') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             ->add('restartCount') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     protected function configureListFields(ListMapper $listMapper): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $listMapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             ->addIdentifier('id', null, ['route' => ['name' => 'show']]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             ->add('type') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             ->add('createdAt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             ->add('startedAt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             ->add('completedAt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             ->add('getStateName') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             ->add('restartCount') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     protected function configureDatagridFilters(DatagridMapper $datagridMapper): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $class = $this->getClass(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $datagridMapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             ->add('type') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ->add('state', null, [], ChoiceType::class, ['choices' => $class::getStateList()]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 105 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |  |