本文整理匯總了PHP中Cms\Classes\Theme::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Theme::exists方法的具體用法?PHP Theme::exists怎麽用?PHP Theme::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cms\Classes\Theme
的用法示例。
在下文中一共展示了Theme::exists方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fire
/**
* Execute the console command.
* @return void
*/
public function fire()
{
$themeName = $this->argument('name');
$argDirName = $this->argument('dirName');
if ($argDirName && $themeName == $argDirName) {
$argDirName = null;
}
if ($argDirName) {
if (!preg_match('/^[a-z0-9\\_\\-]+$/i', $argDirName)) {
return $this->error('Invalid destination directory name.');
}
if (Theme::exists($argDirName)) {
return $this->error(sprintf('A theme named %s already exists.', $argDirName));
}
}
try {
$themeManager = ThemeManager::instance();
$updateManager = UpdateManager::instance();
$themeDetails = $updateManager->requestThemeDetails($themeName);
if ($themeManager->isInstalled($themeDetails['code'])) {
return $this->error(sprintf('The theme %s is already installed.', $themeDetails['code']));
}
if (Theme::exists($themeDetails['code'])) {
return $this->error(sprintf('A theme named %s already exists.', $themeDetails['code']));
}
$fields = ['Name', 'Description', 'Author', 'URL', ''];
$this->info(sprintf(implode(': %s' . PHP_EOL, $fields), $themeDetails['code'], $themeDetails['description'], $themeDetails['author'], $themeDetails['product_url']));
if (!$this->confirm('Do you wish to continue? [Y|n]', true)) {
return;
}
$this->info('Downloading theme...');
$updateManager->downloadTheme($themeDetails['code'], $themeDetails['hash']);
$this->info('Extracting theme...');
$updateManager->extractTheme($themeDetails['code'], $themeDetails['hash']);
$dirName = $this->themeCodeToDir($themeDetails['code']);
if ($argDirName) {
/*
* Move downloaded theme to a new directory.
* Basically we're renaming it.
*/
File::move(themes_path() . '/' . $dirName, themes_path() . '/' . $argDirName);
/*
* Let's make sure to unflag the 'old' theme as
* installed so it can be re-installed later.
*/
$themeManager->setUninstalled($themeDetails['code']);
$dirName = $argDirName;
}
$this->info(sprintf('The theme %s has been installed. (now %s)', $themeDetails['code'], $dirName));
} catch (Exception $ex) {
$this->error($ex->getMessage());
}
}
示例2: fire
/**
* Execute the console command.
* @return void
*/
public function fire()
{
$themeManager = ThemeManager::instance();
$themeName = $this->argument('name');
$themeExists = Theme::exists($themeName);
if (!$themeExists) {
$themeName = strtolower(str_replace('.', '-', $themeName));
$themeExists = Theme::exists($themeName);
}
if (!$themeExists) {
return $this->error(sprintf('The theme %s does not exist.', $themeName));
}
if (!$this->confirmToProceed(sprintf('This will DELETE theme "%s" from the filesystem and database.', $themeName))) {
return;
}
try {
$themeManager->deleteTheme($themeName);
$this->info(sprintf('The theme %s has been deleted.', $themeName));
} catch (Exception $ex) {
$this->error($ex->getMessage());
}
}