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


PHP Event::subject方法代码示例

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


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

示例1: getFooter

 /**
  * Method that adds footer element to the Layout.
  *
  * @param  Cake\Event\Event $event Event object
  * @return void
  */
 public function getFooter(Event $event)
 {
     if (!$event->subject()->elementExists(static::ELEMENT_FOOTER)) {
         return;
     }
     $event->result = $event->subject()->element(static::ELEMENT_FOOTER);
 }
开发者ID:QoboLtd,项目名称:cakephp-qobo-admin-panel,代码行数:13,代码来源:LayoutListener.php

示例2: _prettifyEntity

 /**
  * Method that prepares entity to run through pretiffy logic.
  *
  * @param  \Cake\ORM\Entity  $entity Entity
  * @param  \Cake\Event\Event $event  Event instance
  * @return void
  */
 protected function _prettifyEntity(Entity $entity, Event $event)
 {
     if (!in_array($event->subject()->request->query('format'), [static::FORMAT_PRETTY])) {
         return;
     }
     $this->_prettify($entity, $event->subject()->{$event->subject()->name}, []);
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:14,代码来源:ViewViewListener.php

示例3: construct

 public function construct(Event $event)
 {
     // @codingStandardsIgnoreEnd
     // @codingStandardsIgnoreStart
     // CakePHP specific tags
     $event->subject()->getTwig()->addTokenParser(new TokenParser\Cell());
     $event->subject()->getTwig()->addTokenParser(new TokenParser\Element());
     // @codingStandardsIgnoreEnd
 }
开发者ID:Adnan0703,项目名称:TwigView,代码行数:9,代码来源:TokenParsersListener.php

示例4: getMyHead

 /**
  * getMyHead method
  *
  * In case we're operating with dynamic CSV tables,
  * we want to overwrite the page title to be used as moduleAlias().
  *
  * @param Cake\Event\Event $event used for getting reports
  * @return void
  */
 public function getMyHead(Event $event)
 {
     $table = TableRegistry::get($event->subject()->request['controller']);
     if ($table) {
         if (method_exists($table, 'moduleAlias') && is_callable([$table, 'moduleAlias'])) {
             $event->subject()->assign('title', $table->moduleAlias());
         }
     }
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:18,代码来源:LayoutListener.php

示例5: beforePaginate

 /**
  * Automatically parse and contain related table classes
  *
  * @param \Cake\Event\Event $event Before paginate event
  * @return void
  */
 public function beforePaginate(Event $event)
 {
     $contained = $event->subject()->query->contain();
     if (!empty($contained)) {
         return;
     }
     $models = $this->models();
     if (empty($models)) {
         return;
     }
     $event->subject()->query->contain(array_keys($models));
 }
开发者ID:AmuseXperience,项目名称:api,代码行数:18,代码来源:RelatedModelsListener.php

示例6: shutdown

 /**
  * Data collection callback.
  *
  * @param \Cake\Event\Event $event The shutdown event.
  * @return void
  */
 public function shutdown(Event $event)
 {
     $controller = $event->subject();
     /* @var \Cake\Network\Request $request */
     $request = $controller ? $controller->request : null;
     $this->_data = ['matchedRoute' => $request ? $request->param('_matchedRoute') : null];
 }
开发者ID:cakephp,项目名称:debug_kit,代码行数:13,代码来源:RoutesPanel.php

示例7: seoToHtml

 /**
  * Set To Html
  *
  * @param Cake\Event\Event $event Event
  * @return mixed void or null if no uri founded
  */
 public function seoToHtml(Event $event)
 {
     if (array_key_exists('prefix', $this->_controller->request->params) && in_array($this->_controller->request->params['prefix'], $this->config('excludePrefix'))) {
         return;
     }
     $uri = $this->getUriDatas();
     if (!$uri) {
         return null;
     }
     $event->subject()->assign('title', $this->getTitle($uri));
     if ($uri->seo_meta_tags) {
         $metas = $this->getMetaTags($uri->seo_meta_tags);
         $event->subject()->append('meta', implode('', $metas));
     }
     $event->subject()->prepend('meta', $this->getCanonicalTag($uri));
 }
开发者ID:orgasmicnightmare,项目名称:cakephp-seo,代码行数:22,代码来源:SeoComponent.php

示例8: shutdown

 /**
  * Shutdown event
  *
  * @param \Cake\Event\Event $event The event
  * @return void
  */
 public function shutdown(Event $event)
 {
     $controller = $event->subject();
     $errors = [];
     $walker = function (&$item) use(&$walker) {
         if ($item instanceof Query || $item instanceof ResultSet) {
             $item = $item->toArray();
         } elseif ($item instanceof Closure || $item instanceof PDO || $item instanceof SimpleXmlElement) {
             $item = 'Unserializable object - ' . get_class($item);
         } elseif ($item instanceof Exception) {
             $item = sprintf('Unserializable object - %s. Error: %s in %s, line %s', get_class($item), $item->getMessage(), $item->getFile(), $item->getLine());
         } elseif (is_object($item) && method_exists($item, '__debugInfo')) {
             // Convert objects into using __debugInfo.
             $item = array_map($walker, $item->__debugInfo());
         }
         return $item;
     };
     // Copy so viewVars is not mutated.
     $vars = $controller->viewVars;
     array_walk_recursive($vars, $walker);
     foreach ($vars as $k => $v) {
         // Get the validation errors for Entity
         if ($v instanceof EntityInterface) {
             $errors[$k] = $this->_getErrors($v);
         } elseif ($v instanceof Form) {
             $formError = $v->errors();
             if (!empty($formError)) {
                 $errors[$k] = $formError;
             }
         }
     }
     $this->_data = ['content' => $vars, 'errors' => $errors];
 }
开发者ID:franky0930,项目名称:MarketingConnex,代码行数:39,代码来源:VariablesPanel.php

示例9: injectEditor

 public function injectEditor(Event $event, $layoutFile)
 {
     $_view = $event->subject();
     $content = $_view->fetch('content');
     if (Configure::read('Editorial.autoload')) {
         $searchClass = Configure::read('Editorial.autoload');
         if (empty($searchClass)) {
             $searchClass = 'editor';
         }
         $plugin = Configure::read('Editorial.editor');
         list($vendor, $class) = $this->vendorSplit($plugin);
         $searchRegex = '/(<textarea.*class\\=\\".*' . Configure::read('Editorial.class') . '.*\\"[^>]*>.*<\\/textarea>)/isU';
         //preg_match_all($searchRegex, $content, $matches);
         //debug($matches);
         if (Plugin::loaded($plugin) !== false && preg_match_all($searchRegex, $content, $matches)) {
             if (!$_view->helpers()->has('Editor')) {
                 $options['className'] = $class . '.' . $class;
                 if ($vendor) {
                     $options['className'] = $vendor . '/' . $options['className'];
                 }
                 $options['options'] = $plugin . '.defaults';
                 if ($editorDefaults = Configure::read('Editorial.' . $class . '.defaults')) {
                     $options['options'] = $editorDefaults;
                 }
                 $_view->loadHelper('Editor', $options);
                 $_view->Editor->initialize();
             }
             $_view->Editor->connect($content);
         }
     }
 }
开发者ID:mindforce,项目名称:cakephp-editorial,代码行数:31,代码来源:EditorialEvent.php

示例10: beforeFilter

 /**
  * Callback
  *
  * @param \Cake\Event\Event $event
  * @return \Cake\Network\Response|array|null
  */
 public function beforeFilter(Event $event)
 {
     $this->Controller = $event->subject();
     if (!$this->config('enabled')) {
         return null;
     }
     if ($actions = $this->config('actions')) {
         $action = !empty($this->Controller->request->params['action']) ? $this->Controller->request->params['action'] : '';
         if (!in_array($action, $actions)) {
             return null;
         }
     }
     $this->Controller->request->params['isJson'] = isset($this->Controller->request->params['url']['_ext']) && $this->Controller->request->params['url']['_ext'] === 'json';
     $modelName = $this->config('modelName');
     if (empty($modelName)) {
         $modelName = $this->Controller->modelClass;
     }
     list(, $modelName) = pluginSplit($modelName);
     $this->config('modelName', $modelName);
     if (!$this->Controller->{$modelName}->behaviors()->has('Ratable')) {
         $this->Controller->{$modelName}->behaviors()->load('Ratings.Ratable', $this->_config);
     }
     $this->Controller->helpers[] = 'Ratings.Rating';
     $params = $this->request->data + $this->request->query + $this->_config['params'];
     if (!method_exists($this->Controller, 'rate')) {
         if (isset($params['rate']) && isset($params['rating'])) {
             $userId = $this->config('userId') ?: $this->Controller->Auth->user($this->config('userIdField'));
             return $this->rate($params['rate'], $params['rating'], $userId, $params['redirect']);
         }
     }
 }
开发者ID:dereuromark,项目名称:cakephp-ratings,代码行数:37,代码来源:RatingsComponent.php

示例11: checkRecordAccess

 /**
  * Check
  *
  * @param \Cake\Event\Event $event The beforeFind event that was fired.
  * @param \Cake\ORM\Query $query Query
  * @param \ArrayObject $options The options for the query
  * @return void
  */
 public function checkRecordAccess(Event $event, Query $query, ArrayObject $options)
 {
     $table = TableRegistry::get('RolesCapabilities.Capabilities');
     // current request parameters
     $request = $table->getCurrentRequest();
     // skip if current model does not match request's model
     if (array_diff(pluginSplit($event->subject()->registryAlias()), [$request['plugin'], $request['controller']])) {
         return;
     }
     // get capability owner type identifier
     $type = $table->getTypeOwner();
     // get user's action capabilities
     $userActionCapabilities = $table->getUserActionCapabilities();
     // skip if no user's action capabilities found or no user's action
     // owner specific capabilities found for current request's action
     if (empty($userActionCapabilities)) {
         return;
     }
     if (!isset($userActionCapabilities[$request['plugin']][$request['controller']][$request['action']][$type])) {
         return;
     }
     // set query where clause based on user's owner capabilities assignment fields
     foreach ($userActionCapabilities[$request['plugin']][$request['controller']][$request['action']][$type] as $userActionCapability) {
         $query->where([$userActionCapability->getField() => $table->getCurrentUser('id')]);
     }
 }
开发者ID:QoboLtd,项目名称:cakephp-roles-capabilities,代码行数:34,代码来源:ModelBeforeFindEventsListener.php

示例12: beforeFiler

 /**
  * beforeFilter initTabsItems
  *
  * @param Cake/Event/Event $event Event
  * @return void
  */
 public function beforeFiler(Event $event)
 {
     $this->setController($event->subject());
     if (method_exists($this->Controller, 'initTabsItems')) {
         $this->Controller->initTabsItems($event);
     }
 }
开发者ID:crabstudio,项目名称:app,代码行数:13,代码来源:TabsComponent.php

示例13: onSuccessRegister

 /**
  * Send an activation link on success registered user
  * @param Event $event
  */
 public function onSuccessRegister(Event $event)
 {
     $controller = $event->subject();
     $user = $event->data['user'];
     $controller->_sendActivationEmail($user)->template('Bazibartar.register')->subject('فعال سازی حساب کاربری')->send();
     $controller->Flash->success(__d('users', 'you are success register, and an activation email has been send, check your email'));
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:11,代码来源:UsersEventHandler.php

示例14: startup

 /**
  * Startup callback.
  *
  * @param Event $event
  */
 public function startup(Event $event)
 {
     if (!$event->subject()->isAdmin()) {
         $this->__setForLayout();
         $this->__createModules();
     }
 }
开发者ID:Cheren,项目名称:union,代码行数:12,代码来源:ModuleComponent.php

示例15: shutdown

 /**
  * Data collection callback.
  *
  * @param \Cake\Event\Event $event The shutdown event.
  * @return void
  */
 public function shutdown(Event $event)
 {
     /* @var Controller $controller */
     $controller = $event->subject();
     $request = $controller->request;
     $this->_data = ['params' => $request->params, 'query' => $request->query, 'data' => $request->data, 'cookie' => $request->cookies, 'get' => $_GET, 'matchedRoute' => $request->param('_matchedRoute'), 'headers' => ['response' => headers_sent($file, $line), 'file' => $file, 'line' => $line]];
 }
开发者ID:cakephp,项目名称:debug_kit,代码行数:13,代码来源:RequestPanel.php


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