Skip to content
Snippets Groups Projects

#3368149 MR for the changes.

Open Nitin Lama requested to merge issue/file_entity-3368149:3368149--t-calls into 8.x-2.x
34 files
+ 580
215
Compare changes
  • Side-by-side
  • Inline
Files
34
@@ -7,11 +7,12 @@ use Drupal\Core\Ajax\CloseDialogCommand;
use Drupal\Core\Ajax\OpenDialogCommand;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Form\FormState;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\file\FileInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\File\FileSystemInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -19,6 +20,18 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class FileController extends ControllerBase {
use StringTranslationTrait;
/**
* Constructs a new \Drupal\file_entity\Controller\FileController object.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation
* The translation service.
*/
    • Comment on lines +25 to +30

      The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

Please register or sign in to reply
public function __construct(TranslationInterface $translation) {
$this->setStringTranslation($translation);
}
/**
* The file system service.
*
@@ -78,7 +91,7 @@ class FileController extends ControllerBase {
// Ensure there is a valid token to download this file.
if (!$this->config('file_entity.settings')->get('allow_insecure_download')) {
if (!isset($_GET['token']) || $_GET['token'] !== $file->getDownloadToken()) {
return new Response(t('Access to file @url denied', array('@url' => $file->getFileUri())), 403);
return new Response($this->t('Access to file @url denied', array('@url' => $file->getFileUri())), 403);
}
}
@@ -99,7 +112,7 @@ class FileController extends ControllerBase {
return new BinaryFileResponse($file->getFileUri(), 200, $headers, FALSE, 'attachment');
}
catch (FileNotFoundException $e) {
return new Response(t('File @uri not found', array('@uri' =>$file->getFileUri())), 404);
return new Response($this->t('File @uri not found', array('@uri' =>$file->getFileUri())), 404);
}
}
Loading