@@ -27,12 +27,12 @@ add a PDF brochure for each product. To do so, add a new property called
27
27
#[ORM\Column(type: 'string')]
28
28
private $brochureFilename;
29
29
30
- public function getBrochureFilename()
30
+ public function getBrochureFilename(): string
31
31
{
32
32
return $this->brochureFilename;
33
33
}
34
34
35
- public function setBrochureFilename($brochureFilename)
35
+ public function setBrochureFilename(string $brochureFilename)
36
36
{
37
37
$this->brochureFilename = $brochureFilename;
38
38
@@ -126,13 +126,14 @@ Finally, you need to update the code of the controller that handles the form::
126
126
use Symfony\Component\HttpFoundation\File\Exception\FileException;
127
127
use Symfony\Component\HttpFoundation\File\UploadedFile;
128
128
use Symfony\Component\HttpFoundation\Request;
129
+ use Symfony\Component\HttpFoundation\Response;
129
130
use Symfony\Component\Routing\Annotation\Route;
130
131
use Symfony\Component\String\Slugger\SluggerInterface;
131
132
132
133
class ProductController extends AbstractController
133
134
{
134
135
#[Route('/product/new', name: 'app_product_new')]
135
- public function new(Request $request, SluggerInterface $slugger)
136
+ public function new(Request $request, SluggerInterface $slugger): Response
136
137
{
137
138
$product = new Product();
138
139
$form = $this->createForm(ProductType::class, $product);
@@ -245,7 +246,7 @@ logic to a separate service::
245
246
) {
246
247
}
247
248
248
- public function upload(UploadedFile $file)
249
+ public function upload(UploadedFile $file): string
249
250
{
250
251
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
251
252
$safeFilename = $this->slugger->slug($originalFilename);
@@ -260,7 +261,7 @@ logic to a separate service::
260
261
return $fileName;
261
262
}
262
263
263
- public function getTargetDirectory()
264
+ public function getTargetDirectory(): string
264
265
{
265
266
return $this->targetDirectory;
266
267
}
0 commit comments