コード例 #1
0
 public function directoryAction(Request $request)
 {
     try {
         $params = ApiHelper::checkRequiredParameters($request->query->all(), array('key'));
         $project = $this->container->get('resource.factory.simple')->getProject($params['key']);
         return new Response(json_encode(array('name' => $project->getName(), 'url' => $this->container->get('resource.writer')->generateRemotePathFromString($project->getFullPath()))), 200);
     } catch (\Exception $e) {
         return new Response(json_encode(array('error' => $e->getMessage())), 500);
     }
 }
コード例 #2
0
 public function pushAction(Request $request)
 {
     try {
         $params = ApiHelper::checkRequiredParameters($request->request->all(), array('key', 'data'));
         $resource = $this->container->get('resource.factory.stream')->create($params['key'], $params);
         $remote = $this->container->get('resource.writer')->write($resource, $params['data']);
         return new Response(json_encode(array('name' => $resource->getFilename(), 'url' => $remote)), 200);
     } catch (\Exception $e) {
         return new Response(json_encode(array('error' => $this->getDisplayedErrorMessage($e))), 500);
     }
 }