# |
Jun 1st 2021, 21:03 |
tyler.adam.lazenby |
On unit tests, I want to test to see if the response contains a new account id, since I return it in application/json form. How can I do that? |
# |
Jun 1st 2021, 21:02 |
thomas465 |
well, here the tag id is 10 |
# |
Jun 1st 2021, 21:02 |
kevin.pfeifer |
ah ok your junction table has an id |
# |
Jun 1st 2021, 21:01 |
thomas465 |
https://book.cakephp.org/4/en/orm/saving-data.html#saving-additional-data-to-the-join-table |
# |
Jun 1st 2021, 21:01 |
thomas465 |
it looks like the example in the docs ``` 'tags' => [ [ 'id' => 10, '_joinData' => [ 'comment' => '123123' ] ], // Other courses.``` |
# |
Jun 1st 2021, 20:57 |
kevin.pfeifer |
and it does look like that? ```$entity['tags'] = [ '_ids' => [ '23' ] ];``` where 23 is one valid tag id |
# |
Jun 1st 2021, 20:52 |
thomas465 |
(the import script is just doing pathEntity on handcrafted arrays so i would not think it makes a difference) |
# |
Jun 1st 2021, 20:51 |
thomas465 |
let me give it a try |
# |
Jun 1st 2021, 20:47 |
kevin.pfeifer |
does it also happen when you add that entry “normally” via your template or does it just happen with your import script |
# |
Jun 1st 2021, 20:45 |
thomas465 |
My issue is that when running a import/sync it keeps touching the same 5 tags resulting in deadlock errors after a while |
# |
Jun 1st 2021, 20:45 |
thomas465 |
(ok that was terrible english) I’m creating a new link in the link table, (with some extra joindata) all that works fine, but it updates the modified date of the `tag` i’m linking to, is that expected behaviour ? |
# |
Jun 1st 2021, 20:43 |
thomas465 |
Question when saving belongsToMany() association with _joinData … is it expected that the modified date of the target table? So if `products -> products_tags -> tags` it updates the modifed col of `tags` |
# |
Jun 1st 2021, 20:43 |
kevin.pfeifer |
well you get the parsed json data via ```$data = $this->getRequest()->getData()``` if you want the raw body you could try look at your $_POST Variable (if you sent your data via POST) |
# |
Jun 1st 2021, 20:06 |
rightscoreanalysis |
is $this->request->input() the best way to read raw json body |
# |
Jun 1st 2021, 19:10 |
tyler.adam.lazenby |
right, that is what I just did now, but the issue is that I have to add that to the table class itself as a method and I can reuse that |
# |
Jun 1st 2021, 19:05 |
richard |
makes more sense to add something like that to $validator |
# |
Jun 1st 2021, 19:04 |
richard |
@tyler.adam.lazenby you wouldn’t see the error until you attempt a save on buildRules |
# |
Jun 1st 2021, 18:34 |
kevin.pfeifer |
is it the developer mentioned in the comments at the start of the style.css in the theme? |
# |
Jun 1st 2021, 18:33 |
jonathan086 |
Understood Kevin! This is frustrating when I am directed to the wrong avenue. |
# |
Jun 1st 2021, 18:28 |
kevin.pfeifer |
Just FYI: CakePHP is a complete MVC Framework in which you build whole websites with it, not "just" some little library you use to build themes with |
# |
Jun 1st 2021, 18:25 |
jonathan086 |
I am reaching back out to the developer Kevin. Thanks for your time and appreciate it. |
# |
Jun 1st 2021, 18:17 |
kevin.pfeifer |
+ i find it very suspect, that a theme developer tells you (a customer) to update a "library" the theme developer used to build the theme (which I still doubt) This should in my opinion always be the job of the theme developer, not the customer |
# |
Jun 1st 2021, 18:11 |
kevin.pfeifer |
do you have a composer.json inside your theme |
# |
Jun 1st 2021, 18:10 |
jonathan086 |
That is the reason why I contacted you. |
# |
Jun 1st 2021, 18:10 |
jonathan086 |
Thanks Kevin! The developer told me to update the cake PHP. |
# |
Jun 1st 2021, 17:47 |
kevin.pfeifer |
@jonathan086 your errors are related to your Wordpress Theme "Nova" not being compatible with your new PHP Version. So upgrade your Theme (if possible without changes, not always the case) But generally this is a CakePHP support channel, not a Wordpress Support channel and your error currently has nothing to do with cakephp |
# |
Jun 1st 2021, 17:41 |
jonathan086 |
After updating the value of String to CakeText, I am getting this error: *Parse error*: syntax error, unexpected ‘new’ (T_NEW) in */var/www/vhosts/scainc.net/httpdocs/wp-content/themes/nova/app/libs/inflector.php* on line *300* |
# |
Jun 1st 2021, 17:39 |
jonathan086 |
*Fatal error*: Cannot use ‘String’ as class name as it is reserved in */var/www/vhosts/scainc.net/httpdocs/wp-content/themes/nova/app/libs/string.php* on line *28* |
# |
Jun 1st 2021, 17:39 |
jonathan086 |
https://www.scainc.net/ |
# |
Jun 1st 2021, 17:39 |
jonathan086 |
I am in need of help. I used a wordpress theme and its framework was built on CakePHP. Upon upgrading wordpress to the latest version, I had to move the PHP version to 7.*. After updating, I am getting the following error: |
# |
Jun 1st 2021, 17:24 |
tyler.adam.lazenby |
I just tried with __invoke as returning false, and it is still doing that |
# |
Jun 1st 2021, 17:18 |
tyler.adam.lazenby |
```$rules->add(new NotHasOneAsFirstChar('phone', 'You cannot use 1 as the first character of a phone number.'), 'notHasOneAsFirstCharacter');``` |
# |
Jun 1st 2021, 17:18 |
slackebot |
return $value[0] != "1"; } protected function cleanValue(string $value): array|string|null { $pattern = "/[^0-9]+/"; $replacement = ""; return preg_replace($pattern, $replacement, $value); } }``` |
# |
Jun 1st 2021, 17:18 |
slackebot |
function __construct(string $field, ?string $message = null) { $this->_fields = $field; if ($message) { $this->message = $message; } else { $this->message = __("That value is invalid."); } } public function __invoke(EntityInterface $entity, array $options): bool { $value = $entity->get($this->_fields); $value = $this->cleanValue($value); |
# |
Jun 1st 2021, 17:18 |
tyler.adam.lazenby |
```<?php namespace App\Model\Rule; use Cake\Datasource\EntityInterface; class NotHasOneAsFirstChar { /** * Name of fields or fields that this rule should be applied to. * @var string */ protected string $_fields; /** * Default message that should be set. Default message is "That value is invalid.". * @var string|null */ protected ?string $message; public |
# |
Jun 1st 2021, 17:17 |
tyler.adam.lazenby |
I am still struggling with this. All I am trying to do is prevent the user from putting 1 as the first character for their phone number. It is being passed with an input mask so that it is easier for the user to put it in. I can clean off the mask pretty easily. Once I have done that, my test is trying to pass "(123) 567-8910" so that it will fail the validation test. Bu the entity doesn't have any errors. |
# |
Jun 1st 2021, 17:02 |
tyler.adam.lazenby |
ok, thanks |
# |
Jun 1st 2021, 17:02 |
ndm |
Not at all, that's the save operation flow options. Simply store the constructor argument value in a property and use that in the invoke method. |
# |
Jun 1st 2021, 17:02 |
tyler.adam.lazenby |
oh I see now |
# |
Jun 1st 2021, 16:52 |
tyler.adam.lazenby |
Question... how would the $options parameter be used with that constructor? |
# |
Jun 1st 2021, 16:40 |
tyler.adam.lazenby |
ok that should work |