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


PHP CommandContext::getSubject方法代码示例

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


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

示例1: execute

 /**
  * Command handler
  *
  * This functions returns void to prevent is from breaking the chain.
  *
  * @param   string  $name    The command name
  * @param   object  $context The command context
  * @return  void
  */
 public function execute($name, CommandContext $context)
 {
     $type = '';
     if ($context->getSubject()) {
         $identifier = clone $context->getSubject()->getIdentifier();
         if ($identifier->path) {
             $type = array_shift($identifier->path);
         } else {
             $type = $identifier->name;
         }
     }
     $parts = explode('.', $name);
     $name = 'on' . ucfirst(array_shift($parts)) . ucfirst($type) . StringInflector::implode($parts);
     $event = new Event(clone $context);
     $event->setTarget($context->getSubject());
     $this->getEventDispatcher()->dispatchEvent($name, $event);
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:26,代码来源:event.php

示例2: execute

 /**
  * Command handler
  *
  * This function translates the command name to a command handler function of the format '_beforeController[Command]'
  * or '_afterController[Command]. Command handler functions should be declared protected.
  *
  * @param 	string           $name	    The command name
  * @param 	CommandContext  $context 	The command context
  * @return 	boolean Always returns TRUE
  */
 public final function execute($name, CommandContext $context)
 {
     $identifier = clone $context->getSubject()->getIdentifier();
     $type = array_shift($identifier->path);
     $parts = explode('.', $name);
     $method = '_' . $parts[0] . ucfirst($type) . ucfirst($parts[1]);
     if (method_exists($this, $method)) {
         $this->{$method}($context);
     }
     return true;
 }
开发者ID:janssit,项目名称:www.rvproductions.be,代码行数:21,代码来源:abstract.php

示例3: execute

 /**
  * Command handler
  *
  * @param   string           $name     The command name
  * @param   CommandContext  $context  The command context
  *
  * @return  mixed  Method result if the method exsist, NULL otherwise.
  */
 public function execute($name, CommandContext $context)
 {
     $type = '';
     $result = null;
     if ($context->getSubject()) {
         $identifier = clone $context->getSubject()->getIdentifier();
         if ($identifier->path) {
             $type = array_shift($identifier->path);
         } else {
             $type = $identifier->name;
         }
     }
     $parts = explode('.', $name);
     $method = !empty($type) ? '_' . $type . ucfirst(StringInflector::implode($parts)) : '_' . lcfirst(StringInflector::implode($parts));
     //If the method exists call the method and return the result
     if (in_array($method, $this->getMethods())) {
         $result = $this->{$method}($context);
     }
     return $result;
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:28,代码来源:command.php

示例4: execute

 /**
  * Command handler
  *
  * This function translated the command name to a command handler function of the format '_before[Command]' or
  * '_after[Command]. Command handler functions should be declared protected.
  *
  * @param   string          $name     The command name
  * @param   CommandContext  $context  The command context
  *
  * @return  mixed  Method result if the method exists, NULL otherwise.
  */
 public function execute($name, CommandContext $context)
 {
     $result = null;
     $identifier = clone $context->getSubject()->getIdentifier();
     $type = array_pop($identifier->path);
     $parts = explode('.', $name);
     $method = '_' . $parts[0] . ucfirst($type) . ucfirst($parts[1]);
     //If the method exists call the method and return the result
     if (method_exists($this, $method)) {
         $result = $this->{$method}($context);
     }
     return $result;
 }
开发者ID:janssit,项目名称:www.rvproductions.be,代码行数:24,代码来源:abstract.php


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