# |
Jun 27th 2021, 18:36 |
cnizzardini |
Yeah I was engaging Mark over twitter and he pointed me in this direction |
# |
Jun 27th 2021, 18:35 |
kevin.pfeifer |
well you can definitely create an issue where you explain what you would like to be implemented. Since this feature is not directly supported by cakephp (but the library cakephp uses for DI) I guess there needs to be more done for this to work. as well as the fact that the DI container is marked as experimental ;) |
# |
Jun 27th 2021, 18:33 |
cnizzardini |
Hmm... I wonder if I should report a bug eh? |
# |
Jun 27th 2021, 18:31 |
kevin.pfeifer |
seems like it is stuck trying to resolve the ServerRequest class because these values never change |
# |
Jun 27th 2021, 18:30 |
kevin.pfeifer |
well i can definitely confirm your error, ( i get a *`Maximum function nesting level of '256' reached`)* |
# |
Jun 27th 2021, 18:22 |
cnizzardini |
https://container.thephpleague.com/3.x/auto-wiring/ |
# |
Jun 27th 2021, 18:22 |
cnizzardini |
I'm trying to avoid needing to define the arguments using auto-wiring |
# |
Jun 27th 2021, 18:21 |
cnizzardini |
I am doing this in Plugin.php, but I don't think that should matter |
# |
Jun 27th 2021, 18:21 |
kevin.pfeifer |
well the way how I use the DI container with arguments is like that: ``` $container->add( CategoryHelper::class ); $container->add( AlfredFTP::class ) ->addArgument(CategoryHelper::class);``` |
# |
Jun 27th 2021, 18:21 |
cnizzardini |
```<b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in <b>/srv/app/vendor/league/container/src/Argument/ArgumentResolverTrait.php</b> on line <b>20</b>``` |
# |
Jun 27th 2021, 18:21 |
cnizzardini |
Resulting in |
# |
Jun 27th 2021, 18:20 |
cnizzardini |
```$container ->add(GetActorService::class); $container ->defaultToShared() ->delegate((new ReflectionContainer()));``` |
# |
Jun 27th 2021, 18:20 |
cnizzardini |
So i tried something like this: |
# |
Jun 27th 2021, 18:19 |
cnizzardini |
But I'd like to not need to define the arguments |
# |
Jun 27th 2021, 18:19 |
cnizzardini |
```/** @var Container $container */ $container ->add(GetActorService::class) ->addArgument(new ActorsTable());``` |
# |
Jun 27th 2021, 18:19 |
cnizzardini |
So this works fine: |
# |
Jun 27th 2021, 18:18 |
cnizzardini |
I'm probably doing stuff wrong |
# |
Jun 27th 2021, 18:17 |
kevin.pfeifer |
I heavily use the new DI container, and got no problems. Can you explain your problem in more detail? |
# |
Jun 27th 2021, 18:16 |
cnizzardini |
Has anyone gotten auto wiring working with the new DI stuff? I am getting timeouts. |
# |
Jun 27th 2021, 15:33 |
kevin.pfeifer |
well thats something I totally overlooked when i read through the documentation :see_no_evil: ,:) |
# |
Jun 27th 2021, 15:20 |
ndm |
@alamnaryab Configure a custom finder for the related identifier's ORM Resolver, you can then contain your associations in that finder. https://stackoverflow.com/questions/63057543/cakephp-4-1-user-entity-as-authorization-identity-associated-fields/63061706#63061706 |
# |
Jun 27th 2021, 10:55 |
alamnaryab |
I think it is like below but I could not found any documentation or example ``` $result = $this->Authentication->setIdentity($userWithContainedModels); $result = $result->getResult();``` |
# |
Jun 27th 2021, 10:41 |
kevin.pfeifer |
``` $result = $this->Authentication->getResult(); if($result){ $user = $result->getData(); }``` the $user is an entity which has its own fields but does not contain any fields from other (containing) models (like roles) How to tell the authentication service that the resulting user entity should contain other models I can’t tell you right now but I am curious too :thinking_face: |
# |
Jun 26th 2021, 23:02 |
alamnaryab |
`$result = $this->Authentication->getResult();` `$result` has a protected property `_data` which has logged in user record. I am not able to find documentation how to append its protect property `_data` |
# |
Jun 26th 2021, 22:59 |
alamnaryab |
Good Morning I am using cakephp 4 Authentication plugin https://book.cakephp.org/4/en/tutorials-and-examples/cms/authentication.html on successful login I also want to get roles from database for that user. how can I do? |
# |
Jun 26th 2021, 18:52 |
cnizzardini |
nevermind, it comes from the league/container, but is not present in the cakephp container interface so phpstorm doesn't know |
# |
Jun 26th 2021, 18:49 |
cnizzardini |
Documentation indicates there is a `$container->share` method, but I don't see one https://book.cakephp.org/4/en/development/dependency-injection.html#adding-shared-services |
# |
Jun 26th 2021, 15:51 |
mokiwaa |
Thk you |
# |
Jun 26th 2021, 15:50 |
mokiwaa |
I will check again the logs file and debugkit sql generated ... |
# |
Jun 26th 2021, 15:44 |
kevin.pfeifer |
well a hasMany and hasOne aren't that different from a database structure point of view. I haven't used the proffer plugin till now but I guess this shouldn't be the problem. Either way do you have something in your logs directory that could lead to you to some problem? Or maybe check the DebugKit generated sql when showing the file(s) if everything looks like you expect it |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
but no luck |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
and echo $this->Form->control('brand_logo', ['label'=>'Logo', 'type'=>'file']); |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
I have tried to use echo $this->Form->control('brand_logos', ['label'=>'Logo', 'type'=>'file']); |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
in the form |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
the image get upload |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
but if I use hasMany |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
I cant make it work |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
with hasOne association |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
I have a problem with the proffer plugin |
# |
Jun 26th 2021, 15:36 |
kevin.pfeifer |
just ask :) |
# |
Jun 26th 2021, 15:35 |
mokiwaa |
:) |