public function createService(\Zend\ServiceManager\ServiceLocatorInterface $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 self($sessionConfig, $sessionStorage, $sessionSaveHandler);
     } else {
         $sessionManager = new self();
     }
     \Zend\Session\Container::setDefaultManager($sessionManager);
     return $sessionManager;
 }
Esempio n. 2
0
 /**
  * Factory method.
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $service = new PicService();
     $service->setEntityManager($serviceLocator->get('Doctrine\\ORM\\EntityManager'));
     $service->setAuthService($serviceLocator->get('zfcuser_auth_service'));
     return $service;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $router = $serviceLocator->get('Router');
     $application = $serviceLocator->get('Application');
     $options = $serviceLocator->get('zfcuser_module_options');
     return new RedirectCallback($application, $router, $options);
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $em = $serviceLocator->get('doctrine.entitymanager.orm_default');
     $options = $serviceLocator->get('BiBoBlogOptions');
     $form = new \BiBoBlog\Form\BiBoBlogForm($em, $options);
     return $form;
 }
Esempio n. 5
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $entity = $serviceLocator->get('Techtree\\Entity\\Research');
     $table = new ResearchTable($adapter, $entity);
     return $table;
 }
 public function createService(ServiceLocatorInterface $sm)
 {
     $service = new TableService();
     $service->setCityCodesTable($sm->get('city-codes-table'));
     $service->setListingsTable($sm->get('listings-table'));
     return $service;
 }
Esempio n. 7
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $pluginManager = $serviceLocator->get('Phpro\\MailManager\\PluginManager');
     $adapter = $serviceLocator->get('Phpro\\MailManager\\DefaultAdapter');
     $instance = new Instance($pluginManager, $adapter);
     return $instance;
 }
 /**
  * Create and return a Console adapter instance.
  * In case we're not in a Console environment, return a dummy stdClass object.
  *
  * In order to disable adapter auto-detection and use a specific adapter (and charset),
  * add the following fields to application configuration, for example:
  *
  *     'console' => array(
  *         'adapter' => 'MyConsoleAdapter',     // always use this console adapter
  *         'charset' => 'MyConsoleCharset',     // always use this console charset
  *      ),
  *      'service_manager' => array(
  *          'invokables' => array(
  *              'MyConsoleAdapter' => 'Zend\Console\Adapter\Windows',
  *              'MyConsoleCharset' => 'Zend\Console\Charset\DESCG',
  *          )
  *      )
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return AdapterInterface|stdClass
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // First, check if we're actually in a Console environment
     if (!Console::isConsole()) {
         // SM factory cannot currently return null, so we return dummy object
         return new stdClass();
     }
     // Read app config and determine Console adapter to use
     $config = $serviceLocator->get('Config');
     if (!empty($config['console']) && !empty($config['console']['adapter'])) {
         // use the adapter supplied in application config
         $adapter = $serviceLocator->get($config['console']['adapter']);
     } else {
         // try to detect best console adapter
         $adapter = Console::detectBestAdapter();
         $adapter = new $adapter();
     }
     // check if we have a valid console adapter
     if (!$adapter instanceof AdapterInterface) {
         // SM factory cannot currently return null, so we convert it to dummy object
         return new stdClass();
     }
     // Optionally, change Console charset
     if (!empty($config['console']) && !empty($config['console']['charset'])) {
         // use the charset supplied in application config
         $charset = $serviceLocator->get($config['console']['charset']);
         $adapter->setCharset($charset);
     }
     return $adapter;
 }
Esempio n. 9
0
 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $entity = $serviceLocator->get('Blog\\Entity\\Blog');
     $table = new BlogTable($adapter, $entity);
     return $table;
 }
Esempio n. 10
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $options = $serviceLocator->get('cdiuser_options');
     $em = $serviceLocator->get('zfcuser_doctrine_em');
     $userSession = new \CdiUser\Service\UserSession($options, $em, $serviceLocator);
     return $userSession;
 }
Esempio n. 11
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     // The parameters in Doctrine 2 and ZF2 are slightly different.
     // Below is an example how we can reuse the db settings
     $doctrineDbConfig = (array) $config['db'];
     $doctrineDbConfig['driver'] = strtolower($doctrineDbConfig['driver']);
     if (!isset($doctrineDbConfig['dbname'])) {
         $doctrineDbConfig['dbname'] = $doctrineDbConfig['database'];
     }
     if (!isset($doctrineDbConfig['host'])) {
         $doctrineDbConfig['host'] = $doctrineDbConfig['hostname'];
     }
     if (!isset($doctrineDbConfig['user'])) {
         $doctrineDbConfig['user'] = $doctrineDbConfig['username'];
     }
     $doctrineConfig = Setup::createAnnotationMetadataConfiguration($config['doctrine']['entity_path'], true);
     $entityManager = DoctrineEntityManager::create($doctrineDbConfig, $doctrineConfig);
     if (isset($config['doctrine']['initializers'])) {
         $eventManager = $entityManager->getEventManager();
         foreach ($config['doctrine']['initializers'] as $initializer) {
             $eventClass = new DoctrineEvent(new $initializer(), $serviceLocator);
             $eventManager->addEventListener(\Doctrine\ORM\Events::postLoad, $eventClass);
         }
     }
     if ($serviceLocator->has('doctrine-profiler')) {
         $profiler = $serviceLocator->get('doctrine-profiler');
         $entityManager->getConfiguration()->setSQLLogger($profiler);
     }
     return $entityManager;
 }
Esempio n. 12
0
 /**
  * {@inheritDoc}
  *
  * @throws RuntimeException
  * @return AnnotationBuilder
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /* @var $options FormAnnotationBuilder */
     $options = $serviceLocator->get(FormAnnotationBuilder::class);
     $cache = $serviceLocator->has($options->getCache()) ? $serviceLocator->get($options->getCache()) : null;
     $builder = new AnnotationBuilder($cache);
     if ($serviceLocator->has('FormElementManager')) {
         $serviceLocator->get('FormElementManager')->injectFactory($builder);
     }
     foreach ($options->getAnnotations() as $annotation) {
         $builder->getAnnotationParser()->registerAnnotation($annotation);
     }
     $events = $builder->getEventManager();
     foreach ($options->getListeners() as $listener) {
         $listener = $serviceLocator->has($listener) ? $serviceLocator->get($listener) : new $listener();
         if (!$listener instanceof ListenerAggregateInterface) {
             throw new RuntimeException(sprintf('Invalid event listener (%s) provided', get_class($listener)));
         }
         $events->attach($listener);
     }
     if (null !== $options->getPreserveDefinedOrder()) {
         $builder->setPreserveDefinedOrder($options->getPreserveDefinedOrder());
     }
     return $builder;
 }
