Skip to content

Commit

Permalink
组件创建支持闭包回调,func配置项可以设置回调函数
Browse files Browse the repository at this point in the history
  • Loading branch information
bingcool committed Jun 11, 2018
1 parent c377add commit 0508538
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion score/Core/ComponentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ protected function buildInstance($class, $defination, $params, $com_alias_name)
}

if($name == SWOOLEFY_COM_FUNC) {
call_user_func_array([$object, $defination[$name]], [$defination]);
if(is_string($defination[$name])) {
call_user_func_array([$object, $defination[$name]], [$defination]);
}else if($defination[$name] instanceof Closure) {
call_user_func_array($defination[$name]->bindTo($object, get_class($object)), [$defination]);
}
continue;
}else if(is_array($object->$name)) {
$object->$name = array_merge($object->$name, $value);
Expand Down

0 comments on commit 0508538

Please sign in to comment.