Permalink
Browse files

Renamed FileDataSource to HttpDataSource.

  • Loading branch information...
enyo committed Nov 9, 2010
1 parent af032dc commit 18367be5bb0a0c91642aac52af7eafe46289bef7
@@ -77,10 +77,11 @@ public function getData($map, $exportValues = true, $resourceName = null);
* @param int $limit
* @param bool $exportValues
* @param string $resourceName
+ * @param bool $retrieveTotalRowCount Every Dao can implement a way to retrieve the total row if limit is not null
* @see get()
* @return DaoResultIterator
*/
- public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null);
+ public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null, $retrieveTotalRowCount = false);
/**
* @param int $id
@@ -48,7 +48,7 @@ class FileDaoBase extends Dao {
protected $fileDataSource;
/**
- * @param FileDataSource $fileDataSource The fileDataSource is used to create the requests.
+ * @param HttpDataSource $fileDataSource The fileDataSource is used to create the requests.
* @param string $resourceName You can specify this as an attribute when writing a Dao implementation
* @param array $attributes You can specify this as an attribute when writing a Dao implementation
* @param array $nullAttributes You can specify this as an attribute when writing a Dao implementation
@@ -62,9 +62,9 @@ public function __construct($fileDataSource, $resourceName = null, $attributes =
/**
* Returns the fileDataSource.
*
- * @return FileDataSource
+ * @return HttpDataSource
*/
- public function getFileDataSource() {
+ public function getHttpDataSource() {
return $this->fileDataSource;
}
@@ -78,7 +78,7 @@ public function getFileDataSource() {
*/
public function createDao($daoName) {
$daoClassName = $daoName . 'Dao';
- return new $daoClassName($this->getFileDataSource());
+ return new $daoClassName($this->getHttpDataSource());
}
/**
@@ -191,11 +191,12 @@ public function getData($map, $exportValues = true, $resourceName = null) {
* @param int $limit
* @param bool $exportValues
* @param string $resourceName
+ * @param bool $retrieveTotalRowCount
* @return DaoResultIterator
* @see get()
* @uses $fileDataSource
*/
- public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null) {
+ public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null, $retrieveTotalRowCount = false) {
$result = $this->fileDataSource->getList($this->exportResourceName($resourceName ? $resourceName : ($this->viewName ? $this->viewName : $this->resourceName)), $exportValues ? $this->exportMap($map) : $map, $this->generateSortString($sort), $offset, $limit);
return $this->createIterator($result);
@@ -131,12 +131,25 @@ public function getReferenced($record, $attribute) {
return new DaoKeyListIterator($foreignKeys, $this->getForeignDao(), $this->getForeignKey());
}
+ /**
+ * @param mixed $value
+ */
+ public function exportValue($value) {
+ throw new DaoReferenceException('JoinManyReferences should never be exported.');
+ }
+
/**
* @param mixed $value
* @return mixed the coerced value.
*/
public function coerce($value) {
- throw new DaoReferenceException('JoinManyReferences should never be exported.');
+ if (is_array($value)) {
+ $newValue = array();
+ foreach ($value as $id) {
+ $newValue = (int) $id;
+ }
+ }
+ else return array();
}
}
@@ -54,13 +54,28 @@ public function getReferenced($record, $attribute) {
return $this->getForeignDao()->getIterator(array($this->getForeignKey()=>$record->get($this->getLocalKey())));
}
+
+ /**
+ * @param mixed $value
+ */
+ public function exportValue($value) {
+ throw new DaoReferenceException('JoinManyReferences should never be exported.');
+ }
+
/**
* @param mixed $value
* @return mixed the coerced value.
*/
public function coerce($value) {
- throw new DaoReferenceException('JoinManyReferences should never be exported.');
+ if (is_array($value)) {
+ $newValue = array();
+ foreach ($value as $id) {
+ $newValue = (int) $id;
+ }
+ }
+ else return array();
}
+
}
@@ -166,11 +166,13 @@ public function getData($map, $exportValues = true, $resourceName = null) {
* @param int $limit
* @param bool $exportValues
* @param string $resourceName
+ * @param bool $retrieveTotalRowCount
* @see get()
* @see generateQuery()
* @return DaoResultIterator
*/
- public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null) {
+ public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null, $retrieveTotalRowCount = false) {
+ if ($retrieveTotalRowCount) throw new DaoException ('Retrieving total row count is not yet implemented in the SqlDaoBase.');
return $this->getIteratorFromQuery($this->generateQuery($map, $sort, $offset, $limit, $exportValues, $resourceName ? $resourceName : ($this->viewName ? $this->viewName : $this->resourceName)));
}
@@ -2,7 +2,7 @@
/**
- * This file contains the basic FileDataSource class.
+ * This file contains the basic HttpDataSource class.
*
* @author Matthias Loitsch <developer@ma.tthias.com>
* @copyright Copyright (c) 2010, Matthias Loitsch
@@ -25,14 +25,14 @@
/**
- * The Exception base class for FileDataSourceException.
+ * The Exception base class for HttpDataSourceException.
*
* @author Matthias Loitsch <developer@ma.tthias.com>
* @copyright Copyright (c) 2010, Matthias Loitsch
* @package DataSource
* @subpackage DataSourceExceptions
*/
-class FileDataSourceException extends DataSourceException { };
+class HttpDataSourceException extends DataSourceException { };
/**
@@ -45,7 +45,7 @@ class FileDataSourceException extends DataSourceException { };
* @copyright Copyright (c) 2010, Matthias Loitsch
* @package DataSource
*/
-abstract class FileDataSource extends DataSource {
+abstract class HttpDataSource extends DataSource {
/**
* This is the object used to actually get the files.
@@ -13,7 +13,7 @@ public function exportResourceName($resource = null) {
public function get($map = null, $exportValues = true, $resourceName = null) { }
public function find($map = null, $exportValues = true, $resourceName = null) { }
public function getData($map, $exportValues = true, $resourceName = null) { }
- public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null) { }
+ public function getIterator($map, $sort = null, $offset = null, $limit = null, $exportValues = true, $resourceName = null, $retrieveTotalRowCount = false) { }
public function insert($object) { }
public function update($object) { }
public function delete($object) { }

0 comments on commit 18367be

Please sign in to comment.