private function _process(tubepress_api_ioc_ContainerBuilderInterface $containerBuilder, $id) { $logger = $containerBuilder->get('tubepress_internal_logger_BootLogger'); $finderFactory = $containerBuilder->get('finder_factory'); $bootSettings = $containerBuilder->get(tubepress_api_boot_BootSettingsInterface::_); $context = $containerBuilder->get(tubepress_api_options_ContextInterface::_); $urlFactory = $containerBuilder->get(tubepress_api_url_UrlFactoryInterface::_); $langUtils = $containerBuilder->get(tubepress_api_util_LangUtilsInterface::_); $stringUtils = $containerBuilder->get(tubepress_api_util_StringUtilsInterface::_); $serializer = new tubepress_internal_boot_helper_uncached_Serializer($bootSettings); $factory = new tubepress_internal_boot_helper_uncached_contrib_ThemeFactory($context, $urlFactory, $langUtils, $logger, $stringUtils, $finderFactory); $manifestFinder = new tubepress_internal_boot_helper_uncached_contrib_ManifestFinder(TUBEPRESS_ROOT . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $id, DIRECTORY_SEPARATOR . $id, 'theme.json', $logger, $bootSettings, $finderFactory); $manifests = $manifestFinder->find(); $themes = array(); foreach ($manifests as $path => $manifestData) { $theme = $factory->fromManifestData($path, $manifestData); if (is_array($theme)) { continue; } if ($theme->getName() === 'changeme/themename') { //ignore the starter theme continue; } $themes[] = $theme; } $bootArtifacts = $containerBuilder->getParameter(tubepress_internal_boot_PrimaryBootstrapper::CONTAINER_PARAM_BOOT_ARTIFACTS); $bootArtifacts = array_merge($bootArtifacts, array($id => $serializer->serialize($themes))); $containerBuilder->setParameter(tubepress_internal_boot_PrimaryBootstrapper::CONTAINER_PARAM_BOOT_ARTIFACTS, $bootArtifacts); $containerBuilder->set('tubepress_internal_boot_helper_uncached_contrib_ThemeFactory', $factory); }
public function testFindAll() { $this->_mockBootSettings->shouldReceive('getUserContentDirectory')->once()->andReturn('user-content-dir-path'); list($handle, $path) = $this->getTemporaryFile(); $this->_setupFilesystem($handle, $path, json_encode(array('hi' => 'there'))); $actual = $this->_sut->find(); $this->assertTrue(is_array($actual)); $this->assertCount(1, $actual); $keys = array_keys($actual); $this->assertEquals($path, $keys[0]); $this->assertEquals(array('hi' => 'there'), $actual[$path]); }
private function _findAllAddons() { $manifests = $this->_manifestFinder->find(); $addons = array(); foreach ($manifests as $path => $data) { try { $errors = $this->_addonFactory->fromManifestData($path, $data); if (is_array($errors)) { //these will have been logged already continue; } $addons[] = $errors; } catch (Exception $e) { continue; } } if (!isset($this->_serializer)) { $this->_serializer = array(new tubepress_internal_boot_helper_uncached_Serializer($this->_bootSettings), 'serialize'); } $artifacts = array('add-ons' => call_user_func($this->_serializer, $addons, $this->_bootSettings)); $this->_containerBuilder->setParameter(tubepress_internal_boot_PrimaryBootstrapper::CONTAINER_PARAM_BOOT_ARTIFACTS, $artifacts); return $addons; }
/** * @param $pathToManifest * * @return tubepress_api_contrib_AddonInterface */ protected function getAddonFromManifest($pathToManifest) { $mockUrlFactory = $this->mock(tubepress_api_url_UrlFactoryInterface::_); $mockUrlFactory->shouldReceive('fromString')->andReturnUsing(function ($incoming) { $factory = new tubepress_url_impl_puzzle_UrlFactory($_SERVER); return $factory->fromString($incoming); }); $logger = new tubepress_internal_logger_BootLogger(false); $urlFactory = new tubepress_url_impl_puzzle_UrlFactory(); $bootSettings = new tubepress_internal_boot_BootSettings($logger, $urlFactory); $langUtils = new tubepress_util_impl_LangUtils(); $stringUtils = new tubepress_util_impl_StringUtils(); $finderFactory = new tubepress_internal_finder_FinderFactory(); $manifestFinder = new tubepress_internal_boot_helper_uncached_contrib_ManifestFinder(dirname($pathToManifest), 'whatevs', 'manifest.json', $logger, $bootSettings, $finderFactory); $addonFactory = new tubepress_internal_boot_helper_uncached_contrib_AddonFactory($logger, $urlFactory, $langUtils, $stringUtils, $bootSettings); $addonManifests = $manifestFinder->find(); $this->assertTrue(count($addonManifests) === 1, 'Expected 1 add-on but got ' . count($addonManifests)); $addons = array(); foreach ($addonManifests as $manifestPath => $contents) { $addons[] = $addonFactory->fromManifestData($manifestPath, $contents); } $this->assertTrue($addons[0] instanceof tubepress_api_contrib_AddonInterface); return $addons[0]; }