Exemplo n.º 1
0
 /**
  * {@InheritDoc}
  */
 protected function handleResource(array $resources)
 {
     if (empty($this->relatedResource)) {
         return parent::handleResource($resources);
     }
     if (SnsSubscription::RESOURCE_NAME == $this->relatedResource && SnsTopic::RESOURCE_NAME == $this->resource || SnsEndpoint::RESOURCE_NAME == $this->relatedResource && SnsApplication::RESOURCE_NAME == $this->resource) {
         $child = ArrayUtils::get($this->resources, $this->relatedResource);
         if (isset($child, $child['class_name'])) {
             $className = $child['class_name'];
             if (!class_exists($className)) {
                 throw new InternalServerErrorException('Service configuration class name lookup failed for resource ' . $this->relatedResource);
             }
             /** @var BaseSnsResource $resource */
             $resource = $this->instantiateResource($className, $child);
             $resource->setParentResource($this->resourceId);
             $newPath = $this->resourceArray;
             array_shift($newPath);
             array_shift($newPath);
             array_shift($newPath);
             $newPath = implode('/', $newPath);
             return $resource->handleRequest($this->request, $newPath);
         }
     }
     throw new BadRequestException("Invalid related resource '{$this->relatedResource}' for resource '{$this->resource}'.");
 }
Exemplo n.º 2
0
 /**
  * {@InheritDoc}
  */
 protected function handleResource(array $resources)
 {
     try {
         return parent::handleResource($resources);
     } catch (NotFoundException $ex) {
         // If version 1.x, the resource could be a table
         //            if ($this->request->getApiVersion())
         //            {
         //                $resource = $this->instantiateResource( Table::class, [ 'name' => $this->resource ] );
         //                $newPath = $this->resourceArray;
         //                array_shift( $newPath );
         //                $newPath = implode( '/', $newPath );
         //
         //                return $resource->handleRequest( $this->request, $newPath, $this->outputFormat );
         //            }
         throw $ex;
     }
 }