1<?php 2 3/** 4 * EasySwift Response Tracker 5 * Please read the LICENSE file 6 * @copyright Chris Corbyn <chris@w3style.co.uk> 7 * @author Chris Corbyn <chris@w3style.co.uk> 8 * @package EasySwift 9 * @license GNU Lesser General Public License 10 */ 11 12require_once dirname(__FILE__) . "/../ClassLoader.php"; 13Swift_ClassLoader::load("Swift_Events_ResponseListener"); 14 15/** 16 * EasySwift, Swift Response Tracker. 17 * Updates properties in EasySwift when a response is received by Swift. 18 * @package EasySwift 19 * @author Chris Corbyn <chris@w3style.co.uk> 20 */ 21class Swift_Plugin_EasySwiftResponseTracker implements Swift_Events_ResponseListener 22{ 23 /** 24 * The target object to update 25 * @var EasySwift 26 */ 27 protected $target = null; 28 29 /** 30 * Constructor 31 * @param EasySwift The instance of EasySwift to run against 32 */ 33 public function __construct($obj) 34 { 35 $this->target = $obj; 36 } 37 /** 38 * Response listener method 39 * @param Swift_Events_ResponseEvent The event occured in Swift 40 */ 41 public function responseReceived(Swift_Events_ResponseEvent $e) 42 { 43 $this->target->lastResponse = $e->getString(); 44 $this->target->responseCode = $e->getCode(); 45 } 46} 47