-
Notifications
You must be signed in to change notification settings - Fork 10
/
FilesystemTransportFactory.php
35 lines (30 loc) · 1.12 KB
/
FilesystemTransportFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
namespace SchedulerBundle\Transport;
use SchedulerBundle\SchedulePolicy\SchedulePolicyOrchestratorInterface;
use Symfony\Component\Serializer\SerializerInterface;
use function sys_get_temp_dir;
use function strpos;
/**
* @author Guillaume Loulier <contact@guillaumeloulier.fr>
*/
final class FilesystemTransportFactory implements TransportFactoryInterface
{
/**
* {@inheritdoc}
*/
public function createTransport(Dsn $dsn, array $options, SerializerInterface $serializer, SchedulePolicyOrchestratorInterface $schedulePolicyOrchestrator): TransportInterface
{
return new FilesystemTransport($dsn->getOption('path', sys_get_temp_dir()), [
'execution_mode' => $dsn->getHost(),
'filename_mask' => $dsn->getOption('filename_mask', '%s/_symfony_scheduler_/%s.json'),
], $serializer, $schedulePolicyOrchestrator);
}
/**
* {@inheritdoc}
*/
public function support(string $dsn, array $options = []): bool
{
return 0 === strpos($dsn, 'fs://') || 0 === strpos($dsn, 'filesystem://') || 0 === strpos($dsn, 'file://');
}
}