예제 #1
0
 /**
  * @Route("/{id}", methods="DELETE", requirements={"id"="\d+"})
  * @Request({"id": "int"}, csrf=true)
  */
 public function deleteAction($id)
 {
     if ($project = File::find($id)) {
         if (!App::user()->hasAccess('download: manage downloads')) {
             return ['error' => __('Access denied.')];
         }
         $project->delete();
     }
     return ['message' => 'success'];
 }
 /**
  * {@inheritdoc}
  */
 public function generate(array $parameters = [])
 {
     $id = $parameters['id'];
     $category_id = isset($parameters['category_id']) ? $parameters['category_id'] : 0;
     if (!isset($this->cacheEntries[$id . '-' . $category_id])) {
         if (!($file = File::find($id))) {
             throw new RouteNotFoundException('File not found.');
         }
         if ($category_id && !($category = Category::find($category_id))) {
             throw new RouteNotFoundException('Category not found.');
         }
         $this->addCache($file, $category_id, isset($category) ? $category->slug : App::config('bixie/download')->get('root_category', 'root'));
     }
     $meta = $this->cacheEntries[$id . '-' . $category_id];
     $parameters['slug'] = $meta['slug'];
     unset($parameters['id']);
     unset($parameters['category_id']);
     return $parameters;
 }