本文整理汇总了PHP中DataMapper::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP DataMapper::__call方法的具体用法?PHP DataMapper::__call怎么用?PHP DataMapper::__call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataMapper
的用法示例。
在下文中一共展示了DataMapper::__call方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
public function __call($method, $arguments)
{
static $watched_methods = array('_choices_display', '_display', '_has_rule', '_has_admin', '_has_many_add', '_has_many_del', '_as_admin_widget', '_choices_array', '_is_related_changed', '_type_get', '_label_get', '_admin_get', '_id_get', '_value_set');
foreach ($watched_methods as $watched_method) {
// See if called method is a watched method
if (strpos($method, $watched_method) !== FALSE) {
$pieces = explode($watched_method, $method);
if (!empty($pieces[0]) && !empty($pieces[1])) {
// Watched method is in the middle
return $this->{'_' . trim($watched_method, '_')}($pieces[0], array_merge(array($pieces[1]), $arguments));
} else {
// Watched method is a prefix or suffix
return $this->{'_' . trim($watched_method, '_')}(str_replace($watched_method, '', $method), $arguments);
}
}
}
return parent::__call($method, $arguments);
}
示例2: __call
public function __call($key, $args = array())
{
$prfx = 'present_';
if (substr($key, 0, strlen($prfx)) == $prfx) {
$short_key = substr($key, strlen($prfx));
$presenter = $this->presenter();
if ($presenter === NULL) {
// attempt to load presenter
$presenter = HC_App::presenter($this->my_class(), $this);
if ($presenter) {
$this->set_presenter($presenter);
} else {
$this->set_presenter(FALSE);
}
}
if ($presenter && method_exists($presenter, $short_key)) {
array_unshift($args, $this);
return call_user_func_array(array($presenter, $short_key), $args);
// return $presenter->{$short_key}( $this );
} else {
if (property_exists($this, $short_key)) {
return $this->{$short_key};
} else {
return NULL;
}
}
}
return parent::__call($key, $args);
}