remove dumb feature, just extend the class, doi

This commit is contained in:
John Bintz 2010-02-07 11:15:24 -05:00
parent e02cfc4df6
commit 4d998aefb8
3 changed files with 13 additions and 34 deletions

View File

@ -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;
}
}
}

View File

@ -1,13 +1,13 @@
<?php
/*
Plugin Name: ComicPress Core
Plugin URI: http://comicpress.org/
Plugin URI: http://core.comicpress.org/
Description: Provides the core functionality of ComicPress, a powerful media and structured category management system geared toward creative works.
Version: 1.0
Author: John Bintz
Author URI: http://comicpress.org/
Copyright 2009 John Bintz (email : john@coswellproductions.com)
Copyright 2009-2010 John Bintz (email : john@coswellproductions.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -393,18 +393,4 @@ class ComicPressBackendFilesystemFactoryTest extends PHPUnit_Framework_TestCase
)
), $fa->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));
}
}