コード例 #1
0
ファイル: ElasticSearch2.php プロジェクト: stopsopa/utils
 protected function _index($service, $index, $type, $tdata, $id, OutputInterface $output = null)
 {
     if (!$output) {
         $output = new ConsoleOutput();
     }
     $output->writeln("    Update element '{$id}' of type: '{$type}'");
     //        $atonce                 = UtilArray::cascadeGet($tdata, 'mapping.maxresults');
     //        $useidfrom              = UtilArray::cascadeGet($tdata, 'mapping.useidfrom');
     $setupquerybuilder = UtilArray::cascadeGet($tdata, 'mapping.setupquerybuilder');
     $findbyid = UtilArray::cascadeGet($tdata, 'mapping.findbyid');
     $transform = UtilArray::cascadeGet($tdata, 'mapping.transformermethod');
     /* @var $qb QueryBuilder */
     $qb = call_user_func(array($service, $findbyid), $id);
     $r = $this->dbal->fetchAssoc($qb->getSQL());
     if ($transform) {
         $r = call_user_func(array($service, $transform), $r);
     }
     $row = array();
     foreach ($tdata['properties'] as $name => &$f) {
         $row[$name] = UtilNested::get($r, $f['mapping']['field']);
     }
     $output->write("    Update: {$id}\r");
     $result = $this->api('PUT', "/{$index}/{$type}/{$id}", $row);
     $output->writeln(PrettyJson::encode($result));
 }
コード例 #2
0
ファイル: AbstractApp.php プロジェクト: stopsopa/utils
 public static function getStpaConfig($key = null, $default = null)
 {
     if (static::$stpaconfig === null) {
         $root = static::getRootDir();
         $config = "{$root}/stpaconfig.ini";
         try {
             UtilFilesystem::checkFile($config);
         } catch (Exception $ex) {
             $config = "{$root}/vendor/stopsopa/utils/src/Stopsopa/UtilsBundle/Resources/config/stpaconfig.ini";
         }
         static::$stpaconfig = parse_ini_file($config, true);
         $root = static::getRootDir();
         static::_bindConfig(static::$stpaconfig, $root);
     }
     return UtilArray::cascadeGet(static::$stpaconfig, $key, $default);
 }