示例#1
0
 public function setPath($path)
 {
     $this->path = $path;
     $data = $this->request->request->all();
     UtilArray::cascadeSet($data, $this->field, $path);
     $this->request->request = new ParameterBag($data);
     return $this;
 }
示例#2
0
 protected static function &_get(&$o, $p)
 {
     $result;
     if (static::_isArrayAccessable($o)) {
         try {
             if (UtilArray::offsetExists($o, $p)) {
                 $result =& $o[$p];
                 return $result;
             }
         } catch (UtilArrayException $ex) {
             throw new UtilFormAccessorException($ex->getMessage());
         }
     }
     $result = static::accessorGet($o, $p);
     return $result;
 }
示例#3
0
 /**
  * @param array $array
  *
  * @return Response
  */
 public function extendJson(array $array = array(), $setjsonheader = false)
 {
     $json = $this->getJson();
     return $this->setContent(UtilArray::arrayMergeRecursiveDistinct($json, $array), $setjsonheader);
 }
示例#4
0
 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));
 }
示例#5
0
文件: Sms.php 项目: stopsopa/utils
 protected function _setupMultiple(&$post)
 {
     preg_match_all('#\\[%(\\d+)%\\]#', $post['message'], $m);
     if (count($m[0])) {
         $max = 0;
         foreach ($m[1] as $k) {
             ++$max;
             if ($max > 4) {
                 $this->_throw('Dozwolone są tylko 4 argumenty');
             }
             if ($k != $max) {
                 $this->_throw('Utrzymuj kolejność parametrach, zaczynając od 1, obecna kolejność to: ' . print_r($m[1], true));
             }
         }
         $params = [];
         $i = 0;
         foreach ($m[1] as $k) {
             $k = "param{$k}";
             $params[$k] = $i++;
         }
         if (count($params)) {
             // są parametry
             $pcount = count($this->phones);
             $scount = count($params);
             foreach ($params as $p => &$ii) {
                 $tt = [];
                 $i = 0;
                 foreach ($this->params as &$par) {
                     $pc = count($par);
                     if ($pc != $scount) {
                         $this->_throw("Liczba parametrów ({$pc}) w zestawie nr '{$i}' jest inna niż liczba zanczników w templatece ({$scount})");
                     }
                     if (UtilArray::isAssoc($par)) {
                         if (!isset($par[$p])) {
                             $this->_throw("Brak parametru '{$p}' w zestawie parametrów w elemencie {$i}");
                         }
                         $tt[] = $par[$p];
                     } else {
                         $tt[] = $par[$ii];
                     }
                     ++$i;
                 }
                 $c = count($tt);
                 if ($c != $pcount) {
                     $this->_throw("Liczba wartości w zestawie parametrów ({$c}) '{$p}' nie jest równa ilości odbiorców ({$pcount})");
                 }
                 $params[$p] = Urlizer::unaccent(implode('|', $tt));
             }
             $post = array_merge($post, $params);
         }
     }
 }
示例#6
0
 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);
 }