2017-05-12 9 views
1

私はデータベースから私を生成したAppBundle/Entityのエンティティを持っています。私は中括弧などで@parmと値を変更するつもりならば関連エンティティ関連 - 手作業で変更する

Sylius\Component\Core\Model\ShopUser 

<?php 

namespace AppBundle\Entity; 

/* 
* 
* ExtensionSyliusShopUser 
*/ 
class ExtensionSyliusShopUser 
{/** 
* Set user 
* 
* @param \AppBundle\Entity\SyliusShopUser $user 
* 
* @return ExtensionSyliusShopUser 
*/ 
public function setUser(\AppBundle\Entity\SyliusShopUser $user = null) 
{ 
    $this->user = $user; 

    return $this; 
} 

/** 
* Get user 
* 
* @return \AppBundle\Entity\SyliusShopUser 
*/ 
public function getUser() 
{ 
    return $this->user; 
} 

は今、私はにsetUser() & getUser()を変更したい

public function setUser(\Sylius\Component\Core\Model\ShopUser $user = null) 

私はエラーを取得します:

アソシエーションフィールド「AppBundle \ Entity」のタイプ「AppBundle \ Entity \ SyliusShopUser」の期待値\ ExtensionSyliusShopUser#$ user "には、代わりに" Sylius \ Component \ Core \ Model \ ShopUser "があります。

どうすれば変更できますか?

<?xml version="1.0" encoding="utf-8"?> 
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> 
<entity name="AppBundle\Entity\ExtensionSyliusShopUser" table="extension_sylius_shop_user"> 
    <indexes> 
     <index name="user_id" columns="user_id"/> 
    </indexes> 
    <id name="id" type="integer" column="id"> 
     <generator strategy="IDENTITY"/> 
    </id> 
    <field name="wishlist" type="text" column="wishlist" length="65535" nullable="true"> 
     <options> 
     <option name="fixed"/> 
     </options> 
    </field> 
    <many-to-one field="user" target-entity="SyliusShopUser" fetch="LAZY"> 
     <join-columns> 
     <join-column name="user_id" referenced-column-name="id"/> 
     </join-columns> 
    </many-to-one> 
    </entity> 
</doctrine-mapping> 

答えて

1

$ userプロパティ(列)の定義を変更する必要があります。これは、提供したコードサンプルには表示されません。 XML設定ファイルの場合は

/** 
* @ORM\ManyToOne(targetEntity="Sylius\Component\Core\Model\ShopUser") 
*/ 
private $user; 

<many-to-one field="user" target-entity="Sylius\Component\Core\Model\ShopUser"> 
+0

これは悲しげに機能していないあなたは注釈を使用する場合には

は次のようになりますです。 – craphunter

+1

マッピング定義はどこにありますか? – kormik

+0

よろしくお願いします。それは働いている。私はtarget-entity = "SyliusShopUser"をtarget-entity = "Syliusy \ ... \ SyliusShopUser"に設定するのを忘れていました。 – craphunter

関連する問題