本文整理汇总了PHP中Sylius\Bundle\ThemeBundle\Model\ThemeInterface::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeInterface::getPath方法的具体用法?PHP ThemeInterface::getPath怎么用?PHP ThemeInterface::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Bundle\ThemeBundle\Model\ThemeInterface
的用法示例。
在下文中一共展示了ThemeInterface::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getApplicationPaths
/**
* @param string $resourceName
* @param ThemeInterface $theme
*
* @return array
*/
protected function getApplicationPaths($resourceName, ThemeInterface $theme)
{
$paths = [sprintf('%s/%s', $theme->getPath(), $resourceName)];
if ($this->deviceDetection->getType() !== null) {
$paths[] = sprintf('%s/%s/%s', $theme->getPath(), $this->deviceDetection->getType(), $resourceName);
krsort($paths);
}
return $paths;
}
示例2:
function it_throws_an_exception_if_settings_schema_does_not_exist(ThemeInterface $theme)
{
$theme->getTitle()->willReturn('Candy shop');
$theme->getName()->willReturn('candy/shop');
$theme->getPath()->willReturn($this->vfsStream->url());
$this->shouldThrow(new \InvalidArgumentException(sprintf('Could not find settings schema of theme "Candy shop" (candy/shop) in file "%s"', $this->vfsStream->url() . '/Settings.php')))->during('getSchema', [$theme]);
}
示例3: getBundlePaths
/**
* @param string $resourcePath
* @param ThemeInterface $theme
*/
protected function getBundlePaths($resourcePath, ThemeInterface $theme)
{
$bundleName = $this->getBundleNameFromResourcePath($resourcePath);
$resourceName = $this->getResourceNameFromResourcePath($resourcePath);
$bundles = $this->kernel->getBundle($bundleName, false);
$paths = [];
if (is_array($bundles)) {
foreach ($bundles as $bundle) {
if ($this->deviceDetection->getType() !== null) {
$paths[] = sprintf('%s/%s/%s/%s', $theme->getPath(), $this->deviceDetection->getType(), $bundle->getName(), $resourceName);
}
$paths[] = sprintf('%s/%s/%s', $theme->getPath(), $bundle->getName(), $resourceName);
}
}
return $paths;
}
示例4:
function it_throws_an_exception_if_resource_can_not_be_located(Filesystem $filesystem, ThemeInterface $theme)
{
$theme->getName()->willReturn('theme/name');
$theme->getPath()->willReturn('/theme/path');
$filesystem->exists('/theme/path/resource')->willReturn(false);
$this->shouldThrow(ResourceNotFoundException::class)->during('locateResource', ['resource', $theme]);
}
示例5: locateResource
/**
* {@inheritdoc}
*/
public function locateResource($resourceName, ThemeInterface $theme)
{
$path = sprintf('%s/%s', $theme->getPath(), $resourceName);
if (!$this->filesystem->exists($path)) {
throw new ResourceNotFoundException($resourceName, $theme);
}
return $path;
}
示例6: it_should_return_global_variables
public function it_should_return_global_variables(ThemeInterface $theme, ThemeContextInterface $themeContext)
{
$theme->getName()->willReturn('swp/theme-one');
$theme->getPath()->willReturn('/path/to/theme/');
$themeContext->getTheme()->shouldBeCalled()->willReturn($theme);
$globals = ['theme' => $theme];
$this->getGlobals()->shouldReturn($globals);
}
示例7:
function it_returns_an_array_of_translation_resources_paths(FinderFactoryInterface $finderFactory, Finder $finder, ThemeInterface $theme)
{
$finderFactory->create()->willReturn($finder);
$theme->getPath()->willReturn('/theme');
$finder->in('/theme')->shouldBeCalled()->willReturn($finder);
$finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder);
$finder->getIterator()->willReturn(new \ArrayIterator(['/theme/messages.en.yml', '/theme/translations/messages.en.yml', '/theme/translations/messages.en.yml.jpg', '/theme/translations/messages.yml', '/theme/AcmeBundle/translations/messages.pl_PL.yml']));
$this->findTranslationFiles($theme)->shouldReturn(['/theme/translations/messages.en.yml', '/theme/AcmeBundle/translations/messages.pl_PL.yml']);
}
示例8: getScreenshotPath
/**
* @param ThemeInterface $theme
* @param int $screenshotNumber
*
* @return string
*/
private function getScreenshotPath(ThemeInterface $theme, $screenshotNumber)
{
$screenshots = $theme->getScreenshots();
if (!isset($screenshots[$screenshotNumber])) {
throw new NotFoundHttpException(sprintf('Theme "%s" does not have screenshot #%d', $theme->getTitle(), $screenshotNumber));
}
$screenshotRelativePath = $screenshots[$screenshotNumber];
return rtrim($theme->getPath(), \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR . $screenshotRelativePath;
}
示例9:
function it_throws_an_exception_if_resource_can_not_be_located(Filesystem $filesystem, KernelInterface $kernel, ThemeInterface $theme, BundleInterface $childBundle, BundleInterface $parentBundle)
{
$kernel->getBundle('ParentBundle', false)->willReturn([$childBundle, $parentBundle]);
$childBundle->getName()->willReturn('ChildBundle');
$parentBundle->getName()->willReturn('ParentBundle');
$theme->getName()->willReturn('theme/name');
$theme->getPath()->willReturn('/theme/path');
$filesystem->exists('/theme/path/ChildBundle/views/index.html.twig')->shouldBeCalled()->willReturn(false);
$filesystem->exists('/theme/path/ParentBundle/views/index.html.twig')->shouldBeCalled()->willReturn(false);
$this->shouldThrow(ResourceNotFoundException::class)->during('locateResource', ['@ParentBundle/Resources/views/index.html.twig', $theme]);
}
示例10: getSchema
/**
* {@inheritdoc}
*/
public function getSchema(ThemeInterface $theme)
{
$schemaPath = sprintf('%s/Settings.php', $theme->getPath());
if (!file_exists($schemaPath)) {
throw new \InvalidArgumentException(sprintf('Could not find settings schema of theme "%s" (%s) in file "%s"', $theme->getTitle(), $theme->getName(), $schemaPath));
}
$schema = (require $schemaPath);
if (!$schema instanceof SchemaInterface) {
throw new \InvalidArgumentException(sprintf('File "%s" must return an instance of "%s"', $schemaPath, SchemaInterface::class));
}
return $schema;
}
示例11:
function it_finds_translation_files_and_adds_them_to_translator(ContainerBuilder $containerBuilder, ThemeRepositoryInterface $themeRepository, ThemeInterface $firstTheme, ThemeInterface $secondTheme, Definition $translatorDefinition)
{
$containerBuilder->get("sylius.theme.repository")->shouldBeCalled()->willReturn($themeRepository);
$themeRepository->findAll()->shouldBeCalled()->willReturn([$firstTheme, $secondTheme]);
$firstTheme->getPath()->shouldBeCalled()->willReturn($this->getFirstThemePath());
$secondTheme->getPath()->shouldBeCalled()->willReturn($this->getSecondThemePath());
$containerBuilder->getParameter('kernel.bundles')->shouldBeCalled()->willReturn(["SampleBundle" => "/Foo/Bar"]);
$containerBuilder->addResource(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'))->shouldBeCalled();
$containerBuilder->findDefinition('translator.default')->shouldBeCalled()->willReturn($translatorDefinition);
$translatorDefinition->getArgument(3)->shouldBeCalled()->willReturn(["resource_files" => ["en" => ["/lorem/ipsum/messages.en.yml"]]]);
$translatorDefinition->replaceArgument(3, ["resource_files" => ["en" => ["/lorem/ipsum/messages.en.yml", $this->getFirstThemePath() . '/SampleBundle/translations/messages.en.yml', $this->getFirstThemePath() . '/translations/messages.en.yml', $this->getSecondThemePath() . '/translations/messages.en.yml']]])->shouldBeCalled();
$this->process($containerBuilder);
}
示例12: locateResource
/**
* {@inheritdoc}
*
* @param string $resourcePath Eg. "@AcmeBundle/Resources/views/template.html.twig"
*/
public function locateResource($resourcePath, ThemeInterface $theme)
{
$this->assertResourcePathIsValid($resourcePath);
$bundleName = $this->getBundleNameFromResourcePath($resourcePath);
$resourceName = $this->getResourceNameFromResourcePath($resourcePath);
$bundles = $this->kernel->getBundle($bundleName, false);
foreach ($bundles as $bundle) {
$path = sprintf('%s/%s/%s', $theme->getPath(), $bundle->getName(), $resourceName);
if ($this->filesystem->exists($path)) {
return $path;
}
}
throw new ResourceNotFoundException($resourcePath, $theme);
}
示例13: iShouldNotSeeThemedHomepage
/**
* @Then I should not see a homepage from :theme theme
*/
public function iShouldNotSeeThemedHomepage(ThemeInterface $theme)
{
$content = file_get_contents(rtrim($theme->getPath(), '/') . '/SyliusShopBundle/views/Homepage/index.html.twig');
Assert::notSame($this->homePage->getContents(), $content);
}
示例14: iShouldNotSeeThemedHomepage
/**
* @Then I should not see a homepage from :theme theme
*/
public function iShouldNotSeeThemedHomepage(ThemeInterface $theme)
{
$content = file_get_contents(rtrim($theme->getPath(), '/') . '/SyliusWebBundle/views/Frontend/Homepage/main.html.twig');
expect($this->homePage->getContents())->notToBe($content);
}
示例15: themeChangesHomepageTemplateContents
/**
* @Given /^(this theme) changes homepage template contents to "([^"]+)"$/
*/
public function themeChangesHomepageTemplateContents(ThemeInterface $theme, $contents)
{
$file = rtrim($theme->getPath(), '/') . '/SyliusShopBundle/views/Homepage/index.html.twig';
$dir = dirname($file);
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
file_put_contents($file, $contents);
}