本文整理汇总了PHP中yii\helpers\FileHelper::exist方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::exist方法的具体用法?PHP FileHelper::exist怎么用?PHP FileHelper::exist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\FileHelper
的用法示例。
在下文中一共展示了FileHelper::exist方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadActiveModules
public function loadActiveModules($isAdmin)
{
$moduleManager = LuLu::getService('modularityService');
$this->activeModules = $moduleManager->getActiveModules($isAdmin);
$module = $isAdmin ? 'AdminModule' : 'HomeModule';
foreach ($this->activeModules as $m)
{
$moduleId = $m['id'];
$moduleDir = $m['dir'];
$ModuleClassName = $m['dir_class'];
$this->setModule($moduleId, [
'class' => 'source\modules\\' . $moduleDir . '\\' . $module
]);
$serviceFile= LuLu::getAlias('@source').'\modules\\' .$moduleDir.'\\'.$ModuleClassName.'Service.php';
if(FileHelper::exist($serviceFile))
{
$serviceClass = 'source\modules\\' .$moduleDir.'\\'.$ModuleClassName.'Service.php';
$serviceInstance = new $serviceClass();
$this->set($serviceInstance->getServiceId(), $serviceInstance);
}
}
}
示例2: checkHomeThemeFile
public static function checkHomeThemeFile($fileName, $checkDefault = true)
{
$currentTheme = Resource::getHomeTheme();
$path = LuLu::getAlias('statics') . '/themes/' . $currentTheme . $fileName . '.php';
if (!FileHelper::exist($path) && $checkDefault) {
$currentTheme = 'd';
$path = LuLu::getAlias('statics') . '/themes/' . $currentTheme . $fileName . '.php';
} else {
return $currentTheme;
}
if (!FileHelper::exist($path)) {
return false;
}
return $currentTheme;
}
示例3: loadAllModules
private function loadAllModules()
{
if ($this->allModules !== null) {
return $this->allModules;
}
$this->allModules = [];
$moduleRootPath = LuLu::getAlias('@source') . '/modules';
if ($moduleRootDir = @dir($moduleRootPath)) {
while (($moduleFolder = $moduleRootDir->read()) !== false) {
$currentModuleDir = $moduleRootPath . '/' . $moduleFolder;
if (preg_match('|^\\.+$|', $moduleFolder) || !is_dir($currentModuleDir)) {
continue;
}
$moduleClassName = ucwords($moduleFolder);
if (FileHelper::exist($currentModuleDir . '/' . $moduleClassName . 'Info.php')) {
$class = 'source\\modules\\' . $moduleFolder . '\\' . $moduleClassName . 'Info';
} else {
continue;
}
$instance = null;
try {
// $moduleObj = LuLu::createObject($class);
$instance = new $class();
if (empty($instance->id)) {
$instance->id = $moduleFolder;
}
if (empty($instance->name)) {
$instance->name = $moduleFolder;
}
} catch (Exception $e) {
$instance = null;
}
if ($instance !== null) {
$has_admin = FileHelper::exist($currentModuleDir . '/admin/AdminModule.php') ? true : false;
$has_home = FileHelper::exist($currentModuleDir . '/home/HomeModule.php') ? true : false;
$this->allModules[$instance->id] = ['id' => $instance->id, 'dir' => $moduleFolder, 'dir_class' => $moduleClassName, 'class' => $class, 'instance' => $instance, 'can_install' => true, 'can_uninstall' => true, 'has_admin' => $has_admin, 'has_home' => $has_home, 'can_active_admin' => false, 'can_active_home' => false];
}
}
}
return $this->allModules;
}
示例4: executeSql
private function executeSql($db, $file)
{
$file = LuLu::getAlias('@data/sql') . '/' . $file . '.sql';
if (!FileHelper::exist($file)) {
self::_appendLog('SQL文件:' . $file . '不存在', true);
return false;
}
$tbPre = $db->tablePrefix;
$content = @file_get_contents($file);
$sqls = self::_splitsql($content);
if (is_array($sqls)) {
foreach ($sqls as $sql) {
if (trim($sql) != '') {
$db->createCommand(str_replace('#@__', $tbPre, $sql))->execute();
}
}
} else {
$db->createCommand(str_replace('#@__', $tbPre, $sql))->execute();
}
return true;
}