eZ Publish  [trunk]
eznotificationtransport.php
Go to the documentation of this file.
00001 <?php
00002 /**
00003  * File containing the eZNotificationTransport class.
00004  *
00005  * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
00006  * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
00007  * @version //autogentag//
00008  * @package kernel
00009  */
00010 
00011 /*!
00012   \class eZNotificationTransport eznotificationtransport.php
00013   \brief The class eZNotificationTransport does
00014 
00015 */
00016 class eZNotificationTransport
00017 {
00018     /*!
00019      Constructor
00020     */
00021     function eZNotificationTransport()
00022     {
00023     }
00024 
00025     /**
00026      * Returns a shared instance of the eZNotificationTransport class.
00027      *
00028      *
00029      * @param string|false $transport Uses notification.ini[TransportSettings]DefaultTransport if false
00030      * @param bool $forceNewInstance
00031      * @return eZNotificationTransport
00032      */
00033     static function instance( $transport = false, $forceNewInstance = false )
00034     {
00035         $ini = eZINI::instance( 'notification.ini' );
00036         if ( $transport == false )
00037         {
00038             $transport = $ini->variable( 'TransportSettings', 'DefaultTransport' );
00039         }
00040         $transportImpl =& $GLOBALS['eZNotificationTransportGlobalInstance_' . $transport ];
00041         $class = $transportImpl !== null ? strtolower( get_class( $transportImpl ) ) : '';
00042 
00043         $fetchInstance = false;
00044         if ( !preg_match( '/.*?transport/', $class ) )
00045                 $fetchInstance = true;
00046 
00047         if ( $forceNewInstance  )
00048         {
00049             $fetchInstance = true;
00050         }
00051 
00052         if ( $fetchInstance )
00053         {
00054             $extraPluginPathArray = $ini->variable( 'TransportSettings', 'TransportPluginPath' );
00055             $pluginPathArray = array_merge( array( 'kernel/classes/notification/' ),
00056                                             $extraPluginPathArray );
00057             foreach( $pluginPathArray as $pluginPath )
00058             {
00059                 $transportFile = $pluginPath . $transport . 'notificationtransport.php';
00060                 if ( file_exists( $transportFile ) )
00061                 {
00062                     include_once( $transportFile );
00063                     $className = $transport . 'notificationtransport';
00064                     $impl = new $className( );
00065                     break;
00066                 }
00067             }
00068         }
00069         if ( !isset( $impl ) )
00070         {
00071             $impl = new eZNotificationTransport();
00072             eZDebug::writeError( 'Transport implementation not supported: ' . $transport, __METHOD__ );
00073         }
00074         return $impl;
00075     }
00076 
00077     function send( $address = array(), $subject, $body, $transportData = null )
00078     {
00079         return true;
00080     }
00081 }
00082 
00083 ?>