/**
  * {@inheritDoc}
  */
 public function getResource(Resource\ResourceType $resourceType, Resource\ResourceId $resourceId)
 {
     try {
         $tableGateway = $this->getTablegateway($resourceType);
         $row = $tableGateway->select(array('id' => $resourceId->getValue()))->current();
         if ($row) {
             return $this->hydrateResourceData($row->id, $row->data);
         } else {
             return null;
         }
     } catch (RuntimeException $ex) {
         throw $ex;
     } catch (Exception $ex) {
         throw new RuntimeException('Get resource failed. See previous exception for more details', null, $ex);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getResource(Resource\ResourceType $resourceType, Resource\ResourceId $resourceId)
 {
     try {
         $collection = $this->mongoDb->selectCollection($resourceType->getValue());
         $mongoId = new MongoId($resourceId->getValue());
         $doc = $collection->findOne(array('_id' => $mongoId));
         if ($doc) {
             return $this->hydrateResourceData($doc);
         } else {
             return null;
         }
     } catch (RuntimeException $ex) {
         throw $ex;
     } catch (Exception $ex) {
         throw new RuntimeException('Get resource failed. See previous exception for more details', null, $ex);
     }
 }
示例#3
0
 /**
  * @covers GingerCore\Repository\Resource\ResourceId::getValue
  */
 public function testGetValue()
 {
     $resourceId = new ResourceId('1234');
     $this->assertEquals('1234', $resourceId->getValue());
 }