# |
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);``` |
# |
Jun 24th 2021, 22:47 |
ricmelero |
I use a class with const for named routes |
# |
Jun 24th 2021, 22:47 |
ricmelero |
Sorry, RouteName::login is ['_name' => 'login'] |
# |
Jun 24th 2021, 22:47 |
ricmelero |
I'm having a weird issue with routes, that fails the second time I build the same url, in this case a named route: ```$loginUrl = Router::url(RouteNames::login); $loginUrl = Router::url(RouteNames::login);``` The first call works ok, building login url, but second fails |
# |
Jun 24th 2021, 21:10 |
marius.treu |
my current approach is with amphp executing the resulting SQL genereated by an cakephp query |
# |
Jun 24th 2021, 21:10 |
marius.treu |
hi all, is there a way to create async queries with the cakephp ORM? |
# |
Jun 24th 2021, 20:12 |
rightscoreanalysis |
my bad, I frogot to prefix themodel with the plugin name |
# |
Jun 24th 2021, 20:02 |
rightscoreanalysis |
anyone able to help with a cake2 question, in my Api model: public $useTable = false; in another model I have: ClassRegistry::init('Api'); but I get: *Error:* Table _apis_ for model _Api_ was not found in datasource _default_. |
# |
Jun 24th 2021, 16:37 |
richard |
no worries, i always thought it was weird too ;) |
# |
Jun 24th 2021, 16:36 |
kaliel |
thank you <3 |
# |
Jun 24th 2021, 16:36 |
kaliel |
@richard oh my god it works, kind of weird |
# |
Jun 24th 2021, 16:35 |
richard |
@kaliel yes |
# |
Jun 24th 2021, 16:35 |
richard |
think it’s ‘_method’ |
# |
Jun 24th 2021, 16:35 |
kaliel |
you mean in Router::url ? |
# |
Jun 24th 2021, 16:35 |
richard |
and you have to if you limit it like that i believe |
# |
Jun 24th 2021, 16:35 |
richard |
@kaliel you can specify the method in the route |
# |
Jun 24th 2021, 16:32 |
kaliel |
```$url = Router::url(['prefix' => 'Api', 'controller' => 'Payment', 'action' => 'notify'], true); // gives a MissingRouteException``` |
# |
Jun 24th 2021, 16:31 |
kaliel |
Hi everyone, any clue on why a route which only accept POST method, is not found by Router;;url() ? ``` $builder->connect('/payment/notify', ['controller' => 'Payment', 'action' => 'notify']) ->setMethods(['POST']);``` |
# |
Jun 24th 2021, 15:11 |
admad |
`contain('Related' => function ($q) { //modify query })` |
# |
Jun 24th 2021, 09:06 |
conehead |
@val I added a Rule "IsNullOrUnique" for that |
# |
Jun 24th 2021, 09:03 |
val |
Hi, is there a way to use `$rules->isUnique()` in 3.x but to ignore this rule if the field value that should be validated is null? |
# |
Jun 24th 2021, 08:47 |
conehead |
Yes, that does work. But I think it would be not so good to catch the event every time something is saved and then 99.9% of the time just do nothing :P I guess I will just go with it by triggering my own event |
# |
Jun 24th 2021, 08:45 |
kevin.pfeifer |
Model.beforeSave here: https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php#L1936 |
# |
Jun 24th 2021, 08:44 |
kevin.pfeifer |
e.g. the global Model.afterSave event is being triggered here https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php#L2009 |
# |
Jun 24th 2021, 08:43 |
slackebot |
coupling is the measure of how little a class is “wired” to external objects, and how much that class is depending on them." |
# |
Jun 24th 2021, 08:43 |
conehead |
Like the first sentence of the Event System says: "Creating maintainable applications is both a science and an art. It is well-known that a key for having good quality code is making your objects loosely coupled and strongly cohesive at the same time. Cohesion means that all methods and properties for a class are strongly related to the class itself and it is not trying to do the job other objects should be doing, while loosely |
# |
Jun 24th 2021, 08:38 |
slackebot |
test it |