From 4d998aefb8565ff504cb1b0f3cac08ecc3a981ed Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 7 Feb 2010 11:15:24 -0500 Subject: [PATCH] remove dumb feature, just extend the class, doi --- .../backends/ComicPressBackendFilesystem.inc | 29 +++++++------------ comicpress-core.php | 4 +-- ...ComicPressBackendFilesystemFactoryTest.php | 14 --------- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/classes/backends/ComicPressBackendFilesystem.inc b/classes/backends/ComicPressBackendFilesystem.inc index 27b112b..abd632f 100644 --- a/classes/backends/ComicPressBackendFilesystem.inc +++ b/classes/backends/ComicPressBackendFilesystem.inc @@ -120,7 +120,7 @@ class ComicPressBackendFilesystemFactory { return $return; } - function process_search_string($post, $type, $filename = null, $replace_object = null) { + function process_search_string($post, $type, $filename = null) { $this->_searches = array($this->search_string); $this->_filename = $filename; @@ -135,23 +135,16 @@ class ComicPressBackendFilesystemFactory { '_replace_' . strtolower(str_replace('-', '_', $matches[1])) => null, '_replace_' . strtolower($parts[0]) => implode('-', array_slice($parts, 1)) ) as $method => $additional) { - $object_calls = array($this); - if (is_object($replace_object)) { - array_unshift($object_calls, $replace_object); - } - - foreach ($object_calls as $obj) { - if (method_exists($obj, $method)) { - $any_found = true; - $found = true; - $result = $obj->{$method}($post, $type, $additional); - if ($result !== false) { - $this->_searches[$i] = str_replace($matches[0], $result, $search); - break 2; - } else { - // array state change, start over - break 2; - } + if (method_exists($this, $method)) { + $any_found = true; + $found = true; + $result = $this->{$method}($post, $type, $additional); + if ($result !== false) { + $this->_searches[$i] = str_replace($matches[0], $result, $search); + break; + } else { + // array state change, start over + break; } } } diff --git a/comicpress-core.php b/comicpress-core.php index 82c3214..16baa16 100644 --- a/comicpress-core.php +++ b/comicpress-core.php @@ -1,13 +1,13 @@ get_urls_for_post_roots($roots, (object)array('post_date' => '2010-01-01'))); } - - function testProvideReplaceObject() { - $fa = $this->getMock('ComicPressBackendFilesystemFactory', array('_replace_wordpress', '_replace_type')); - - $fa->search_string = '%wordpress%/%type%'; - - $fa->expects($this->once())->method('_replace_wordpress')->will($this->returnValue('wordpress')); - $fa->expects($this->never())->method('_replace_type'); - - $replace = $this->getMock('ReplaceObject', array('_replace_type')); - $replace->expects($this->once())->method('_replace_type')->will($this->returnValue('type')); - - $this->assertEquals(array('wordpress/type'), $fa->process_search_string(null, 'type', null, $replace)); - } }