当前位置: 首页>>代码示例>>PHP>>正文


PHP RecursiveIteratorIterator::getSubIterator方法代码示例

本文整理汇总了PHP中RecursiveIteratorIterator::getSubIterator方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::getSubIterator方法的具体用法?PHP RecursiveIteratorIterator::getSubIterator怎么用?PHP RecursiveIteratorIterator::getSubIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RecursiveIteratorIterator的用法示例。


在下文中一共展示了RecursiveIteratorIterator::getSubIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = ArrayHelper::merge(parent::behaviors(), ['authenticator' => ['class' => CompositeAuth::className(), 'authMethods' => [['class' => HttpBearerAuth::className()], ['class' => QueryParamAuth::className(), 'tokenParam' => 'accessToken']]], 'exceptionFilter' => ['class' => ErrorToExceptionFilter::className()], 'corsFilter' => ['class' => \backend\rest\filters\Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['POST', 'PUT', 'OPTIONS', 'PATCH', 'DELETE'], 'Access-Control-Request-Headers' => ['X-Pagination-Total-Count', 'X-Pagination-Page-Count', 'X-Pagination-Current-Page', 'X-Pagination-Per-Page', 'Content-Length', 'Content-type', 'Link'], 'Access-Control-Allow-Credentials' => true, 'Access-Control-Max-Age' => 3600, 'Access-Control-Expose-Headers' => ['X-Pagination-Total-Count', 'X-Pagination-Page-Count', 'X-Pagination-Current-Page', 'X-Pagination-Per-Page', 'Content-Length', 'Content-type', 'Link'], 'Access-Control-Allow-Headers' => ['X-Pagination-Total-Count', 'X-Pagination-Page-Count', 'X-Pagination-Current-Page', 'X-Pagination-Per-Page', 'Content-Length', 'Content-type', 'Link']]]]);
     if (isset(\Yii::$app->params['httpCacheActive']) and \Yii::$app->params['httpCacheActive']) {
         $params = \Yii::$app->getRequest()->getQueryParams();
         unset($params['accessToken']);
         $behaviors['httpCache'] = ['class' => HttpCache::className(), 'params' => $params, 'lastModified' => function ($action, $params) {
             $q = new \yii\db\Query();
             $class = $this->modelClass;
             if (in_array('updated_at', $class::getTableSchema()->getColumnNames())) {
                 return strtotime($q->from($class::tableName())->max('updated_at'));
             }
             if (in_array('modified', $class::getTableSchema()->getColumnNames())) {
                 return strtotime($q->from($class::tableName())->max('modified'));
             }
             return null;
         }, 'etagSeed' => function (Action $action, $params) {
             $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($params));
             $keys = array();
             foreach ($iterator as $key => $value) {
                 // Build long key name based on parent keys
                 for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) {
                     $key = $iterator->getSubIterator($i)->key() . '_' . $key;
                     if (!is_array($iterator->getSubIterator($i)->current())) {
                         $value = $iterator->getSubIterator($i)->current() . '_' . $value;
                     }
                 }
                 $keys[] = $key . '-' . $value;
             }
             $uniqueId = implode('-', $keys);
             return $uniqueId;
         }];
     }
     return $behaviors;
 }
开发者ID:portalsway2,项目名称:APEDevices,代码行数:38,代码来源:Controller.php

示例2: _convertToDotNotation

 private function _convertToDotNotation()
 {
     foreach ($this->_iterator as $leafValue) {
         $keys = [];
         foreach (range(0, $this->_iterator->getDepth()) as $depth) {
             $keys[] = $this->_iterator->getSubIterator($depth)->key();
         }
         $key = join(self::DELIMITER, $keys);
         $this->_result[$key] = $leafValue;
     }
 }
开发者ID:tres-framework,项目名称:config,代码行数:11,代码来源:ArrayToDotNotation.php

示例3: parseCfg

 protected function parseCfg()
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data));
     $cfg = array();
     foreach ($iterator as $key => $value) {
         for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) {
             $key = $iterator->getSubIterator($i)->key() . '.' . $key;
         }
         $cfg[$key] = $value;
     }
     foreach ($cfg as $key => $value) {
         if (is_string($value)) {
             if ($count = preg_match_all('({{(.*?)}})', $value, $matches)) {
                 for ($i = 0; $i < $count; $i++) {
                     $cfg[$key] = str_replace($matches[0][$i], $cfg[$matches[1][$i]], $value);
                 }
             }
             foreach ($this->valueParsers as $valueParser) {
                 $cfg[$key] = $valueParser($cfg[$key]);
             }
             $temp =& $this->data;
             $exploded = explode('.', $key);
             foreach ($exploded as $segment) {
                 $temp =& $temp[$segment];
             }
             $temp = $cfg[$key];
             unset($temp);
         }
     }
 }
