Exemple #1
0
 /**
  * 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();
     });
 }
Exemple #2
0
 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');
     });
 }
Exemple #3
0
 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);
     }
 }