本文整理汇总了PHP中RecursiveIteratorIterator类的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator类的具体用法?PHP RecursiveIteratorIterator怎么用?PHP RecursiveIteratorIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RecursiveIteratorIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']));
}
}
}
开发者ID:horros,项目名称:agavi,代码行数:33,代码来源:AgaviDisplayactionsTask.php
示例2: 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
示例3: arrayToXml
/**
* <pre>Converts a Doctrine array graph of the form:
* .array
* . 0 =>
* . array
* . 'id' => '1'
* . 'PersonaDomicilio' =>
* . array
* . 0 =>
* . array
* . 'id' => '1'
* To a XML representation.
*
* @param array $array The array to convert to XML
*
* @return DOMDocument <pre> The XML with following structure:
* . <result>
* . <rootTable_Collection>
* . <rootTable>
* . <id></id>
* . <field1></field1>
* . <relatedTable_Collection>
* . <relatedTable>
* . </relatedTable>
* . <relatedTable>
* . </relatedTable>
* . ::
* . </relatedTable_Collection>
* . </rootTable>
* . <rootTable>
* . ::
* . </rootTable>
* . ::
* . </rootTable_Collection>
* . <result>
* </pre>
*/
public function arrayToXml(array $array)
{
$result = new DOMDocument();
$rootNode = $result->createElement('result');
$result->appendChild($rootNode);
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
$prevLvl = 0;
$component[$prevLvl] = $this->_queryComponents[$this->_rootAlias]['table']->getComponentName();
$obj = $result->createElement($component[$prevLvl] . '_Collection');
$rootNode->appendChild($obj);
foreach ($iterator as $k => $val) {
$depth = $iterator->getDepth();
if ($depth < $prevLvl) {
for ($i = 0; $i < $prevLvl - $depth; $i++) {
$obj = $obj->parentNode;
}
}
if (!is_array($val)) {
$son = $result->createElement($k, $val);
$obj->appendChild($son);
} else {
if (is_numeric($k)) {
$son = $result->createElement($component[$depth]);
} else {
$component[$depth + 1] = $k;
$son = $result->createElement($k . '_Collection');
}
$obj->appendChild($son);
!empty($val) && ($obj = $son);
}
$prevLvl = $depth;
}
return $result;
}
开发者ID:backstageel,项目名称:neatReports,代码行数:71,代码来源:XmlDriver.php
示例4: 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;
}
开发者ID:rasclatt,项目名称:ZipEngine,代码行数:35,代码来源:function.get_directory_list.php
示例5: processMedia
/**
* Media files are just copied over w/o any additional processing
*
* @return \Phrozn\Site
*/
private function processMedia()
{
$projectDir = $this->getProjectDir();
$outputDir = $this->getOutputDir();
$dir = new \RecursiveDirectoryIterator($projectDir . '/media');
$it = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($it as $item) {
$baseName = $item->getBaseName();
if ($item->isFile()) {
$inputFile = $item->getRealPath();
$path = $it->getSubPath();
$outputFile = $outputDir . '/media/' . $path . (!empty($path) ? '/' : '') . basename($inputFile);
// copy media files
try {
$destinationDir = dirname($outputFile);
if (!is_dir($destinationDir)) {
mkdir($destinationDir, 0777, true);
}
if (!copy($inputFile, $outputFile)) {
throw new \Exception(sprintf('Failed transfering "%s" from media folder', $inputFile));
}
$inputFile = str_replace(getcwd(), '.', $inputFile);
$outputFile = str_replace(getcwd(), '.', realpath($outputFile));
$this->getOutputter()->stdout('%b' . $outputFile . '%n copied');
} catch (\Exception $e) {
$this->getOutputter()->stderr($inputFile . ': ' . $e->getMessage());
}
}
}
}
开发者ID:JamieS,项目名称:phrozn,代码行数:35,代码来源:DefaultSite.php
示例6: getTestFiles
/**
* Get Test Files
*
* @param null $directory
* @param null $excludes
* @return array
*/
public static function getTestFiles($directory = null, $excludes = null)
{
if (is_array($directory)) {
$files = array();
foreach ($directory as $d) {
$files = array_merge($files, self::getTestFiles($d, $excludes));
}
return array_unique($files);
}
if ($excludes !== null) {
$excludes = self::getTestFiles((array) $excludes);
}
if ($directory === null || $directory !== realpath($directory)) {
$basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
$directory = str_replace(DS . DS, DS, $basePath . $directory);
}
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
$files = array();
while ($it->valid()) {
if (!$it->isDot()) {
$file = $it->key();
if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) {
$files[] = $file;
}
}
$it->next();
}
return $files;
}
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:36,代码来源:DebugkitGroupTestCase.php
示例7: locate
/**
* @param $target
* @return array
*/
public function locate($target)
{
$paths = [];
$target = sprintf("%s/%s", self::RESOURCE_SUFFIX, $target);
foreach ($this->locations as $location) {
if (!is_dir($location)) {
continue;
}
$location = realpath($location);
$dir = new \RecursiveDirectoryIterator($location, \FilesystemIterator::FOLLOW_SYMLINKS);
$filter = new \RecursiveCallbackFilterIterator($dir, function (\SplFileInfo $current) use(&$paths, $target) {
$fileName = strtolower($current->getFilename());
if ($this->isExcluded($fileName) || $current->isFile()) {
return false;
}
if (!is_dir($current->getPathname() . '/Resources')) {
return true;
} else {
$file = $current->getPathname() . sprintf("/Resources/%s", $target);
if (is_file($file)) {
$paths[] = $file;
}
return false;
}
});
$iterator = new \RecursiveIteratorIterator($filter);
$iterator->rewind();
}
return $paths;
}
开发者ID:EvoCommerceTeam,项目名称:DistribuitionBundle,代码行数:34,代码来源:PlatformResourceLocator.php
示例8: assertDirContentsEquals
protected function assertDirContentsEquals($expDir, $actDir)
{
if (!file_exists($expDir)) {
throw new RuntimeException("Expected dir not found: " . $expDir);
}
if (!file_exists($actDir)) {
throw new RuntimeException("Actual dir not found: " . $actDir);
}
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($expDir));
$expFiles = array();
while ($dir->valid()) {
if (!$dir->isDot()) {
array_push($expFiles, $dir->getSubPathName());
}
$dir->next();
}
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($actDir));
$actFiles = array();
while ($dir->valid()) {
if (!$dir->isDot()) {
array_push($actFiles, $dir->getSubPathName());
}
$dir->next();
}
$this->assertEquals($expFiles, $actFiles);
foreach ($expFiles as $key => $value) {
$expFile = file_get_contents($expDir . DIRECTORY_SEPARATOR . $value);
$actFile = file_get_contents($expDir . DIRECTORY_SEPARATOR . $actFiles[$key]);
$this->assertEquals($expFile, $actFile);
}
}
开发者ID:irfan-blackhawk,项目名称:XSD-to-PHP,代码行数:31,代码来源:LegkoXMLTestCase.php
示例9: 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
示例10: copyAssets
/**
* Recursively copy assets from the source directory to the destination
* directory in the web space, omitting source files.
*
* @param Filesystem $fs
* @param string $from_directory the source
* @param string $to_directory the destination
* @throws \RuntimeException if a problem occurs.
*/
protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
{
Tlog::getInstance()->addDebug("Copying assets from {$from_directory} to {$to_directory}");
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
$fs->mkdir($to_directory, 0777);
/** @var \RecursiveDirectoryIterator $iterator */
foreach ($iterator as $item) {
if ($item->isDir()) {
$dest_dir = $to_directory . DS . $iterator->getSubPathName();
if (!is_dir($dest_dir)) {
if ($fs->exists($dest_dir)) {
$fs->remove($dest_dir);
}
$fs->mkdir($dest_dir, 0777);
}
} elseif (!$this->isSourceFile($item)) {
// We don't copy source files
$dest_file = $to_directory . DS . $iterator->getSubPathName();
if ($fs->exists($dest_file)) {
$fs->remove($dest_file);
}
$fs->copy($item, $dest_file);
}
}
}
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:34,代码来源:AsseticAssetManager.php
示例11: testBuildPhar
public function testBuildPhar()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Building the phar does not work on HHVM.');
}
$target = dirname(self::$pharPath);
$fs = new Filesystem();
$fs->removeDirectory($target);
$fs->ensureDirectoryExists($target);
chdir($target);
$it = new \RecursiveDirectoryIterator(__DIR__ . '/../../../', \RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($ri as $file) {
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
$fs->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
$proc = new Process('php ' . escapeshellarg('./bin/compile'), $target);
$exitcode = $proc->run();
if ($exitcode !== 0 || trim($proc->getOutput())) {
$this->fail($proc->getOutput());
}
$this->assertTrue(file_exists(self::$pharPath));
}
开发者ID:alancleaver,项目名称:composer,代码行数:27,代码来源:AllFunctionalTest.php
示例12: copyOldVersion
function copyOldVersion()
{
if (!is_dir(PATH)) {
echo 'Creating new oldVersion dir...<br>';
mkdir(PATH);
}
$source = "../";
$dest = PATH;
// Set a stream context timeout for file reading
$context = stream_context_create(array('http' => array('timeout' => 60)));
echo 'Moving current ICEcoder files...<br>';
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
if (strpos($source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), "oldVersion") == false) {
// Don't move backups, plugins or .git away
$testPath = $source . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
$testPath = str_replace("\\", "/", $testPath);
if (strpos($testPath, "/backups/") == false && strpos($testPath, "/plugins/") == false && strpos($testPath, "/.git/") == false) {
if ($item->isDir()) {
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 0755);
} else {
rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
}
}
}
$icv_url = "https://icecoder.net/latest-version.txt";
echo 'Detecting current version of ICEcoder...<br>';
$icvInfo = getData($icv_url, 'curl', 'Sorry, couldn\'t figure out latest version.');
echo 'Latest version of ICEcoder is ' . $icvInfo . '<br>';
openZipNew($icvInfo);
}
开发者ID:JpaKaagman,项目名称:ICEcoder,代码行数:31,代码来源:updater.php
示例13: rmdir
public function rmdir($path) {
if (!$this->isDeletable($path)) {
return false;
}
try {
$it = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->getSourcePath($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();
}
return rmdir($this->getSourcePath($path));
} catch (\UnexpectedValueException $e) {
return false;
}
}
开发者ID:ninjasilicon,项目名称:core,代码行数:35,代码来源:local.php
示例14: __construct
/**
* Constructor.
*
* @param \RecursiveIteratorIterator $iterator The Iterator to filter
* @param int $minDepth The min depth
* @param int $maxDepth The max depth
*/
public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = INF)
{
$this->minDepth = $minDepth;
$iterator->setMaxDepth(INF === $maxDepth ? -1 : $maxDepth);
parent::__construct($iterator);
}
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:14,代码来源:DepthRangeFilterIterator.php
示例15: execute
/**
* {@inheritdoc}
*
* @see \Symfony\Component\Console\Command\Command::execute()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$assets = $this->getContainer()->getParameter('asf_layout.assets');
$this->tinymce_config = $assets['tinymce'];
$dest_dir = $input->getArgument('target_dir') ? $input->getArgument('target_dir') : null;
if (is_null($dest_dir) && isset($this->tinymce_config['customize']['dest_dir'])) {
$dest_dir = $this->tinymce_config['customize']['dest_dir'];
}
$exclude_files = $input->getOption('exclude_files') ? $input->getOption('exclude_files') : $this->tinymce_config['customize']['exclude_files'];
$src_dir = sprintf('%s', $this->tinymce_config['tinymce_dir']);
$fs = new Filesystem();
try {
if (!$fs->exists($dest_dir)) {
$fs->mkdir($dest_dir);
}
} catch (IOException $e) {
$output->writeln(sprintf('<error>Could not create directory %s.</error>', $dest_dir));
return;
}
if (false === file_exists($src_dir)) {
$output->writeln(sprintf('<error>Source directory "%s" does not exist. Did you install TinyMCE ? ' . 'Don\'t forget to specify the path to TinyMCE folder in ' . '"asf_layout.assets.tinymce.tinymce_dir".</error>', $src_dir));
return;
}
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src_dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
if ($item->isDir() && !in_array($item->getBasename(), $exclude_files)) {
$fs->mkdir($dest_dir . '/' . $iterator->getSubPathName());
} elseif (!in_array($item->getBasename(), $exclude_files)) {
$fs->copy($item, $dest_dir . '/' . $iterator->getSubPathName());
}
}
$output->writeln(sprintf('[OK] TinyMCE files was successfully copied in "%s".', $dest_dir));
}
开发者ID:artscorestudio,项目名称:layout-bundle,代码行数:37,代码来源:CopyTinyMCEFilesCommand.php
示例16: copy
public function copy($target)
{
$result = false;
$encoded = $this->encodePath($target);
$dir = dirname($encoded);
if (!is_dir($encoded)) {
$result = mkdir($encoded, 0755, true);
}
if (is_dir($encoded)) {
$result = true;
// needed for empty directories
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->_encoded), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $f) {
if ($f->isDir()) {
$path = $encoded . '/' . $iterator->getSubPathName();
if (!is_dir($path)) {
$result = mkdir($path);
}
} else {
$result = copy($f, $encoded . '/' . $iterator->getSubPathName());
}
if ($result === false) {
break;
}
}
}
if ($result) {
$this->setPath($target);
}
return $result;
}
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:31,代码来源:folder.php
示例17: _createIterator
/**
* Creates an iterator with settings
* Resets class-wide results
*
* @param $items array
*
* @return object \RecursiveIteratorIterator
*/
protected function _createIterator(array $items)
{
$this->result = [];
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($items));
$iterator->setMaxDepth($this->max_depth);
return $iterator;
}
开发者ID:JREAM,项目名称:php-recursive,代码行数:15,代码来源:AbstractBase.php
示例18: main
/**
* Executes this task.
*/
public function main()
{
if ($this->property === null) {
throw new BuildException('The property attribute must be specified');
}
if ($this->path === null) {
throw new BuildException('The path attribute must be specified');
}
$check = new AgaviModuleFilesystemCheck();
$check->setConfigDirectory($this->project->getProperty('module.directory.config'));
$check->setPath($this->path->getAbsolutePath());
if (!$check->check()) {
throw new BuildException('The path attribute must be a valid module base directory');
}
$actions = array();
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath() . DIRECTORY_SEPARATOR . $this->project->getProperty('module.directory.actions')));
for (; $iterator->valid(); $iterator->next()) {
$rdi = $iterator->getInnerIterator();
if ($rdi->isDot() || !$rdi->isFile()) {
continue;
}
$file = $rdi->getSubpathname();
if (preg_match('#Action\\.class\\.php$#', $file)) {
$actions[] = str_replace(DIRECTORY_SEPARATOR, '.', substr($file, 0, -16));
}
}
$list = new AgaviArraytostringTransform();
$list->setInput($actions);
$list->setDelimiter(' ');
$this->project->setUserProperty($this->property, $list->transform());
}
开发者ID:philippjenni,项目名称:icinga-web,代码行数:34,代码来源:AgaviListactionsTask.php
示例19: copyFile
function copyFile($source, $dest)
{
$is_dot = array('.', '..');
if (is_dir($source)) {
if (version_compare((double) phpversion(), (double) '5.3', '<')) {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
} else {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
}
foreach ($iterator as $file) {
if (version_compare((double) phpversion(), (double) '5.2.17', '<=')) {
if (in_array($file->getBasename(), $is_dot)) {
continue;
}
} elseif (version_compare((double) phpversion(), (double) '5.3', '<')) {
if ($file->isDot()) {
continue;
}
}
if ($file->isDir()) {
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), true);
} else {
copy($file, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
}
unset($iterator, $file);
} else {
copy($source, $dest);
}
return true;
}
开发者ID:johnulist,项目名称:autoindex,代码行数:31,代码来源:index.php
示例20: copy
/**
* Copies a file or directory.
* @return void
* @throws Nette\IOException
*/
public static function copy($source, $dest, $overwrite = TRUE)
{
if (stream_is_local($source) && !file_exists($source)) {
throw new Nette\IOException("File or directory '{$source}' not found.");
} elseif (!$overwrite && file_exists($dest)) {
throw new Nette\InvalidStateException("File or directory '{$dest}' already exists.");
} elseif (is_dir($source)) {
static::createDir($dest);
foreach (new \FilesystemIterator($dest) as $item) {
static::delete($item);
}
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
if ($item->isDir()) {
static::createDir($dest . '/' . $iterator->getSubPathName());
} else {
static::copy($item, $dest . '/' . $iterator->getSubPathName());
}
}
} else {
static::createDir(dirname($dest));
if (@stream_copy_to_stream(fopen($source, 'r'), fopen($dest, 'w')) === FALSE) {
// @ is escalated to exception
throw new Nette\IOException("Unable to copy file '{$source}' to '{$dest}'.");
}
}
}
开发者ID:Richmond77,项目名称:learning-nette,代码行数:31,代码来源:FileSystem.php
注:本文中的RecursiveIteratorIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论