Example #1
0
 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);
 }
Example #2
0
 /**
  * @dataProvider getSerializeData
  */
 public function testSerialize($encoding, $nonSerialized, $serialized)
 {
     $this->_mockBootSettings->shouldReceive('getSerializationEncoding')->twice()->andReturn($encoding);
     $actualSerialized = $this->_sut->serialize($nonSerialized);
     $this->assertEquals($serialized, $actualSerialized);
     $actualDeserialized = $this->_sut->unserialize($serialized);
     $this->assertEquals($nonSerialized, $actualDeserialized);
 }
 public function __construct(array $bootArtifacts, $key, tubepress_api_log_LoggerInterface $logger, tubepress_internal_boot_helper_uncached_Serializer $serializer)
 {
     $this->_logger = $logger;
     $this->_nameToInstanceMap = array();
     if (!isset($bootArtifacts[$key])) {
         throw new InvalidArgumentException("{$key} not found in boot artifacts");
     }
     $contributables = $serializer->unserialize($bootArtifacts[$key]);
     if (!is_array($contributables)) {
         throw new InvalidArgumentException('Expected to deserialize an array');
     }
     foreach ($contributables as $contributable) {
         if (!$contributable instanceof tubepress_api_contrib_ContributableInterface) {
             throw new InvalidArgumentException('Unserialized data contained a non contributable');
         }
         $name = $contributable->getName();
         $this->_nameToInstanceMap[$name] = $contributable;
     }
 }
 /**
  * @param tubepress_api_ioc_ContainerBuilderInterface $containerBuilder The primary service container builder.
  *
  * @api
  *
  * @since 4.0.0
  */
 public function process(tubepress_api_ioc_ContainerBuilderInterface $containerBuilder)
 {
     if (!$containerBuilder->hasParameter(tubepress_internal_boot_PrimaryBootstrapper::CONTAINER_PARAM_BOOT_ARTIFACTS)) {
         return;
     }
     $bootArtifacts = $containerBuilder->getParameter(tubepress_internal_boot_PrimaryBootstrapper::CONTAINER_PARAM_BOOT_ARTIFACTS);
     if (!is_array($bootArtifacts) || !isset($bootArtifacts['themes'])) {
         return;
     }
     $serializedThemes = $bootArtifacts['themes'];
     $bootSettings = $containerBuilder->get(tubepress_api_boot_BootSettingsInterface::_);
     $serializer = new tubepress_internal_boot_helper_uncached_Serializer($bootSettings);
     $unserializedThemes = $serializer->unserialize($serializedThemes);
     $adjustedSystemThemes = $this->_adjustLegacySystemThemes($containerBuilder, $unserializedThemes);
     $userLegacyThemes = $this->_findUserLegacyThemes($bootSettings, $containerBuilder);
     $allLegacyThemes = array_merge($adjustedSystemThemes, $userLegacyThemes);
     $allThemes = array_merge($unserializedThemes, $allLegacyThemes);
     $serializedThemes = $serializer->serialize($allThemes);
     $bootArtifacts['themes'] = $serializedThemes;
     $containerBuilder->setParameter(tubepress_internal_boot_PrimaryBootstrapper::CONTAINER_PARAM_BOOT_ARTIFACTS, $bootArtifacts);
 }