Esempio n. 1
0
 /**
  * Perfomr increment action.
  *
  * @param $id
  * @return int
  */
 public function actionIncrement($id)
 {
     $entity = $this->findEntity($id);
     $command = new IncrementCountCommand($entity);
     $content = $command->execute();
     $this->context->getLogger()->info('IncrementCountCommand completed successfully. Result: ' . $content);
     $config = $this->context->getConfig();
     foreach ($config->getPartnerPorts() as $port) {
         $partnerBaseUrl = 'http://' . $config->getHost() . ':' . $port;
         $command = new SyncCommand($id, $entity->getCount(), $partnerBaseUrl);
         if ($command->execute()) {
             $this->context->getLogger()->info('Synchronization with instance ' . $partnerBaseUrl . ' completed successfully.');
         } else {
             $this->context->getLogger()->error('An error occurred during synchronization with instance:' . $partnerBaseUrl);
             $this->context->getLogger()->error('Detail: ' . $command->getErrorMessage());
         }
     }
     return $content;
 }