コード例 #1
0
 public static function getAllChainedByMasterFromChainedStart($componentClass, $master, $chainedType, $parentDataSelect = array())
 {
     if (Kwc_Abstract::getFlag($componentClass, 'chainedType') != $chainedType) {
         return array();
     }
     $ret = array();
     foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($componentClass, $parentDataSelect) as $chainedStart) {
         //if additional subroots are above trl subroot (eg. domains)
         if ($sr = $chainedStart->parent->getSubroot()) {
             $masterSr = $master;
             while (Kwc_Abstract::getFlag($masterSr->componentClass, 'chainedType') != $chainedType) {
                 $masterSr = $masterSr->parent;
                 if (!$masterSr) {
                     continue 2;
                 }
             }
             if ($masterSr->parent && $sr != $masterSr->parent->getSubroot()) {
                 continue;
             }
         }
         $i = Kwc_Chained_Abstract_Component::getChainedByMasterAndType($master, $chainedStart, $chainedType, $parentDataSelect);
         if ($i) {
             $ret[] = $i;
         }
     }
     return $ret;
 }
コード例 #2
0
 public function getChildData($parentDatas, $select = array())
 {
     Kwf_Benchmark::count('GenChained::getChildData');
     $ret = array();
     if (is_array($select)) {
         $select = new Kwf_Component_Select($select);
     }
     $chainedType = $this->getGeneratorFlag('chainedType');
     $slaveData = $select->getPart(Kwf_Component_Select::WHERE_CHILD_OF);
     while ($slaveData) {
         if (Kwc_Abstract::getFlag($slaveData->componentClass, 'chainedType') == $chainedType) {
             break;
         }
         $slaveData = $slaveData->parent;
     }
     $parentDataSelect = new Kwf_Component_Select();
     $parentDataSelect->copyParts(array('ignoreVisible'), $select);
     $parentDatas = is_array($parentDatas) ? $parentDatas : array($parentDatas);
     foreach ($parentDatas as $parentData) {
         foreach ($this->_getChainedChildComponents($parentData, $select) as $component) {
             $pData = array();
             if (!$parentData) {
                 if (!$slaveData) {
                     $pData = Kwc_Chained_Abstract_Component::getAllChainedByMaster($component->parent, $chainedType, $parentDataSelect);
                 } else {
                     $chainedComponent = Kwc_Chained_Abstract_Component::getChainedByMasterAndType($component->parent, $slaveData, $chainedType, $parentDataSelect);
                     if ($chainedComponent) {
                         $pData = array($chainedComponent);
                     }
                 }
             } else {
                 $pData = array($parentData);
             }
             foreach ($pData as $d) {
                 $data = $this->_createData($d, $component, $select);
                 if ($data) {
                     $ret[] = $data;
                 }
             }
         }
     }
     return $ret;
 }