Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/ApiPlatform/Resources/Configuration/DebugMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Configuration;

use ApiPlatform\Metadata\ApiResource;
use PrestaShop\PrestaShop\Core\Domain\Configuration\Command\SwitchDebugModeCommand;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSUpdate;

#[ApiResource(
operations: [
/* new CQRSGet(
uriTemplate: '/debug/status',
CQRSQuery: GetDebugModeStatus::class,
scopes: ['debug_mode_read']
),*/
new CQRSUpdate(
uriTemplate: '/debug/toggle',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toggle word seems weird in this context to me.
To me, toggle action is for disable when enabled or enable when disabled, and without specify an argument.
But here, we can enable or disable debug mode with an argument in the request body.

Maybe here, just this is enough 🤔

Suggested change
uriTemplate: '/debug/toggle',
uriTemplate: '/debug-mode',

and pass the enable in the body.

CQRSCommand: SwitchDebugModeCommand::class,
scopes: ['debug_mode_write']
),
],
)]
class DebugMode
{
public string $enableDebugMode;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe enableDebugMode is too obvious here.

Let's keep that simple:

Suggested change
public string $enableDebugMode;
public string $enable;

What do you think?

}
Loading