/** * Create a tag * * @access protected * @return boolean the result true if removed * @param QuickTag\Model\StoredTag $tag * @throws QuickTag\QuickTagException if database operation fails */ protected function createTag(StoredTag $tag) { $result = null; try { if ($tag->getTagCreated() === null) { $tag->setTagCreated(new DateTime()); } # new tag store it $result = $this->gateway->insertQuery()->start()->addColumn('tag_title', $tag->getTitle())->addColumn('tag_weight', $tag->getWeight())->addColumn('tag_user_context', $tag->getUserContext())->addColumn('tag_date_created', $tag->getTagCreated())->end()->insert(); if ($result) { $tag->setTagId((int) $this->gateway->lastInsertId()); } # normalise the return if ($result === null) { $result = false; } } catch (DBALGatewayException $exception) { throw new QuickTagException($exception->getMessage(), 0, $exception); } return $result; }
public function testEntityProperties() { $tag_id = 1; $tag_user_context = 3; $tag_date_created = new DateTime(); $tag_weight = 3.56; $tag_title = 'finance'; $entity = new StoredTag(); $entity->setTagId($tag_id); $entity->setUserContext($tag_user_context); $entity->setTagCreated($tag_date_created); $entity->setWeight($tag_weight); $entity->setTitle($tag_title); $this->assertEquals($tag_id, $entity->getTagId()); $this->assertEquals($tag_user_context, $entity->getUserContext()); $this->assertEquals($tag_date_created, $entity->getTagCreated()); $this->assertEquals($tag_weight, $entity->getWeight()); $this->assertEquals($tag_title, $entity->getTitle()); }
public function toArray(StoredTag $entity) { return array('tagId' => $entity->getTagId(), 'tagCreated' => $entity->getTagCreated(), 'tagTitle' => $entity->getTitle(), 'tagWeight' => $entity->getWeight(), 'tagUserContext' => $entity->getUserContext()); }