예제 #1
0
 /**
  * Получает сервис из локатора если он есть
  * или сначала помещает его туда
  *
  * @return object
  */
 public function getService()
 {
     if (!$this->locator->checkService($this->service)) {
         $this->buildService(true);
     }
     return $this->locator->get($this->service);
 }
예제 #2
0
 /**
  * @return array
  */
 public function __invoke()
 {
     // get the module manager
     $moduleManager = $this->serviceLocator->get('ModuleManager');
     // get all loaded modules application wide
     $loadedModules = array_keys($moduleManager->getLoadedModules());
     // remove default unwanted modules
     $loadedModules = array_diff($loadedModules, $this->config['skip_modules']);
     // loop through all the loaded modules
     foreach ($loadedModules as $loadedModule) {
         $moduleClass = '\\' . $loadedModule . '\\Module';
         $moduleObject = new $moduleClass();
         if (!$moduleObject->getConfig()) {
             continue;
         }
         // get all routes for current module
         $module = $moduleManager->getModule($loadedModule);
         $routes = $module->getConfig()['router']['routes'];
         // if the routes variable (array) is not empty
         if (!empty($routes)) {
             // loop through each route
             foreach ($routes as $key => $route) {
                 // check for route type for the root route and act accordingly
                 //                    $this->_setRootRoute($route, $key);
                 // loop the children routes and act accordingly
                 $this->_setResources($route, $key);
             }
         }
     }
     return $this->_resources;
 }
예제 #3
0
 /**
  * @param bool $view determines if the routes should be properly formatted for views
  * @return array
  */
 public function fetchAllRoutes($view = false)
 {
     //        $this->_format_for_view = $view;
     // get the module manager
     $moduleManager = $this->serviceLocator->get('ModuleManager');
     // get all loaded modules application wide
     $loadedModules = array_keys($moduleManager->getLoadedModules());
     // remove default unwanted modules
     $loadedModules = array_diff($loadedModules, $this->config['skip_modules']);
     // loop through all the loaded modules
     foreach ($loadedModules as $loadedModule) {
         $moduleClass = '\\' . $loadedModule . '\\Module';
         $moduleObject = new $moduleClass();
         if (!$moduleObject->getConfig()) {
             continue;
         }
         // get all routes for current module
         $module = $moduleManager->getModule($loadedModule);
         if ($routes = $module->getConfig()['router']['routes']) {
             // if the routes variable (array) is not empty
             if (!empty($routes)) {
                 // loop through each route
                 foreach ($routes as $key => $route) {
                     $this->_setResources($route, $key);
                 }
             }
         }
     }
     return $this->_resources;
 }
예제 #4
0
 public function __construct(ServiceLocator $sl, $path)
 {
     $this->request = $sl->get('request');
     $this->response = $sl->get('response');
     $this->path = $path;
     // …
 }
예제 #5
0
 public function getByLatitudeAndLongitude($latitude, $longitude, $unit = 'c')
 {
     $query = $this->resolveWeatherQuery($latitude, $longitude, $unit);
     $namespacedQuery = static::API_ENDPOINT . '?q=' . urlencode($query) . '&format=json';
     // could use ->json() but we want an object, not an array
     $result = ServiceLocator::get('httpClient')->get($namespacedQuery);
     $json = $result->getBody()->getContents();
     if (empty($json)) {
         throw new \Exception('Yahoo weather API did not respond with any content');
     }
     $this->weatherData = json_decode($json);
     if (json_last_error() != JSON_ERROR_NONE) {
         throw new \Exception('Yahoo responded with an invalid json');
     }
 }
예제 #6
0
 /**
  * @param $name
  * @return ServiceLocator|mixed
  * @throws \InvalidArgumentException
  */
 public function __get($name)
 {
     switch (strtolower($name)) {
         case 'services':
         case 'servicelocator':
             return $this->serviceLocator;
         case 'router':
             return $this->serviceLocator->get('Router');
         case 'routes':
             return $this->serviceLocator->get('Router')->getRouteStack();
         default:
             if ($this->serviceLocator->has($name)) {
                 return $this->serviceLocator->get($name);
             }
     }
     throw new \InvalidArgumentException($name . ' is not a valid property in the application object or a valid service in the ServiceLocator');
 }
예제 #7
0
 protected function setCitiesWeatherCache($value)
 {
     return ServiceLocator::get('cache')->set($this->resolveCitiesWeatherKey(), $value);
 }
예제 #8
0
 /**
  * Returns the actual object referenced by this Instance object.
  * @param ServiceLocator|Container $container the container used to locate the referenced object.
  * If null, the method will first try `Yii::$app` then `Yii::$container`.
  * @return object the actual object referenced by this Instance object.
  */
 public function get($container = null)
 {
     if ($container) {
         return $container->get($this->id);
     }
     if (app() && app()->has($this->id)) {
         return app()->get($this->id);
     } else {
         return Container::getInstance()->get($this->id);
     }
 }
