本文整理汇总了PHP中ClassLoader::getBaseDir方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::getBaseDir方法的具体用法?PHP ClassLoader::getBaseDir怎么用?PHP ClassLoader::getBaseDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::getBaseDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchData
public function fetchData()
{
$files = $this->getTransformedFiles();
$baseDir = ClassLoader::getBaseDir();
$query = $this->getOption('query');
$found = array();
foreach ($files as $file) {
if (strpos(file_get_contents($file['path']), $query) !== false) {
$found[] = array('id' => $file['id'], 'name' => basename($file['path']));
}
}
$count = count($found);
$ret = array();
$ret['records'] = array();
// $found;
$ret['count'] = $count;
$offset = $this->getOption('offset');
// pp($offset);
$ret['from'] = $offset;
if ($ret['from'] == '' || $ret['from'] < 0) {
$ret['from'] = 0;
}
$ret['to'] = $this->getOption('limit') + $offset;
// $ret['from'];
for ($i = $offset; $i < $ret['to'] && $i < $ret['count']; $i++) {
$ret['records'][] = $found[$i];
}
$diff = $ret['to'] - $ret['from'];
$c = count($ret['records']);
if ($diff != $c) {
$ret['to'] = $ret['from'] + $c;
}
$ret['from']++;
$ret['meta'] = array();
return $ret;
}
示例2: export
public function export()
{
require_once ClassLoader::getRealPath('library.pclzip') . '/pclzip.lib.php';
$id = $this->getRequest()->get('id');
$files = $this->getThemeFiles($id);
if ($files === null) {
return new ActionRedirectResponse('backend.theme', 'index');
}
do {
$path = ClassLoader::getRealPath('cache.tmp.theme_export_' . rand(1, 10000000));
} while (file_exists($path));
$zipFilePath = $path . '_archive.zip';
$confFilePath = $path . DIRECTORY_SEPARATOR . 'theme.conf';
foreach (array($zipFilePath, $confFilePath) as $fp) {
if (!is_dir(dirname($fp))) {
mkdir(dirname($fp), 0777, true);
}
}
file_put_contents($confFilePath, sprintf('[Theme]' . "\n" . 'name = %s', $id));
$archive = new PclZip($zipFilePath);
chdir(ClassLoader::getBaseDir());
$files[] = $confFilePath;
$archive->add($files, PCLZIP_OPT_REMOVE_PATH, $path);
$this->application->rmdir_recurse($path);
$response = new ObjectFileResponse(ObjectFile::getNewInstance('ObjectFile', $zipFilePath, $id . '.zip'));
$response->deleteFileOnComplete();
return $response;
}