/**
  * @param IConfiguration $config
  * @param string $configFolder
  * @param bool $usePrefix
  *
  * @return IConfiguration
  */
 public function loadConfigurations(IConfiguration $config, $configFolder, $usePrefix = false)
 {
     $diretory = new \DirectoryIterator($configFolder);
     foreach ($diretory as $fileinfo) {
         if ($fileinfo->isDot() || !$fileinfo->isFile() || !$fileinfo->isReadable() || substr($fileinfo->getFilename(), -strlen($this->extension), strlen($this->extension)) != $this->extension) {
             continue;
         }
         $prefix = "";
         if ($usePrefix) {
             $prefix = substr($fileinfo->getFilename(), 0, -strlen($this->extension));
         }
         $config->loadFile($fileinfo->getPathname(), $prefix);
     }
     return $config;
 }
 /**
  * @param string $declaration
  *
  * @return string
  * @throws DeclarationNotFound
  * @throws \Exception
  */
 public function getClassname($declaration)
 {
     if (!$this->injectionConfiguration->has($declaration)) {
         throw new DeclarationNotFound("Declaration of Class '" . $declaration . "' not found.");
     }
     $json = $this->injectionConfiguration->get($declaration);
     if (!isset($json["class"])) {
         throw new \Exception("Index 'class' not found in declaration '" . $declaration . "'.");
     }
     return $json["class"];
 }
 /**
  *
  */
 public function prepareResponse()
 {
     $this->response = $this->application->returnResponse();
     if ($this->applicationConfig->get("accept-control-allow-origin") != NULL) {
         $accepts = explode(",", $this->applicationConfig->get("accept-control-allow-origin"));
         foreach ($accepts as $accept) {
             $this->response->setHeader("Access-Control-Allow-Origin: " . $accept, false);
         }
     }
     $this->response->process();
 }
Exemple #4
0
 /**
  * @param IConfiguration $applicationConfiguration
  */
 public function init(IConfiguration $applicationConfiguration)
 {
     $this->router->parseExpressions();
     $this->router->detectCurrentRoute($this->kernel->getRequest()->url(), $this->kernel->getServer()->getRequestMethod());
     $this->kernel->getRequest()->assignExpressionValues($this->router);
     $ds = DIRECTORY_SEPARATOR;
     $proxyPath = $this->kernel->getServer()->getDocumentRoot() . "var" . $ds . "cache" . $ds . "Proxies";
     $entityPath = $this->kernel->getServer()->getDocumentRoot() . "src";
     if (!file_exists($proxyPath)) {
         mkdir($proxyPath, 0770, true);
     }
     $isDevMode = $applicationConfiguration->get("devmode") == true;
     $emConfig = Setup::createAnnotationMetadataConfiguration(array($entityPath), $isDevMode, $proxyPath);
     /*$emConfig->addCustomStringFunction("GROUP_CONCAT", "DoctrineExtensions\\Query\\Mysql\\GroupConcat");
     		$emConfig->addCustomStringFunction("DATE_FORMAT", "DoctrineExtensions\\Query\\Mysql\\DateFormat");
     		$emConfig->addCustomStringFunction("IFNULL", "DoctrineExtensions\\Query\\Mysql\\IfNull");
     		$emConfig->addCustomStringFunction("STR_TO_DATE", "DoctrineExtensions\\Query\\Mysql\\StrToDate");
     		$emConfig->addCustomStringFunction("CONCAT_WS", "DoctrineExtensions\\Query\\Mysql\\ConcatWs");
     		$emConfig->addCustomStringFunction("DATEDIFF", "DoctrineExtensions\\Query\\Mysql\\DateDiff");
     		$emConfig->addCustomStringFunction("MATCH_AGAINST", "DoctrineExtensions\\Query\\Mysql\\MatchAgainst");
     		$emConfig->addCustomStringFunction("REGEXP", "DoctrineExtensions\\Query\\Mysql\\Regexp");
     		$emConfig->addCustomStringFunction("IFELSE", "DoctrineExtensions\\Query\\Mysql\\IfElse");*/
     if (!empty($applicationConfiguration->get("repository-factory"))) {
         $repositoryFactory = $applicationConfiguration->get("repository-factory");
         $emConfig->setRepositoryFactory(new $repositoryFactory());
     }
     if (!$isDevMode) {
         $memcache = new \Memcache();
         $memcache->addServer("127.0.0.1", 11211);
         $cacheDriver = new MemcacheCache();
         $cacheDriver->setMemcache($memcache);
         $cacheDriver->setNamespace($this->kernel->getServer()->getHttpHost());
         $emConfig->setResultCacheImpl($cacheDriver);
         $emConfig->setQueryCacheImpl($cacheDriver);
         $emConfig->setMetadataCacheImpl($cacheDriver);
     }
     $conn = array('dbname' => $applicationConfiguration->get("dbname"), 'user' => $applicationConfiguration->get("dbuser"), 'password' => $applicationConfiguration->get("dbpassword"), 'host' => $applicationConfiguration->get("dbhost"), 'charset' => $applicationConfiguration->get("dbcharset"), 'driver' => $applicationConfiguration->get("dbdriver"));
     $em = $this->injector->getClassname("doctrine.entitymanager");
     $this->kernel->setEntityManager($em::create($conn, $emConfig));
 }
Exemple #5
0
 /**
  *
  */
 public function shutdown()
 {
     if ($this->devmode) {
         $monitor = new Monitor();
         $this->response->addValue("memory_usage", $monitor->getUsedMemory());
         $this->response->addValue("memory_peak", $monitor->getPeak());
         $this->stopwatch->end();
         $this->response->addValue("time_elapsed", $this->stopwatch->getTimeElapsed());
     }
     if ($this->applicationConfig->get("accept-control-allow-origin") != NULL) {
         $accepts = explode(",", $this->applicationConfig->get("accept-control-allow-origin"));
         foreach ($accepts as $accept) {
             $this->response->setHeader("Access-Control-Allow-Origin: " . $accept, false);
         }
     }
     $this->response->process();
 }