Ejemplo n.º 1
0
 /**
  * @param Core\Events\LoadFormDatas $event
  */
 public static function execute(LoadFormDatasEvent $event)
 {
     $route = $event->getRoute();
     $objectId = $event->getObjectId();
     $parameters = $event->getParameters();
     if ($route === '/centreon-configuration/poller/update') {
         try {
             $brokerParameters = Broker::getParameters($objectId, "*");
             $brokerCompleteParameters = array();
             foreach ($brokerParameters as $key => $value) {
                 $brokerCompleteParameters['centreon-broker__' . $key] = $value;
             }
             $event->addParameters($brokerCompleteParameters);
         } catch (\Exception $e) {
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Get broker config from broker id
  *
  * @param int $brokerId
  */
 public static function getBrokerConfigFromBrokerId($brokerId)
 {
     $dbconn = Di::getDefault()->get('db_centreon');
     $poller = Broker::getParameters($brokerId, 'poller_id');
     $pollerId = $poller['poller_id'];
     $configuration = self::getBrokerConfigFromPollerId($pollerId);
     $query = 'SELECT config_name' . ' FROM cfg_centreonbroker' . ' WHERE config_id = :config_id';
     $stmt = $dbconn->prepare($query);
     $stmt->bindParam(':config_id', $brokerId, \PDO::PARAM_INT);
     $stmt->execute();
     $row = $stmt->fetch();
     if ($row === false) {
         throw new \Exception("Can't get config name");
     }
     $brokerName = $row['config_name'];
     $brokerConfig = array();
     if (isset($configuration['content']['broker']['setup'])) {
         $setups = $configuration['content']['broker']['setup'];
         foreach ($setups as $setup) {
             if (isset($setup['params']['mode'])) {
                 $modes = $setup['params']['mode'];
                 foreach ($modes as $mode) {
                     if (isset($mode['normal'])) {
                         $normals = $mode['normal'];
                         foreach ($normals as $normal) {
                             if (isset($normal['general']['name']) && $normal['general']['name'] == $brokerName) {
                                 $brokerConfig = $normal;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $brokerConfig;
 }