/**
  * Event for after Comments requests are updated in the application
  *
  * @param   Event  $event  Event object
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onCommentAfterUpdate(Event $event)
 {
     // Pull the arguments array
     $arguments = $event->getArguments();
     // Add a RTC label if the item is in that status
     $this->checkRTClabel($arguments['hookData'], $arguments['github'], $arguments['logger'], $arguments['project'], $arguments['table']);
 }
Ejemplo n.º 2
0
 /**
  * Event for after test is submitted in the application.
  *
  * @param   Event  $event  The Event object.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onTestAfterSubmit(Event $event)
 {
     // Pull the arguments array
     $arguments = $event->getArguments();
     $status = $this->getStatus($arguments['project'], $arguments['data']->testsSuccess, $arguments['data']->testsFailure, $arguments['issueNumber']);
     $this->createStatus($arguments['github'], $arguments['project'], $arguments['issueNumber'], $status);
 }
 /**
  * Event for after pull requests are updated in the application
  *
  * @param   Event  $event  Event object
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onPullAfterUpdate(Event $event)
 {
     // Pull the arguments array
     $arguments = $event->getArguments();
     // Place the JoomlaCode ID in the issue title if it isn't already there
     $this->updatePullTitle($arguments['hookData'], $arguments['github'], $arguments['logger'], $arguments['project'], $arguments['table']);
     // Add a RTC label if the item is in that status
     $this->addRTClabel($arguments['hookData'], $arguments['github'], $arguments['logger'], $arguments['project'], $arguments['table']);
 }
Ejemplo n.º 4
0
 /**
  * Event for after issues are created in the application
  *
  * @param   Event  $event  Event object
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onIssueAfterCreate(Event $event)
 {
     // Pull the arguments array
     $arguments = $event->getArguments();
     // Only perform these events if this is a new issue, action will be 'opened'
     if ($arguments['action'] === 'opened') {
         // Add a "no code" label
         $this->addCodelabel($arguments['hookData'], $arguments['github'], $arguments['logger'], $arguments['project']);
     }
 }
Ejemplo n.º 5
0
 /**
  * Test the offsetUnset method.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testOffsetUnset()
 {
     // No exception.
     unset($this->instance['foo']);
     $this->instance['foo'] = 'bar';
     unset($this->instance['foo']);
     $this->assertFalse($this->instance->hasArgument('foo'));
 }
 /**
  * Constructor
  *
  * @param   object  &$subject  The object to observe
  * @param   array   $config    An optional associative array of configuration settings.
  *                             Recognized key values include 'name', 'group', 'params', 'language'
  *                             (this list is not meant to be comprehensive).
  *
  * @since   11.1
  */
 public function __construct(&$subject, $config = array())
 {
     // Get the parameters.
     if (isset($config['params'])) {
         if ($config['params'] instanceof Registry) {
             $this->params = $config['params'];
         } else {
             $this->params = new Registry();
             $this->params->loadString($config['params']);
         }
     }
     // Get the plugin name.
     if (isset($config['name'])) {
         $this->_name = $config['name'];
     }
     // Get the plugin type.
     if (isset($config['type'])) {
         $this->_type = $config['type'];
     }
     parent::__construct($subject);
 }
Ejemplo n.º 7
0
 /**
  * Trigger an event.
  *
  * @param   EventInterface|string  $event  The event object or name.
  *
  * @return  EventInterface  The event after being passed through all listeners.
  *
  * @since   1.0
  */
 public function triggerEvent($event)
 {
     if (!$event instanceof EventInterface) {
         if (isset($this->events[$event])) {
             $event = $this->events[$event];
         } else {
             $event = new Event($event);
         }
     }
     if (isset($this->listeners[$event->getName()])) {
         foreach ($this->listeners[$event->getName()] as $listener) {
             if ($event->isStopped()) {
                 return $event;
             }
             if ($listener instanceof Closure) {
                 call_user_func($listener, $event);
             } else {
                 call_user_func(array($listener, $event->getName()), $event);
             }
         }
     }
     return $event;
 }
Ejemplo n.º 8
0
 /**
  * Listen to onSomething.
  *
  * @param   Event  $event  The event.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onSomething(Event $event)
 {
     $event->setArgument('listeners', array('first'));
 }
 /**
  * RegisterContentTypeFailureEvent constructor.
  *
  * @param   string      $type       The name of the content type
  * @param   \Exception  $exception  The exception
  */
 public function __construct($type, $exception)
 {
     parent::__construct('onRegisterContentTypeFailure', ['type' => $type, 'exception' => $exception]);
 }
 /**
  * RenderContentTypeSuccessEvent constructor.
  *
  * @param   string           $type    The name of the content type
  * @param   StreamInterface  $stream  The stream to which the content is added
  */
 public function __construct($type, $stream)
 {
     parent::__construct('onAfter' . $type, ['type' => $type, 'stream' => $stream]);
 }
 /**
  * DefinitionCreatedEvent constructor.
  *
  * @param   string        $entityClass The class of the entity
  * @param   Entity        $definition  The definition
  * @param   EntityBuilder $builder     The builder
  */
 public function __construct($entityClass, Entity $definition, EntityBuilder $builder)
 {
     parent::__construct('onDefinitionCreated', ['entityClass' => $entityClass, 'definition' => $definition, 'builder' => $builder]);
 }
 /**
  * DefinitionCreatedEvent constructor.
  *
  * @param   string        $entityName The name of the entity
  * @param   EntityBuilder $builder    The builder
  */
 public function __construct($entityName, EntityBuilder $builder)
 {
     parent::__construct('onCreateDefinition', ['className' => $entityName, 'builder' => $builder]);
 }