开发者ID:laborci,项目名称:PhlexDev,代码行数:30,代码来源:ConfigParser.php

示例4: buildArray

 public function buildArray()
 {
     $directory = new \RecursiveDirectoryIterator('assets');
     $iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::CHILD_FIRST);
     $tree = [];
     foreach ($iterator as $info) {
         //if (in_array($info->getFilename(), ['.', '..'])) continue;
         if ($iterator->getDepth() >= 2 || !$iterator->isDir() || $iterator->isDot()) {
             continue;
         }
         if ($iterator->getDepth() == 1) {
             $path = $info->isDir() ? [$iterator->getDepth() - 1 => $info->getFilename()] : [$info->getFilename()];
         } else {
             $path = $info->isDir() ? [$info->getFilename() => []] : [$info->getFilename()];
         }
         for ($depth = $iterator->getDepth() - 1; $depth >= 0; $depth--) {
             $path = [$iterator->getSubIterator($depth)->current()->getFilename() => $path];
         }
         $tree = array_merge_recursive($tree, $path);
     }
     $data = array();
     foreach ($tree as $category => $children) {
         foreach ($children as $index => $value) {
             $data[$category][] = $value;
         }
     }
     foreach ($data as $category => $children) {
         $parentId = $this->addEntry($category, '0');
         foreach ($children as $index => $value) {
             $this->addEntry($value, $parentId);
         }
     }
     return $data;
 }
开发者ID:tomshaw,项目名称:directory,代码行数:34,代码来源:HomeController.php

示例5: setup

 /**
  * [setup description]
  * @param  Array  $array
  * @return void
  * @link   http://stackoverflow.com/a/10424516
  */
 protected function setup(array $array)
 {
     $ritit = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));
     $this->arr = array();
     foreach ($ritit as $leafValue) {
         $keys = array();
         foreach (range(0, $ritit->getDepth()) as $depth) {
             $keys[] = $ritit->getSubIterator($depth)->key();
         }
         $this->set(join('.', $keys), $leafValue);
     }
 }
开发者ID:jalet,项目名称:tvnu-config,代码行数:18,代码来源:AdapterAbstract.php

示例6: __construct

 /**
  * Liste le répertoire
  * @param string $pPath
  */
 public function __construct($pPath)
 {
     $this->_directory = $pPath;
     $ritit = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pPath), \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($ritit as $splFileInfo) {
         $path = $splFileInfo->isDir() ? array($splFileInfo->getFilename() => array()) : array($splFileInfo->getFilename());
         for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) {
             $path = array($ritit->getSubIterator($depth)->current()->getFilename() => $path);
         }
         $this->_files = array_merge_recursive($this->_files, $path);
     }
 }
开发者ID:Vultur,项目名称:themecheck,代码行数:16,代码来源:ListDirectoryFiles.php

示例7: registerContainerParametersRecursive

 protected function registerContainerParametersRecursive(ContainerBuilder $container, $alias, $config)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($config), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $value) {
         $path = array();
         for ($i = 0; $i <= $iterator->getDepth(); $i++) {
             $path[] = $iterator->getSubIterator($i)->key();
         }
         $key = $alias . '.' . implode(".", $path);
         $container->setParameter($key, $value);
     }
 }
开发者ID:cjchamado,项目名称:CroppicBundle,代码行数:12,代码来源:FbeenCroppicExtension.php

示例8: extractRepositoriesUrls

 private function extractRepositoriesUrls(array $repositories)
 {
     $urls = array();
     $recursiveIteratorRepositories = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($repositories));
     foreach ($recursiveIteratorRepositories as $key => $leaf) {
         if ('url' === $key) {
             $repositoryPosition = $recursiveIteratorRepositories->getSubIterator(0)->key();
             $urls[$repositoryPosition][] = $leaf;
         }
     }
     return $urls;
 }
开发者ID:TomzxForks,项目名称:melody,代码行数:12,代码来源:WorkingDirectoryFactory.php

