Skip to content

Commit

Permalink
Renamed resources
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed Mar 25, 2024
1 parent 6682329 commit 5bec6e6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion router/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
->controller(Collection\NavbarRequest::class);

// Collection Forms
$form = $routes->collection('megio.collections.form')->prefix('/megio/collections/form');
$form = $routes->collection('megio.collections.form.')->prefix('/megio/collections/form');
$form->add('creating', '/creating')
->methods(['POST'])
->controller(Collection\Form\AddFormRequest::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Console/PermissionsUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(private readonly AuthResourceManager $manager)

protected function execute(InputInterface $input, OutputInterface $output): int
{
$types = array_filter(ResourceType::cases(), fn($case) => $case !== ResourceType::ROUTER_VIEW);
$types = array_filter(ResourceType::cases(), fn($case) => $case !== ResourceType::VUE_ROUTER);
$result = $this->manager->updateResources(true, [], ...$types);

foreach ($result['created'] as $resource) {
Expand Down
8 changes: 4 additions & 4 deletions src/Database/Enum/ResourceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
enum ResourceType: string
{
case ROUTER = 'router';
case ROUTER_VIEW = 'router.view';
case COLLECTION_RECIPE = 'collection.recipe';
case VUE_ROUTER = 'vue.router';
case COLLECTION_DATA = 'collection.data';
case COLLECTION_NAV = 'collection.nav';

public function getResourcesMethodName(): string {
// Method names in AuthResourceManager
return match($this) {
self::ROUTER => 'routerResources',
self::ROUTER_VIEW => 'routerViewResources',
self::COLLECTION_RECIPE => 'collectionDataResources',
self::VUE_ROUTER => 'routerViewResources',
self::COLLECTION_DATA => 'collectionDataResources',
self::COLLECTION_NAV => 'collectionNavResources',
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Manager/AuthResourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function updateResources(bool $flush = true, array $viewResources = [], R
foreach ($types as $type) {
$methodName = $type->getResourcesMethodName();

if ($type === ResourceType::ROUTER_VIEW) {
if ($type === ResourceType::VUE_ROUTER) {
$sourceNames = $this->$methodName($viewResources);
} else {
$sourceNames = $this->$methodName();
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class Router
{
public const ROUTE_API = 'megio.api';
public const ROUTE_APP = 'megio.app';
public const ROUTE_COLLECTION_PREFIX = 'megio.collection.recipe.';
public const ROUTE_COLLECTION_PREFIX = 'megio.collection.data.';
public const ROUTE_META_NAVBAR = 'megio.collection.nav';
}
8 changes: 4 additions & 4 deletions src/Http/Request/Resource/ReadAllRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function process(array $data): Response
$groups = $this->groupResources($resources, $roles);
$groups = $this->sortCollectionDataResources($groups);

$types = array_filter(ResourceType::cases(), fn($case) => $case !== ResourceType::ROUTER_VIEW);
$types = array_filter(ResourceType::cases(), fn($case) => $case !== ResourceType::VUE_ROUTER);

if ($data['make_view_diff']) {
$types = ResourceType::cases();
Expand Down Expand Up @@ -114,7 +114,7 @@ private function groupResources(array $resources, array $roles): array
*/
private function sortCollectionDataResources(array $resources): array
{
$key = ResourceType::COLLECTION_RECIPE->value;
$key = ResourceType::COLLECTION_DATA->value;
if (array_key_exists($key, $resources)) {
$groups = [];
foreach ($resources[$key] as $value) {
Expand All @@ -135,11 +135,11 @@ private function sortCollectionDataResources(array $resources): array

private function createHint(ResourceType $type, string $name): string|null
{
if ($type === ResourceType::ROUTER_VIEW) {
if ($type === ResourceType::VUE_ROUTER) {
return null;
}

if ($type === ResourceType::COLLECTION_NAV || $type === ResourceType::COLLECTION_RECIPE) {
if ($type === ResourceType::COLLECTION_NAV || $type === ResourceType::COLLECTION_DATA) {
$last = pathinfo($name, PATHINFO_EXTENSION);
$name = substr_replace($name, '', -strlen($last) - 1, strlen($last) + 1);
}
Expand Down

0 comments on commit 5bec6e6

Please sign in to comment.