2013-10-15 51 views
0

I'm並且創造了一些新的領域一個自己的模型(如deviceVersion(串)&設備類型(字符串)。FOSUserBundle的UserManager忽略使用FOSUserBundle領域

如果我創建一個新用戶,並添加這些特定的領域,一切都很好:

$user = new User(); 
$user -> setEmail('[email protected]'); 
// Default stuff 
$user -> setDevicetype('Android'); 
$user -> setDeviceversion('4.2.2'); 

$em = $this->getDoctrine()->getManager(); 
$em->persist($user); 
$em->flush(); 

echo $user->getDevicetype(); // outputs Android 
echo $user->getDeviceversion(); // outputs 4.2.2 

的問題是,在數據庫領域的「設備類型」 &「deviceversion」是NULL

即使查詢完全忽略了那些新的領域:

INSERT INTO my_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, .... 

列確實存在, PHP應用程序/控制檯學說:架構:更新--force --env = 「開發」

沒有任何問題產生的列。

任何想法如何解決這個問題? 我第一次嘗試UserManager,仍然NULL,通過EM切換到手動,仍爲NULL。

+0

Semms就像是一個典型的緩存問題。 重新啓動mysql/php5-fpm之後,所有東西都像例外 – develth

回答

1

在你User.orm.xml你必須覆蓋這些領域,並把參數nullable=true

像這樣:

<field name="confirmationToken" column="confirmation_token" type="string" nullable="true" /> 
<field name="passwordRequestedAt" column="password_requested_at" type="datetime" nullable="true" /> 
+0

一樣運行因此,我必須在我自己的UserBundle中重寫User.orm.xml並在其中覆蓋User.php? 我已經試過它的靜態方式,並直接將其添加到捆綁的模型和XML中,結果相同。 – develth

+0

我擴展了FOSUserBundle的'User.php'和'User.orm.xml',它在這裏有效。 –

+0

@Ricardo Simas OP還沒有確定他正在使用xml映射,可能是他正在使用yaml文件進行映射或者只是使用實體 –