*/ class SnapshotRepository { protected Finder $finder; protected ParameterBagInterface $parameters; public function __construct(ParameterBagInterface $parameters) { $this->finder = new Finder(); $this->parameters = $parameters; } public function find(): array { $objects = []; $files = $this->finder ->files() ->in($this->parameters->get('motion_snapshots_directory')) ->name('/.*\.mp4$/s') ->sortByModifiedTime(); foreach ($files as $file) { $date = basename($file->getPath()); $time = str_replace(['.mp4', '-'], ['', ':'], $file->getBasename()); $movie = $file->getPath().'/'.$file->getBasename(); $thumbnail = str_replace('.mp4', '.jpg', $movie); $snapshot = new Snapshot(); $snapshot ->setDate(new \DateTime($date.' '.$time)) ->setMovie($movie) ->setThumbnail($thumbnail); $objects[] = $snapshot; } return $objects; } }