Zend framework2 ZfcUser使用附加的get函数扩展用户类
我是Zend2框架的新手,安装了ZfcUser,并添加了一个数据库列,我希望通过以下方式访问该列:Zend framework2 ZfcUser使用附加的get函数扩展用户类,zend-framework2,zfcuser,Zend Framework2,Zfcuser,我是Zend2框架的新手,安装了ZfcUser,并添加了一个数据库列,我希望通过以下方式访问该列: <?php echo $this->zfcUserIdentity()->getOrg(); ?> 任何关于扩展用户类以访问此变量的帮助都将不胜感激 Ryan扩展ZfcUser用户实体,以包括您的新属性和访问者。您需要在自己的模块中执行此操作,或者如果您使用的是skeleton应用程序,则在应用程序中模块将起作用 <?php namespace Applicat
<?php echo $this->zfcUserIdentity()->getOrg(); ?>
任何关于扩展用户类以访问此变量的帮助都将不胜感激
Ryan扩展ZfcUser用户实体,以包括您的新属性和访问者。您需要在自己的模块中执行此操作,或者如果您使用的是skeleton应用程序,则在
应用程序中
模块将起作用
<?php
namespace Application\Entity;
use ZfcUser\Entity\User;
class MyUser extends User
{
protected $org;
public function setOrg($org)
{
$this->org = $org;
return $this;
}
public function getOrg()
{
return $this->org;
}
}
取消对该行的注释,并用您创建的MyUser
实体的完全限定类名替换该值
'user_entity_class' => 'Application\Entity\MyUser',
然后尝试访问您的方法
<?php echo $this->zfcUserIdentity()->getOrg(); ?>
扩展ZfcUser用户实体以包括新属性和访问者。您需要在自己的模块中执行此操作,或者如果您使用的是skeleton应用程序,则在
应用程序中
模块将起作用
<?php
namespace Application\Entity;
use ZfcUser\Entity\User;
class MyUser extends User
{
protected $org;
public function setOrg($org)
{
$this->org = $org;
return $this;
}
public function getOrg()
{
return $this->org;
}
}
取消对该行的注释,并用您创建的MyUser
实体的完全限定类名替换该值
'user_entity_class' => 'Application\Entity\MyUser',
然后尝试访问您的方法
<?php echo $this->zfcUserIdentity()->getOrg(); ?>
感谢您的快速回复!我省略了setOrg函数。谢谢你的快速回复!我省略了setOrg函数。