Skip to content

Deprecate methods - #2

Open
delamux wants to merge 17 commits into
cakemojo:1.3.xfrom
delamux:deprecate-methods
Open

Deprecate methods#2
delamux wants to merge 17 commits into
cakemojo:1.3.xfrom
delamux:deprecate-methods

Conversation

@delamux

@delamux delamux commented Feb 17, 2024

Copy link
Copy Markdown
Collaborator
  • Refactor and remove deprecated methods

@delamux
delamux requested a review from steinkel February 17, 2024 14:59
Comment thread src/Utility/NotificationManager.php
Comment thread src/Controller/Component/NotifierComponent.php
Comment thread src/Utility/NotificationManager.php Outdated

foreach ((array)$data['users'] as $user) {
$entity = $model->newEntity();
$model->saveMany($entities);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if save fails?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will handle the error.

$item->set('state', 0);
$model->save($item);
$item->set('state', Notification::READ_STATUS);
$this->table->save($item);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if save fails?

foreach ((array)$data['users'] as $userId) {
$finalData = array_merge($data, ['user_id' => $userId]);
$entity = $model->newEntity($finalData);
$entity->set('vars', $data['vars']);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I needed it to do this because for any reason, passing the data in the newEntities with the arrays of arrays was not entering in the property 'vars' of the Entity which is in charge of jsonEncode. Was setting up the vars as empty string

Comment thread src/Controller/Component/NotifierComponent.php
Comment thread src/Utility/NotificationManager.php Outdated

foreach ((array)$data['users'] as $user) {
$entity = $model->newEntity();
$model->saveMany($entities);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will handle the error.

@delamux
delamux requested a review from steinkel February 20, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants