Source for file base.php

Documentation is available at base.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Application
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Joomla Platform Base Application Class
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Application
  17.  * @since       12.1
  18.  */
  19. abstract class JApplicationBase
  20. {
  21.     /**
  22.      * The application dispatcher object.
  23.      *
  24.      * @var    JEventDispatcher 
  25.      * @since  12.1
  26.      */
  27.     protected $dispatcher;
  28.  
  29.     /**
  30.      * The application identity object.
  31.      *
  32.      * @var    JUser 
  33.      * @since  12.1
  34.      */
  35.     protected $identity;
  36.  
  37.     /**
  38.      * The application input object.
  39.      *
  40.      * @var    JInput 
  41.      * @since  12.1
  42.      */
  43.     public $input = null;
  44.  
  45.     /**
  46.      * Method to close the application.
  47.      *
  48.      * @param   integer  $code  The exit code (optional; default is 0).
  49.      *
  50.      * @return  void 
  51.      *
  52.      * @codeCoverageIgnore
  53.      * @since   12.1
  54.      */
  55.     public function close($code 0)
  56.     {
  57.         exit($code);
  58.     }
  59.  
  60.     /**
  61.      * Get the application identity.
  62.      *
  63.      * @return  mixed  A JUser object or null.
  64.      *
  65.      * @since   12.1
  66.      */
  67.     public function getIdentity()
  68.     {
  69.         return $this->identity;
  70.     }
  71.  
  72.     /**
  73.      * Registers a handler to a particular event group.
  74.      *
  75.      * @param   string    $event    The event name.
  76.      * @param   callable  $handler  The handler, a function or an instance of a event object.
  77.      *
  78.      * @return  JApplicationBase  The application to allow chaining.
  79.      *
  80.      * @since   12.1
  81.      */
  82.     public function registerEvent($event$handler)
  83.     {
  84.         if ($this->dispatcher instanceof JEventDispatcher)
  85.         {
  86.             $this->dispatcher->register($event$handler);
  87.         }
  88.  
  89.         return $this;
  90.     }
  91.  
  92.     /**
  93.      * Calls all handlers associated with an event group.
  94.      *
  95.      * @param   string  $event  The event name.
  96.      * @param   array   $args   An array of arguments (optional).
  97.      *
  98.      * @return  array   An array of results from each function call, or null if no dispatcher is defined.
  99.      *
  100.      * @since   12.1
  101.      */
  102.     public function triggerEvent($eventarray $args null)
  103.     {
  104.         if ($this->dispatcher instanceof JEventDispatcher)
  105.         {
  106.             return $this->dispatcher->trigger($event$args);
  107.         }
  108.  
  109.         return null;
  110.     }
  111.  
  112.     /**
  113.      * Allows the application to load a custom or default dispatcher.
  114.      *
  115.      * The logic and options for creating this object are adequately generic for default cases
  116.      * but for many applications it will make sense to override this method and create event
  117.      * dispatchers, if required, based on more specific needs.
  118.      *
  119.      * @param   JEventDispatcher  $dispatcher  An optional dispatcher object. If omitted, the factory dispatcher is created.
  120.      *
  121.      * @return  JApplicationBase This method is chainable.
  122.      *
  123.      * @since   12.1
  124.      */
  125.     public function loadDispatcher(JEventDispatcher $dispatcher null)
  126.     {
  127.         $this->dispatcher ($dispatcher === nullJEventDispatcher::getInstance($dispatcher;
  128.  
  129.         return $this;
  130.     }
  131.  
  132.     /**
  133.      * Allows the application to load a custom or default identity.
  134.      *
  135.      * The logic and options for creating this object are adequately generic for default cases
  136.      * but for many applications it will make sense to override this method and create an identity,
  137.      * if required, based on more specific needs.
  138.      *
  139.      * @param   JUser  $identity  An optional identity object. If omitted, the factory user is created.
  140.      *
  141.      * @return  JApplicationBase This method is chainable.
  142.      *
  143.      * @since   12.1
  144.      */
  145.     public function loadIdentity(JUser $identity null)
  146.     {
  147.         $this->identity ($identity === nullJFactory::getUser($identity;
  148.  
  149.         return $this;
  150.     }
  151. }

Documentation generated on Tue, 19 Nov 2013 14:54:25 +0100 by phpDocumentor 1.4.3