Esempio n. 13
0
 /**
  * Retrieve array of menu items
  *
  * Returns only items with 'main' equal to TRUE
  *
  * @return array
  */
 public function getMainItems()
 {
     $result = array_filter($this->serviceLocator->get('config')['nav'], function ($value) {
         return isset($value['main']) && (bool) $value['main'];
     });
     return $result;
 }
 /**
  * Retourne le translator.
  *
  * @var \Zend\I18n\Translator\Translator
  */
 public function _getServTranslator()
 {
     if (!$this->_servTranslator) {
         $this->_servTranslator = $this->_serviceLocator->get('translator');
     }
     return $this->_servTranslator;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var \Zend\Mvc\Application $app */
     $app = $serviceLocator->get('Application');
     /** @var \Zend\Mvc\Router\Http\RouteMatch $routeMatch */
     $routeMatch = $app->getMvcEvent()->getRouteMatch();
     if ($routeMatch->getParam('viewModel')) {
         $viewModel = $serviceLocator->get($routeMatch->getParam('viewModel'));
         if (!$viewModel instanceof ViewModel) {
             throw new \RuntimeException('ViewModel must be instance of ' . ViewModel::class);
         }
     } else {
         $viewModel = new ViewModel();
     }
     if (!$viewModel->getTemplate()) {
         $template = $routeMatch->getParam('template');
         if ($template) {
             if (!is_string($template)) {
                 throw new \RuntimeException('Parameter template must be string');
             }
             $viewModel->setTemplate($template);
         }
     }
     return $viewModel;
 }
 /**
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return object
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $manifest = $serviceLocator->get('manifest');
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB(self::DEFAULT_DB);
     $config->setMetadataCacheImpl(new ArrayCache());
     //create driver chain
     $chain = new MappingDriverChain();
     foreach ($manifest['documents'] as $namespace => $path) {
         $driver = new AnnotationDriver(new AnnotationReader(), $path);
         $chain->addDriver($driver, $namespace);
     }
     $config->setMetadataDriverImpl($chain);
     //register filters
     foreach ($manifest['filters'] as $name => $class) {
         $config->addFilter($name, $class);
     }
     //create event manager
     $eventManager = new EventManager();
     foreach ($manifest['subscribers'] as $subscriber) {
         $eventManager->addEventSubscriber($serviceLocator->get($subscriber));
     }
     //register annotations
     AnnotationRegistry::registerLoader(function ($className) {
         return class_exists($className);
     });
     $conn = new Connection(null, array(), $config);
     return DocumentManager::create($conn, $config, $eventManager);
 }
 /**
  * create AnalyticsAccessRcmUserAcl
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return AnalyticsAccessRcmUserAcl
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $rcmUserService = $serviceLocator->get('RcmUser\\Service\\RcmUserService');
     $config = $serviceLocator->get('config');
     $resourceConfig = $config['Reliv\\RcmGoogleAnalytics']['acl-resource-config'];
     return new AnalyticsAccessRcmUserAcl($rcmUserService, $resourceConfig['privilege'], $resourceConfig['resourceId'], $resourceConfig['providerId']);
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $app = $serviceLocator->get('Application');
     $sessionManager = $app->getServiceManager()->get('SessionManagerDefault');
     $sessionID = $sessionManager->getId();
     $roleInfo = $sessionManager->getStorage()->getMetadata('__ZY');
     $authManager = $serviceLocator->get('authenticationManagerDefault');
     /**
      * if role info is not displayed and user not registered , then user is guest
      */
     if ($authManager->getStorage()->isEmpty()) {
         $sessionManager->getStorage()->setMetadata('__ZY', array('role' => 'guest', 'roleID' => 7));
         return array('name' => 'guest', 'id' => 7);
     } else {
         /**
          * if role info is not set and user is registered, then get
          * user role due to user name
          */
         $roleResult = $serviceLocator->get('serviceAclRoleFinder');
         if ($roleResult['found']) {
             //print_r($roleResult['resultSet']);
             $sessionManager->getStorage()->setMetadata('__ZY', array('role' => strtolower(trim($roleResult['resultSet'][0]['name'])), 'roleID' => $roleResult['resultSet'][0]['id']));
             return $roleResult['resultSet'][0];
         } else {
             $sessionManager->getStorage()->setMetadata('__ZY', array('role' => 'guest', 'roleID' => 7));
             return array('name' => 'guest', 'id' => 7);
         }
     }
 }
