{"error":{"code":500,"message":"Internal Server Error","exception":[{"message":"Notice: unserialize(): Error at offset 0 of 13 bytes","class":"Symfony\\Component\\Debug\\Exception\\ContextErrorException","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"H:\\xampp\\htdocs\\rest_test\\vendor\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\Types\\ArrayType.php","line":58,"args":[]},{"namespace":"Doctrine\\DBAL\\Types","short_class":"ArrayType","class":"Doctrine\\DBAL\\Types\\ArrayType","type":"->","function":"convertToPHPValue","file":"H:\\xampp\\htdocs\\rest_test\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\Internal\\Hydration\\SimpleObjectHydrator.php","line":131,"args":[["string","Admin,Default"],["object","Doctrine\\DBAL\\Platforms\\MySqlPlatform"]]},
<?php
namespace AppBundle\Entity\Dto;
use AppBundle\Other\Arr;
/**
* User
*
*/
class UserDTO
{
/**
*
* @var int
*/
public $id;
/**
*
* @var string
*/
public $login;
/**
*
* @var int
*/
public $dzoId;
/**
*
* @var string
*/
public $dzoName;
/**
* Roles
* @var string
*/
public $roles;
/**
*
* @var string
*/
public $fullname;
/**
*
* @var string
*/
public $email;
public function __construct(\AppBundle\Entity\User $userInfo)
{
$this->id = $userInfo->getId();
$this->login = $userInfo->getUsername();
$dzo = $userInfo->getDzo();
if ($dzo != null) {
$this->dzoId = $dzo->getId();
$this->dzoName = $dzo->getName();
}
$this->roles = $this->plainRoles($userInfo);
$this->email = $userInfo->getEmail();
$this->fullname = $userInfo->getFullname();
}
private function plainRoles(\AppBundle\Entity\User $user)
{
$roles = $user->getRoles();
return join(',', $roles);
}
private function getRolesInfo($str)
{
$parts = explode('-::-', $str);
$roles = [];
foreach ($parts as $p) {
$deserialized = \unserialize($p);
$roles = array_merge($roles, $deserialized);
}
return join(',', array_unique($roles));
}
}