# |
Dec 3rd 2019, 16:39 |
shifat.it |
https://pastebin.com/135UPfpG |
# |
Dec 3rd 2019, 16:39 |
shifat.it |
how to convert this in association |
# |
Dec 3rd 2019, 16:27 |
noel |
Seems that was a red-herring anyhow because either side of that logic split I still get a malformed URL :thinking_face: |
# |
Dec 3rd 2019, 16:18 |
noel |
It's false by default and in my case it is throwing an error because for some unknown reason it is producing a URL without a controller or action set. I thought it might be this problem: https://crud-json-api.readthedocs.io/en/latest/additional-information/common-issues.html#missing-routes ... but I've added all my models into the routes and it's still happening. So I'm stumped. Have been for 2 days now. |
# |
Dec 3rd 2019, 16:16 |
noel |
It's clear that it's used in generating those links but it seems to be a switch, which writes them one way if enabled and another if not and the difference is neither clear nor documented: https://github.com/FriendsOfCake/crud-json-api/blob/382907f1d9cca4fe23fc9113d93bb9ea45037806/src/Schema/JsonApi/DynamicEntitySchema.php#L285 |
# |
Dec 3rd 2019, 16:15 |
noel |
Yes it does, of course... but the question is what precisely has it to do with them :slightly_smiling_face: |
# |
Dec 3rd 2019, 16:15 |
josbeir |
=> https://jsonapi.org/format/#document-resource-object-related-resource-links |
# |
Dec 3rd 2019, 16:15 |
josbeir |
i'm guessing it has to do with related content links in json:api |
# |
Dec 3rd 2019, 16:13 |
noel |
@josbeir Thanks. I have read the spec, however that string `_jsonApiBelongsToLinks` does not appear in the spec. In the CRUD implementation it splits the logic based on that setting but it's not clear why nor what it's doing – the code has no related comments and nor do the docs. |
# |
Dec 3rd 2019, 16:05 |
sohnyrin |
That was it, headers problem gone :) |
# |
Dec 3rd 2019, 16:00 |
sohnyrin |
ok thanks, the warning must be the problem then |
# |
Dec 3rd 2019, 16:00 |
sohnyrin |
ohhh |
# |
Dec 3rd 2019, 16:00 |
ricksaccous |
generally whenever i get the headers have already been sent message that means there is an error on that action/ a deprecation warning of some sort/etc |
# |
Dec 3rd 2019, 16:00 |
sohnyrin |
Yes my entity is called "Evaluations" my method is "Analysis" and I call /Evaluations/Analysis in the url |
# |
Dec 3rd 2019, 15:59 |
ricksaccous |
@sohnyrin are you putting this in a controller action? |
# |
Dec 3rd 2019, 15:57 |
sohnyrin |
Hi ! :slightly_smiling_face: I'm using a php script that calls php-curl on my cake app but I get a warning that headers have already been sent. I put "die;'" as first line in my method so the header is sent somewhere else before? |
# |
Dec 3rd 2019, 15:54 |
josbeir |
@noel read up on json:api spec |
# |
Dec 3rd 2019, 15:45 |
noel |
Any CRUD masters here? :slightly_smiling_face: What does this config setting do? `_jsonApiBelongsToLinks` |
# |
Dec 3rd 2019, 15:44 |
ndm |
Pre new HTTP stack I was storing the global listeners in the config, and then apply them manually on test setup. But `Application::bootstrap()` should work, gave it a quick test and it works as expected, it's run for each test and will register events on the fresh event manager. |
# |
Dec 3rd 2019, 15:34 |
birdy247 |
doesnt work :( |
# |
Dec 3rd 2019, 15:34 |
birdy247 |
actually |
# |
Dec 3rd 2019, 15:33 |
ndm |
By default it's included via `require_once` , ie only once, so subsequent tests won't run it again. |
# |
Dec 3rd 2019, 15:31 |
birdy247 |
because we already incluce bootstrap.php at the top of this |
# |
Dec 3rd 2019, 15:31 |
birdy247 |
weird |
# |
Dec 3rd 2019, 15:29 |
birdy247 |
I moved them in there and it works :slightly_smiling_face: |
# |
Dec 3rd 2019, 15:28 |
ndm |
or maybe I'm mixing things up, I'd have to look how I did it in some of my apps |
# |
Dec 3rd 2019, 15:27 |
ndm |
If you're on the "new" HTTP stack, then moving registering events into `Application::bootstrap()` should work I think. |
# |
Dec 3rd 2019, 15:25 |
birdy247 |
Can we do anything for this test? |
# |
Dec 3rd 2019, 15:25 |
birdy247 |
right |
# |
Dec 3rd 2019, 15:25 |
ndm |
The global event manager is being reset on every test run to avoid events stacking up / bleeding into other tets |
# |
Dec 3rd 2019, 15:23 |
birdy247 |
In a controller (integration) test |
# |
Dec 3rd 2019, 15:23 |
birdy247 |
however, when we run a test, it is never called |
# |
Dec 3rd 2019, 15:22 |
birdy247 |
The Model.Initalize is hit fine |
# |
Dec 3rd 2019, 15:20 |
birdy247 |
EventManager::instance()->on('Model.initialize', function (Event $event) { //TODO - attach the tenant scope for all ArticlesManager tables if ($event->getSubject()->getRegistryAlias() == "ArticlesManager.Articles") { } |
# |
Dec 3rd 2019, 15:19 |
birdy247 |
We have attached an event listener in our bootstrap.php file |
# |
Dec 3rd 2019, 15:19 |
birdy247 |
Hi |
# |
Dec 3rd 2019, 15:12 |
ndm |
@ckjksl The result set that point 2 refers to is basically the result set from point 3 and 4. After results have been retrieved, being it from cache, or from the database, that result set will be assigned to a property of the query instance, and will be returned for all subsequent requests to fetch results for that query instance (until it's being marked dirty). https://github.com/cakephp/cakephp/blob/3.8.6/src/Datasource/QueryTrait.php#L298 |
# |
Dec 3rd 2019, 15:07 |
gianmarxgagliardi |
thanks |
# |
Dec 3rd 2019, 15:06 |
gianmarxgagliardi |
@neon1024 wroooooooooooooooooooo |
# |
Dec 3rd 2019, 15:06 |
gianmarxgagliardi |
@neon1024 I solved -> https://stackoverflow.com/questions/59141547/cakephp-displays-the-id-display-table-name-from-two-different-tables-with-relati/59142515#59142515 |
# |
Dec 3rd 2019, 15:02 |
ckjksl |
haha, that's true. Does that mean in step 2., the query is able to ask for a "results set" without executing the query (as in step 4.)? |