本文整理汇总了PHP中Cms\Classes\Page::extend方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::extend方法的具体用法?PHP Page::extend怎么用?PHP Page::extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cms\Classes\Page
的用法示例。
在下文中一共展示了Page::extend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootBackend
/**
* Boot stuff for Backend
*
* @return void
*/
public function bootBackend()
{
Page::extend(function (Page $page) {
$handler = new PageHandler($page);
$page->bindEvent('model.beforeUpdate', function () use($handler) {
$handler->onBeforeUpdate();
});
$page->bindEvent('model.afterDelete', function () use($handler) {
$handler->onAfterDelete();
});
});
Event::listen('redirects.changed', function () {
PublishManager::instance()->publish();
});
}
示例2: register
public function register()
{
/*
* Defer event 2 levels deep to let others contribute before this registers.
*/
Event::listen('backend.form.extendFieldsBefore', function ($widget) {
$widget->bindEvent('form.extendFieldsBefore', function () use($widget) {
EventRegistry::instance()->registerFormFieldReplacements($widget);
});
});
/*
* Handle translated page URLs
*/
Page::extend(function ($page) {
$page->extendClassWith('RainLab\\Translate\\Behaviors\\TranslatablePageUrl');
});
}
示例3: fixValidations
public function fixValidations()
{
CmsPage::extend(function ($page) {
$page->rules['url'] = ['required', 'regex:/^\\/[۰-۹آا-یa-z0-9\\/\\:_\\-\\*\\[\\]\\+\\?\\|\\.\\^\\\\$]*$/iu'];
});
//edit blog url validation rule
if (PluginManager::instance()->exists('rainlab.blog')) {
\RainLab\Blog\Models\Post::extend(function ($post) {
$post->rules['slug'] = ['required', 'regex:/^[۰-۹آا-یa-z0-9\\/\\:_\\-\\*\\[\\]\\+\\?\\|]*$/iu', 'unique:rainlab_blog_posts'];
});
}
//extending rainlab.pages
if (PluginManager::instance()->exists('rainlab.pages')) {
//edit rainlab page url validation rule
\RainLab\Pages\Classes\Page::extend(function ($page) {
$page->rules['url'] = ['required', 'regex:/^\\/[۰-۹آا-یa-z0-9\\/_\\-]*$/iu', 'uniqueUrl'];
});
//edit rainlab page filename in crating
\RainLab\Pages\Classes\Page::creating(function ($page) {
$page->fileName = \Str::ascii($page->fileName);
}, -1);
}
}