示例9: getNavBar

 /**
  * Get the wiki root directory files tree
  * @param  string wiki root directory
  * @return array
  */
 public function getNavBar($navPath)
 {
     $recursiveIteratorIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($navPath, \FilesystemIterator::SKIP_DOTS));
     $filesTree = [];
     foreach ($recursiveIteratorIterator as $splFileInfo) {
         $path = $splFileInfo->isDir() ? array($splFileInfo->getFilename() => []) : array($splFileInfo->getFilename());
         for ($depth = $recursiveIteratorIterator->getDepth() - 1; $depth >= 0; $depth--) {
             $path = [$recursiveIteratorIterator->getSubIterator($depth)->current()->getFilename() => $path];
         }
         $filesTree = array_merge_recursive($filesTree, $path);
     }
     return $filesTree;
 }
开发者ID:mrjuliuss,项目名称:lecter,代码行数:18,代码来源:Lecter.php

示例10: arrayKeyToStringPath

 /**
  * Converts a multi-dimensional array to dot-notation single dimensional strings
  * Convert:
  *  [
  *      'foo'   =>  [
  *          'bar'   =>  'baz
  *      ],
  *      'baa'   =>  'sheep'
  *  ]
  *
  * TO
  *  [
  *      'foo.bar'   =>  'baz',
  *      'baa'       =>  'sheep'
  *  ]
  *
  * @param $arrayContents
  *
  * @return array
  */
 public function arrayKeyToStringPath($arrayContents)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($arrayContents));
     $result = [];
     foreach ($iterator as $leafValue) {
         $keys = [];
         foreach (range(0, $iterator->getDepth()) as $depth) {
             $keys[] = $iterator->getSubIterator($depth)->key();
         }
         $result[join(self::SEPARATOR, $keys)] = $leafValue;
     }
     return $result;
 }
开发者ID:brunty,项目名称:laravel-environment,代码行数:33,代码来源:ArrayHelper.php

示例11: extractKeys

 public function extractKeys($array, $prefix = null)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));
     $keys = [];
     foreach ($iterator as $key => $value) {
         // Build long key name based on parent keys
         for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) {
             $key = $iterator->getSubIterator($i)->key() . '.' . $key;
         }
         $keys[] = $prefix . "." . $key;
     }
     return $keys;
 }
开发者ID:hpkns,项目名称:laravel-config,代码行数:13,代码来源:ConfigDump.php

示例12: flatten

 public function flatten()
 {
     $ritit = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->config));
     $result = array();
     foreach ($ritit as $leafValue) {
         $keys = array();
         foreach (range(0, $ritit->getDepth()) as $depth) {
             $keys[] = $ritit->getSubIterator($depth)->key();
         }
         $result[join('.', $keys)] = $leafValue;
     }
     return $result;
 }
开发者ID:wispira,项目名称:framework,代码行数:13,代码来源:Config.php

示例13: handleResponse

 /**
  * Override response handler to flatten array
  */
 protected function handleResponse($response, OutputInterface $output)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($response));
     $result = [];
     foreach ($iterator as $leafValue) {
         $keys = [];
         foreach (range(0, $iterator->getDepth()) as $depth) {
             $keys[] = $iterator->getSubIterator($depth)->key();
         }
         $result[join('.', $keys)] = $leafValue;
     }
     return parent::handleResponse($result, $output);
 }
开发者ID:gjorgiev,项目名称:platform,代码行数:16,代码来源:ConfigGet.php

示例14: compact

 /**
  * Convert a php nested array to mongo like dot notation
  * @see http://stackoverflow.com/questions/10424335/php-convert-multidimensional-array-to-2d-array-with-dot-notation-keys
  * @param array $array
  * @return array
  */
 public static function compact(array $array)
 {
     $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
     $rVal = [];
     foreach ($iterator as $leafValue) {
         $keys = array();
         foreach (range(0, $iterator->getDepth()) as $depth) {
             $keys[] = $iterator->getSubIterator($depth)->key();
         }
         $rVal[join('.', $keys)] = $leafValue;
     }
     return $rVal;
 }
开发者ID:ptheofan,项目名称:dot-notation,代码行数:19,代码来源:DotNotation.php

示例15: getRecursive

 /**
  * @param string $directory 
  */
 public static function getRecursive($directory)
 {
     $recursiveIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     $r = array();
     foreach ($recursiveIterator as $splFileInfo) {
         $path = array('children' => array($splFileInfo->getFilename() => array('type' => $splFileInfo->getType())));
         for ($depth = $recursiveIterator->getDepth() - 1; $depth >= 0; $depth--) {
             $path = array('children' => array($recursiveIterator->getSubIterator($depth)->current()->getFilename() => $path));
         }
         $r = array_merge_recursive($r, $path);
     }
     self::deep_ksort($r);
     return $r;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:17,代码来源:Helper.php


注:本文中的RecursiveIteratorIterator::getSubIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。