示例#1
0
 /**
  * Функции, доступные только администраторам
  */
 public function saveLibItem(LibItemDb $item, AdminLibBean $bean)
 {
     $this->LOGGER->info("{} lib item: {}", $item->hasId() ? 'Updating' : 'Creating', $item);
     //UPDATE
     if ($item->hasId()) {
         $bean->updateLibItem($item);
         return;
         //---
     }
     //CREATE
     $id = $bean->createLibItem($item);
     $this->LOGGER->info("Lib item successfully created in DB, id: {$id}. Trying to create folded entity.");
     try {
         $this->createEntity($item->getIdent());
     } catch (Exception $ex) {
         $this->LOGGER->info("Cannot create entity, reason: {$ex->getMessage()}. Removing LibEntity from DB.");
         $bean->removeLibEntity($id);
         throw $ex;
     }
     $this->LOGGER->info('Lib entity successfully created.');
 }