Ejemplo n.º 13
0
 /**
  * QueryDatabaseEvent constructor.
  *
  * @param   string       $entityClass The class of the entity
  * @param   QueryBuilder $builder     The query builder
  */
 public function __construct($entityClass, QueryBuilder $builder)
 {
     parent::__construct('onQueryDatabase', ['entityClass' => $entityClass, 'query' => $builder]);
 }
 /**
  * RegisterContentTypeEvent constructor.
  *
  * @param   string    $type     The name of the content type
  * @param   callable  $handler  The content type handler
  */
 public function __construct($type, $handler)
 {
     parent::__construct('onBeforeRegisterContentType', ['type' => $type, 'handler' => $handler]);
 }
Ejemplo n.º 15
0
 /**
  * Triggers an event if a listener is set.
  *
  * @param   string  $eventName  Name of the event to trigger.
  * @param   array   $arguments  Associative array of arguments for the event.
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function triggerEvent($eventName, array $arguments)
 {
     if (!$this->listenerSet) {
         return;
     }
     /* @type \JTracker\Application $application */
     $application = $this->getContainer()->get('app');
     $event = new Event($eventName);
     // Add default event arguments.
     $event->addArgument('github', $this->github ?: GithubFactory::getInstance($application))->addArgument('logger', $application->getLogger())->addArgument('project', $application->getProject());
     // Add event arguments passed as parameters.
     foreach ($arguments as $name => $value) {
         $event->addArgument($name, $value);
     }
     // Trigger the event.
     $this->dispatcher->triggerEvent($event);
 }
Ejemplo n.º 16
0
 /**
  * Triggers an event if a listener is set
  *
  * @param   string                 $eventName  Name of the event to trigger
  * @param   AbstractDatabaseTable  $table      Table object
  * @param   array                  $optional   Associative array of optional arguments for the event
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function triggerEvent($eventName, AbstractDatabaseTable $table, array $optional = array())
 {
     if ($this->listenerSet) {
         $event = new Event($eventName);
         // Add the event params
         $event->addArgument('hookData', $this->hookData)->addArgument('table', $table)->addArgument('github', $this->github)->addArgument('logger', $this->logger)->addArgument('project', $this->project);
         // Add optional params if present
         if (count($optional) > 0) {
             foreach ($optional as $name => $value) {
                 $event->addArgument($name, $value);
             }
         }
         // Trigger the event
         $this->dispatcher->triggerEvent($event);
     }
 }
 /**
  * RenderContentTypeFailureEvent constructor.
  *
  * @param   string      $type       The name of the content type
  * @param   \Exception  $exception  The exception
  */
 public function __construct($type, $exception)
 {
     parent::__construct('onRender' . $type . 'Failure', ['type' => $type, 'exception' => $exception]);
 }
 /**
  * RenderContentTypeEvent constructor.
  *
  * @param   string               $type     The name of the content type
  * @param   ContentTypeInterface $content  The content element
  */
 public function __construct($type, $content)
 {
     parent::__construct('onBeforeRender' . $type, ['type' => $type, 'content' => $content]);
 }
Ejemplo n.º 19
0
 /**
  * Constructor.
  *
  * @param   string            $name     The event name.
  * @param   SessionInterface  $session  The SessionInterface object for this event.
  *
  * @since   __DEPLOY_VERSION__
  */
 public function __construct($name, SessionInterface $session)
 {
     parent::__construct($name);
     $this->session = $session;
 }
Ejemplo n.º 20
0
 /**
  * Add argument to event. It will use a setter method if one exists. The setters have the signature:
  *
  * set<ArgumentName>($value): mixed
  *
  * where:
  *
  * $value  is the value being set by the user
  * It returns the value to return to set in the $arguments array of the event.
  *
  * @param   string  $name   Argument name.
  * @param   mixed   $value  Value.
  *
  * @return  $this
  *
  * @since   __DEPLOY_VERSION__
  */
 public function setArgument($name, $value)
 {
     $methodName = 'set' . ucfirst($name);
     if (method_exists($this, $methodName)) {
         $value = $this->{$methodName}($value);
     }
     return parent::setArgument($name, $value);
 }
Ejemplo n.º 21
0
 /**
  * Listen to onSomething.
  *
  * @param   Event  $event  The event.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function onSomething(Event $event)
 {
     $listeners = $event->getArgument('listeners');
     $listeners[] = 'third';
     $event->setArgument('listeners', $listeners);
 }