From: Vincent Vanwaelscappel Date: Tue, 7 Jan 2020 18:41:28 +0000 (+0100) Subject: wip #3274 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7635ce8ac23f0e8bbc60d4ea4fa4edf0946f40f8;p=cubist_cms-back.git wip #3274 @4 --- diff --git a/src/app/Application.php b/src/app/Application.php new file mode 100644 index 0000000..c083b35 --- /dev/null +++ b/src/app/Application.php @@ -0,0 +1,22 @@ +get('app.variants', []); + } + + /** + * @return bool + */ + public function hasVariant() + { + return count($this->getVariants()) > 0; + } +} diff --git a/src/app/Magic/Fields/SiteVariant.php b/src/app/Magic/Fields/SiteVariant.php new file mode 100644 index 0000000..42f0fa9 --- /dev/null +++ b/src/app/Magic/Fields/SiteVariant.php @@ -0,0 +1,22 @@ +_adminType = 'hidden'; + $this->_options = ['default' => 'default']; + } else { + $this->_options = array_combine($variants, $variants); + } + parent::__construct($attributes); + } +} diff --git a/src/app/Magic/Fields/SiteVariantMultiple.php b/src/app/Magic/Fields/SiteVariantMultiple.php new file mode 100644 index 0000000..58a60ca --- /dev/null +++ b/src/app/Magic/Fields/SiteVariantMultiple.php @@ -0,0 +1,13 @@ +_multiple = true; + parent::__construct($attributes); + } +} diff --git a/src/app/Magic/Models/Locale.php b/src/app/Magic/Models/Locale.php index af2f966..e852dd4 100644 --- a/src/app/Magic/Models/Locale.php +++ b/src/app/Magic/Models/Locale.php @@ -30,6 +30,11 @@ class Locale extends CubistMagicAbstractModel 'type' => 'Country', 'label' => 'Drapeau']); + $this->addField(['name' => 'variant', + 'type' => 'SiteVariant', + 'label' => 'Variante du site', + 'column' => true]); + $this->addField(['name' => 'inherit', 'type' => 'LocaleEnabled', 'label' => 'Hériter les traductions de']); @@ -88,7 +93,8 @@ class Locale extends CubistMagicAbstractModel return array_keys(self::getLocales()); } - public static function getEnabledLocalesCodes(){ + public static function getEnabledLocalesCodes() + { return array_keys(self::getLocalesDataForFront()['enabled']); }