本文整理匯總了PHP中sfDoctrineRecord::__call方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfDoctrineRecord::__call方法的具體用法?PHP sfDoctrineRecord::__call怎麽用?PHP sfDoctrineRecord::__call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfDoctrineRecord
的用法示例。
在下文中一共展示了sfDoctrineRecord::__call方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __call
/**
* Provides getter and setter methods.
*
* @param string $method The method name
* @param array $arguments The method arguments
*
* @return mixed The returned value of the called method
*/
public function __call($method, $arguments)
{
$failed = false;
try {
return parent::__call($method, $arguments);
} catch (Exception $e) {
$failed = true;
}
if ($failed) {
try {
if (in_array($verb = substr($method, 0, 3), array('set', 'get'))) {
$name = substr($method, 3);
/* @var $table Doctrine_Table */
$table = $this->getTable();
foreach ($table->getRelations() as $alias => $relation) {
if ($name == str_replace('_', '', $alias)) {
$entityName = $alias;
}
}
return call_user_func_array(array($this, $verb), array_merge(array($entityName), $arguments));
}
} catch (Exception $e) {
$failed = true;
}
if ($failed) {
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown method %s::%s', get_class($this), $method));
}
}
}
示例2: __call
/**
* Provides access to i18n methods
*
* @param string $method The method name
* @param array $arguments The method arguments
*
* @return mixed The returned value of the called method
*/
public function __call($method, $arguments)
{
try {
return parent::__call($method, $arguments);
} catch (Exception $parentException) {
try {
if ($this->getTable()->hasI18n() && ($i18n = $this->getCurrentTranslation())) {
return call_user_func_array(array($i18n, $method), $arguments);
}
} catch (Exception $e) {
}
throw $parentException;
}
}