/** * {@inheritdoc} */ public function load($resource, $type = null) { if (!$this->filesystem->exists($resource)) { throw new \InvalidArgumentException(sprintf('Given theme metadata file "%s" does not exists!', $resource)); } $themeData = $this->transformResourceContentsToArray($this->filesystem->getFileContents($resource)); $theme = $this->themeFactory->createFromArray($themeData); $theme->setPath(substr($resource, 0, strrpos($resource, '/'))); return $theme; }
/** * {@inheritdoc} */ public function load($resource, $type = null) { if (!file_exists($resource)) { throw new \InvalidArgumentException(sprintf('Given theme metadata file "%s" does not exists!', $resource)); } $themeData = $this->transformResourceContentsToArray(file_get_contents($resource)); $theme = $this->themeFactory->createFromArray($themeData); $theme->setPath(realpath(dirname($resource))); return $theme; }
function it_loads_valid_theme_file(FilesystemInterface $filesystem, ThemeFactoryInterface $themeFactory, ThemeInterface $theme) { $filesystem->exists('/themes/SampleTheme/theme.json')->willReturn(true); $filesystem->getFileContents('/themes/SampleTheme/theme.json')->willReturn('{ "name": "Sample Theme", "slug": "sylius/sample-theme", "description": "Lorem ipsum dolor sit amet." }'); $themeFactory->createFromArray(["name" => "Sample Theme", "slug" => "sylius/sample-theme", "description" => "Lorem ipsum dolor sit amet."])->willReturn($theme); $theme->setPath('/themes/SampleTheme')->shouldBeCalled(); $this->load('/themes/SampleTheme/theme.json')->shouldReturn($theme); }
function it_loads_valid_theme_file(ThemeFactoryInterface $themeFactory, ThemeInterface $theme) { $themeFactory->createFromArray(["name" => "Sample Theme", "logical_name" => "sylius/sample-theme", "description" => "Lorem ipsum dolor sit amet."])->shouldBeCalled()->willReturn($theme); $theme->setPath(realpath(dirname($this->getValidThemeFilePath())))->shouldBeCalled(); $this->load($this->getValidThemeFilePath())->shouldHaveType('Sylius\\Bundle\\ThemeBundle\\Model\\ThemeInterface'); }