getMethodFromAction() 공개 정적인 메소드

Transform an "action" token into a method name
public static getMethodFromAction ( string $action ) : string
$action string
리턴 string
예제 #1
0
 /**
  * @return type
  */
 public function getMethodName()
 {
     if (!$this->methodName) {
         $action = $this->getRouteMatch()->getParam('action', 'not-found');
         $this->setMethodName(AbstractController::getMethodFromAction($action));
     }
     return $this->methodName;
 }
예제 #2
0
 /**
  * Получение метаданных
  *
  * @param WorkflowDispatchEventInterface $e
  *
  * @return MetadataInterface|null
  */
 public function onLoadMetadataHandler(WorkflowDispatchEventInterface $e)
 {
     $mvcEvent = $e->getMvcEvent();
     $controller = $mvcEvent->getTarget();
     if (!$controller instanceof AbstractController) {
         $this->getLog()->notice('Unable to retrieve the metadata for scheduling workflow. No controller object in the property "target" MvcEvent.');
         return null;
     }
     $routeMatch = $mvcEvent->getRouteMatch();
     if (!$routeMatch) {
         $this->getLog()->notice('Unable to retrieve the metadata for scheduling workflow. Do not set RouteMatch');
         return null;
     }
     $action = $routeMatch->getParam('action', 'not-found');
     $actionMethod = AbstractController::getMethodFromAction($action);
     if (!method_exists($controller, $actionMethod)) {
         $this->getLog()->notice(sprintf('Unable to retrieve the metadata for scheduling workflow. There is no action(%s) in controller(%s)', $actionMethod, get_class($controller)));
         return null;
     }
     $controllerClassName = get_class($controller);
     $metadata = $this->getMetadataReader()->loadMetadataForAction($controllerClassName, $actionMethod);
     return $metadata;
 }
 /**
  * Определение entryId на основе параметров роута
  *
  * @param ResolveEntryIdEventInterface $event
  *
  * @return integer|null
  *
  * @throws Exception\InvalidMetadataException
  */
 public function onResolveEntryIdHandler(ResolveEntryIdEventInterface $event)
 {
     $this->getLog()->info('Getting the value "entryId" to run the Workflow based on the router settings');
     $mvcEvent = $event->getWorkflowDispatchEvent()->getMvcEvent();
     $controller = $mvcEvent->getTarget();
     if (!$controller instanceof AbstractController) {
         $this->getLog()->notice('Unable to get the value of "entryId" to start the workflow. No controller object in the property "target" MvcEvent.');
         return null;
     }
     $routeMatch = $mvcEvent->getRouteMatch();
     if (!$routeMatch) {
         return null;
     }
     $action = $routeMatch->getParam('action', 'not-found');
     $actionMethod = AbstractController::getMethodFromAction($action);
     if (!method_exists($controller, $actionMethod)) {
         $this->getLog()->notice('Unable to get the value of "entryId" to start the workflow. Do not set RouteMatch');
         return null;
     }
     $controllerClassName = get_class($controller);
     $metadata = $this->getMetadataReader()->loadMetadataForAction($controllerClassName, $actionMethod);
     if (!$metadata instanceof MetadataInterface) {
         $errMsg = sprintf('Metadata not implement %s', MetadataInterface::class);
         throw new Exception\InvalidMetadataException($errMsg);
     }
     $entryIdParam = $metadata->getEntryIdRouterParam();
     $entryId = $routeMatch->getParam($entryIdParam, null);
     $this->getLog()->info('Meaning "entryId" to run the Workflow based on the router settings', ['entryId' => $entryId]);
     return $entryId;
 }