Пример #1
0
 protected function onCreateJsonData(CreateJsonDataEvent $aEvt)
 {
     $model = $this->getModel();
     $rules = $this->getDataRules()->toArray();
     foreach ($rules as $k) {
         $s = StructUtils::scout($model, $k);
         if ($s[0]) {
             $aEvt->getJsonData()->set($k, $s[1]);
         }
     }
 }
Пример #2
0
 /**
  * Gets items specified by paths from the source array, and sets them in the returned array.
  * @param array $aArray Source array.
  * @param array $aPaths Array of paths to items.
  * @param bool $aFill If true, non-existent items will be set to null.
  * @return array Array containing extracted items.
  */
 public static function extract($aArray, $aPaths, $aFill = false)
 {
     $arr = array();
     foreach ($aPaths as $k) {
         $p = StructUtils::scout($aArray, $k);
         if ($p[0]) {
             StructUtils::set($arr, $k, $p[1]);
         } else {
             if ($aFill) {
                 StructUtils::set($arr, $k, null);
             }
         }
     }
     return $arr;
 }