Example #1
0
 public static function &find($name, $value)
 {
     $right = Sequence::right($name);
     return Controller::run(static::$layers, function &(&$layer) use($right, $value) {
         if (Sequence::get($layer, $right) == $value) {
             return $layer;
         }
         $r = null;
         return $r;
     });
 }
 public function getAttributes($args = array(), $alias = null)
 {
     $attributes = $this->attributes;
     if ($alias !== null) {
         if (!isset($this->aliases[$alias])) {
             throw new FactoryException(\Yii::t(Factory::LOG_CATEGORY, 'Alias "{alias}" not found for class "{class}"', array('{alias}' => $alias, '{class}' => $this->className)));
         }
         $attributes = array_merge($attributes, $this->aliases[$alias]);
     }
     $attributes = array_merge($attributes, $args);
     foreach ($attributes as $key => $value) {
         $attributes[$key] = is_object($value) ? $value : Sequence::get($value);
     }
     return $attributes;
 }
Example #3
0
 public static function &get(&$obj, $right, $start = 0, $end = null, $make = false)
 {
     //получить из obj значение right до end(не включая) брать начинаем с start
     if (is_null($end)) {
         $end = sizeof($right);
     }
     $r = null;
     if ($end === $start) {
         return $obj;
     }
     if (is_null($obj)) {
         return $r;
     }
     //Даже если make мы не изменим ссылку null на obj в javascript так что и тут так
     if (is_array($obj)) {
         if ($make && @(!is_array($obj[$right[$start]]))) {
             $obj[$right[$start]] = array();
         }
         if ($make || @(!is_null($obj[$right[$start]]))) {
             //Если передать несуществующее свойство в функцию принимающую ссылку то это свойство начнёт существовать
             return Sequence::get($obj[$right[$start]], $right, ++$start, $end, $make);
         }
     } elseif (is_object($obj)) {
         $name = $right[$start];
         if ($make && !is_array($obj->{$name})) {
             $obj->{$name} = array();
         }
         if (property_exists($obj, $name)) {
             //К методам объектов обращаться не можем
             return Sequence::get($obj->{$name}, $right, ++$start, $end, $make);
         }
     } else {
         return $r;
     }
     return $r;
     /*
     		if(is_null($end))$end=sizeof($right);
     		if($end===$start)return $obj;
     		if(is_null($obj))return;
     		
     		if(is_array($obj)){
     			if($make&&!is_array($obj[$right[$start]]))$obj[$right[$start]]=array();
     			if(array_key_exists($right[$start],$obj)){
     				return Sequence::get($obj[$right[$start]],$right,++$start,$end,$make);
     			}
     		}else if(is_object($obj)){
     			if($make&&!is_array($obj->$$right[$start]))$obj->$$right[$start]=array();
     			if(property_exists($obj,$right[$start])){//К методам объектов обращаться не можем
     				return Sequence::get($obj->$right[$start],$right,++$start,$end,$make);
     			}
     		}else{
     			return NULL;
     		}*/
 }