JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • AbstractEvent
  • DelegatingDispatcher
  • Dispatcher
  • Event
  • EventImmutable
  • ListenersPriorityQueue
  • Priority

Interfaces

  • DispatcherAwareInterface
  • DispatcherInterface
  • EventInterface

Traits

  • DispatcherAwareTrait
  1 <?php
  2 /**
  3  * Part of the Joomla Framework Event Package
  4  *
  5  * @copyright  Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
  6  * @license    GNU General Public License version 2 or later; see LICENSE
  7  */
  8 
  9 namespace Joomla\Event;
 10 
 11 use InvalidArgumentException;
 12 
 13 /**
 14  * Default Event class.
 15  *
 16  * @since  1.0
 17  */
 18 class Event extends AbstractEvent
 19 {
 20     /**
 21      * Add an event argument, only if it is not existing.
 22      *
 23      * @param   string  $name   The argument name.
 24      * @param   mixed   $value  The argument value.
 25      *
 26      * @return  Event  This method is chainable.
 27      *
 28      * @since   1.0
 29      */
 30     public function addArgument($name, $value)
 31     {
 32         if (!isset($this->arguments[$name]))
 33         {
 34             $this->arguments[$name] = $value;
 35         }
 36 
 37         return $this;
 38     }
 39 
 40     /**
 41      * Set the value of an event argument.
 42      * If the argument already exists, it will be overridden.
 43      *
 44      * @param   string  $name   The argument name.
 45      * @param   mixed   $value  The argument value.
 46      *
 47      * @return  Event  This method is chainable.
 48      *
 49      * @since   1.0
 50      */
 51     public function setArgument($name, $value)
 52     {
 53         $this->arguments[$name] = $value;
 54 
 55         return $this;
 56     }
 57 
 58     /**
 59      * Remove an event argument.
 60      *
 61      * @param   string  $name  The argument name.
 62      *
 63      * @return  mixed  The old argument value or null if it is not existing.
 64      *
 65      * @since   1.0
 66      */
 67     public function removeArgument($name)
 68     {
 69         $return = null;
 70 
 71         if (isset($this->arguments[$name]))
 72         {
 73             $return = $this->arguments[$name];
 74             unset($this->arguments[$name]);
 75         }
 76 
 77         return $return;
 78     }
 79 
 80     /**
 81      * Clear all event arguments.
 82      *
 83      * @return  array  The old arguments.
 84      *
 85      * @since   1.0
 86      */
 87     public function clearArguments()
 88     {
 89         $arguments = $this->arguments;
 90         $this->arguments = array();
 91 
 92         return $arguments;
 93     }
 94 
 95     /**
 96      * Stop the event propagation.
 97      *
 98      * @return  void
 99      *
100      * @since   1.0
101      */
102     public function stop()
103     {
104         $this->stopped = true;
105     }
106 
107     /**
108      * Set the value of an event argument.
109      *
110      * @param   string  $name   The argument name.
111      * @param   mixed   $value  The argument value.
112      *
113      * @return  void
114      *
115      * @throws  InvalidArgumentException  If the argument name is null.
116      *
117      * @since   1.0
118      */
119     public function offsetSet($name, $value)
120     {
121         if (is_null($name))
122         {
123             throw new InvalidArgumentException('The argument name cannot be null.');
124         }
125 
126         $this->setArgument($name, $value);
127     }
128 
129     /**
130      * Remove an event argument.
131      *
132      * @param   string  $name  The argument name.
133      *
134      * @return  void
135      *
136      * @since   1.0
137      */
138     public function offsetUnset($name)
139     {
140         $this->removeArgument($name);
141     }
142 }
143 
Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.