public function select($hash = null) { $statement = 'SELECT * FROM `cfp`'; $values = []; if ($hash !== null) { $statement .= ' WHERE `hash`= :hash'; $values['hash'] = $hash; } $statement = $this->pdo->prepare($statement); $list = new \Callingallpapers\Api\Entity\CfpList(); $statement->execute($values); $content = $statement->fetchAll(); if (count($content) < 1) { throw new \UnexpectedValueException('No CFPs found', 404); } foreach ($content as $item) { $cfp = new \Callingallpapers\Api\Entity\Cfp(); $cfp->setName($item['name']); $cfp->setDateCfpEnd(new \DateTimeImmutable($item['dateCfpEnd'])); $cfp->setDateCfpStart(new \DateTimeImmutable($item['dateCfpStart'])); $cfp->setUri($item['uri']); $cfp->setTimezone(new \DateTimeZone($item['timezone'])); $cfp->setDateEventStart(new \DateTimeImmutable($item['dateEventStart'])); $cfp->setDateEventEnd(new \DateTimeImmutable($item['dateEventEnd'])); $cfp->setDescription($item['description']); $cfp->setEventUri($item['eventUri']); $cfp->setIconUri($item['iconUri']); $cfp->setLatitude($item['latitude']); $cfp->setLongitude($item['longitude']); $cfp->setLocation($item['location']); $cfp->setTags(explode(',', $item['tags'])); $cfp->setLastUpdated(new \DateTimeImmutable($item['lastUpdate'])); $list->add($cfp); } return $list; }
public static function setDescription(Cfp $cfp, array $array) { if (!isset($array['description'])) { return; } $cfp->setDescription(filter_var($array['description'], FILTER_SANITIZE_STRING)); }