Beispiel #1
0
 public function __construct(Connection $connection, $config, $eshost, $esport, $eslog, $files)
 {
     $this->dbal = $connection;
     $this->config = $config;
     $this->eshost = $eshost;
     $this->esport = $esport;
     $this->eslog = $eslog;
     $this->files = $files;
     $this->eslogh = $this->eslog;
     $this->eslogi = 0;
     if (!file_exists($this->eslog)) {
         if (!mkdir($this->eslog, 0777, true)) {
             throw new Exception("Can't create direcoty '{$this->eslog}'");
         }
     }
     $this->eslog .= DIRECTORY_SEPARATOR . date('Y_m_d_H_i_s') . "_populate.log";
     UtilFilesystem::checkIfFileExistOrICanCreate($this->eslog, true);
     $this->eslogh = fopen($this->eslog, 'a');
     $this->url = $eshost . ':' . $esport;
     if (!@is_array($this->config['indexes'])) {
         throw new Exception("Invalid config, no 'indexes' key");
     }
     foreach ($this->config['indexes'] as &$data) {
         foreach ($data['types'] as $type => &$tdata) {
             foreach ($tdata['properties'] as $field => &$properties) {
                 if (!isset($properties['mapping'])) {
                     $properties['mapping'] = array();
                 }
                 if (!isset($properties['mapping']['field'])) {
                     $properties['mapping']['field'] = $field;
                 }
             }
         }
     }
 }