Skip to content

Commit

Permalink
Refacto EmployeeController based on PrestaShopAdminController
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Oct 17, 2024
1 parent 999336f commit 6e68643
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 185 deletions.
4 changes: 2 additions & 2 deletions src/Adapter/Employee/EmployeeFormAccessChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function isRestrictedAccess($employeeId)
public function isRestrictedAccess(int $employeeId): bool
{
if (!is_int($employeeId)) {
throw new InvalidArgumentException(sprintf('Employee ID must be an integer, %s given', gettype($employeeId)));
Expand All @@ -73,7 +73,7 @@ public function isRestrictedAccess($employeeId)
/**
* {@inheritdoc}
*/
public function canAccessEditFormFor($employeeId)
public function canAccessEditFormFor(int $employeeId): bool
{
// To access super admin edit form you must be a super admin.
if ($this->employeeDataProvider->isSuperAdmin($employeeId)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Employee/FormLanguageChanger.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(LegacyContext $legacyContext)
/**
* {@inheritdoc}
*/
public function changeLanguageInCookies($languageIsoCode)
public function changeLanguageInCookies(string $languageIsoCode): void
{
$this->legacyContext->getContext()->cookie->employee_form_lang = (int) Language::getIdByIso($languageIsoCode);
$this->legacyContext->getContext()->cookie->write();
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Employee/NavigationMenuToggler.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(LegacyContext $legacyContext)
/**
* {@inheritdoc}
*/
public function toggleNavigationMenuInCookies($shouldCollapse)
public function toggleNavigationMenuInCookies(bool $shouldCollapse): void
{
$this->legacyContext->getContext()->cookie->collapse_menu = (int) $shouldCollapse;
$this->legacyContext->getContext()->cookie->write();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface EmployeeFormAccessCheckerInterface
*
* @return bool
*/
public function isRestrictedAccess($employeeId);
public function isRestrictedAccess(int $employeeId): bool;

/**
* Check if context employee can access edit form for given employee.
Expand All @@ -51,5 +51,5 @@ public function isRestrictedAccess($employeeId);
*
* @return bool
*/
public function canAccessEditFormFor($employeeId);
public function canAccessEditFormFor(int $employeeId): bool;
}
2 changes: 1 addition & 1 deletion src/Core/Employee/FormLanguageChangerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ interface FormLanguageChangerInterface
*
* @param string $languageIsoCode two letter iso code of the language
*/
public function changeLanguageInCookies($languageIsoCode);
public function changeLanguageInCookies(string $languageIsoCode): void;
}
2 changes: 1 addition & 1 deletion src/Core/Employee/NavigationMenuTogglerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ interface NavigationMenuTogglerInterface
*
* @param bool $shouldCollapse if true - collapse the navigation, expand it otherwise
*/
public function toggleNavigationMenuInCookies($shouldCollapse);
public function toggleNavigationMenuInCookies(bool $shouldCollapse): void;
}
2 changes: 1 addition & 1 deletion src/Core/Team/Employee/Configuration/OptionsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function canBeChanged()
public function canBeChanged(): bool
{
if (!$this->multistoreFeature->isUsed()
&& $this->multistoreContextChecker->isSingleShopContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ interface OptionsCheckerInterface
*
* @return bool
*/
public function canBeChanged();
public function canBeChanged(): bool;
}
Loading

0 comments on commit 6e68643

Please sign in to comment.