/**
  * Test the custom domain handling.
  *
  * @return void
  */
 public function testCustomDomain()
 {
     $translator = new StaticTranslator();
     $translator->setValue('test-custom-domain', 'custom-domain-value', 'custom');
     $translator->setValue('test-custom-domain', 'custom-domain-value-en', 'custom', 'en');
     $this->assertSame('custom-domain-value', $translator->translate('test-custom-domain', 'custom'));
     $this->assertSame('custom-domain-value', $translator->translate('test-custom-domain', 'custom', array('unused')));
     $this->assertSame('custom-domain-value-en', $translator->translate('test-custom-domain', 'custom', array('unused'), 'en'));
 }
Esempio n. 2
0
 /**
  * Parse the palettes from the input screen into the data container.
  *
  * @param IMetaModelDataDefinition $container The data container.
  *
  * @return void
  */
 protected function parsePalettes(IMetaModelDataDefinition $container)
 {
     $inputScreen = $this->getInputScreenDetails();
     $metaModel = $this->getMetaModel();
     if ($container->hasDefinition(PalettesDefinitionInterface::NAME)) {
         $palettesDefinition = $container->getDefinition(PalettesDefinitionInterface::NAME);
     } else {
         $palettesDefinition = new DefaultPalettesDefinition();
         $container->setDefinition(PalettesDefinitionInterface::NAME, $palettesDefinition);
     }
     $palette = new Palette();
     $palette->setName('default')->setCondition(new DefaultPaletteCondition());
     $palettesDefinition->addPalette($palette);
     foreach ($inputScreen->getLegends() as $legendName => $legend) {
         $paletteLegend = new Legend($legendName);
         $paletteLegend->setInitialVisibility(isset($legend['visible']) && (bool) $legend['visible']);
         $palette->addLegend($paletteLegend);
         $this->translator->setValue($legendName . '_legend', isset($legend['name']) ? $legend['name'] : '', $container->getName());
         foreach ($legend['properties'] as $propertyName) {
             $property = new Property($propertyName);
             $paletteLegend->addProperty($property);
             $propInfo = $inputScreen->getProperty($propertyName);
             $chain = new PropertyConditionChain();
             $property->setEditableCondition($chain);
             $chain->addCondition(new BooleanCondition(!(isset($propInfo['info']['readonly']) && $propInfo['info']['readonly'])));
             if ($metaModel->hasVariants() && !$metaModel->getAttribute($propertyName)->get('isvariant')) {
                 $chain->addCondition(new PropertyValueCondition('varbase', 1));
             }
             $extra = $propInfo['info'];
             $chain = new PropertyConditionChain();
             $property->setVisibleCondition($chain);
             $chain->addCondition(new BooleanCondition(!(isset($extra['doNotShow']) && $extra['doNotShow'] || isset($extra['hideInput']) && $extra['hideInput'])));
             $propertyConditions = $inputScreen->getConditionsFor($propertyName);
             if ($propertyConditions !== null) {
                 $chain->addCondition($propertyConditions);
             }
             // If variants, do show only if allowed.
             if ($metaModel->hasVariants()) {
                 $chain->addCondition(new IsVariantAttribute());
             }
         }
     }
 }