当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::raise方法代码示例

本文整理汇总了PHP中Event::raise方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::raise方法的具体用法?PHP Event::raise怎么用?PHP Event::raise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event::raise方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * wrapper for delete
  *
  * @return ORM
  */
 public function delete()
 {
     // hook
     Event::raise($this, Event::BEFORE_DELETE, array('model' => $this));
     // delete
     $result = parent::delete();
     // hook
     Event::raise($this, Event::AFTER_DELETE, array('model' => $this));
     // return orm
     return $result;
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:16,代码来源:ORM.php

示例2: delete

 /**
  * Overwrite delete
  * dont check on owner id, as the entire tree will be gone
  * deleted is an array with items
  */
 protected function delete($model)
 {
     // check rights
     if (!Acl::instance()->allowed($this->_controller, 'delete', $model->owner_id, $model->website_id)) {
         throw HTTP_Exception::factory(403, 'Delete not allowed on :controller :id', array(':controller' => $this->_controller, ':id' => $model->id));
     }
     // call hook
     Event::raise($this, Event::BEFORE_DELETE, array('model' => $model));
     //delete
     $deleted = $model->delete();
     // call hook
     Event::raise($this, Event::AFTER_DELETE, array('deleted' => $deleted));
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:18,代码来源:Branch.php

示例3: action_module

 /**
  * Get module navigation
  */
 public function action_module()
 {
     // get request
     $request = Request::initial();
     // get settings
     $settings = Settings::factory($request->controller());
     // navigation viewer
     $navigation = Viewer::instance('Navigation')->settings($settings->get('navigation'))->request(Request::initial())->acl(Acl::instance());
     // create view
     $view = View::factory($settings->get('view.navigation'), array('navigation' => $navigation));
     // raise event
     Event::raise($this, Event::BEFORE_NAVIGATION_RENDER, array('navigation' => $navigation));
     // render view
     $this->response->body($view->render());
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:18,代码来源:Navigation.php

示例4: init

 /**
  * init
  */
 public function init()
 {
     // raise event
     Event::raise($this, Event::BEFORE_INIT);
     // get website and feed it the current uri so we can figure out the ->id()
     $website = Website::instance()->uri(Request::initial()->uri());
     // set controller vars
     $this->_website = $website->id();
     $this->_directory = Request::current()->directory();
     $this->_controller = Request::current()->controller();
     $this->_action = Request::current()->action();
     $this->_language = isset(Identity::instance()->user) ? Identity::instance()->user->language : 'nl';
     // manually set website in Website
     // this will be used by alias
     Website::instance()->id($this->_website);
     // set state session
     // get state instance for this website / controller
     State::session(Session::instance('database'));
     $this->_state = State::instance($this->_website . '.' . $this->_controller);
     // set route in URL helper
     URL::route('backend');
     // Let Filereader cache results
     Reader::cache(Cache::instance('reader_backend'), 'backend');
     // set default language
     Text::language($this->_language);
     // get that language's text instance and configure it
     Text::instance($this->_language)->load(array_keys(Settings::factory('modules')->as_array()))->group($this->_controller)->substitutes('module');
     // set URL presets
     $base = URL::base();
     URL::set('base', $base);
     URL::set('library', $base . 'library/');
     URL::set('vendor', $base . 'vendor/');
     URL::set('files', $base . 'files/');
     // set website in view
     View::set_global('_website', $this->_website);
     // set language in view
     View::set_global('_language', $this->_language);
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:41,代码来源:Base.php

示例5: copy

 /**
  * copy
  * 
  */
 protected function copy($model)
 {
     // check rights
     if (!Acl::instance()->allowed($this->_controller, 'copy', $model->owner_id, $model->website_id)) {
         throw HTTP_Exception::factory(403, 'Copy not allowed on :controller :id', array(':controller' => $this->_controller, ':id' => $model->id));
     }
     // create copied values
     $values = $model->as_array();
     unset($values['id']);
     $values['title'] = 'Copy ' . $values['title'];
     $values['owner_id'] = Identity::instance()->id;
     $values['editor_id'] = Identity::instance()->id;
     // create copy
     $copy = ORM::factory($this->_settings->get('model'));
     $copy->values($values);
     // call hook
     Event::raise($this, Event::BEFORE_COPY, array('model' => $model, 'copy' => $copy));
     // save copy
     $copy->save();
     // call hook
     Event::raise($this, Event::AFTER_COPY, array('model' => $model, 'copy' => $copy));
     // return copy
     return $copy;
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:28,代码来源:Item.php

示例6: markup

 /**
  * Form::markup()
  * add non functioning element to elements list
  * used for markup in the view
  * 
  * @param string $type
  * @param array $attributes
  * @return
  */
 public function markup($keyOrType, $typeOrSettings = array(), $settings = array())
 {
     // normalize
     if (is_array($typeOrSettings)) {
         $key = FALSE;
         $type = $keyOrType;
         $settings = $typeOrSettings;
     } else {
         $key = $keyOrType;
         $type = $typeOrSettings;
     }
     // raise hook
     Event::raise($this, Event::BEFORE_FORM_MARKUP, array('form' => $this, 'key' => $key, 'type' => $type, 'settings' => $settings));
     // create element
     $element = new stdClass();
     // store settings
     foreach ($settings as $var => $val) {
         $element->{$var} = $val;
     }
     // set default values
     $element->key = $key;
     $element->type = $type;
     $element->required = FALSE;
     $element->error = FALSE;
     $element->attributes = isset($settings['attributes']) ? $settings['attributes'] : array();
     $element->attributes['class'] = isset($element->attributes['class']) ? $element->attributes['class'] : '';
     // store element in list
     $this->_elements[] = $element;
     // rais hook
     Event::raise($this, Event::AFTER_FORM_MARKUP, array('form' => $this, 'element' => $element));
     // return it
     return $element;
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:42,代码来源:Form.php

示例7: store

 /**
  * create files in db
  */
 protected function store($form, $hash)
 {
     // get files in the temp/hash dir
     $files = FS::files($this->_settings->get('path_temp') . $hash . DIRECTORY_SEPARATOR);
     // set the files in the form
     $form->files($files);
     Event::raise($this, Event::BEFORE_STORE_FORM_PARSE, array('form' => $form));
     if ($form->valid()) {
         // get the hash of the temp dir from qs
         $hash = $this->request->param('id');
         // get the form values
         $values = $form->values();
         // loop through temp files
         for ($i = 0; $i < count($files); $i++) {
             // createmodel
             $model = ORM::factory($this->_settings->get('model'));
             // set group if one is active
             if ($group = $this->_state->get('group', FALSE)) {
                 $model->group_id = $group;
             }
             // undouble filename
             $file = FS::name_unique($files[$i], $this->_settings->get('path_files'));
             // store it
             FS::move($this->_settings->get('path_temp') . $hash . DIRECTORY_SEPARATOR . $files[$i], $this->_settings->get('path_files') . $file);
             // permissions
             FS::permissions($this->_settings->get('path_files') . $file, 0744);
             // set item properties
             $model->created = date('y-m-d H:i:s', time());
             $model->owner_id = Identity::instance()->id;
             $model->editor_id = Identity::instance()->id;
             $model->website_id = $this->_website;
             // set file
             $model->file = $file;
             // set additional info (mostly title)
             foreach ($values as $key => $value) {
                 if (is_array($value) && isset($value[$i])) {
                     $model->{$key} = $value[$i];
                 }
             }
             // call hook
             Event::raise($this, Event::BEFORE_STORE, array('model' => $model, 'form' => $form));
             //save
             $model->save();
             // call hook
             Event::raise($this, Event::AFTER_STORE, array('model' => $model, 'form' => $form));
         }
         // return true
         return TRUE;
     } else {
         // create viewer
         $viewer = Viewer::factory('Form', $form)->text(Text::instance());
         // render form
         $view = View::factory($this->_settings->get('view.create'), array('viewer' => $viewer));
         // event
         Event::raise($this, Event::BEFORE_STORE_RENDER, array('model' => NULL, 'form' => $form, 'viewer' => $viewer, 'view' => $view));
         // render
         $this->response->body($view->render());
         // return false
         return FALSE;
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:64,代码来源:File.php

示例8: queue

 /**
  * Queues an event to be dispatched later.
  *
  * @param string $eventName
  * @param ...$args
  */
 public function queue($eventName, $args = null)
 {
     $args = func_get_args();
     $eventArgs = array_splice($args, 1);
     \Event::raise($eventName, $eventArgs);
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:12,代码来源:EventGeneratorTrait.php


注:本文中的Event::raise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。