Added feature #15998: Create a new API to send mails based on SwiftMailer to replace...
[Packages/TYPO3.CMS.git] / typo3 / contrib / swiftmailer / classes / Swift / StreamFilters / StringReplacementFilterFactory.php
1 <?php
2
3 /*
4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 //@require 'Swift/StreamFilters/StringReplacementFilter.php';
12 //@require 'Swift/StreamFilterFactory.php';
13
14 /**
15 * Creates filters for replacing needles in a string buffer.
16 * @package Swift
17 * @author Chris Corbyn
18 */
19 class Swift_StreamFilters_StringReplacementFilterFactory
20 implements Swift_ReplacementFilterFactory
21 {
22
23 /** Lazy-loaded filters */
24 private $_filters = array();
25
26 /**
27 * Create a new StreamFilter to replace $search with $replace in a string.
28 * @param string $search
29 * @param string $replace
30 * @return Swift_StreamFilter
31 */
32 public function createFilter($search, $replace)
33 {
34 if (!isset($this->_filters[$search][$replace]))
35 {
36 if (!isset($this->_filters[$search]))
37 {
38 $this->_filters[$search] = array();
39 }
40
41 if (!isset($this->_filters[$search][$replace]))
42 {
43 $this->_filters[$search][$replace] = array();
44 }
45
46 $this->_filters[$search][$replace]
47 = new Swift_StreamFilters_StringReplacementFilter($search, $replace);
48 }
49
50 return $this->_filters[$search][$replace];
51 }
52
53 }