@@ -13,12 +13,13 @@ trait BaseHtmlPropertiesTrait{
1313 protected $ properties =array ();
1414 abstract protected function ctrl ($ name , $ value , $ typeCtrl );
1515 abstract protected function removeOldValues (&$ oldValue , $ allValues );
16+ abstract protected function _getElementBy ($ callback ,$ elements );
1617 public function getProperties () {
1718 return $ this ->properties ;
1819 }
1920
2021 /**
21- * @param array|string $properties
22+ * @param array $properties
2223 * @return BaseHtml
2324 */
2425 public function setProperties ($ properties ) {
@@ -109,20 +110,6 @@ protected function setPropertyCtrl($name, $value, $typeCtrl) {
109110 }
110111
111112 protected function getElementByPropertyValue ($ propertyName ,$ value , $ elements ) {
112- if (\is_array ($ elements )) {
113- $ flag =false ;
114- $ index =0 ;
115- while ( !$ flag && $ index < sizeof ($ elements ) ) {
116- if ($ elements [$ index ] instanceof BaseHtml)
117- $ flag =($ elements [$ index ]->propertyContains ($ propertyName , $ value ) === true );
118- $ index ++;
119- }
120- if ($ flag === true )
121- return $ elements [$ index - 1 ];
122- } elseif ($ elements instanceof BaseHtml) {
123- if ($ elements ->propertyContains ($ propertyName , $ value ) === true )
124- return $ elements ;
125- }
126- return null ;
113+ return $ this ->_getElementBy (function ($ element ) use ($ propertyName ,$ value ){return $ element ->propertyContains ($ propertyName , $ value ) === true ;}, $ elements );
127114 }
128115}
0 commit comments