summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/TActiveRecordConfig.php
diff options
context:
space:
mode:
authorgodzilla80@gmx.net <>2009-05-10 10:51:52 +0000
committergodzilla80@gmx.net <>2009-05-10 10:51:52 +0000
commit5d276345aa8fc6eefed3793d59cc73ae0d0247b5 (patch)
tree68dd1b84da8a54cf2a99b65748f6a6dd2e45b7ea /framework/Data/ActiveRecord/TActiveRecordConfig.php
parentd0d261bec97595492a4d1da44121c6fb919ea2ed (diff)
Fixed Issue #74
Introduce a new property 'InvalidFinderResult' (related new enum TActiveRecordInvalidFinderResult) to TActiveRecordConfig, TActiveRecordManager, TActiveRecord that allows to control how TActiveRecord react if an invalid magic-finder invoked. Possible values are: Exception - throw TActiveRecordException like before rev1545 Null - return null (default for backward compatibility reasons) To change behavior: <module class="System.Data.ActiveRecord.TActiveRecordConfig" InvalidFinderResult="Exception"/> or MyActiveRecord->setInvalidFinderResult(TActiveRecordInvalidFinderResult::Exception); or override MyActiveRecord->getInvalidFinderResult() to always return TActiveRecordInvalidFinderResult::Exception
Diffstat (limited to 'framework/Data/ActiveRecord/TActiveRecordConfig.php')
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordConfig.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/framework/Data/ActiveRecord/TActiveRecordConfig.php b/framework/Data/ActiveRecord/TActiveRecordConfig.php
index 63f05aef..fb57fd33 100644
--- a/framework/Data/ActiveRecord/TActiveRecordConfig.php
+++ b/framework/Data/ActiveRecord/TActiveRecordConfig.php
@@ -11,6 +11,7 @@
*/
Prado::using('System.Data.TDataSourceConfig');
+Prado::using('System.Data.ActiveRecord.TActiveRecordManager');
/**
* TActiveRecordConfig module configuration class.
@@ -74,17 +75,25 @@ class TActiveRecordConfig extends TDataSourceConfig
private $_enableCache=false;
/**
+ * Defaults to '{@link TActiveRecordInvalidFinderResult::Null Null}'
+ *
+ * @var TActiveRecordInvalidFinderResult
+ * @since 3.1.5
+ */
+ private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null;
+
+ /**
* Initialize the active record manager.
* @param TXmlDocument xml configuration.
*/
public function init($xml)
{
parent::init($xml);
- Prado::using('System.Data.ActiveRecord.TActiveRecordManager');
$manager = TActiveRecordManager::getInstance();
if($this->getEnableCache())
$manager->setCache($this->getApplication()->getCache());
$manager->setDbConnection($this->getDbConnection());
+ $manager->setInvalidFinderResult($this->getInvalidFinderResult());
}
/**
@@ -103,5 +112,26 @@ class TActiveRecordConfig extends TDataSourceConfig
{
return $this->_enableCache;
}
-}
-
+
+ /**
+ * @return TActiveRecordInvalidFinderResult Defaults to '{@link TActiveRecordInvalidFinderResult::Null Null}'.
+ * @see setInvalidFinderResult
+ * @since 3.1.5
+ */
+ public function getInvalidFinderResult()
+ {
+ return $this->_invalidFinderResult;
+ }
+
+ /**
+ * Define the way an active record finder react if an invalid magic-finder invoked
+ *
+ * @param TActiveRecordInvalidFinderResult
+ * @see getInvalidFinderResult
+ * @since 3.1.5
+ */
+ public function setInvalidFinderResult($value)
+ {
+ $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult');
+ }
+} \ No newline at end of file