Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "The 2LE's CruditPlatform Bundle.",
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.4",
"symfony/console": "^7.0 || ^8.0",
"2lenet/crudit-bundle": "^1.0",
"2lenet/credential-bundle": "^2.0",
"2lenet/credential-bundle": "^3.0",
"2lenet/dashboard2-bundle": "^2.0",
"symfony/framework-bundle": "^7.0 || ^8.0",
"symfony/http-kernel": "^7.0 || ^8.0",
Expand Down
22 changes: 6 additions & 16 deletions src/Service/CruditCredentialWarmup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\EntityManagerInterface;
use Lle\CredentialBundle\Contracts\CredentialWarmupInterface;
use Lle\CredentialBundle\Factory\CredentialFactory;
use Lle\CredentialBundle\Repository\CredentialRepository;
use Lle\CredentialBundle\Service\CredentialWarmupTrait;
use Lle\CruditBundle\Contracts\CrudConfigInterface;
Expand All @@ -18,28 +19,28 @@ public function __construct(
#[AutowireIterator('crudit.config')] protected iterable $cruditConfigs,
protected CredentialRepository $credentialRepository,
protected EntityManagerInterface $entityManager,
protected CredentialFactory $credentialFactory,
) {
}

public function warmUp(): void
{
$i = 0;
/** @var CrudConfigInterface $cruditConfig */
foreach ($this->cruditConfigs as $cruditConfig) {
/** @var string $rubrique */
$rubrique = $cruditConfig->getName();

foreach (CrudConfigInterface::BASIC_ACTIONS_KEYS as $role => $label) {
$this->createRoleForAction($cruditConfig, $role, $rubrique, $label, $i++);
$this->createRoleForAction($cruditConfig, $role, $rubrique, $label);
}

// Page Roles
foreach (CrudConfigInterface::BASIC_FIELDS_KEYS as $key) {
$this->createRoleForFields($cruditConfig, $key, $rubrique, $i++);
$this->createRoleForFields($cruditConfig, $key, $rubrique);
}

foreach ($cruditConfig::ADDITIONAL_FIELDS_KEYS as $key) {
$this->createRoleForFields($cruditConfig, $key, $rubrique, $i++);
$this->createRoleForFields($cruditConfig, $key, $rubrique);
}

// Actions Roles
Expand All @@ -49,7 +50,6 @@ public function warmUp(): void
$action->getPath()->getRole(),
$rubrique,
$action->getLabel(),
$i++,
type: 'credential.action.list',
);
}
Expand All @@ -59,7 +59,6 @@ public function warmUp(): void
$action->getRole(),
$rubrique,
$action->getLabel(),
$i++,
type: 'credential.action.list',
);
}
Expand All @@ -72,7 +71,6 @@ public function warmUp(): void
$action->getPath()->getRole(),
$rubrique,
$action->getLabel(),
$i++,
type: 'credential.action.item',
);
}
Expand All @@ -82,7 +80,6 @@ public function warmUp(): void
$action->getRole(),
$rubrique,
$action->getLabel(),
$i++,
type: 'credential.action.item',
);
}
Expand All @@ -95,7 +92,6 @@ public function warmUp(): void
$action->getPath()->getRole(),
$rubrique,
$action->getLabel(),
$i++,
type: 'credential.action.show',
);
}
Expand All @@ -105,7 +101,6 @@ public function warmUp(): void
$action->getRole(),
$rubrique,
$action->getLabel(),
$i++,
type: 'credential.action.show',
);
}
Expand All @@ -119,7 +114,6 @@ public function warmUp(): void
$tabs->getRole(),
$rubrique,
$tabs->getLabel(),
$i++,
type: 'credential.tab',
);
}
Expand All @@ -134,7 +128,6 @@ public function warmUp(): void
$brick->getRole(),
$rubrique,
$tabs->getLabel(),
$i++,
type: $brick->getTitle() ?? (
'credential.'
. strtolower(str_replace('Config', '', end($brickClassPart)))
Expand All @@ -152,18 +145,16 @@ public function createRoleForAction(
string $role,
string $rubrique,
string $label,
int $i,
): void {
$this->checkAndCreateCredential(
strtoupper('ROLE_' . $crudConfig->getName() . '_' . $role),
$rubrique,
strtolower('action.' . $label),
$i,
type: 'credential.action',
);
}

public function createRoleForFields(CrudConfigInterface $cruditConfig, string $key, string $rubrique, int $i): void
public function createRoleForFields(CrudConfigInterface $cruditConfig, string $key, string $rubrique): void
{
foreach ($cruditConfig->getFields($key) as $field) {
$fields = $field instanceof Field ? [$field] : $field;
Expand All @@ -174,7 +165,6 @@ public function createRoleForFields(CrudConfigInterface $cruditConfig, string $k
$subField->getRole(),
$rubrique,
$subField->getLabel(),
$i,
type: 'credential.field',
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Service/FrontMenuCredentialWarmup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\EntityManagerInterface;
use Lle\CredentialBundle\Contracts\CredentialWarmupInterface;
use Lle\CredentialBundle\Factory\CredentialFactory;
use Lle\CredentialBundle\Repository\CredentialRepository;
use Lle\CredentialBundle\Service\CredentialWarmupTrait;
use Lle\CruditBundle\Registry\MenuRegistry;
Expand All @@ -15,7 +16,8 @@ class FrontMenuCredentialWarmup implements CredentialWarmupInterface
public function __construct(
protected MenuRegistry $menuRegistry,
protected CredentialRepository $credentialRepository,
protected EntityManagerInterface $entityManager
protected EntityManagerInterface $entityManager,
protected CredentialFactory $credentialFactory,
) {
}

Expand All @@ -30,7 +32,6 @@ public function warmUp(): void
$menuItem->getRole(),
$rubrique,
"Menu " . str_replace("menu.", "", $menuItem->getId()),
$i++
);
}
foreach ($menuItem->getChildren() as $submenuItem) {
Expand All @@ -41,7 +42,6 @@ public function warmUp(): void
$submenuItem->getRole(),
$rubrique,
"↳ Sous menu " . str_replace("menu.", "", $submenuItem->getId()),
$i++
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Service/WidgetCredentialWarmup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\EntityManagerInterface;
use Lle\CredentialBundle\Contracts\CredentialWarmupInterface;
use Lle\CredentialBundle\Factory\CredentialFactory;
use Lle\CredentialBundle\Repository\CredentialRepository;
use Lle\CredentialBundle\Service\CredentialWarmupTrait;
use Lle\DashboardBundle\Service\WidgetProvider;
Expand All @@ -16,20 +17,19 @@ public function __construct(
protected WidgetProvider $widgetProvider,
protected CredentialRepository $credentialRepository,
protected EntityManagerInterface $entityManager,
protected CredentialFactory $credentialFactory,
) {
}

public function warmUp(): void
{
$rubrique = "Widgets";
$i = 0;
if ($this->widgetProvider->getWidgetTypes()) {
foreach ($this->widgetProvider->getWidgetTypes() as $widget) {
$this->checkAndCreateCredential(
$widget->getRole(),
$rubrique,
$widget->getName(),
$i++,
type: 'credential.widget'
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Service/WorkflowCredentialWarmup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\EntityManagerInterface;
use Lle\CredentialBundle\Contracts\CredentialWarmupInterface;
use Lle\CredentialBundle\Factory\CredentialFactory;
use Lle\CredentialBundle\Repository\CredentialRepository;
use Lle\CredentialBundle\Service\CredentialWarmupTrait;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
Expand All @@ -17,6 +18,7 @@ public function __construct(
#[AutowireIterator('workflow')] protected iterable $workflows,
protected CredentialRepository $credentialRepository,
protected EntityManagerInterface $entityManager,
protected CredentialFactory $credentialFactory,
) {
}

Expand All @@ -34,7 +36,6 @@ public function warmUp(): void
$role,
strtoupper($workflowName),
'credential.transition.' . strtolower($transition->getName()),
0,
type: 'credential.transition',
);
}
Expand Down
Loading