當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ThemeInterface::getParents方法代碼示例

本文整理匯總了PHP中Sylius\Bundle\ThemeBundle\Model\ThemeInterface::getParents方法的典型用法代碼示例。如果您正苦於以下問題:PHP ThemeInterface::getParents方法的具體用法?PHP ThemeInterface::getParents怎麽用?PHP ThemeInterface::getParents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sylius\Bundle\ThemeBundle\Model\ThemeInterface的用法示例。


在下文中一共展示了ThemeInterface::getParents方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: check

 /**
  * {@inheritdoc}
  */
 public function check(ThemeInterface $theme, array $previousThemes = [])
 {
     if (0 === count($theme->getParents())) {
         return;
     }
     $previousThemes = array_merge($previousThemes, [$theme]);
     foreach ($theme->getParents() as $parent) {
         if (in_array($parent, $previousThemes, true)) {
             throw new CircularDependencyFoundException(array_merge($previousThemes, [$parent]));
         }
         $this->check($parent, $previousThemes);
     }
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:16,代碼來源:CircularDependencyChecker.php

示例2: getThemeHierarchy

 /**
  * {@inheritdoc}
  */
 public function getThemeHierarchy(ThemeInterface $theme = null)
 {
     if (null === $theme) {
         return [];
     }
     $parents = [];
     foreach ($theme->getParents() as $parent) {
         $parents = array_merge($parents, $this->getThemeHierarchy($parent));
     }
     return array_merge([$theme], $parents);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:14,代碼來源:ThemeHierarchyProvider.php

示例3:

 function it_finds_circular_dependency_if_theme_parents_are_cycled(ThemeInterface $firstTheme, ThemeInterface $secondTheme, ThemeInterface $thirdTheme, ThemeInterface $fourthTheme)
 {
     $firstTheme->getParents()->willReturn([$secondTheme, $thirdTheme]);
     $secondTheme->getParents()->willReturn([$thirdTheme]);
     $thirdTheme->getParents()->willReturn([$fourthTheme]);
     $fourthTheme->getParents()->willReturn([$secondTheme]);
     $firstTheme->getName()->willReturn('first/theme');
     $secondTheme->getName()->willReturn('second/theme');
     $thirdTheme->getName()->willReturn('third/theme');
     $fourthTheme->getName()->willReturn('fourth/theme');
     $this->shouldThrow(CircularDependencyFoundException::class)->during('check', [$firstTheme]);
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:12,代碼來源:CircularDependencyCheckerSpec.php

示例4:

 function it_ensures_cohesion_between_parent_themes(ThemeLoaderInterface $themeLoader, ThemeRepositoryInterface $themeRepository, ThemeMergerInterface $themeMerger, ThemeInterface $loadedTheme, ThemeInterface $loadedParentTheme, ThemeInterface $existingParentTheme)
 {
     $themeRepository->findAll()->willReturn([$existingParentTheme]);
     $existingParentTheme->getName()->willReturn('parent-theme/name');
     $themeLoader->load()->willReturn([$loadedTheme, $loadedParentTheme]);
     $loadedTheme->getName()->willReturn('theme/name');
     $loadedTheme->getParents()->willReturn([$loadedParentTheme]);
     $themeRepository->findOneByName('theme/name')->willReturn(null);
     $loadedParentTheme->getName()->willReturn('parent-theme/name');
     $loadedParentTheme->getParents()->willReturn([]);
     $themeRepository->findOneByName('parent-theme/name')->willReturn($existingParentTheme);
     $loadedTheme->removeParent($loadedParentTheme)->shouldBeCalled();
     $loadedTheme->addParent($existingParentTheme)->shouldBeCalled();
     $themeMerger->merge($existingParentTheme, $loadedParentTheme)->willReturn($existingParentTheme);
     $themeRepository->add($loadedTheme)->shouldBeCalled();
     $themeRepository->add($existingParentTheme)->shouldBeCalled();
     $themeRepository->add($loadedParentTheme)->shouldNotBeCalled();
     $this->synchronize();
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:19,代碼來源:ThemeSynchronizerSpec.php

示例5:

 function it_returns_theme_list_in_hierarchized_order(ThemeInterface $firstTheme, ThemeInterface $secondTheme)
 {
     $firstTheme->getParents()->willReturn([$secondTheme]);
     $secondTheme->getParents()->willReturn([]);
     $this->getThemeHierarchy($firstTheme)->shouldReturn([$firstTheme, $secondTheme]);
 }
開發者ID:Sylius,項目名稱:SyliusThemeBundle,代碼行數:6,代碼來源:ThemeHierarchyProviderSpec.php


注:本文中的Sylius\Bundle\ThemeBundle\Model\ThemeInterface::getParents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。