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

Notice: This thread is very old.
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?

David Grudl
Nette Core | 8133
+
0
-

What exception it throws?

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

David Grudl
Nette Core | 8133
+
0
-

Hmmm, I see…

How do you work with this structure?

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.

David Grudl
Nette Core | 8133
+
0
-

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

David Grudl
Nette Core | 8133
+
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))
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)