Skip to content

Conversation

@dereuromark
Copy link
Owner

@dereuromark dereuromark commented Mar 7, 2024

As discussed in #410 this is all we can do for now it seems.
It is optional, so everything works also as before

The idea is to have a bit more native DTO support built in
Now you can do

bin/cake dto generate for

    <dto name="EventUpdateNotificationQueueData" immutable="true">
        <field name="eventId" type="int" required="true"/>
        <field name="mailer" type="string" required="true"/>
        <field name="type" type="string" required="true"/>
    </dto>

and

$dataDto = OrderUpdateNotificationQueueDataDto::createFromArray([
    OrderUpdateNotificationQueueDataDto::FIELD_ORDER_ID => $order->id,
    OrderUpdateNotificationQueueDataDto::FIELD_MAILER => 'Request',
    OrderUpdateNotificationQueueDataDto::FIELD_TYPE => 'request',
]);
$this->getTableLocator()->get('Queue.QueuedJobs')->createJob('OrderUpdateNotification', $dataDto);

as well as this inside the queue task:

    public function run(array $data, int $jobId): void
    {
        $dataDto = OrderUpdateNotificationQueueDataDto::createFromArray($data);

        $order = $this->fetchTable('Orders')->get($dataDto->getOrderId());
        $this->getMailer($queueData->getMailer())->send($dataDto->getType(), [$order]);
    }

with maximum IDE and Stan support as well as immediate errors on missing required fields etc.

@dereuromark dereuromark added this to the 8.x milestone Mar 7, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 70.94%. Comparing base (ff47bfb) to head (731d4b4).

Files Patch % Lines
src/Model/Table/QueuedJobsTable.php 85.71% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #413      +/-   ##
============================================
+ Coverage     70.91%   70.94%   +0.03%     
- Complexity      693      698       +5     
============================================
  Files            37       37              
  Lines          2427     2433       +6     
============================================
+ Hits           1721     1726       +5     
- Misses          706      707       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dereuromark dereuromark merged commit 722bafb into master Mar 7, 2024
@dereuromark dereuromark deleted the support-dto-input branch March 7, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants