wintercms / wn-builder-plugin

GUI for building plugins in Winter CMS
MIT License
34 stars 12 forks source link

Error adding permissions #32

Closed faselunare closed 1 year ago

faselunare commented 2 years ago

Step to reproduce Go to permission tabs Add permission like

conference.event.create | base33.conference::lang.conference.events.event | base33.conference::lang.conference.events.event_create

before save, translations are added in the lang.php file

<?php return [
    'plugin' => [
        'name' => 'Conference',
        'description' => 'Events management plugin',
    ],
    'conference' => [
        'events' => [
            'event' => 'Event',
            'event_create' => 'Create',
        ],
    ],
];

while saving I get this error

Screenshot 2022-03-16 at 20 28 05

and is impossible to save permission

faselunare commented 2 years ago

While this code is present in the lang.php file

'conference' => [
        'events' => [
            'event' => 'Event',
            'event_create' => 'Create',
        ],
    ],

I get this other error

  htmlspecialchars(): Argument #1 ($string) must be of type string, array given
/Users/francesco/Dev/sites/wn-conference/vendor/winter/storm/src/Support/helpers.php line 23

system.log is empty, no stack trace available

faselunare commented 2 years ago

After an investigation, seems that when creating a new string, you can't have something like this

base33.conference::lang.event.event_create

but just

base33.conference::lang.event_create

in the preview version of builder string like this

base33.conference::lang.event.opening

works fine

see an old piece of code that works


<?php return [
    'plugin' => [
        'name' => 'Conference',
        'description' => '',
    ],
    'event' => [
        'opening' => 'Opening',
        'closing' => 'Closing',
    ],
    ... 
    ``` 
bennothommo commented 2 years ago

@faselunare I can't replicate this, even with the steps you've added above. You may need to do some more investigation and see if you can narrow it down somewhere.

faselunare commented 2 years ago

Ok, the same error happened when creating backend menu image

Create a new menu's voice add a code with 'something.somethingelse' and get the error

bennothommo commented 2 years ago

@faselunare can you please post your entire lang file(s)? I cannot replicate the above either.

faselunare commented 2 years ago

this is one lang file from another smallest plugin i'm working on

<?php return [
    'plugin' => [
        'name' => 'Exhibition Catalog',
        'description' => 'Create a catalog of exhibition elements, for example: exhibition spaces, artwork... end with a form for request informations about the selected products.',
    ],
    'forms' => [
        'reorder' => 'Reorder',
    ],
    'title' => 'Title',
    'slug' => 'Slug',
    'description' => 'Description',
    'parent' => 'Parent',
    'isactive' => 'Is active',
    'excat' => 'Exhibition Catalog',
    'create' => 'Create',
    'excat_categories' => 'Exhibition Catalog Categories',
    'select_parent' => 'Select parent category',
    'media' => 'Media',
    'content' => 'Content',
    'image' => 'Image',
    'gallery' => 'Gallery',
    'active' => 'Active',
    'assets' => 'Assets',
    'items' => 'Items',
    'categories' => 'Categories',
    'price' => 'Price',
    'test' => [
        'active' => 'test active',
    ],
    'permission' => [
        'edit_category' => 'Edit category',
    ],
];

now seems to work when i use a string like base33.excat::lang.permission.edit

bennothommo commented 2 years ago

@faselunare so you're no longer experiencing the issue?

faselunare commented 2 years ago

no

bennothommo commented 1 year ago

Thanks @faselunare. Please let me know if the issue reoccurs and we'll reopen.