File tree Expand file tree Collapse file tree 5 files changed +6
-10
lines changed Expand file tree Collapse file tree 5 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -273,7 +273,7 @@ looking for mapping information::
273
273
274
274
/**
275
275
* @ORM\OneToMany(
276
- * targetEntity="Comment",
276
+ * targetEntity="App\Entity\ Comment",
277
277
* mappedBy="post",
278
278
* orphanRemoval=true
279
279
* )
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ logic to a separate service::
236
236
$fileName = md5(uniqid()).'.'.$file->guessExtension();
237
237
238
238
try {
239
- $file->move($this->getTargetDir (), $fileName);
239
+ $file->move($this->getTargetDirectory (), $fileName);
240
240
} catch (FileException $e) {
241
241
// ... handle exception if something happens during file upload
242
242
}
Original file line number Diff line number Diff line change @@ -381,11 +381,7 @@ following method to the ``ProductRepository`` class::
381
381
WHERE p.id = :id'
382
382
)->setParameter('id', $productId);
383
383
384
- try {
385
- return $query->getSingleResult();
386
- } catch (\Doctrine\ORM\NoResultException $exception) {
387
- return null;
388
- }
384
+ return $query->getOneOrNullResult();
389
385
}
390
386
391
387
Now, you can use this method in your controller to query for a ``Product ``
Original file line number Diff line number Diff line change @@ -469,7 +469,7 @@ you will learn about next!).
469
469
// ...
470
470
471
471
/**
472
- * @ORM\ManyToMany(targetEntity="Tag", cascade={"persist"})
472
+ * @ORM\ManyToMany(targetEntity="App\Entity\ Tag", cascade={"persist"})
473
473
*/
474
474
protected $tags;
475
475
@@ -481,7 +481,7 @@ you will learn about next!).
481
481
# ...
482
482
oneToMany :
483
483
tags :
484
- targetEntity : Tag
484
+ targetEntity : App\Entity\ Tag
485
485
cascade : [persist]
486
486
487
487
.. code-block :: xml
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ Consider this example:
222
222
class Service
223
223
{
224
224
/**
225
- * @ORM\ManyToOne(targetEntity="Host")
225
+ * @ORM\ManyToOne(targetEntity="App\Entity\ Host")
226
226
*/
227
227
public $host;
228
228
You can’t perform that action at this time.
0 commit comments