items = new ArrayCollection(); } /** * @Id @Column(type="integer") * @GeneratedValue */ protected $id; public function getId() { return $this->id; } /** * @Column(type="datetime") */ protected $dateCreated = null; public function getDateCreated() { return $this->dateCreated; } /** * @Column(type="datetime") */ protected $dateModified = null; public function getDateModified() { return $this->dateModified; } /** * @Column(type="string") * @var string */ protected $title = ''; /** * @return string */ public function getTitle() { return $this->title; } /** * @Column(type="string") * @var string */ protected $description = ''; /** * @return string */ public function getDescription() { return $this->description; } /** * @Column(type="string") * @var string */ protected $accessCode = ''; /** * @return string */ public function getAccessCode() { return $this->accessCode; } /** * @Column(columnDefinition="integer unsigned") * @var int User ID */ protected $owner = 0; /** * @return \UserInfo */ public function getOwner() { return \UserInfo::getByID($this->owner); } /** * @Column(type="boolean") * @var bool */ protected $canBrowse = true; /** * @param null|bool $value * @return bool */ public function canBrowse($value = null) { if($value === null) { return $this->canBrowse; } $this->canBrowse = (bool) $value; return $this->canBrowse; } /** * @OneToMany(targetEntity="DesignVise\Items", mappedBy="collections") * @var Items[]|ArrayCollection */ private $items; /** * @return Items[]|ArrayCollection */ public function getItems() { return $this->items; } /** * returns a collection object for the given collection ID * @param int $id * @return Collections */ public static function getByID($id) { $db = \Database::get(); $em = $db->getEntityManager(); return $em->find('\DesignVise\Collections', $id); } /** * @param int $owner User ID * @return int */ public static function getNumberOfCollections($owner) { $db = \Database::get(); $em = $db->getEntityManager(); $qb = $em->createQueryBuilder(); $qb->select($qb->expr()->count('c')) ->from('DesignVise\Collections', 'c') ->where('c.owner = ?1') ->setParameter(1, $owner); $query = $qb->getQuery(); return $query->getSingleScalarResult(); } }