From 2c5d98f1666f92f1692e9a92b32d4c224c6d4829 Mon Sep 17 00:00:00 2001 From: Craig Davis Date: Mon, 28 Apr 2014 10:09:45 -0500 Subject: [PATCH] Change template list to DirectoryIterator. Closes #24 The glob directory iterator is not compatible with the phar file. The DirectoryIterator appears to be able to handle it in both dev mode and deployed phar. --- src/Resume/Command/TemplatesCommand.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Resume/Command/TemplatesCommand.php b/src/Resume/Command/TemplatesCommand.php index 9919a31..bec4b60 100644 --- a/src/Resume/Command/TemplatesCommand.php +++ b/src/Resume/Command/TemplatesCommand.php @@ -18,11 +18,16 @@ class TemplatesCommand extends Command { $this->app = $this->getApplication(); $tplData = array('templates' => array()); - foreach (glob($this->app->templatePath . '/*', GLOB_ONLYDIR) as $dir) { + foreach (new \DirectoryIterator($this->app->templatePath) as $fileInfo) { + if ($fileInfo->isDot() || !$fileInfo->isDir()) { + continue; + } + $descriptionPath = $fileInfo->getPathname() . '/description.txt'; + print $descriptionPath . "\n"; $tplData['templates'][] = (object) array( - 'name' => basename($dir), - 'description' => file_exists($dir . '/description.txt') - ? trim(file_get_contents($dir . '/description.txt')) + 'name' => $fileInfo->getBasename(), + 'description' => file_exists($descriptionPath) + ? trim(file_get_contents($descriptionPath)) : 'No description available' ); }