Example #1
0
 public function fromDic($dic)
 {
     $hashes = array_keys($dic);
     $currentHashes = $this->keyModel->getHashesByIdProject($this->id_project);
     $hashesToDelete = array_diff($currentHashes, $hashes);
     $dicToCreate = array_filter($dic, function ($key) use($currentHashes) {
         return !in_array($key, $currentHashes);
     }, ARRAY_FILTER_USE_KEY);
     if ($hashesToDelete) {
         $this->deleted = $this->keyModel->deleteByHashes($hashesToDelete);
     } else {
         $this->deleted = 0;
     }
     if ($dicToCreate) {
         $this->created = $this->keyModel->createFromDic($this->id_project, $dicToCreate);
     } else {
         $this->created = 0;
     }
 }
Example #2
0
 public function destroy()
 {
     $id_key = $this->request->getUInt('id');
     $this->keyModel->delete($id_key);
     $this->server->sendOK();
 }