| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * This software consists of voluntary contributions made by many individuals | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * and is licensed under the MIT license. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | namespace SanSessionToolbar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Zend\EventManager\EventInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Zend\ModuleManager\Feature\ConfigProviderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Zend\ModuleManager\Feature\DependencyIndicatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Zend\Mvc\MvcEvent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Zend\Session\Container; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Zend\Stdlib\SplQueue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @author Abdul Malik Ikhsan <[email protected]> | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 30 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | class Module implements ConfigProviderInterface, DependencyIndicatorInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      * Bootstrap Handle FlashMessenger session show | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |      * @param MvcEvent $e | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public function onBootstrap(MvcEvent $e) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $app = $e->getApplication(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $sharedEvm = $app->getEventManager()->getSharedManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $sharedEvm->attach( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             'Zend\Mvc\Controller\AbstractActionController', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             'dispatch', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             array($this, 'flashMessengerHandler'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      * @param EventInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     public function flashMessengerHandler(EventInterface $e) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $controller = $e->getTarget(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $flash = $controller->plugin('flashMessenger'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $container = new Container('FlashMessenger'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $reCreateFlash = $container->getArrayCopy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         foreach ($reCreateFlash as $key => $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             if ($row instanceof SplQueue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                 $flashPerNameSpace = $flash->setNamespace($key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                 $valuesMessage = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                 foreach ($row->toArray() as $keyArray => $rowArray) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                     $flashPerNameSpace->addMessage($rowArray); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                     $valuesMessage[] = $rowArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 $container->offsetSet($key, $valuesMessage); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function getConfig() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         return include __DIR__.'/../config/module.config.php'; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     public function getModuleDependencies() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         return array('ZendDeveloperTools'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 90 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |  |