Example #1
0
 /**
  * Import configuration data.
  *
  * $params structure:
  * array(
  * 	'format' => 'json'|'xml'
  * 	'source' => configuration data in specified format,
  * 	'rules' => array(
  * 		'hosts' => array('createMissing' => true, 'updateExisting' => false),
  * 		'templates' => array('createMissing' => true, 'updateExisting' => true),
  * 		...
  * 	)
  * )
  *
  * @param $params
  *
  * @return bool
  */
 public function import($params)
 {
     $importReader = CImportReaderFactory::getReader($params['format']);
     $data = $importReader->read($params['source']);
     $data = (new CXmlValidator())->validate($data, $params['format']);
     $importConverterFactory = new CImportConverterFactory();
     $converterChain = new CConverterChain();
     $converterChain->addConverter('1.0', $importConverterFactory->getObject('1.0'));
     $converterChain->addConverter('2.0', $importConverterFactory->getObject('2.0'));
     $adapter = new CImportDataAdapter(ZABBIX_EXPORT_VERSION, $converterChain);
     $adapter->load($data);
     $configurationImport = new CConfigurationImport($params['rules'], new CImportReferencer(), new CImportedObjectContainer(), new CTriggerExpression());
     return $configurationImport->import($adapter);
 }
 /**
  * Get formatted template screens.
  *
  * @return array
  */
 protected function getFormattedTemplateScreens()
 {
     if (!isset($this->formattedData['templateScreens'])) {
         $this->formattedData['templateScreens'] = $this->adapter->getTemplateScreens();
     }
     return $this->formattedData['templateScreens'];
 }