本文整理汇总了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);
}
}
示例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);
}
示例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]);
}
示例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();
}
示例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]);
}