Esempio n. 19
0
 /**
  * Create the aggregate view resolver
  *
  * Creates a Zend\View\Resolver\AggregateResolver and attaches the template
  * map resolver and path stack resolver
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ViewResolver\AggregateResolver
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $resolver = new ViewResolver\AggregateResolver();
     $resolver->attach($serviceLocator->get('ViewTemplateMapResolver'));
     $resolver->attach($serviceLocator->get('ViewTemplatePathStack'));
     return $resolver;
 }
Esempio n. 20
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $config = $config['oauth2'];
     $tokenStorageObj = $serviceLocator->get($config['tokenStore']);
     return $tokenStorageObj;
 }
Esempio n. 21
0
 /**
  * Create and return the router
  *
  * Retrieves the "router" key of the Config service, and uses it
  * to instantiate the router. Uses the TreeRouteStack implementation by
  * default.
  *
  * @param  ServiceLocatorInterface        $serviceLocator
  * @param  string|null                     $cName
  * @param  string|null                     $rName
  * @return \Zend\Mvc\Router\RouteStackInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
 {
     $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
     // Defaults
     $routerClass = 'Zend\\Mvc\\Router\\Http\\TreeRouteStack';
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     // Console environment?
     if ($rName === 'ConsoleRouter' || $cName === 'router' && Console::isConsole()) {
         // We are in a console, use console router defaults.
         $routerClass = 'Zend\\Mvc\\Router\\Console\\SimpleRouteStack';
         $routerConfig = isset($config['console']['router']) ? $config['console']['router'] : array();
     }
     // Obtain the configured router class, if any
     if (isset($routerConfig['router_class']) && class_exists($routerConfig['router_class'])) {
         $routerClass = $routerConfig['router_class'];
     }
     // Inject the route plugins
     if (!isset($routerConfig['route_plugins'])) {
         $routePluginManager = $serviceLocator->get('RoutePluginManager');
         $routerConfig['route_plugins'] = $routePluginManager;
     }
     // Obtain an instance
     $factory = sprintf('%s::factory', $routerClass);
     return call_user_func($factory, $routerConfig);
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $pdo = $serviceLocator->get('servicePostgrePdo');
     $authManager = $serviceLocator->get('authenticationManagerDefault');
     $authStorage = $authManager->getStorage()->read();
     if (isset($authStorage['username'])) {
         $userName = $authStorage['username'];
         try {
             $pdo->beginTransaction();
             $statement = $pdo->prepare(" \n\n                    SELECT   a.role_id as id , r.name as name\n                    FROM info_users a\n                    inner join sys_acl_roles r on r.id = a.role_id AND r.active =0 AND r.deleted =0    \n                    where a.active = 0 AND a.deleted = 0 AND\n                    username = :username");
             $statement->bindValue(':username', $userName, \PDO::PARAM_STR);
             $statement->execute();
             $result = $statement->fetchAll(\PDO::FETCH_ASSOC);
             $errorInfo = $statement->errorInfo();
             if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) {
                 throw new \PDOException($errorInfo[0]);
             }
             $pdo->commit();
             return array("found" => true, "errorInfo" => $errorInfo, "resultSet" => $result);
         } catch (\PDOException $e) {
             $pdo->rollback();
             return array("found" => false, "errorInfo" => $e->getMessage());
         }
     } else {
         return array("found" => false, "errorInfo" => 'user name not found!!!');
     }
 }
Esempio n. 23
0
 /**
  * Prepare Exam service
  * 
  * @uses Exam
  * 
  * @access public
  * @param ServiceLocatorInterface $serviceLocator
  * @return Exam
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $query = $serviceLocator->get('wrapperQuery')->setEntity('Courses\\Entity\\ExamBook');
     $systemCacheHandler = $serviceLocator->get('systemCacheHandler');
     $notification = $serviceLocator->get('Notifications\\Service\\Notification');
     return new Exam($query, $systemCacheHandler, $notification);
 }
Esempio n. 24
0
 public function createService(ServiceLocatorInterface $sm)
 {
     $mailService = $sm->get('Base\\Service\\MailService');
     $configManager = $sm->get('Base\\Manager\\ConfigManager');
     $optionManager = $sm->get('Base\\Manager\\OptionManager');
     return new MailService($mailService, $configManager, $optionManager);
 }
 /**
  * Create and return a view manager based on detected environment
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ConsoleViewManager|HttpViewManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (Console::isConsole()) {
         return $serviceLocator->get('ConsoleViewManager');
     }
     return $serviceLocator->get('HttpViewManager');
 }
Esempio n. 26
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->entityManager = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     $this->programService = new ProgramService();
     $this->programService->setServiceLocator($this->serviceManager);
 }
Esempio n. 27
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $mapper = new MethodMapper();
     $mapper->setEntityPrototype($serviceLocator->get('app_method'));
     $mapper->setHydrator($serviceLocator->get('app_method_hydrator'));
     return $mapper;
 }
Esempio n. 28
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $identity = $serviceLocator->get('api-identity');
     $usersRepository = $serviceLocator->get('CodeOrders\\V1\\Rest\\Users\\UsersRepository');
     $user = $usersRepository->findBy(['username' => $identity->getRoleId()])->current();
     return new AuthService($user);
 }
 /**
  * {@inheritDoc}
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var \Detail\Commanding\Options\ModuleOptions $moduleOptions */
     $moduleOptions = $serviceLocator->get('Detail\\Commanding\\Options\\ModuleOptions');
     /** @var \Detail\Commanding\CommandHandlerManager $commandHandlerManager */
     $commandHandlerManager = $serviceLocator->get('Detail\\Commanding\\CommandHandlerManager');
     $commandHandlerManager->setServiceLocator($serviceLocator);
     $commandDispatcher = new CommandDispatcher($commandHandlerManager);
     $commands = $moduleOptions->getCommands();
     foreach ($commands as $command) {
         if (!isset($command['command'])) {
             throw new Exception\ConfigException('Command is missing required configuration option "command"');
         }
         if (!isset($command['handler'])) {
             throw new Exception\ConfigException('Command is missing required configuration option "handler"');
         }
         $commandDispatcher->register($command['command'], $command['handler']);
     }
     $listeners = $moduleOptions->getListeners();
     foreach ($listeners as $listenerName) {
         /** @todo Lazy load listeners? */
         /** @var ListenerAggregateInterface $listener */
         $listener = $serviceLocator->get($listenerName);
         $listener->attach($commandDispatcher->getEventManager());
     }
     return $commandDispatcher;
 }
Esempio n. 30
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $AuthService = $serviceLocator->get("Ellie\\Service\\Authentication");
     $doctrineService = $serviceLocator->get('Doctrine\\ORM\\EntityManager');
     // die(var_dump($doctrineService));
     return new Service($doctrineService, $AuthService);
 }