Skip to content

Commit 25ea1ad

Browse files
committed
InstanceViewer->setInstance refacto
1 parent 0ed595b commit 25ea1ad

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

Ajax/common/html/traits/BaseHtmlEventsTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function onCreate($jsCode){
5858
return $this;
5959
}
6060

61-
public function addEventsOnRun(JsUtils $js) {
61+
public function addEventsOnRun(JsUtils $js=NULL) {
6262
$this->_eventsOnCreate($js);
6363
if (isset($this->_bsComponent)) {
6464
foreach ( $this->_events as $event => $jsCode ) {
@@ -81,13 +81,13 @@ public function addEventsOnRun(JsUtils $js) {
8181
}
8282
}
8383

84-
protected function _eventsOnCreate(JsUtils $js){
84+
protected function _eventsOnCreate(JsUtils $js=NULL){
8585
if(isset($this->_events["_create"])){
8686
$create=$this->_events["_create"];
8787
if(\is_array($create)){
8888
$create=\implode("", $create);
8989
}
90-
if($create!=="")
90+
if(isset($js) && $create!=="")
9191
$js->exec($create,true);
9292
unset($this->_events["_create"]);
9393
}

Ajax/semantic/widgets/base/InstanceViewer.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,35 @@ public function setInstance($instance) {
138138
$this->properties=$this->getDefaultProperties();
139139
}else{
140140
foreach ($this->visibleProperties as $property){
141-
if(\is_callable($property)){
142-
$this->properties[]=$property;
143-
}elseif(\is_string($property)){
144-
try{
145-
$this->_beforeAddProperty(\sizeof($this->properties), $property);
146-
$rProperty=$this->reflect->getProperty($property);
147-
$this->properties[]=$rProperty;
148-
}catch(\Exception $e){
149-
$this->_beforeAddProperty(\sizeof($this->properties), $property);
150-
$this->properties[]=$property;
151-
}
152-
}elseif(\is_int($property)){
153-
$props=$this->getDefaultProperties();
154-
if(isset($props[$property]))
155-
$this->properties[]=$props[$property];
156-
else
157-
$this->properties[]=$property;
158-
}else{
159-
$this->properties[]=$property;
160-
}
141+
$this->setInstanceProperty($property);
161142
}
162143
}
163144
return $this;
164145
}
165146

147+
private function setInstanceProperty($property){
148+
if(\is_callable($property)){
149+
$this->properties[]=$property;
150+
}elseif(\is_string($property)){
151+
try{
152+
$this->_beforeAddProperty(\sizeof($this->properties), $property);
153+
$rProperty=$this->reflect->getProperty($property);
154+
$this->properties[]=$rProperty;
155+
}catch(\Exception $e){
156+
$this->_beforeAddProperty(\sizeof($this->properties), $property);
157+
$this->properties[]=$property;
158+
}
159+
}elseif(\is_int($property)){
160+
$props=$this->getDefaultProperties();
161+
if(isset($props[$property]))
162+
$this->properties[]=$props[$property];
163+
else
164+
$this->properties[]=$property;
165+
}else{
166+
$this->properties[]=$property;
167+
}
168+
}
169+
166170
protected function getDefaultProperties(){
167171
$result=[];
168172
$properties=$this->reflect->getProperties();

0 commit comments

Comments
 (0)