Beispiel #1
0
 /**
  * Save them, to be used by Router Classes
  *
  * @throws Next\Tools\RoutesGerenerator\RoutesGeneratorException
  *   Unable to record route
  */
 public function save()
 {
     set_time_limit(0);
     // Sorting Routes by Length...
     $this->routes = array_map(array($this, 'sort'), $this->routes);
     $records = 0;
     foreach ($this->routes as $application => $routes) {
         foreach ($routes as $route) {
             // Setting Model Values
             $this->manager->setSource(array('requestMethod' => $route['requestMethod'], 'application' => $application, 'class' => $route['class'], 'method' => $route['method'], 'URI' => $route['route'], 'requiredParams' => serialize($route['params']['required']), 'optionalParams' => serialize($route['params']['optional'])));
             // Cleaning Information of Previous Iteration
             $this->manager->reset();
             // Trying to insert
             try {
                 $this->manager->insert();
                 // Increment Counter
                 $records += 1;
             } catch (StatementException $e) {
                 // Re-throw as RoutesDatabaseException
                 throw RoutesGeneratorException::recordingFailure(array($route['route'], $route['class'], $route['method'], $e->getMessage()));
             }
         }
     }
     // Final Message
     printf('%s Routes analyzed, parsed and recorded in %f seconds', $records, microtime(TRUE) - $this->startTime);
 }