private function addCallbackHandlers($store, $configuration) { $propertyRegistry = new PropertyRegistry(); /** * @see https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks.md */ $this->handlers['SMW::Property::initProperties'] = function () use($propertyRegistry) { return $propertyRegistry->register(); }; /** * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateOutputPageBeforeExec */ $this->handlers['SkinTemplateOutputPageBeforeExec'] = function (&$skin, &$template) use($store, $configuration) { $bySubpageLinksFinder = new BySubpageLinksFinder(); $bySubpageLinksFinder->setSubpageDiscoverySupportState($configuration['useSubpageFinderFallback']); $byPropertyHierarchicalLinksFinder = new ByPropertyHierarchicalLinksFinder($store); $byPropertyHierarchicalLinksFinder->setFindClosestDescendantState($configuration['tryToFindClosestDescendant']); $byPropertyHierarchicalLinksFinder->setPropertySearchPatternByNamespace($configuration['propertySearchPatternByNamespace']); $htmlBreadcrumbLinksBuilder = new HtmlBreadcrumbLinksBuilder($byPropertyHierarchicalLinksFinder, $bySubpageLinksFinder); $htmlBreadcrumbLinksBuilder->setLinker(new DummyLinker()); $htmlBreadcrumbLinksBuilder->setBreadcrumbTrailStyleClass($configuration['breadcrumbTrailStyleClass']); $htmlBreadcrumbLinksBuilder->setBreadcrumbDividerStyleClass($configuration['breadcrumbDividerStyleClass']); $skinTemplateOutputModifier = new SkinTemplateOutputModifier($htmlBreadcrumbLinksBuilder); $skinTemplateOutputModifier->modifyTemplate($template); $skinTemplateOutputModifier->modifyOutput($skin->getOutput()); return true; }; /** * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay */ $this->handlers['BeforePageDisplay'] = function (&$output, &$skin) use($configuration) { $pageDisplayOutputModifier = new PageDisplayOutputModifier(); $pageDisplayOutputModifier->setHideSubpageParentState($configuration['hideSubpageParent']); $pageDisplayOutputModifier->setSubpageByNamespace($configuration['wgNamespacesWithSubpages']); $pageDisplayOutputModifier->modifyOutput($output); return true; }; }
public function testChildSearchForInvalidPropertyType() { $subject = new DIWikiPage('Foo', NS_MAIN); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnValue(array())); $store->expects($this->never())->method('getPropertySubjects'); $instance = new ByPropertyHierarchicalLinksFinder($store); $instance->setFindClosestDescendantState(true); $instance->setPropertySearchPatternByNamespace(array(NS_MAIN => array('_MDAT'))); $instance->tryToFindLinksFor($subject); $this->assertEmpty($instance->getParents()); $this->assertEmpty($instance->getChildren()); }