/** * Returns the block managers handled by the PageTree object * * @param string $slotName * @return array */ public function getBlockManagers($slotName) { $slotManager = $this->templateManager->getSlotManager($slotName); if (null === $slotManager) { return array(); } return $slotManager->getBlockManagersCollection()->getBlockManagers(); }
/** * @dataProvider slotManagerProvider */ public function testCreatesASlotManagerWhenAnyBlockManagerHasBeenInstantiated($slots, $templateSlots, $slotBlocks, $blocks, $generatedSlotManagers = 1) { $this->themeSlots->expects($this->once())->method('getSlots')->will($this->returnValue($slots)); $this->template->expects($this->once())->method('getSlots')->will($this->returnValue($templateSlots)); $pageBlocks = null; if (null !== $slotBlocks) { $c = 0; foreach ($slotBlocks as $slotName) { if (null !== $slotName) { $this->pageBlocks->expects($this->at($c))->method('getSlotBlocks')->with($slotName)->will($this->returnValue(array())); } $c++; } $this->pageBlocks->expects($this->once())->method('getBlocks')->will($this->returnValue($blocks)); $pageBlocks = $this->pageBlocks; } $templateManager = new TemplateManager($this->eventsHandler, $this->factoryRepository, $this->factory, $this->validator); $templateManager->refresh($this->themeSlots, $this->template, $pageBlocks); $this->assertSame($this->themeSlots, $templateManager->getThemeSlots()); $this->assertSame($this->template, $templateManager->getTemplate()); $this->assertSame($pageBlocks, $templateManager->getPageBlocks()); $slotManager = $templateManager->getSlotManager('logo'); $this->assertInstanceOf('\\RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Content\\Slot\\SlotManager', $slotManager); $this->assertCount($generatedSlotManagers, $templateManager->getSlotManagers()); $this->assertCount($generatedSlotManagers, $templateManager->slotsToArray()); $this->assertEquals(array(), $templateManager->slotToArray('logo')); }