I create such records in DOctrine. I am trying to add a cart to a page. These are my entities: My objects:
<?php namespace App\Entity; use Doctrine\Common\Collections\ArrayCollection; class Page { private $p_id; private $p_title; private $p_created_at; private $p_updated_at; private $p_abstract; private $p_fulltext; private $p_author; private $p_url; private $p_meta_title; private $p_meta_keywords; private $p_meta_description; private $p_status; private $p_weight; private $user; protected $pageBaskets; public function __construct() { $this->pageBaskets = new ArrayCollection(); $this->pageMedia = new ArrayCollection(); } public function __get($property) { return $this->property; } public function __set($property,$value) { $this->$property = $value; } public function getPageMedia() { return $this->pageMedia; } public function setUser(\App\Entity\User $user) { $this->user = $user; } public function getMedias() { return $this->pageMedia; } public function getPageBaskets() { return $this->pageBaskets; } public function setPageProperties(array $values) { $this->p_updated_at = new \DateTime("now"); $this->p_title = $values['p_title']; $this->p_abstract = $values['p_abstract']; $this->p_meta_title = $values['p_meta_title']; $this->p_meta_keywords = $values['p_meta_keywords']; $this->p_meta_description = $values['p_meta_description']; $this->p_url = $values['p_url']; $this->p_fulltext = $values['p_abstract']; $this->p_author = ''; $this->p_status = 1; } public function getSimpleValues() { return array( 'p_updated_at' => $this->p_updated_at, 'p_title' => $this->p_title, 'p_abstract' => $this->p_abstract, 'p_meta_title' => $this->p_meta_title, 'p_meta_keywords' => $this->p_meta_keywords, 'p_meta_description' => $this->p_meta_description, 'p_url' => $this->p_url, 'p_fulltext' => $this->p_fulltext, 'p_author' => $this->p_author ); } } ?> <?php namespace App\Entity\Page; use Doctrine\Common\Collections\ArrayCollection; class Basket { private $pb_id; private $page; public function __construct() { } public function __get($property) { return $this->property; } public function __set($property,$value) { $this->$property = $value; } public function setPage($page) { $this->page = $oszpage; } } ?>
But where do such things do:
$page->getPageBaskets()->add($basket);
Im getting: Warning: spl_object_hash () expects parameter 1 to be an object, null given
What am I doing wrong?
source share