本文整理汇总了PHP中Cms\Classes\Page::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::save方法的具体用法?PHP Page::save怎么用?PHP Page::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cms\Classes\Page
的用法示例。
在下文中一共展示了Page::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTargetCmsPageRedirect
public function testTargetCmsPageRedirect()
{
$page = Page::load(Theme::getActiveTheme(), 'adrenth-redirect-testpage');
if ($page === null) {
$page = new Page();
$page->title = 'Testpage';
$page->url = '/adrenth/redirect/testpage';
$page->setFileNameAttribute('adrenth-redirect-testpage');
$page->save();
}
$redirect = new Redirect(['match_type' => Redirect::TYPE_EXACT, 'target_type' => Redirect::TARGET_TYPE_CMS_PAGE, 'from_url' => '/this-should-be-source', 'cms_page' => 'adrenth-redirect-testpage', 'requirements' => null, 'status_code' => 302, 'from_date' => Carbon::now(), 'to_date' => Carbon::now()->addWeek()]);
self::assertTrue($redirect->save());
$rule = RedirectRule::createWithModel($redirect);
self::assertInstanceOf(RedirectRule::class, $rule);
$manager = RedirectManager::createWithRule($rule);
self::assertInstanceOf(RedirectManager::class, $manager);
$result = $manager->match('/this-should-be-source');
self::assertInstanceOf(RedirectRule::class, $result);
self::assertEquals('http://localhost/adrenth/redirect/testpage', $manager->getLocation($result));
self::assertTrue($page->delete());
}
示例2: createPageFromFile
/**
* Creates a page using the contents of a specified file.
* @param string $filePath File containing page contents
* @param string $name New Page name
* @param string $settings Page settings
* @param string $themeCode Theme to create the page
* @return void
*/
protected function createPageFromFile($filePath, $name, $settings, $themeCode)
{
if (!File::exists($filePath)) {
return false;
}
$page = new Page($themeCode);
$page->fill(['fileName' => $name, 'markup' => File::get($filePath), 'settings' => $settings]);
$page->save();
return true;
}