2012-03-03 7 views
6

दिए गए शून्य मैं डॉक्टर में ऐसी प्रविष्टियां बनाते हैं। मैं पेज पर टोकरी जोड़ने की कोशिश कर रहा हूं। मेरे संस्थाओं:सिद्धांत 2 - लगातार त्रुटि - चेतावनी: spl_object_hash() पैरामीटर 1 ऑब्जेक्ट होने की अपेक्षा करता है,

$page->getPageBaskets()->add($basket); 

इम हो रही: चेतावनी:

<?php 

namespace App\Entity; 
use Doctrine\Common\Collections\ArrayCollection; 
/** 
* @Entity(repositoryClass="App\Repository\Page") 
* @Table(name="page") 

*/ 
class Page 
{ 
    /** 
    * @Id @Column(type="integer", name="p_id") 
    * @GeneratedValue 
    */ 
    private $p_id; 
    /** @Column(type="string", name="p_title") */ 
    private $p_title; 
    /** @Column(type="datetime", name="p_created") */ 
    private $p_created_at; 
    /** @Column(type="datetime", name="p_updated_at") */ 
    private $p_updated_at; 
    /** @Column(type="text", name="p_abstract") */ 
    private $p_abstract; 
    /** @Column(type="text", name="p_fulltext", nullable=false) */ 
    private $p_fulltext; 
    /** @Column(type="string", name="p_author", nullable=true) */ 
    private $p_author; 
    /** @Column(type="string", name="p_url",nullable=true) */ 
    private $p_url; 
    /** @Column(type="string", name="p_meta_title",nullable=true) */ 
    private $p_meta_title; 
    /** @Column(type="string", name="p_meta_keywords",nullable=true) */ 
    private $p_meta_keywords; 
    /** @Column(type="string", name="p_meta_description",nullable=true) */ 
    private $p_meta_description; 
     /** @Column(type="string", name="p_status") */ 
    private $p_status; 
    /** @Column(type="string", name="p_weight") */ 
    private $p_weight; 
    /** 
    * @ManyToOne(targetEntity="User", inversedBy="pages") 
    * @JoinColumn(name="p_u_id", referencedColumnName="u_id") 
    */ 
    private $user; 

    /** 
    * @OneToMany(targetEntity="App\Entity\Page\Basket", mappedBy="page", cascade={"persist", "remove"}) 
    */ 
    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; 
    } 
    /** 
    * Set Page Values 
    * @var array $values 
    */ 
    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; 

/** 
* @Entity 
* @Table(name="page_basket") 

*/ 
class Basket 
{ 
    /** 
    * @Id @Column(type="integer", name="pb_id") 
    * @GeneratedValue 
    */ 
    private $pb_id; 
    /** 
    * @ManyToOne(targetEntity="Entity\Page",) 
    * @JoinColumn(name="pb_id", referencedColumnName="p_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; 
    } 
} 

?> 

लेकिन जहां इस तरह के सामान कर रहे हैं यह मेरा संस्थाओं है spl_object_hash() उम्मीद पैरामीटर 1 वस्तु होने के लिए, अशक्त

दिया

मैं क्या गलत कर रहा हूं?

+0

एक ही समस्या होने पर [यहां] (http://stackoverflow.com/questions/21780016/spl-object-hash-expects-parameter-1-to-be-object-null-given) सिवाय इसके कि मुझे पहले से ही एक मिलता है त्रुटि जब मैं मुख्य इकाई को पुनः प्राप्त करने का प्रयास करता हूं! क्या आपको अपनी समस्या का समाधान मिला? –

उत्तर

1

मैन्युअल में उदाहरणों का पालन करने के लिए सबसे अच्छा जब तक आप अधिक आरामदायक न हों। जादू को छोड़ दें _ प्राप्त करें/ _set विधियां। डी 2 अपनी सामग्री को करने के लिए विधि कॉल को अवरुद्ध करने पर निर्भर करता है। एरे के रूप में सरणी संग्रह का इलाज करें और अपनी इकाइयों के साथ बातचीत के लिए विशिष्ट तरीकों का निर्माण करें।

विशेष रूप

:

public function addPageBasket($pageBasket) 
{ 
    $this->pageBaskets[] = $pageBasket; 
} 
... 
$page->addPageBasket($pageBasket); 

पी एस। आपके विशेष प्रश्न के लिए, संभवतः $ टोकरी एक वस्तु नहीं है।

+1

यह मेरे लिए काम नहीं करता है और मैं जादू का उपयोग भी नहीं करता और विधियों को सेट नहीं करता हूं। मुझे अब भी वही त्रुटि मिलती है –

संबंधित मुद्दे

 संबंधित मुद्दे