public function testBoxes() { $page = $this->_root->getComponentById('1'); $this->assertNotNull($page); $boxes = $page->getRecursiveChildComponents(array('box' => true, 'page' => false)); $this->assertEquals(1, count($boxes)); $classes = Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Boxes_Root', array('inherit' => true)); $this->assertEquals(array(), $classes); }
public function testIndirect() { $classes = Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Indirect_Root', array('flags' => array('foo' => true))); $this->assertEquals(1, count($classes)); $this->assertEquals('Kwf_Component_Generator_Indirect_Flag', current($classes)); $classes = Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Indirect_Root', array('flags' => array('bar' => true))); $this->assertEquals(1, count($classes)); $this->assertEquals('Kwf_Component_Generator_Indirect_Flag', current($classes)); $classes = Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Indirect_Root', array('flags' => array('foobar' => true))); $this->assertEquals(1, count($classes)); $this->assertEquals('Kwf_Component_Generator_Indirect_Flag', current($classes)); }
public function testInherit() { $c = $this->_root->getChildComponent('_static')->getChildComponents(); $this->assertEquals(count($c), 1); $this->assertEquals(current($c)->componentId, 'root_static-box'); $c = $this->_root->getChildComponent('_static')->getChildBoxes(); $this->assertEquals(1, count($c)); $this->assertEquals('root_static-box', current($c)->componentId); $cc = Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Inherit_Root', array('flags' => array('foo' => true))); $this->assertEquals(1, count($cc)); $this->assertEquals('Kwf_Component_Generator_Inherit_Box', current($cc)); $c = $this->_root->getChildComponent('_static'); $cc = current($c->getChildComponents(array('hasEditComponents' => true))); $this->assertEquals('root_static-box', $cc->componentId); $c = $c->getRecursiveChildComponents(array('flags' => array('foo' => true))); $this->assertEquals(1, count($c)); $this->assertEquals(current($c)->componentId, 'root_static-box-flag'); $this->assertNotNull($this->_root->getComponentById('root_static-box')); $this->assertEquals($this->_root->getComponentById('root_static-box')->componentId, 'root_static-box'); $this->assertEquals($this->_root->getComponentById('root_static-box-flag')->componentId, 'root_static-box-flag'); }
private function _getPossibleIndirectDbIdShortcutsImpl($class) { if (isset($this->_getPossibleIndirectDbIdShortcutsCache[$class])) { return $this->_getPossibleIndirectDbIdShortcutsCache[$class]; } $ret = array(); $gens = Kwf_Component_Generator_Abstract::getInstances($class); foreach ($gens as $g) { // Do not return page generators // For Page generators the dbIdShortcut is only used for components below the current // page in models if (!$g->getGeneratorFlag('page') && $g->hasSetting('dbIdShortcut') && Kwc_Abstract::getIndirectChildComponentClasses($class, array('componentClass' => $this->_class))) { $ret[] = $g->getSetting('dbIdShortcut'); } } $this->_getPossibleIndirectDbIdShortcutsCache[$class] = $ret; foreach (Kwc_Abstract::getChildComponentClasses($class, array('page' => false)) as $c) { $ret = array_merge($ret, $this->_getPossibleIndirectDbIdShortcutsImpl($c)); } $this->_getPossibleIndirectDbIdShortcutsCache[$class] = $ret; return $ret; }
public function testFlag() { $this->assertEquals(count(Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Recursive_Static', array('flags' => array('foo' => true)))), 1); $this->_assertRecursiveIds($this->_root->getChildComponent('_static'), array('flags' => array('foo' => true)), array('root_static-static2-flag')); }
private function _formatChildConstraints($select, $childSelect) { $childSelect = clone $childSelect; $select = clone $select; if ($select->hasPart(Kwf_Model_Select::LIMIT_COUNT)) { $select->unsetPart(Kwf_Model_Select::LIMIT_COUNT); } if ($select->hasPart(Kwf_Component_Select::WHERE_FILENAME)) { $select->unsetPart(Kwf_Component_Select::WHERE_FILENAME); } if ($select->hasPart(Kwf_Component_Select::WHERE_HOME)) { $select->unsetPart(Kwf_Component_Select::WHERE_HOME); } $classes = Kwc_Abstract::getIndirectChildComponentClasses($this->componentClass, $select); $page = $this; $ic = $this->inheritClasses; foreach ($ic as $c) { $classes = array_merge($classes, Kwc_Abstract::getIndirectChildComponentClasses($c, $select)); } // Nur bei hasEditComponents, Root soll keine Domain-Komponenten anzeigen // Hack-Alarm :D if ($select->hasPart(Kwf_Component_Select::WHERE_HAS_EDIT_COMPONENTS) && $this instanceof Kwf_Component_Data_Root) { $cc = array(); foreach ($classes as $class) { if (!is_instance_of($class, 'Kwc_Root_DomainRoot_Domain_Component')) { $cc[] = $class; } } $classes = $cc; } $childSelect->whereComponentClasses(array_unique($classes)); return $childSelect; }
private function _assertRec($constraints, $count) { $classes = Kwc_Abstract::getIndirectChildComponentClasses('Kwf_Component_Generator_Components_Recursive', $constraints); $this->assertEquals($count, count($classes)); }