Olá Alura, Tudo bom?
aqui estou com o erro no delete do curso de docterine, segue abaixo o link
link git@github.com:tiagobrandao03/2612-doctrine.git
arquivo delete-student.php
<?php
use Alura\Doctrine\Entity\Student;
use Alura\Doctrine\Helper\EntityManagerCreator;
require_once __DIR__.'/../vendor/autoload.php';
$entityManager = EntityManagerCreator::createEntityManager();
$student = $entityManager->getPartialReference(Student::class,$argv[1]);
$entityManager->remove($student);
$entityManager->flush();
O comando que eu usei:
php bin/delete-student.php 8
O erro é esse:
PHP Fatal error: Uncaught LogicException: Attempting to change readonly property Alura\Doctrine\Entity\Student::$id. in C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ReflectionReadonlyProperty.php:46
Stack trace:
#0 C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1272): Doctrine\ORM\Mapping\ReflectionReadonlyProperty->setValue(Object(Alura\Doctrine\Entity\Student), NULL)
#1 C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(454): Doctrine\ORM\UnitOfWork->executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata))
#2 C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(403): Doctrine\ORM\UnitOfWork->commit(NULL)
#3 C:\xampp\htdocs\2612-doctrine\bin\delete-student.php(12): Doctrine\ORM\EntityManager->flush()
#4 {main}
thrown in C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ReflectionReadonlyProperty.php on line 46
Fatal error: Uncaught LogicException: Attempting to change readonly property Alura\Doctrine\Entity\Student::$id. in C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ReflectionReadonlyProperty.php:46
Stack trace:
#0 C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1272): Doctrine\ORM\Mapping\ReflectionReadonlyProperty->setValue(Object(Alura\Doctrine\Entity\Student), NULL)
#1 C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(454): Doctrine\ORM\UnitOfWork->executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata))
#2 C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(403): Doctrine\ORM\UnitOfWork->commit(NULL)
#3 C:\xampp\htdocs\2612-doctrine\bin\delete-student.php(12): Doctrine\ORM\EntityManager->flush()
#4 {main}
thrown in C:\xampp\htdocs\2612-doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ReflectionReadonlyProperty.php on line 46