# |
Jun 25th 2021, 09:26 |
staccato123 |
vendor/autoload.php seems to be being called twice |
# |
Jun 25th 2021, 09:26 |
staccato123 |
is this the right location for assistance with upgrading from 2.x to 3.x? I have followed the instructions but I am still getting "PHP Fatal error: Cannot declare class App\Console\Command\AppShell, because the name is already in use" when I use the built-in server, and similar (but a different class) with Apache |
# |
Jun 25th 2021, 09:24 |
staccato123 |
Hi all |
# |
Jun 25th 2021, 09:14 |
paolo.bragagni |
miss something? |
# |
Jun 25th 2021, 09:13 |
paolo.bragagni |
infact in appcontroller I have $this->viewBuilder()->Setlayout('TwitterBootstrap/default'); |
# |
Jun 25th 2021, 09:08 |
admad |
Because context matters. Doing $this->layout in a controller won't do anything, you are just setting a non existent property. `$this->viewBuilder()->setLayout('ajax');` should work unless the layout is being reset again somewhere like beforeRender() |
# |
Jun 25th 2021, 07:07 |
paolo.bragagni |
$this->layout = 'ajax'; inside the view did it. (but WHY??) |
# |
Jun 25th 2021, 07:04 |
paolo.bragagni |
still default layout |
# |
Jun 25th 2021, 07:04 |
paolo.bragagni |
no way |
# |
Jun 25th 2021, 07:04 |
paolo.bragagni |
$this->viewBuilder()->setLayout('ajax'); |
# |
Jun 25th 2021, 06:58 |
paolo.bragagni |
it still use the default layout |
# |
Jun 25th 2021, 06:58 |
paolo.bragagni |
cant use the 'ajax template |
# |
Jun 25th 2021, 06:58 |
paolo.bragagni |
if ($this->request->is('ajax')) { $this->layout = 'ajax'; $this->render('addAjaxBelong', 'ajax'); } |
# |
Jun 25th 2021, 06:58 |
paolo.bragagni |
hey |
# |
Jun 25th 2021, 04:35 |
greg138 |
Out of curiosity, why do you decode and then re-encode the file contents? Any chance that some part of that is failing to give what you expect? |
# |
Jun 24th 2021, 23:15 |
slackebot |
add into the controller ```$body = $this->request->getBody()->getContents(); dd($body);``` I get this [appname]\src\Controller\WoocommerceController.php#L61\^]8;;\ "" |
# |
Jun 24th 2021, 23:15 |
tyler.adam.lazenby |
What I get when I send in the request like this ```$signature = 'GKZ8mf9PiGLgAykuvlvcSEvUgw53IyNw0DfWv3lSbwo='; $this->configRequest(['headers' => [ Configure::read('WooCommerce.webhook.headers.signature') => $signature, 'content-type' => 'application/json', 'accept' => '*/*', ]]); $this->post(Router::url(['controller' => 'Woocommerce', 'action' => 'sendOrderEmail']), json_encode($this->json));``` and then |
# |
Jun 24th 2021, 23:13 |
kevin.pfeifer |
@ricmelero I would have to try to reproduce that routing error later/tomorrow. But you can of course create an issue in the cakephp repo |
# |
Jun 24th 2021, 23:12 |
ricmelero |
I read, a test, sorry |
# |
Jun 24th 2021, 23:11 |
tyler.adam.lazenby |
because I am getting a response on dd() commands inside that controller action |
# |
Jun 24th 2021, 23:11 |
tyler.adam.lazenby |
yeah That's not the issue |
# |
Jun 24th 2021, 23:11 |
tyler.adam.lazenby |
yes |
# |
Jun 24th 2021, 23:11 |
tyler.adam.lazenby |
I think sooo |
# |
Jun 24th 2021, 23:11 |
kevin.pfeifer |
@tyler.adam.lazenby have you enabled route loading in your tests? https://book.cakephp.org/4/en/development/testing.html#loading-routes-in-tests |
# |
Jun 24th 2021, 23:09 |
ricmelero |
that's $this here? a controller? |
# |
Jun 24th 2021, 23:09 |
ricmelero |
I'm using Cakephp 4 by the way |
# |
Jun 24th 2021, 23:08 |
tyler.adam.lazenby |
wait I might need to make this header for application/json |
# |
Jun 24th 2021, 23:07 |
ricmelero |
it's weird that the same call with same arguments, works one time and fails... |
# |
Jun 24th 2021, 23:06 |
ricmelero |
I guess I can handle it, in fact I can add the "lang" key in other places.. but I just wanted to know if I was doing something bad or if I should open a bug... |
# |
Jun 24th 2021, 23:06 |
tyler.adam.lazenby |
```$path = join(DS, [ROOT, 'tests', 'Resource', 'order.json']); $this->json = json_decode(file_get_contents($path), TRUE);``` |
# |
Jun 24th 2021, 23:05 |
tyler.adam.lazenby |
to simulate an order being sent from my webhook |
# |
Jun 24th 2021, 23:05 |
tyler.adam.lazenby |
I am just trying to make it so that the post is sending the json that I have gotten from the file. |
# |
Jun 24th 2021, 23:04 |
ricmelero |
@kevin.pfeifer the first time is built while seting up the AuthenticationService, but then I call in other places like the templates |
# |
Jun 24th 2021, 23:04 |
tyler.adam.lazenby |
```$signature = 'GKZ8mf9PiGLgAykuvlvcSEvUgw53IyNw0DfWv3lSbwo='; $this->configRequest(['headers' => [ Configure::read('WooCommerce.webhook.headers.signature') => $signature ]]); $this->post(Router::url(['controller' => 'Woocommerce', 'action' => 'sendOrderEmail']), json_encode($this->json));``` |
# |
Jun 24th 2021, 23:04 |
tyler.adam.lazenby |
I am not sure why, but my json is not being passed to the controller action when I run this as a test |
# |
Jun 24th 2021, 23:02 |
kevin.pfeifer |
so you cant pass the already matched (correct) first url to the place, where you need it again (2nd url) later? |
# |
Jun 24th 2021, 22:55 |
ricmelero |
which seems to be intentioned, but leads to a weird an unpredictable behavior |
# |
Jun 24th 2021, 22:51 |
ricmelero |
As far as I can see, here is the issue src/Routing/Route/Route.php:366 ```// Remove defaults that are also keys. They can cause match failures foreach ($this->keys as $key) { unset($this->defaults[$key]); }``` |
# |
Jun 24th 2021, 22:50 |
ricmelero |
what I was trying to do is to setup a default lang... but it seems that Route::match() is mutating internals of the route, so after first match, the defaults changes, making next match call fails |
# |
Jun 24th 2021, 22:48 |
ricmelero |
this is the route definition, I'm using the AdMad/I18n Routing plugin |
# |
Jun 24th 2021, 22:48 |
ricmelero |
```$builder->connect('/', ['controller' => 'Authentication', 'action' => 'login', 'lang' => 'es'], RouteNames::login);``` |