Browse Source

Ajustement Setting & Section

packProduct
Guillaume 3 years ago
parent
commit
a51a7ba1d7
8 changed files with 43 additions and 13 deletions
  1. +2
    -2
      Controller/ControllerTrait.php
  2. +15
    -0
      Definition/SectionSettingDefinition.php
  3. +0
    -3
      Form/Setting/BaseSettingType.php
  4. +2
    -2
      Form/Setting/SectionSettingsFormType.php
  5. +14
    -1
      Repository/Section/SectionStore.php
  6. +5
    -2
      Resolver/SectionResolver.php
  7. +2
    -0
      Resources/translations/admin.fr.yaml
  8. +3
    -3
      Twig/StoreTwigExtension.php

+ 2
- 2
Controller/ControllerTrait.php View File

@@ -142,9 +142,9 @@ trait ControllerTrait
return $this->get(SectionResolver::class)->getCurrent();
}

public function getSectionCurrentSlug(): string
public function getSectionCurrentDevAlias(): string
{
return $this->getSectionCurrent()->getSlug();
return $this->getSectionCurrent()->getDevAlias();
}

public function getCartCurrent(): OrderShopInterface

+ 15
- 0
Definition/SectionSettingDefinition.php View File

@@ -13,6 +13,8 @@ class SectionSettingDefinition extends AbstractSettingDefinition
const SETTING_ORDER_CLOSED_START = 'orderClosedStart';
const SETTING_ORDER_CLOSED_END = 'orderClosedEnd';
const SETTING_ORDER_MAXIMUM_PER_CYCLE = 'orderMaximumPerCycle';
/*const SETTING_COLOR_PRIMARY = 'colorPrimary';
const SETTING_COLOR_SECONDARY = 'colorSecondary';*/

const VALUE_ORDER_STATE_DEFAULT = 'default';
const VALUE_ORDER_STATE_OPEN = 'open';
@@ -60,6 +62,19 @@ class SectionSettingDefinition extends AbstractSettingDefinition
'category' => self::CATEGORY_GENERAL,
]
);

/*$this->addSettingText(
[
'name' => self::SETTING_COLOR_PRIMARY,
'category' => self::CATEGORY_GENERAL,
]
);
$this->addSettingText(
[
'name' => self::SETTING_COLOR_SECONDARY,
'category' => self::CATEGORY_GENERAL,
]
);*/
}

public function getCategories()

+ 0
- 3
Form/Setting/BaseSettingType.php View File

@@ -59,9 +59,6 @@ abstract class BaseSettingType extends SovBaseSettingType
$label = 'setting_definition.'.$transCategory.'.settings.'.$settingName ;

if(isset($settingDefinition) && $settingDefinition) {



$this->buildFormSetting($label, $form, $settingDefinition, $settingEntity);
}
}

+ 2
- 2
Form/Setting/SectionSettingsFormType.php View File

@@ -13,8 +13,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;

class SectionSettingsFormType extends AbstractType
{
protected $em;
protected $translatorAdmin;
protected EntityManagerInterface $em;
protected TranslatorAdmin $translatorAdmin;

public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin)
{

+ 14
- 1
Repository/Section/SectionStore.php View File

@@ -30,7 +30,7 @@ class SectionStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
$this->addFilterByMerchantOptionnal($query);
return $query;
}

@@ -39,6 +39,19 @@ class SectionStore extends AbstractStore
return $query;
}

public function getOneBySlug(string $slug, bool $isOnline = true, $query = null)
{
$query = $this->createDefaultQuery($query);

$query->filterBySlug($slug);

if ($isOnline) {
$query->filterIsOnline();
}

return $query->findOne();
}

public function getOneDefault($query = null)
{
$query = $this->createDefaultQuery($query);

+ 5
- 2
Resolver/SectionResolver.php View File

@@ -61,12 +61,15 @@ class SectionResolver
return $currentAdminSection;
} // front
else {
$sectionStore = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent());
$merchantCurrent = $this->merchantResolver->getCurrent();
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent);
$sectionCurrent = null;
$sectionDefault = $sectionStore->getOneDefault();

if(isset($requestAttributesArray['section'])) {
$sectionCurrent = $sectionStore->getOneBySlug($requestAttributesArray['section']);
$sectionCurrent = $sectionStore
->setMerchant($merchantCurrent)
->getOneBySlug($requestAttributesArray['section']);
}

return $sectionCurrent ?: $sectionDefault;

+ 2
- 0
Resources/translations/admin.fr.yaml View File

@@ -43,6 +43,8 @@ setting_definition:
orderClosedStart: Période commandes fermées (début)
orderClosedEnd: Période commandes fermées (fin)
orderMaximumPerCycle: Nombre maximum de commande par cycle de vente
colorPrimary: Couleur primaire
colorSecondary: Couleur secondaire

entity:
default:

+ 3
- 3
Twig/StoreTwigExtension.php View File

@@ -85,7 +85,7 @@ class StoreTwigExtension extends AbstractExtension
new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']),
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']),
new TwigFunction('section_current', [$this, 'getSectionCurrent']),
new TwigFunction('section_slug_current', [$this, 'getSectionSlugCurrent']),
new TwigFunction('section_current_slug', [$this, 'getSectionCurrentSlug']),
new TwigFunction('merchant_setting', [$this, 'getMerchantSetting']),
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']),
new TwigFunction('section_setting', [$this, 'getSectionSetting']),
@@ -110,7 +110,7 @@ class StoreTwigExtension extends AbstractExtension
return $this->sectionResolver->getCurrent();
}

public function getSectionSlugCurrent(): string
public function getSectionCurrentSlug(): string
{
return $this->sectionResolver->getCurrent()->getSlug();
}
@@ -149,7 +149,7 @@ class StoreTwigExtension extends AbstractExtension
return $this->settingSolver->getSettingValue($section, $settingName);
}

public function getSectionSettingCurrent(string $settingName): string
public function getSectionSettingCurrent(string $settingName): ?string
{
return $this->settingSolver->getSettingValue($this->getSectionCurrent(), $settingName);
}

Loading…
Cancel
Save