本文整理汇总了PHP中RecursiveIteratorIterator::next方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::next方法的具体用法?PHP RecursiveIteratorIterator::next怎么用?PHP RecursiveIteratorIterator::next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Executes this task.
*/
public function main()
{
if ($this->path === null) {
throw new BuildException('The path attribute must be specified');
}
$check = new AgaviModuleFilesystemCheck();
$check->setConfigDirectory($this->project->getProperty('module.config.directory'));
$check->setPath($this->path->getAbsolutePath());
if (!$check->check()) {
throw new BuildException('The path attribute must be a valid module base directory');
}
/* We don't know whether the module is configured or not here, so load the
* values we want properly. */
$this->tryLoadAgavi();
$this->tryBootstrapAgavi();
require_once AgaviConfigCache::checkConfig(sprintf('%s/%s/module.xml', $this->path->getAbsolutePath(), (string) $this->project->getProperty('module.config.directory')));
$actionPath = AgaviToolkit::expandVariables(AgaviToolkit::expandDirectives(AgaviConfig::get(sprintf('modules.%s.agavi.action.path', strtolower($this->path->getName())), '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php')), array('moduleName' => $this->path->getName()));
$pattern = '#^' . AgaviToolkit::expandVariables(str_replace('\\$\\{actionName\\}', '${actionName}', preg_quote($actionPath, '#')), array('actionName' => '(?P<action_name>.*?)')) . '$#';
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath()));
for (; $iterator->valid(); $iterator->next()) {
$rdi = $iterator->getInnerIterator();
if ($rdi->isDot() || !$rdi->isFile()) {
continue;
}
$file = $rdi->getPathname();
if (preg_match($pattern, $file, $matches)) {
$this->log(str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name']));
}
}
}
示例2: testRecursiveIterator
public function testRecursiveIterator()
{
$document = $this->createDocument();
$iterator = new RecursiveDomIterator($document);
$iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
$iterator->rewind();
$this->assertEquals('html', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('head', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('title', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('Hello World', $iterator->current()->textContent);
$iterator->next();
$this->assertEquals('body', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('div', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('p', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('foo', $iterator->current()->textContent);
$iterator->next();
$this->assertEquals('div', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('p', $iterator->current()->tagName);
$iterator->next();
$this->assertEquals('bar', $iterator->current()->textContent);
}
示例3: rmdir
/**
* Remove recursively the directory named by dirname.
*
* @param string $dirname Path to the directory
* @param boolean $followLinks Removes symbolic links if set to true
* @return boolean True if success otherwise false
* @throws Exception When the directory does not exist or permission denied
*/
public static function rmdir($dirname, $followLinks = false)
{
if (!is_dir($dirname) && !is_link($dirname)) {
throw new Exception(sprintf('Directory %s does not exist', $dirname));
}
if (!is_writable($dirname)) {
throw new Exception('You do not have renaming permissions');
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new Exception(sprintf('Permission denied for %s', $iterator->getPathName()));
}
if ($iterator->isLink() && false === (bool) $followLinks) {
$iterator->next();
continue;
}
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
return rmdir($dirname);
}
示例4: recursive_rmdir
private function recursive_rmdir($dirname, $followLinks = false)
{
if (is_dir($dirname) && !is_link($dirname)) {
if (!is_writable($dirname)) {
throw new Exception('You do not have renaming permissions!');
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new Exception(sprintf('Permission Denied: %s.', $iterator->getPathName()));
}
if ($iterator->isLink() && false === (bool) $followLinks) {
$iterator->next();
}
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
// Fix for Windows.
return rmdir($dirname);
} else {
throw new Exception(sprintf('Directory %s does not exist!', $dirname));
}
}
示例5: rmdir
public function rmdir($path)
{
try {
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->buildPath($path)), \RecursiveIteratorIterator::CHILD_FIRST);
/**
* RecursiveDirectoryIterator on an NFS path isn't iterable with foreach
* This bug is fixed in PHP 5.5.9 or before
* See #8376
*/
$it->rewind();
while ($it->valid()) {
/**
* @var \SplFileInfo $file
*/
$file = $it->current();
if (in_array($file->getBasename(), array('.', '..'))) {
$it->next();
continue;
} elseif ($file->isDir()) {
rmdir($file->getPathname());
} elseif ($file->isFile() || $file->isLink()) {
unlink($file->getPathname());
}
$it->next();
}
if ($result = @rmdir($this->buildPath($path))) {
$this->cleanMapper($path);
}
return $result;
} catch (\UnexpectedValueException $e) {
return false;
}
}
示例6: findDirectories
public static function findDirectories($rootDir, $multiMap = true)
{
if (!is_dir($rootDir)) {
throw new \LogicException($rootDir . ' is not a directory');
}
$elements = array();
$d = @dir($rootDir);
if (!$d) {
throw new \LogicException('Directory is not readable');
}
$dirs = array();
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($rootDir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
while ($it->valid()) {
if (!$it->isDir()) {
$it->next();
} else {
$cur = $it->current();
if ($cur->isDir()) {
if ($multiMap) {
$dirs[$cur->getPath()][] = $cur->getFilename();
} else {
$dirs[] = $cur->getPath();
}
}
$it->next();
}
}
return $dirs;
}
示例7: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
$tmpdir = $CFG->tempdir;
// Default to last weeks time.
$time = time() - $CFG->tempdatafoldercleanup * 3600;
$dir = new \RecursiveDirectoryIterator($tmpdir);
// Show all child nodes prior to their parent.
$iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);
// An array of the full path (key) and date last modified.
$modifieddateobject = array();
// Get the time modified for each directory node. Nodes will be updated
// once a file is deleted, so we need a list of the original values.
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
$modifieddateobject[$node] = $iter->getMTime();
}
// Now loop through again and remove old files and directories.
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
// Check if file or directory is older than the given time.
if ($modifieddateobject[$node] < $time) {
if ($iter->isDir() && !$iter->isDot()) {
// Don't attempt to delete the directory if it isn't empty.
if (!glob($node . DIRECTORY_SEPARATOR . '*')) {
if (@rmdir($node) === false) {
mtrace("Failed removing directory '{$node}'.");
}
}
}
if ($iter->isFile()) {
if (@unlink($node) === false) {
mtrace("Failed removing file '{$node}'.");
}
}
} else {
// Return the time modified to the original date only for real files.
if ($iter->isDir() && !$iter->isDot()) {
touch($node, $modifieddateobject[$node]);
}
}
}
}
示例8: array_flatten
function array_flatten(array $array, $key_separator = '/')
{
$result = array();
// a stack of strings
$keys = array();
$prev_depth = -1;
$iter = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
// rewind() is necessary
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$curr_depth = $iter->getDepth();
$diff_depth = $prev_depth - $curr_depth + 1;
//##### TODO: It would be nice to do this with a single function.
while ($diff_depth > 0) {
array_pop($keys);
--$diff_depth;
}
/*
Note:
http://bugs.php.net/bug.php?id=52425
array_shift/array_pop: add parameter that tells how many to elements to pop
*/
array_push($keys, $iter->key());
if (is_scalar($iter->current())) {
$result[implode($key_separator, $keys)] = $iter->current();
}
$prev_depth = $curr_depth;
}
return $result;
}
示例9: get_directory_list
function get_directory_list($settings = false)
{
$directory = !empty($settings['dir']) ? $settings['dir'] : CLIENT_DIR . "/";
$array = array();
$array['dirs'] = array();
$array['host'] = array();
$array['root'] = array();
if (!is_dir($directory)) {
return false;
}
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);
// Loop through directories
while ($dir->valid()) {
try {
$file = $dir->current();
ob_start();
echo $file;
$data = ob_get_contents();
ob_end_clean();
$data = trim($data);
if (basename($data) != '.' && basename($data) != '..') {
$array['host'][] = $data;
$array['root'][] = str_replace(ROOT_DIR, "", $data);
if (is_dir($data) && !in_array($data . "/", $array['dirs'])) {
$array['dirs'][] = $data . "/";
}
}
unset($data);
$dir->next();
} catch (UnexpectedValueException $e) {
continue;
}
}
return isset($array) ? $array : false;
}
示例10: runTest
/**
* Executes a specific Selenium System Tests in your machine
*
* @param string $seleniumPath Optional path to selenium-standalone-server-x.jar
* @param string $pathToTestFile Optional name of the test to be run
* @param string $suite Optional name of the suite containing the tests, Acceptance by default.
*
* @return mixed
*/
public function runTest($pathToTestFile = null, $suite = 'acceptance')
{
$this->runSelenium();
// Make sure to Run the Build Command to Generate AcceptanceTester
$this->_exec("php vendor/bin/codecept build");
if (!$pathToTestFile) {
$this->say('Available tests in the system:');
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('tests/' . $suite, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
$tests = array();
$iterator->rewind();
$i = 1;
while ($iterator->valid()) {
if (strripos($iterator->getSubPathName(), 'cept.php') || strripos($iterator->getSubPathName(), 'cest.php')) {
$this->say('[' . $i . '] ' . $iterator->getSubPathName());
$tests[$i] = $iterator->getSubPathName();
$i++;
}
$iterator->next();
}
$this->say('');
$testNumber = $this->ask('Type the number of the test in the list that you want to run...');
$test = $tests[$testNumber];
}
$pathToTestFile = 'tests/' . $suite . '/' . $test;
$this->taskCodecept()->test($pathToTestFile)->arg('--steps')->arg('--debug')->run()->stopOnFail();
// Kill selenium server
// $this->_exec('curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer');
}
示例11: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
$tmpdir = $CFG->tempdir;
// Default to last weeks time.
$time = strtotime('-1 week');
$dir = new \RecursiveDirectoryIterator($tmpdir);
// Show all child nodes prior to their parent.
$iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
// Check if file or directory is older than the given time.
if ($iter->getMTime() < $time) {
if ($iter->isDir() && !$iter->isDot()) {
// Don't attempt to delete the directory if it isn't empty.
if (!glob($node . DIRECTORY_SEPARATOR . '*')) {
if (@rmdir($node) === false) {
mtrace("Failed removing directory '{$node}'.");
}
}
}
if ($iter->isFile()) {
if (@unlink($node) === false) {
mtrace("Failed removing file '{$node}'.");
}
}
}
}
}
示例12: getFile
/**
* @param $path
* @return mixed|string
*/
private function getFile($path)
{
$returnView = $this->viewFolder . $path . '.php';
if (!file_exists($returnView)) {
$dir = $path;
$dir = explode('/', $dir);
unset($dir[count($dir) - 1]);
$dir = implode('/', $dir);
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->viewFolder . $dir));
while ($it->valid()) {
if (!$it->isDot()) {
$cache['SelectView'] = strrev($path);
$cache['SelectView'] = explode("/", $cache['SelectView'])[0];
$cache['SelectView'] = strrev($cache['SelectView']);
$cache['ReturnView'] = explode(".", $it->key());
unset($cache['ReturnView'][count($cache['ReturnView']) - 1]);
$cache['ReturnView'] = implode('.', $cache['ReturnView']);
$cache['ReturnView'] = explode("\\", $cache['ReturnView']);
$cache['ReturnView'] = $cache['ReturnView'][count($cache['ReturnView']) - 1];
if ($cache['ReturnView'] == $cache['SelectView']) {
$returnView = $it->key();
}
}
$it->next();
}
if (!isset($returnView)) {
die('Can not find a file matching these arguments: getView("' . $this->getPath($path, TRUE) . '")');
}
return $returnView;
}
}
示例13: copyDir
/**
* @throws \Seitenbau\FileSystem\FileSystemException
*/
public static function copyDir($source, $destination)
{
if (!is_dir($source)) {
throw new FileSystemException('Sourcedir "' . $source . '" does not exists');
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
if (!self::createDirIfNotExists($destination)) {
return false;
}
// Verzeichnis rekursiv durchlaufen
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if ($iterator->current()->isDir()) {
// relativen Teil des Pfad auslesen
$relDir = str_replace($source, '', $iterator->key());
// Ziel-Verzeichnis erstellen
if (!self::createDirIfNotExists($destination . $relDir)) {
return false;
}
} elseif ($iterator->current()->isFile()) {
$destinationFile = $destination . str_replace($source, '', $iterator->key());
if (!copy($iterator->key(), $destinationFile)) {
return false;
}
}
}
$iterator->next();
}
return true;
}
示例14: is_extension_changed
private static function is_extension_changed($name)
{
$name = strtolower($name);
$extension_build_dir = ROOT_PATH . DS . 'build' . DS . $name;
$extension_path = ROOT_PATH . DS . 'extensions' . DS . $name . '.tar.gz';
if (file_exists($extension_build_dir) && file_exists($extension_path)) {
$dir_iterator = new \RecursiveDirectoryIterator($extension_build_dir);
/**
* @var $iterator \RecursiveDirectoryIterator
*/
$iterator = new \RecursiveIteratorIterator($dir_iterator);
$iterator->rewind();
while ($iterator->valid()) {
if (!$iterator->isDot()) {
$file = $extension_build_dir . DS . $iterator->getSubPathName();
$phar_file = "phar://{$extension_path}/" . $iterator->getSubPathName();
if (!file_exists($phar_file)) {
return true;
} else {
$build_file_hash = md5(file_get_contents($file));
$phar_file_hash = md5(file_get_contents($phar_file));
if ($build_file_hash != $phar_file_hash) {
return true;
}
}
}
$iterator->next();
}
return false;
} else {
return false;
}
}
示例15: next
/**
* Moves to next item in structure.
* Respects filter.
*/
public function next()
{
do {
$this->iterated->attach($this->current());
parent::next();
} while ($this->valid() && (!$this->passes($this->current()) || $this->iterated->contains($this->current())));
}