Example #1
0
 public function deploy($method)
 {
     unset($method['id']);
     $method['status'] = Resource::STATUS_ACTIVE;
     if ($method['request'] > 0) {
         $method['requestCache'] = $this->getSchemaCache($method['request']);
     }
     if ($method['response'] > 0) {
         $method['responseCache'] = $this->getSchemaCache($method['response']);
     }
     if ($method['action'] > 0) {
         $method['actionCache'] = $this->getActionCache($method['action']);
     }
     $this->routesMethodTable->create($method);
 }
Example #2
0
 /**
  * Reads all relations of the provided route and writes them to the tables
  *
  * @param integer $routeId
  */
 public function updateRelations($routeId)
 {
     // remove all existing entries
     $this->removeExistingRelations($routeId);
     // get dependencies of the config
     $methods = $this->routesMethodTable->getMethods($routeId);
     $schemas = $this->getDependingSchemas($methods);
     $actions = $this->getDependingActions($methods);
     foreach ($schemas as $schemaId) {
         $this->routesSchemaTable->create(array('routeId' => $routeId, 'schemaId' => $schemaId));
     }
     foreach ($actions as $actionId) {
         $this->routesActionTable->create(array('routeId' => $routeId, 'actionId' => $actionId));
     }
 }
Example #3
0
 public function delete($actionId)
 {
     $action = $this->actionTable->get($actionId);
     if (!empty($action)) {
         // check depending
         if ($this->routesMethodTable->hasAction($actionId)) {
             throw new StatusCode\BadRequestException('Cannot delete action because a route depends on it');
         }
         // delete route dependencies
         $this->routesActionTable->deleteByAction($action['id']);
         $this->actionTable->delete(array('id' => $action['id']));
     } else {
         throw new StatusCode\NotFoundException('Could not find action');
     }
 }
Example #4
0
 public function delete($schemaId)
 {
     $schema = $this->schemaTable->get($schemaId);
     if (!empty($schema)) {
         // check whether we have routes which depend on this schema
         if ($this->routesMethodTable->hasSchema($schemaId)) {
             throw new StatusCode\BadRequestException('Cannot delete schema because a route depends on it');
         }
         // delete route dependencies
         $this->routesSchemaTable->deleteBySchema($schema['id']);
         $this->schemaTable->delete(array('id' => $schema['id']));
     } else {
         throw new StatusCode\NotFoundException('Could not find schema');
     }
 }
Example #5
0
 public function getAllowedMethods($routeId, $version)
 {
     return $this->methodTable->getAllowedMethods($routeId, $version);
 }