Source for file callback.php

Documentation is available at callback.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Log
  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! Callback Log class
  14.  *
  15.  * This class allows logging to be handled by a callback function.
  16.  * This allows unprecedented flexibility in the way logging can be handled.
  17.  *
  18.  * @package     Joomla.Platform
  19.  * @subpackage  Log
  20.  * @since       12.2
  21.  */
  22. {
  23.     /**
  24.      * @var    callable  The function to call when an entry is added - should return True on success
  25.      * @since  12.2
  26.      */
  27.     protected $callback;
  28.  
  29.     /**
  30.      * Constructor.
  31.      *
  32.      * @param   array  &$options  Log object options.
  33.      *
  34.      * @since   12.2
  35.      */
  36.     public function __construct(array &$options)
  37.     {
  38.         // Call the parent constructor.
  39.         parent::__construct($options);
  40.  
  41.         // Throw an exception if there is not a valid callback
  42.         if (isset($this->options['callback']&& is_callable($this->options['callback']))
  43.         {
  44.             $this->callback = $this->options['callback'];
  45.         }
  46.         else
  47.         {
  48.             throw new JLogException(JText::_('JLogLoggerCallback created without valid callback function.'));
  49.         }
  50.     }
  51.  
  52.     /**
  53.      * Method to add an entry to the log.
  54.      *
  55.      * @param   JLogEntry  $entry  The log entry object to add to the log.
  56.      *
  57.      * @return  boolean  True on success.
  58.      *
  59.      * @since   12.2
  60.      * @throws  LogException
  61.      */
  62.     public function addEntry(JLogEntry $entry)
  63.     {
  64.         // Pass the log entry to the callback function
  65.         call_user_func($this->callback$entry);
  66.     }
  67. }

Documentation generated on Tue, 19 Nov 2013 14:55:00 +0100 by phpDocumentor 1.4.3