Exemplo n.º 1
0
 public static function makeGroupedKeepersArr(KeeperData $keeperData)
 {
     self::$data = $keeperData->getData();
     self::$groupCriteria = $keeperData->getGroupCriteria();
     self::$keeper = $keeperData->getKeeper();
     $groupCriteriaUniqueValues = [];
     foreach (self::$data as $item) {
         foreach ($item as $key => $value) {
             if ($key === self::$groupCriteria) {
                 if (!in_array($value, $groupCriteriaUniqueValues, TRUE)) {
                     $groupCriteriaUniqueValues[] = $value;
                 }
             }
         }
     }
     $keepersArr = [];
     foreach ($groupCriteriaUniqueValues as $criteriaValue) {
         $groupKeeper = clone self::$keeper;
         $groupKeeper->{self::$groupCriteria} = $criteriaValue;
         $keepersArr[$criteriaValue] = $groupKeeper;
     }
     return $keepersArr;
 }
Exemplo n.º 2
0
 protected function prepareKeeper()
 {
     $keeper = new \StdClass();
     foreach (self::$groupProperties as $propertyName => $propertyValue) {
         $keeper->{$propertyName} = NULL;
     }
     if (!is_null(self::$groupCriteriaHigherLevel)) {
         $keeperData = new KeeperData();
         $keeperData->setData(self::$data);
         $keeperData->setKeeper($keeper);
         $keeperData->setGroupCriteria(self::$groupCriteriaHigherLevel);
         $keeper = Keeper::makeGroupedKeepersArr($keeperData);
     }
     self::$groupKeeper = $keeper;
     return NULL;
 }
Exemplo n.º 3
0
 protected function prepareAddUpKeeper()
 {
     $keeper = new \StdClass();
     foreach (self::$data as $item) {
         foreach ($item as $key => $value) {
             $keeper->{$key} = NULL;
         }
         break;
     }
     if (!is_null(self::$groupCriteria)) {
         $keeperData = new KeeperData();
         $keeperData->setData(self::$data);
         $keeperData->setKeeper($keeper);
         $keeperData->setGroupCriteria(self::$groupCriteria);
         $keeper = Keeper::makeGroupedKeepersArr($keeperData);
     }
     self::$addUpKeeper = $keeper;
     return NULL;
 }