本文整理汇总了PHP中Filesystem::listContents方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::listContents方法的具体用法?PHP Filesystem::listContents怎么用?PHP Filesystem::listContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::listContents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadConfig
/**
* loadConfig
*
* @param string $name
* @access public
* @return void
*/
public function loadConfig($name = '')
{
$baseDir = PATH_APP . DS . 'config' . DS . 'search' . DS . 'types';
if ($name == '') {
$configFiles = Filesystem::listContents($baseDir);
$config = array();
foreach ($configFiles as $file) {
if (Filesystem::extension($baseDir . $file['path']) == 'php') {
$typeConfig = (require_once $baseDir . $file['path']);
array_push($config, $typeConfig);
}
}
return $config;
} elseif ($name != '') {
$filename = $baseDir . DS . $name . '.php';
if (Filesystem::exists($filename)) {
$config = (include $filename);
} else {
$config = false;
}
return $config;
}
return false;
}
示例2: editTask
/**
* Edit Newsletter Story Task
*
* @return void
*/
public function editTask()
{
//get request vars
$this->view->type = strtolower(Request::getVar("type", "primary"));
$this->view->id = Request::getInt("id", 0);
$this->view->sid = Request::getInt("sid", 0);
//load campaign
$this->view->newsletter = new Newsletter($this->database);
$this->view->newsletter->load($this->view->id);
//default object
$this->view->story = new stdClass();
$this->view->story->id = null;
$this->view->story->order = null;
$this->view->story->title = null;
$this->view->story->story = null;
$this->view->story->readmore_title = null;
$this->view->story->readmore_link = null;
//are we editing
if ($this->view->sid) {
if ($this->view->type == "primary") {
$this->view->story = new PrimaryStory($this->database);
} else {
$this->view->story = new SecondaryStory($this->database);
}
$this->view->story->load($this->view->sid);
}
// Set any errors
if ($this->getError()) {
$this->view->setError($this->getError());
}
// If we are creating an auto-generated newsletter
if ($this->view->type == 'autogen') {
// Load available sources
$this->view->enabledSources = Event::trigger('newsletter.onGetEnabledDigests');
/* It should be noted that these are not served via the CMS, per se. Rather they
* JavaScript will manipulate the DOM and save the HTML as a string into the Primary
* Story content field.
*/
// The path where the Story Template Layouts are.
$viewPath = dirname(__DIR__) . DS . 'views' . DS . 'storytemplates' . DS . 'tmpl';
// Get available layouts
$contents = Filesystem::listContents($viewPath);
// Empty bucket to hold layout names;
$this->view->layouts = array();
// Make sure we aren't including any cruft.
foreach ($contents as $file) {
// Check for php extention
if (Filesystem::extension($viewPath . DS . $file['path']) == 'php' && $file['path'] != '/index.php') {
// Some trimming of the leading / and the .php; push into bucket
array_push($this->view->layouts, rtrim(ltrim($file['path'], "//"), ".php"));
}
}
// Display the alternative layout
$this->view->setLayout('_autogen')->display();
} else {
// Output the HTML
$this->view->setLayout('edit')->display();
}
}
示例3: testNoop
public function testNoop()
{
$filesystem = new Filesystem(new Adapter\Local(__DIR__ . '/files'), new Cache\Noop());
$filesystem->write('test.txt', 'contents');
$this->assertTrue($filesystem->has('test.txt'));
$this->assertInternalType('array', $filesystem->listContents());
$cache = $filesystem->getCache();
$cache->setComplete('', false);
$cache->flush();
$cache->autosave();
$this->assertFalse($cache->isComplete('', false));
$this->assertFalse($cache->read('something'));
$this->assertFalse($cache->getMetadata('something'));
$this->assertFalse($cache->getMimetype('something'));
$this->assertFalse($cache->getSize('something'));
$this->assertFalse($cache->getTimestamp('something'));
$this->assertFalse($cache->getVisibility('something'));
$this->assertFalse($cache->listContents('', false));
$filesystem->delete('test.txt');
}