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

return $this->get(SectionResolver::class)->getCurrent(); 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 public function getCartCurrent(): OrderShopInterface

+ 15
- 0
Definition/SectionSettingDefinition.php View File

const SETTING_ORDER_CLOSED_START = 'orderClosedStart'; const SETTING_ORDER_CLOSED_START = 'orderClosedStart';
const SETTING_ORDER_CLOSED_END = 'orderClosedEnd'; const SETTING_ORDER_CLOSED_END = 'orderClosedEnd';
const SETTING_ORDER_MAXIMUM_PER_CYCLE = 'orderMaximumPerCycle'; 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_DEFAULT = 'default';
const VALUE_ORDER_STATE_OPEN = 'open'; const VALUE_ORDER_STATE_OPEN = 'open';
'category' => self::CATEGORY_GENERAL, '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() public function getCategories()

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

$label = 'setting_definition.'.$transCategory.'.settings.'.$settingName ; $label = 'setting_definition.'.$transCategory.'.settings.'.$settingName ;


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



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

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



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


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

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



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


return $query; 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) public function getOneDefault($query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);

+ 5
- 2
Resolver/SectionResolver.php View File

return $currentAdminSection; return $currentAdminSection;
} // front } // front
else { else {
$sectionStore = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent());
$merchantCurrent = $this->merchantResolver->getCurrent();
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent);
$sectionCurrent = null; $sectionCurrent = null;
$sectionDefault = $sectionStore->getOneDefault(); $sectionDefault = $sectionStore->getOneDefault();


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


return $sectionCurrent ?: $sectionDefault; return $sectionCurrent ?: $sectionDefault;

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

orderClosedStart: Période commandes fermées (début) orderClosedStart: Période commandes fermées (début)
orderClosedEnd: Période commandes fermées (fin) orderClosedEnd: Période commandes fermées (fin)
orderMaximumPerCycle: Nombre maximum de commande par cycle de vente orderMaximumPerCycle: Nombre maximum de commande par cycle de vente
colorPrimary: Couleur primaire
colorSecondary: Couleur secondaire


entity: entity:
default: default:

+ 3
- 3
Twig/StoreTwigExtension.php View File

new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']), new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']),
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']), new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']),
new TwigFunction('section_current', [$this, 'getSectionCurrent']), 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', [$this, 'getMerchantSetting']),
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']), new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']),
new TwigFunction('section_setting', [$this, 'getSectionSetting']), new TwigFunction('section_setting', [$this, 'getSectionSetting']),
return $this->sectionResolver->getCurrent(); return $this->sectionResolver->getCurrent();
} }


public function getSectionSlugCurrent(): string
public function getSectionCurrentSlug(): string
{ {
return $this->sectionResolver->getCurrent()->getSlug(); return $this->sectionResolver->getCurrent()->getSlug();
} }
return $this->settingSolver->getSettingValue($section, $settingName); 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); return $this->settingSolver->getSettingValue($this->getSectionCurrent(), $settingName);
} }

Loading…
Cancel
Save