Esempio n. 1
0
 protected function methodPatchWithId(Request $request, Response $response)
 {
     $cdsId = $request->getAttribute('Primary-Key-Value');
     $cdsConf = $this->getCdsConf($cdsId);
     if (empty($cdsConf)) {
         throw new \Exception("this cds id not found");
     }
     if ($cdsConf['query'] !== '') {
         $query = RqlParser::rqlDecode($cdsConf['query']);
     } else {
         $query = new Query();
     }
     $data = $this->getData($cdsConf['script_name'], $query);
     $query = new Query();
     $query->setQuery(new EqNode('cds_id', $cdsId));
     $items = $this->cds->query($query);
     foreach ($items as $item) {
         $this->cds->delete($item['id']);
     }
     foreach ($data as &$item) {
         $item['cds_id'] = $cdsId;
         $item['data_id'] = $item['id'];
         unset($item['id']);
     }
     $this->cds->create($data);
     $this->cdsManagerStore->update(['id' => $cdsConf['id'], 'freshness_date' => (new \DateTime())->format("Y-m-d H:i:s")]);
     $request = $request->withAttribute('CDS-ID', $cdsId);
     $request = $request->withAttribute('Response-Body', ['cdsId' => $cdsId]);
     $response = $response->withStatus(200);
     return array($request, $response);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  *
  * {@inheritdoc}
  */
 public function delete($id)
 {
     $this->preDelete($id);
     $result = $this->dataStore->delete($id);
     return $this->postDelete($result, $id);
 }