public
Created

DynamicCollectionObjectFormatter class

  • Download Gist
DynamicCollectionObjectFormatter.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
 
/**
* Object formatter for Propel query
* format() returns one of the following
* - a custom ObjectCollection for a given modal name if the class exists ( ex InvoiceObjectCollection class )
* - the default PropelObjectCollection of Propel model objects
*
* @author Lee Leathers
* @author Marius Ghita
* @package propel.runtime.collection
*/
class DynamicCollectionObjectFormatter extends PropelObjectFormatter
{
public function setModalName($modalName)
{
$this->collectionName = $modalName . "ObjectCollection";
if(false === class_exists($this->collectionName))
{
$this->collectionName = "PropelObjectCollection";
}
elseif(false === is_subclass_of($this->collectionName, "PropelObjectCollection"))
{
throw new LogicException(sprintf(
"%s class must be a subclass of PropelObjectCollection",
$this->collectionName)
);
}
 
return $this;
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.