public function find($id)
 {
     $resultSet = $this->tableGateway->select(['id' => (int) $id]);
     if ($resultSet->count() == 1) {
         return $resultSet->current();
     }
     return FALSE;
 }
 public function findBy(array $columns)
 {
     $result = $this->tableGateway->select($columns);
     if (!$result->current()) {
         throw new \Exception('Entity not found.', 404);
     }
     return $result;
 }
 /**
  * Get only one item of resource
  */
 public function find($id)
 {
     $resultSet = $this->tableGateway->select(["id" => (int) $id]);
     $result = $resultSet->current();
     if (!$result) {
         return new ApiProblem(415, "Unsupported Media Type");
     }
     return $result;
 }
 public function delete($id)
 {
     $existe = $this->tableGateway->select(['id' => (int) $id]);
     if (count($existe) === 1) {
         $this->tableGateway->delete(['id' => (int) $id]);
         $existe = $this->tableGateway->select(['id' => (int) $id]);
         if (count($existe) === 1) {
             return new ApiProblem(450, 'Não foi possivel excluir o registro', null, 'Problemas ao excluir');
         }
         return true;
     }
     return new ApiProblem(451, 'O registro não foi encontrado na base de dados', null, 'Registro não encontrado');
 }
 public function findAll()
 {
     $orders = $this->tableGateway->select();
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods()));
     $res = [];
     foreach ($orders as $order) {
         $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]);
         foreach ($items as $item) {
             $order->addItem($item);
         }
         $data = $hydrator->extract($order);
         $res[] = $data;
     }
     $paginatorAdapter = new ArrayAdapter($res);
     return new OrdersCollection($paginatorAdapter);
 }
 /**
  * Fetch an existing resource.
  *
  * @param int|string $id Identifier of resource.
  * @return array|object Resource.
  * @throws DomainException if the resource is not found.
  */
 public function fetch($id)
 {
     $resultSet = $this->table->select([$this->identifierName => $id]);
     if (0 === $resultSet->count()) {
         throw new DomainException('Item not found', 404);
     }
     return $resultSet->current();
 }
 /**
  * Get user resource by username
  * @param string $username
  */
 public function findByUserName($username)
 {
     return $this->tableGateway->select(['username' => $username])->current();
 }
 public function find($id)
 {
     $resultSet = $this->tableGateway->select(['id' => (int) $id]);
     return $resultSet->current();
 }
 public function updateItem($id, array $data)
 {
     $this->itemTable->update($data, ['id' => (int) $id]);
     return $this->itemTable->select(['id' => (int) $id])->current();
 }