[floe] r418 committed - fixing more class naming linkages

0 views
Skip to first unread message

fl...@googlecode.com

unread,
May 23, 2010, 4:02:07 PM5/23/10
to floe-c...@googlegroups.com
Revision: 418
Author: coretxt
Date: Sun May 23 13:01:29 2010
Log: fixing more class naming linkages
http://code.google.com/p/floe/source/detail?r=418

Modified:
/trunk/dev/tests/finder.test.php
/trunk/src/repository/Finder.class.php
/trunk/src/repository/Storage.class.php

=======================================
--- /trunk/dev/tests/finder.test.php Sun Sep 21 21:08:26 2008
+++ /trunk/dev/tests/finder.test.php Sun May 23 13:01:29 2010
@@ -2,7 +2,6 @@
require_once 'simpletest/autorun.php';
require_once 'simpletest/mock_objects.php';
require_once dirname(__FILE__).'/../../src/repository/Finder.class.php';
-require_once
dirname(__FILE__).'/../../src/repository/store/mysql/MysqlQuery.class.php';

if (!defined('DB_HOST')) {
define('DB_HOST', 'localhost');
@@ -26,7 +25,7 @@
class FinderBasicQueryTest extends UnitTestCase {

function setUp() {
- $db = StorageAdaptor::instance();
+ $db = Storage::init();
$person = new Person();
$db->createTable("people", $person->properties());
$db->insert("people",
array("name"=>"Jack", "age"=>29, "gender"=>"male"));
@@ -55,7 +54,7 @@
}

function tearDown() {
- $db = StorageAdaptor::instance();
+ $db = Storage::init();
$db->dropTable("people");
}

=======================================
--- /trunk/src/repository/Finder.class.php Sun Oct 4 02:51:35 2009
+++ /trunk/src/repository/Finder.class.php Sun May 23 13:01:29 2010
@@ -18,7 +18,7 @@
protected $tableName;

function __construct($store=false, $cache=false) {
- $this->storage = StorageAdaptor::instance();
+ $this->storage = Storage::init();
$collectionName = str_replace('Finder', '', get_class($this));
$recordName = Inflect::toSingular($collectionName);
$this->record = new $recordName;
=======================================
--- /trunk/src/repository/Storage.class.php Sun May 23 12:48:23 2010
+++ /trunk/src/repository/Storage.class.php Sun May 23 13:01:29 2010
@@ -21,7 +21,7 @@

private static $storageAdaptor = null;
private static $implementation = null;
- private $currentRecordType;
+ private $recordType;
private $adaptor;

/**
@@ -35,27 +35,31 @@
/**
* Access a global instance of a service adaptor.
*/
- static function adaptor($adaptor = false) {
- $adaptor = ($adaptor) ? $adaptor : Storage_DefaultInstance;
- $serviceAdaptor = $adaptor.'Adaptor';
- $serviceConnection = $adaptor.'Connection';
- require_once 'services/'. strtolower($adaptor) .'/'.
$serviceAdaptor .'.class.php';
- if (!self::$implementation) self::$implementation = new
$serviceAdaptor(new $serviceConnection());
- return self::$implementation;
+ static function adaptor($service = false) {
+ $adaptor = ($service) ? $service : Storage_DefaultInstance;
+ $gateway = $adaptor.'Adaptor';
+ $connection = $adaptor.'Connection';
+ require_once 'services/'. strtolower($adaptor) .'/'.
$gateway .'.class.php';
+ if (!self::$implementation && !$service) {
+ self::$implementation = new $gateway(new $connection());
+ return self::$implementation;
+ } else{
+ return new $gateway(new $connection());
+ }
}

/**
* @ignore
*/
- function __construct($gateway) {
- $this->adaptor = $gateway;
+ function __construct($adaptor) {
+ $this->adaptor = $adaptor;
}

/**
* Converts a passed in value to a record class name.
*/
function setRecordType($type) {
- $this->currentRecordType =
Inflect::toClassName(Inflect::toSingular($type));
+ $this->recordType = Inflect::toClassName(Inflect::toSingular($type));
}

/**
@@ -68,7 +72,7 @@
if (isset($object->type)) {
$record = $object->type;
} else {
- $record = $this->currentRecordType;
+ $record = $this->recordType;
}
return new $record($object);
} else {
@@ -82,7 +86,7 @@
* @return array<Record>
*/
function getRecords() {
- $type = $this->currentRecordType;
+ $type = $this->recordType;
$objects = $this->adaptor->getObjects();
foreach($objects as $object) {
$records[] = new $type($object);

--
You received this message because you are subscribed to the Google Groups "Floe Commits" group.
To post to this group, send email to floe-c...@googlegroups.com.
To unsubscribe from this group, send email to floe-commits...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/floe-commits?hl=en.

Reply all
Reply to author
Forward
0 new messages