хочу написать команду, которая парсит из json и заносит в mysql сущность, и вот после получения данных происходит такой метод:
protected function execute(InputInterface $input, OutputInterface $output): int
{
$books = $this->get_decoded_json($output);
if (!$books) {
return Command::FAILURE;
}
$em = $this->entityManager;
$authors = array();
foreach($books as $id=>$book) {
$dbBook = new Book();
$output->writeln("[$id][Title] $book->title");
$dbBook->setTitle($book->title);
$dbBook->setIsbn($book->isbn);
$dbBook->setPageCount($book->pageCount);
$dbBook->setStatus($book->status);
// $dbBook->setPublishedDate($book->pageCount);
// $dbBook->setThumbnailUrl($book->pageCount);
// $dbBook->setShortDescription($book->pageCount);
// $dbBook->setLongDescription($book->pageCount);
// $this->log($output, $id, $book, 'publishedDate');
$this->log($output, $id, $book, 'shortDescription');
$this->log($output, $id, $book, 'longDescription');
$this->log($output, $id, $book, 'thumbnailUrl');
//$output->writeln($id.': '.$book->authors);
//$output->writeln($id.': '.$book->categories);
//$output->writeln("");
$em->persist($dbBook);
}
$em->flush();
на что консоль отвечает ошибкой: Call to a member function persist() on null