本文整理汇总了PHP中Doctrine_Record::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Record::__call方法的具体用法?PHP Doctrine_Record::__call怎么用?PHP Doctrine_Record::__call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Record
的用法示例。
在下文中一共展示了Doctrine_Record::__call方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValue
/**
* Extract the value of the field from a record.
* @param Doctrine_Record $record
* @return mixed
*/
public function getValue($record)
{
if (!$this->getField()) {
throw new IllegalStateException('Not field defined por relation ' . $this->getName());
}
$getter = 'get' . ucfirst($this->getName());
return $this->getField()->getValue($record->__call($getter, array()));
}
示例2: __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 {
if (in_array($verb = substr($method, 0, 3), array('set', 'get'))) {
$name = substr($method, 3);
$table = $this->getTable();
if ($table->hasRelation($name)) {
$entityName = $name;
} else {
if ($table->hasField($fieldName = $table->getFieldName($name))) {
$entityNameLower = strtolower($fieldName);
if ($table->hasField($entityNameLower)) {
$entityName = $entityNameLower;
} else {
$entityName = $fieldName;
}
} else {
$underScored = $table->getFieldName(sfInflector::underscore($name));
if ($table->hasField($underScored) || $table->hasRelation($underScored)) {
$entityName = $underScored;
} else {
if ($table->hasField(strtolower($name)) || $table->hasRelation(strtolower($name))) {
$entityName = strtolower($name);
} else {
$camelCase = $table->getFieldName(sfInflector::camelize($name));
$camelCase = strtolower($camelCase[0]) . substr($camelCase, 1, strlen($camelCase));
if ($table->hasField($camelCase) || $table->hasRelation($camelCase)) {
$entityName = $camelCase;
} else {
$entityName = $underScored;
}
}
}
}
}
return call_user_func_array(array($this, $verb), array_merge(array($entityName), $arguments));
} else {
$failed = true;
}
} catch (Exception $e) {
$failed = true;
}
if ($failed) {
try {
return parent::__call($method, $arguments);
} catch (Doctrine_Record_UnknownPropertyException $e2) {
}
if (isset($e) && $e) {
throw $e;
} else {
if (isset($e2) && $e2) {
throw $e2;
}
}
}
}
示例3: getValue
/**
* Extract the value of the field from a record.
* @param Doctrine_Record $record
* @return mixed
*/
public function getValue($record)
{
$getter = 'get' . ucfirst($this->getName());
return $record->__call($getter, array());
}
示例4: __call
public function __call($method, $arguments)
{
try {
if (in_array($verb = substr($method, 0, 3), array('set', 'get'))) {
$name = substr($method, 3);
$table = $this->getTable();
if ($table->hasRelation($name)) {
$entityName = $name;
} else {
if ($table->hasField($fieldName = $table->getFieldName($name))) {
$entityName = strtolower($fieldName);
} else {
$underScored = $table->getFieldName(sfInflector::underscore($name));
if ($table->hasField($underScored)) {
$entityName = $underScored;
} else {
if ($table->hasField(strtolower($name))) {
$entityName = strtolower($name);
} else {
$entityName = $underScored;
}
}
}
}
return call_user_func_array(array($this, $verb), array_merge(array($entityName), $arguments));
} else {
return parent::__call($method, $arguments);
}
} catch (Exception $e) {
return parent::__call($method, $arguments);
}
}
示例5: __call
/**
* This magic __call is used to provide propel style accessors to Doctrine models
*
* @param string $m
* @param string $a
* @return void
*/
public function __call($m, $a)
{
try {
$verb = substr($m, 0, 3);
if ($verb == 'set' || $verb == 'get') {
$camelColumn = substr($m, 3);
// If is a relation
if (in_array($camelColumn, array_keys($this->getTable()->getRelations()))) {
$column = $camelColumn;
} else {
$column = sfInflector::underscore($camelColumn);
}
if ($verb == 'get') {
return $this->get($column);
} else {
return $this->set($column, $a[0]);
}
} else {
return parent::__call($m, $a);
}
} catch (Exception $e) {
return parent::__call($m, $a);
}
}