예제 #9
0
파일: Client.php 프로젝트: kairios/sigma
 /**
  * Permet d'afficher seulement les informations présentes sur l'écran de recherche Client (qui sont également les critères)
  * @author Ophélie
  * @param  ServiceLocator $sm
  * @param  array $critere 
  * @since  1.0
  * @return array
  */
 public function getClientsFromForms($sm, $codeClient = '', $raisonSociale = null, $limit = 100)
 {
     $sql = new Sql($sm->get('Zend\\Db\\Adapter\\Adapter'));
     $select = $sql->select();
     $select->columns(array('id', 'societe' => new Expression("CONCAT(c.raison_sociale,' (',a.code_postal,' ',a.ville,', ',a.pays,')')")))->from(array('c' => 'client'))->join(array('a' => 'adresse'), 'a.ref_client = c.id', array(), $select::JOIN_LEFT)->order('raison_sociale ASC');
     $where = new Where();
     if ($codeClient !== '') {
         if ($codeClient === null) {
             //var_dump($codeClient);die();
             $where->isNull('c.code_client')->and;
         } else {
             $where->equalTo('c.code_client', $codeClient)->and;
         }
     }
     if ($raisonSociale !== null) {
         $where->equalTo('c.raison_sociale', $raisonSociale)->and;
     }
     $where->and->nest()->equalTo('a.adresse_principale', 1)->or->isNull('a.adresse_principale')->unnest();
     $select->where($where);
     $statement = $sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     if ($results->isQueryResult()) {
         $resultSet = new ResultSet();
         $resultSet->initialize($results);
         return $resultSet->toArray();
     }
     return array();
 }
예제 #10
0
파일: Instance.php 프로젝트: renyinew/blink
 /**
  * Returns the actual object referenced by this Instance object.
  * @param ServiceLocator|Container $container the container used to locate the referenced object.
  * If null, the method will first try `Yii::$app` then `Yii::$container`.
  * @return object the actual object referenced by this Instance object.
  */
 public function get($container = null)
 {
     if ($container) {
         return $container->get($this->id);
     }
     if (Container::$app && Container::$app->has($this->id)) {
         return Container::$app->get($this->id);
     } else {
         return Container::$instance->get($this->id);
     }
 }
예제 #11
0
 /**
  * Permet d'afficher seulement les informations présentes sur l'écran de recherche Interlocuteur (qui sont également les critères)
  * @author Ophélie
  * @param  ServiceLocator $sm
  * @param  array $critere 
  * @since  1.0
  * @return array
  */
 public function getInterlocuteurs($sm, $critere, $limit = 100)
 {
     $sql = new Sql($sm->get('Zend\\Db\\Adapter\\Adapter'));
     $select = $sql->select();
     $select->columns(array('id', 'nom_complet' => new Expression("CONCAT_WS(' ',titre_civilite,prenom,nom)"), 'email', 'envoi_vers_outlook'))->from(array('i' => 'interlocuteur_fournisseur'))->join(array('f' => 'fournisseur'), 'i.ref_societe_fournisseur = f.id', array('code_fournisseur', 'raison_sociale'), $select::JOIN_LEFT)->order('nom ASC, prenom ASC')->limit($limit);
     $where = new Where();
     $where->equalTo('f.supprime', 0)->and->nest()->like('i.prenom', $critere)->or->like('i.nom', $critere)->or->like('f.code_fournisseur', $critere)->or->like('f.raison_sociale', $critere)->or->like('i.email', $critere)->unnest();
     $select->where($where);
     //\Zend\Debug\Debug::dump($select->getSqlString());die();
     $statement = $sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     if ($results->isQueryResult()) {
         $resultSet = new ResultSet();
         $resultSet->initialize($results);
         return $resultSet->toArray();
     }
     return array();
 }
예제 #12
0
파일: Segment.php 프로젝트: kairios/sigma
 /**
  * [findSegmentByTypeSegment description]
  * @param  ServiceLocator $sm
  * @param  int $typeSegment (ID du type de segment)
  * @return array              (Array de Segment)
  */
 public function findSegmentByTypeSegment($sm, $typeSegment)
 {
     $idType = (int) $typeSegment;
     $query = "SELECT id, intitule_segment \n             FROM segment\n             WHERE ref_type_segment = {$idType}";
     $statement = $sm->get('Zend\\Db\\Adapter\\Adapter')->query($query);
     $results = $statement->execute();
     if ($results->isQueryResult()) {
         $resultSet = new ResultSet();
         $resultSet->initialize($results);
         return $resultSet->toArray();
     }
     return array();
 }
예제 #13
0
파일: Personnel.php 프로젝트: kairios/sigma
 /**
  * Permet d'afficher seulement les informations présentes sur l'écran de recherche Client (qui sont également les critères)
  * @author Ophélie
  * @param  ServiceLocator $sm
  * @param  array $critere 
  * @since  1.0
  * @return array
  */
 public function getListeUtilisateurs($sm)
 {
     $query = "SELECT p.id, CONCAT_WS(' ', p.prenom, p.nom) AS nom_complet, p.email, p.taux_horaire \n             FROM personnel AS p\n             ORDER BY nom_complet ASC\n            ";
     $statement = $sm->get('Zend\\Db\\Adapter\\Adapter')->query($query);
     $results = $statement->execute();
     if ($results->isQueryResult()) {
         $resultSet = new ResultSet();
         $resultSet->initialize($results);
         return $resultSet->toArray();
     }
     return array();
 }
 protected function resolveCitiesDistanceWeatherKey()
 {
     return ServiceLocator::get('config')->get('application.WeatherResultsCompiler.' . 'citiesDistanceWeatherCacheKey');
 }