Nette\DI\Statement does not accept array as entity in Nette 2.3-BETA

4 years ago

blur
Member | 15
+
0
-

I was used to have something like this in config.

someExtension:
    menu: {...}(acl: users, icon: users)

There is updated Statement class in nette 2.3 with new method setEntity(…). It should accept array as well but it does not.
https://api.nette.org/…ent.php.html#41

It's bug or I miss something?

4 years ago

David Grudl
Nette Core | 6850
+
0
-

What exception it throws?

4 years ago

blur
Member | 15
+
0
-

Exception: Nette\InvalidArgumentException Argument is not valid Statement entity.
Because this array have no [0] and [1].

When I create something like this:

menu: {true,true}(acl: users, icon: users)

There is this exception
Service ‘BackMenuData’: Expected function, method or property name, ‘1’ given

4 years ago

David Grudl
Nette Core | 6850
+
0
-

Hmmm, I see…

How do you work with this structure?

4 years ago

blur
Member | 15
+
0
-
"YouTube": {
    Správa videí: :Modules:YouTube:Back:Home:default(acl: users, icon: video-camera)
    Nastavení přístupu: :Modules:YouTube:Back:Home:account(acl: users, icon: user)
    Test: :Modules:YouTube:Back:Home:test(acl: users, icon: users)
    }(acl: users, icon: youtube)

In Nette 2.2* was Neon\Entity so I have menu in this structure with some attributes like icon, Acl resource etc.

4 years ago

David Grudl
Nette Core | 6850
+
0
-

Neon\Entity? It should be stdClass with properties value & attibutes.

4 years ago

David Grudl
Nette Core | 6850
+
0
-

This is really problem and I am unable to find any back compatible solution… Syntax a(b) is now used globally as Statement, before 2.3 there was intermediate stdClass (but it was really weird).

What do you think about this solution?

"YouTube": entity({
    Správa videí: entity(:Modules:YouTube:Back:Home:default, (acl: users, icon: video-camera))
    Nastavení přístupu: entity(:Modules:YouTube:Back:Home:account, (acl: users, icon: user))
    Test: entity(:Modules:YouTube:Back:Home:test, (acl: users, icon: users))
    }, (acl: users, icon: youtube))

4 years ago

blur
Member | 15
+
0
-

Something like this could be ok. If there is no route so it should be settings.

"YouTube":
    Správa videí: :Modules:YouTube:Back:Home:default(acl: users, icon: video-camera)
    Nastavení přístupu: :Modules:YouTube:Back:Home:account(acl: users, icon: user)
    Test: :Modules:YouTube:Back:Home:test(acl: users, icon: users)
    Settings: (acl: users, icon: youtube)