Currently, APIs are simple mappings from FQCN to published APIs via ExtJs Direct.
For example, mapping a directory that contains following classes under namespace MyStuff.example:
My\SimpleClassName
My\Other\RpcClass
Allows usage of following (js-side):
MyStuff.example.SimpleClassName.*
MyStuff.example["Other\\RpcClass"].*
While the concept works very well for simple use cases that don't involve dependencies, this approach doesn't fit the current ZF2 philosophy nor complex approaches, since the FQCN itself does not define what an object looks like.
New logic
My idea is to migrate everything to service IDs. Instantiation of the services themselves would still be based on the main ServiceLocator, so it would work out of the box.
Would give access (js-side) to following direct methods:
my_test_service.*,
another_service.*,
My.FQCN.Named.Service.*,
yet.another.naming.convention.*,
test1.*
test2.*
test3.*
test4.*
This also defers all the instantiation of direct services to the service manager, giving us much more power
Automatical name conversions
I think it would be still possible to use \ and . as namespace separator in the PHP to JS conversion, though I'd prefer to have the end user define it manually. Anyway, this method removes any "grouped" namespacing, by giving direct alias to multiple aliases for a single user to a service.
ServiceLocator services as RPC (WIP)
Current logic
Currently, APIs are simple mappings from FQCN to published APIs via ExtJs Direct.
For example, mapping a directory that contains following classes under namespace
MyStuff.example
:My\SimpleClassName
My\Other\RpcClass
Allows usage of following (js-side):
MyStuff.example.SimpleClassName.*
MyStuff.example["Other\\RpcClass"].*
While the concept works very well for simple use cases that don't involve dependencies, this approach doesn't fit the current ZF2 philosophy nor complex approaches, since the FQCN itself does not define what an object looks like.
New logic
My idea is to migrate everything to service IDs. Instantiation of the services themselves would still be based on the main
ServiceLocator
, so it would work out of the box.For example, defining following services:
my_test_service
another_service
My\FQCN\Named\Service
yet.another.naming.convention
And mapping them as following:
Would give access (js-side) to following direct methods:
my_test_service.*
,another_service.*
,My.FQCN.Named.Service.*
,yet.another.naming.convention.*
,test1.*
test2.*
test3.*
test4.*
This also defers all the instantiation of direct services to the service manager, giving us much more power
Automatical name conversions
I think it would be still possible to use
\
and.
as namespace separator in the PHP to JS conversion, though I'd prefer to have the end user define it manually. Anyway, this method removes any "grouped" namespacing, by giving direct alias to multiple aliases for a single user to a service.