public function __construct() { parent::__construct('workflow'); }
/** * Get the corresponding Tablegateway of the given ResourceType * * @param Resource\ResourceType $resourceType * * @return TableGateway */ protected function getTablegateway(Resource\ResourceType $resourceType) { $type = $resourceType->getValue(); if (!isset($this->tableGateways[$type])) { $this->tableGateways[$type] = new TableGateway($type, $this->zendDbAdapter); } return $this->tableGateways[$type]; }
/** * {@inheritDoc} */ public function updateResource(Resource\ResourceType $resourceType, Resource\ResourceData $resourceData) { try { $collection = $this->mongoDb->selectCollection($resourceType->getValue()); $updateData = $resourceData->getData(); $mongoId = new MongoId($resourceData->getResourceId()->getValue()); $result = $collection->update(array('_id' => $mongoId), array('$set' => $updateData)); if ($result['n'] != 1) { throw new RuntimeException(sprintf('Resource with id <%s> could not be updated, cause resource was not found in database.', $resourceData->getResourceId())); } return $this->getResource($resourceType, $resourceData->getResourceId()); } catch (RuntimeException $ex) { throw $ex; } catch (Exception $ex) { throw new RuntimeException('Updating resource failed. See previous exception for more details', null, $ex); } }
/** * @covers GingerCore\Repository\Resource\ResourceType::__construct * @covers GingerCore\Repository\Resource\ResourceType::getValue */ public function test__constructAndGetValue() { $resourceType = new ResourceType('workflow'); $this->assertEquals('workflow', $resourceType->getValue()); }