clock-work

This commit is contained in:
noor
2023-04-24 17:39:09 +05:30
committed by RafficMohammed
parent cf4bec91a6
commit 1eea7ff15e
178 changed files with 13169 additions and 123 deletions

View File

@@ -0,0 +1,45 @@
<?php namespace Clockwork\DataSource;
use Clockwork\Request\Request;
use Clockwork\Request\Timeline\Timeline;
use Clockwork\Support\Swift\SwiftPluginClockworkTimeline;
use Swift_Mailer;
// Data source for Swift mailer, provides sent emails
class SwiftDataSource extends DataSource
{
// Swift instance
protected $swift;
// Clockwork timeline instance
protected $timeline;
// Create a new data source, takes a Swift instance as an argument
public function __construct(Swift_Mailer $swift)
{
$this->swift = $swift;
$this->timeline = new Timeline;
}
// Listen to the email events
public function listenToEvents()
{
$this->swift->registerPlugin(new SwiftPluginClockworkTimeline($this->timeline));
}
// Adds send emails to the request
public function resolve(Request $request)
{
$request->emailsData = array_merge($request->emailsData, $this->timeline->finalize());
return $request;
}
// Reset the data source to an empty state, clearing any collected data
public function reset()
{
$this->timeline = new Timeline;
}
}