CoolCMS API

GenerateTrait uses trait:short

Handles the "generate now" button by calling {@see \App\UI\Admin\Eshop\Models\Managers\FeedManager::generateNow()}.

Runs under the same CronLockManager lock as the Cron:Eshop:Feed:generate job, so a manual click cannot collide with a running cron. The lock stays here (UI-level protection against double clicks), not in the manager.

Table of Contents

Constants

GENERATE_LOCK_NAME  : string = 'cron.eshop.feed.generate'

Methods

handleGenerateNow()  : void
isTargetAllowed()  : bool
Returns whether the logged-in user may open the given admin target. For visibility (tiles, autocomplete, buttons); it does not throw.
requirePrivilege()  : void
Throws 403 when the logged-in user lacks the given admin privilege.
resolvePageTarget()  : string|null
Returns the RBAC key of the target page: `<presenter>:<action>`, e.g. `:Admin:System:User:show`.

Constants

GENERATE_LOCK_NAME

private string GENERATE_LOCK_NAME = 'cron.eshop.feed.generate'

Methods

handleGenerateNow()

public handleGenerateNow() : void
Attributes
#[Requires]
$methods: 'POST'

isTargetAllowed()

Returns whether the logged-in user may open the given admin target. For visibility (tiles, autocomplete, buttons); it does not throw.

protected isTargetAllowed(string|null $key) : bool

IMPORTANT: fail-closed like requirePrivilege(): an empty key and a presenter without isAllowed() both mean no. A component that skips this question lists the target to everyone.

Parameters
$key : string|null
Return values
bool

requirePrivilege()

Throws 403 when the logged-in user lacks the given admin privilege.

protected requirePrivilege(string $key) : void

Call it as the first statement of a mutating signal, before loading data, so the check cannot be bypassed by something being written first.

Parameters
$key : string

resolvePageTarget()

Returns the RBAC key of the target page: `<presenter>:<action>`, e.g. `:Admin:System:User:show`.

protected static resolvePageTarget(object|null $page) : string|null

Same interpretation as Menu::filterByPrivileges(), BasePresenter::authorizeListing() and PrivilegeCheckTrait::checkCurrentPrivilege(). The key is derived from the page target only, never from a file or class name.

Returns null when the page is missing or has no presenter, so there is nothing to allow.

Parameters
$page : object|null

AdminPage entity (hydrated, hence just object)

Return values
string|null
On this page

Search results