<?php
namespace App\AppBundle\AdminBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use JsonSerializable;
/**
* AddOns
*
* @ORM\Entity
* @ORM\Table(name="admin_access_role_master")
* @ORM\HasLifecycleCallbacks()
*/
class Admin_Access_Role_Master implements JsonSerializable
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default" : 1})
* @Assert\NotBlank()
*/
private $active;
/**
* One user has many tokens. This is the inverse side.
* @ORM\OneToMany(targetEntity="Admin_Access_Role_Sub", mappedBy="admin_access_role_master")
*/
private $admin_access_role_subs;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getActive()
{
return $this->active;
}
/**
* @param mixed $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return mixed
*/
public function getAdminAccessRoleSubs()
{
return $this->admin_access_role_subs;
}
/**
* @param mixed $admin_access_role_subs
*/
public function setAdminAccessRoleSubs($admin_access_role_subs)
{
$this->admin_access_role_subs = $admin_access_role_subs;
}
public function getAdminAccessRoleSubsDetails() {
$adminRoleSubs = array();
foreach ($this->admin_access_role_subs as $admin_access_role_sub) {
array_push($adminRoleSubs, $admin_access_role_sub);
}
return $adminRoleSubs;
}
/**
* @var string $created
*
* @ORM\Column(name="created_at", type="string", nullable=false)
*/
protected $createdAt;
/**
* @var string $updated
*
* @ORM\Column(name="updated_at", type="string", nullable=false)
*/
protected $updatedAt;
public function getCreatedAt()
{
return $this->createdAt;
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setUpdatedAt(round(microtime(true) * 1000));
if ($this->getCreatedAt() === null) {
$this->setCreatedAt(round(microtime(true) * 1000));
}
}
public function __construct() {
$this->admin_access_role_subs = new ArrayCollection();
$this->setCreatedAt(round(microtime(true) * 1000));
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'active' => $this->active,
'name' => $this->name,
'admin_access_role_subs' => $this->getAdminAccessRoleSubsDetails(),
);
}
}