-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Entity and Fixtures #3
Conversation
*/ | ||
private $customerType; | ||
|
||
public function __construct() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в 8.1 не уверен слопает ли доктрина но можно уже так
public function __construct(
private State $state = new InitialState(),
) {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут есть один вопрос, смотри у меня получается что идет как раз связка
`
/**
* @var Collection
*/
#[ORM\OneToMany(mappedBy: "customer", targetEntity: "Quiz")]
private Collection $quiz;
public function __construct()
{
$this->quiz = new ArrayCollection();
}
`
Но если я сделаю короткую инициализацию как я смогу тогда написать #[ORM\OneToMany(mappedBy: "customer", targetEntity: "Quiz")]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В последних версиях должны были добавить возможность писать, проверь если взлетит то ок, нет то оставляй как есть )
public function __construct(
#[ORM\Column(type: 'string')]
private string $firstName,
...
) { }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я написал такую вещь,
public function __construct( #[ORM\OneToMany(mappedBy: "quiz", targetEntity: "Question")] private ArrayCollection $questions, ) { }
Но получил вот такую ошибку при попытке добавить фикстуры:
Too few arguments to function App\Domain\Quiz\Entity\Quiz::__construct(), 0 passed in /srv/app/src/Infractructure/DataFixtures/QuizFixtures.php on line 23 and exactly 1 ex pected
Я поискал в гите в репизотории орм и нашел переписку об этом doctrine/orm#8430
Но правда, этот вопрос остался открытым.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ок, оставляй как было - вроде закрыто doctrine/orm#8266 но либо не релизнулось либо еще в планах, четкого ответа нет - ссылки на эту ишью и она вроде вмержена
/** | ||
* @ORM\PrePersist | ||
*/ | ||
public function setCreatedAtAutomatically() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:void ?
src/Domain/Quiz/Entity/Answer.php
Outdated
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
т.к. используешь php 8 можно попробовать использовать атрибуты (большинство библиотек уже готовы)
Add code Review
No description provided.