-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning: Undefined array key "user_id" in vendor/lm-commons/lmc-user/src/Mapper/UserHydrator.php on line 77 #49
Comments
@vrkansagara, this looks like you user table in your database does not have a What is the schema for the user table in your database? The |
@visto9259 I am trying to use LmcUser + LmcRbacMvc where I am getting this error. I have already configured using this way <?php
namespace User\Entity;
use LmcUser\Entity\User as LmcUserEntity;
use LmcRbacMvc\Identity\IdentityInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use LmcUser\Entity\UserInterface;
use Rbac\Role\RoleInterface;
/**
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User extends LmcUserEntity implements IdentityInterface
{
/**
* @var int|null
*
* @ORM\Id
* @ORM\Column(name="user_id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
* @ORM\Column(name="username",type="string", length=128, unique=true, nullable=true)
*/
protected $username;
/**
* @var string
* @ORM\Column(name="email",type="string", length=128, unique=true, nullable=false)
*/
protected $email;
/**
* @var string
* @ORM\Column(name="display_name",type="string", length=128, unique=false, nullable=true)
*/
protected $displayName;
/**
* @var string
* @ORM\Column(name="password",type="string", length=128, unique=false, nullable=false)
*/
protected $password;
/**
* @var int
* @ORM\Column(name="state",type="integer", unique=false, nullable=true)
*/
protected $state;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set id.
*
* @param int $id
* @return UserInterface
*/
public function setId($id)
{
$this->id = (int) $id;
return $this;
}
/**
* Get username.
*
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* Set username.
*
* @param string $username
* @return UserInterface
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get email.
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set email.
*
* @param string $email
* @return UserInterface
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get displayName.
*
* @return string
*/
public function getDisplayName()
{
return $this->displayName;
}
/**
* Set displayName.
*
* @param string $displayName
* @return UserInterface
*/
public function setDisplayName($displayName)
{
$this->displayName = $displayName;
return $this;
}
/**
* Get password.
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set password.
*
* @param string $password
* @return UserInterface
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get state.
*
* @return int
*/
public function getState()
{
return $this->state;
}
/**
* Set state.
*
* @param int $state
* @return UserInterface
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* @var Collection
* @ORM\ManyToMany(targetEntity="\User\Entity\FlatRole")
* @ORM\JoinTable(name="user_flatrole",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="user_id")},
* inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
* )
*/
private $roles;
public function __construct()
{
$this->roles = new ArrayCollection();
}
/**
* {@inheritDoc}
*/
public function getRoles()
{
return $this->roles->toArray();
}
/**
* Set the list of roles
* @param Collection $roles
*/
public function setRoles(Collection $roles)
{
$this->roles->clear();
foreach ($roles as $role) {
$this->roles[] = $role;
}
}
/**
* Add one role to roles list
* @param \Rbac\Role\RoleInterface $role
*/
public function addRole(RoleInterface $role)
{
$this->roles[] = $role;
}
} User table structure look like this. |
For the roles issue, do you have a roles column in your table? |
That roles come from the relation , I think @visto9259 |
This patch should be needed here public function hydrate(array $data, $object)
{
if (!$object instanceof UserEntityInterface) {
throw new Exception\InvalidArgumentException('$object must be an instance of LmcUser\Entity\UserInterface');
}
if (isset($data['id'])) {
$data = $this->mapField('user_id', 'id', $data);
}
return $this->hydrator->hydrate($data, $object);
} looks like there is issue here https://github.com/LM-Commons/LmcUser/blob/master/src/Mapper/UserHydrator.php#L64 |
Hi @vrkansagara , |
yes, @visto9259 , I do confirm that I was not using LmcUserDoctrineORM. so facing this issue. I also facing much difficult to setup the FlatRole using LmcUserMVC so can you consider to as proposal for the demo repository where it can show the working model for following packages.
this combination is useful to show the basic Dashboard application so any one can easily start using this combination package and start creating application. |
That would be a good idea but we lack the bandwidth to do so. This is all based on volunteer work. There are thousands of installs of LmcUser and LmcRbacMvc without issues. There could be bugs in the code but I suspect that there is something not set up properly in your application. Can you share details on how you define the database adapter in your config? LmcUser uses the class |
@visto9259 , I figured out the issue as i said here. #49 (comment) So this issue can be closed. I have couple of improvement , I will make it PR |
This is just the explanation for the warning and that I knew that the issue was where you pointed out. |
I am using LmcUser + LmcRbacMvc with DoctrineOrmModule with MySQL
Composer.json
It has following settings
The text was updated successfully, but these errors were encountered: