Created
October 19, 2012 08:58
-
-
Save anonymous/3917050 to your computer and use it in GitHub Desktop.
DynamicCollectionObjectFormatter class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment