예제 #1
0
파일: Module.php 프로젝트: odegroot/ers
 public function getServiceConfig()
 {
     return array('factories' => array('Zend\\Session\\SessionManager' => function ($sm) {
         $config = $sm->get('config');
         if (isset($config['session'])) {
             $session = $config['session'];
             $sessionConfig = null;
             if (isset($session['config'])) {
                 $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
                 $options = isset($session['config']['options']) ? $session['config']['options'] : array();
                 $sessionConfig = new $class();
                 $sessionConfig->setOptions($options);
             }
             $sessionStorage = null;
             if (isset($session['storage'])) {
                 $class = $session['storage'];
                 $sessionStorage = new $class();
             }
             $sessionSaveHandler = null;
             if (isset($session['save_handler'])) {
                 // class should be fetched from service manager since it will require constructor arguments
                 $sessionSaveHandler = $sm->get($session['save_handler']);
             }
             $sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
             if (isset($session['validators'])) {
                 $chain = $sessionManager->getValidatorChain();
                 foreach ($session['validators'] as $validator) {
                     $validator = new $validator();
                     $chain->attach('session.validate', array($validator, 'isValid'));
                 }
             }
         } else {
             $sessionManager = new SessionManager();
         }
         Container::setDefaultManager($sessionManager);
         return $sessionManager;
     }, 'OnsiteReg\\Form\\ProductView' => function ($sm) {
         $productView = new Form\ProductView();
         $productView->setServiceLocator($sm);
         return $productView;
     }, 'OnsiteReg\\Form\\CreditCard' => function ($sm) {
         $form = new Form\CreditCard();
         $years = array();
         for ($i = date('Y'); $i <= date('Y') + 15; $i++) {
             $years[] = array('value' => $i, 'label' => $i);
         }
         $form->get('cc_expdate_year')->setAttribute('options', $years);
         $months = array();
         for ($i = 1; $i <= 12; $i++) {
             $months[] = array('value' => $i, 'label' => sprintf('%02d', $i));
         }
         $form->get('cc_expdate_month')->setAttribute('options', $months);
         return $form;
     }, 'OnsiteReg\\Service\\AgegroupService:price' => function ($sm) {
         $agegroupService = new Service\AgegroupService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $agegroups = $em->getRepository("ErsBase\\Entity\\Agegroup")->findBy(array('price_change' => '1'));
         $agegroupService->setAgegroups($agegroups);
         return $agegroupService;
     }, 'OnsiteReg\\Service\\AgegroupService:ticket' => function ($sm) {
         $agegroupService = new Service\AgegroupService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $agegroups = $em->getRepository("ErsBase\\Entity\\Agegroup")->findBy(array('ticket_change' => '1'));
         $agegroupService->setAgegroups($agegroups);
         return $agegroupService;
     }, 'OnsiteReg\\Service\\ETicketService' => function ($sm) {
         $eticketService = new Service\ETicketService();
         $eticketService->setServiceLocator($sm);
         return $eticketService;
     }));
 }
예제 #2
0
파일: Module.php 프로젝트: odegroot/ers
 public function getServiceConfig()
 {
     return array('factories' => array('ErsBase\\Service\\CodeService' => 'ErsBase\\Service\\Factory\\CodeFactory', 'ErsBase\\Service\\EmailService' => function ($sm) {
         $emailService = new Service\EmailService();
         $emailService->setServiceLocator($sm);
         return $emailService;
     }, 'ErsBase\\Service\\CloneService' => function ($sm) {
         $service = new Service\CloneService();
         $service->setServiceLocator($sm);
         return $service;
     }, 'ErsBase\\Service\\AgegroupService:price' => function ($sm) {
         $agegroupService = new Service\AgegroupService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $agegroups = $em->getRepository("ErsBase\\Entity\\Agegroup")->findBy(array('price_change' => '1'));
         $agegroupService->setAgegroups($agegroups);
         return $agegroupService;
     }, 'ErsBase\\Service\\AgegroupService:ticket' => function ($sm) {
         $agegroupService = new Service\AgegroupService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $agegroups = $em->getRepository("ErsBase\\Entity\\Agegroup")->findBy(array('ticket_change' => '1'));
         $agegroupService->setAgegroups($agegroups);
         return $agegroupService;
     }, 'ErsBase\\Service\\DeadlineService:price' => function ($sm) {
         $deadlineService = new Service\DeadlineService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $deadlines = $em->getRepository("ErsBase\\Entity\\Deadline")->findBy(array('price_change' => '1'));
         $deadlineService->setDeadlines($deadlines);
         return $deadlineService;
     }, 'ErsBase\\Service\\DeadlineService:noprice' => function ($sm) {
         $deadlineService = new Service\DeadlineService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $deadlines = $em->getRepository("ErsBase\\Entity\\Deadline")->findBy(array('price_change' => '0'));
         $deadlineService->setDeadlines($deadlines);
         return $deadlineService;
     }, 'ErsBase\\Service\\DeadlineService:all' => function ($sm) {
         $deadlineService = new Service\DeadlineService();
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $deadlines = $em->getRepository("ErsBase\\Entity\\Deadline")->findAll();
         $deadlineService->setDeadlines($deadlines);
         return $deadlineService;
     }, 'ErsBase\\Service\\TicketCounterService' => function ($sm) {
         $ticketCounterService = new Service\TicketCounterService();
         $ticketCounterService->setServiceLocator($sm);
         return $ticketCounterService;
     }, 'ErsBase\\Service\\ETicketService' => function ($sm) {
         $service = new Service\ETicketService();
         $service->setServiceLocator($sm);
         $em = $sm->get('Doctrine\\ORM\\EntityManager');
         $products = $em->getRepository("ErsBase\\Entity\\Product")->findBy(array('visible' => '1'), array('ordering' => 'ASC'));
         $service->setProducts($products);
         return $service;
     }, 'ErsBase\\Service\\OrderService' => function ($sm) {
         $service = new Service\OrderService();
         $service->setServiceLocator($sm);
         return $service;
     }, 'ErsBase\\Service\\OptionService' => function ($sm) {
         $service = new Service\OptionService();
         $service->setServiceLocator($sm);
         return $service;
     }));
 }