Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Let's create a method to:

      1. A simplified way to call events
      2. Plugins having more control over the input and output of methods with events

      We could add the following method to the AppModel class:

          /**
           * Executes the given event
           *
           * @param string $event_name The name of the event to trigger
           * @param array $params The list of parameters to submit to the event handler
           * @return array The list of parameters that were submitted along with any modifications made to them
           *  by the event handlers.  In addition a __return__ item is included with the return array from the event.
           */
          protected function executeAndParseEvent($event_name, $params) {
              $eventFactory = $this->getFromContainer('util.events');
              $eventListener = $eventFactory->listener();
              $eventListener->register($event_name);
              $event = $eventListener->trigger(
                  $eventFactory->event($event_name, $params)
              );
      
              $return = ['__return__' => $event->getReturnValue()];
              $event_params = $event->getParams();
              if (is_array($event_params)) {
                  foreach ($event_params as $event_param => $data) {
                      if (array_key_exists($event_param, $params)) {
                          $return[$event_param] = $data;
                      }
                  }
              }
      
              return $return;
          }
      

        Activity

        jonathan Jonathan Reissmueller created issue -
        jonathan Jonathan Reissmueller made changes -
        Field Original Value New Value
        Fix Version/s 5.3.0-b1 [ 11711 ]
        jonathan Jonathan Reissmueller made changes -
        Assignee Jonathan Reissmueller [ jonathan ]
        jonathan Jonathan Reissmueller made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            jonathan Jonathan Reissmueller
            Reporter:
            jonathan Jonathan Reissmueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Agile