34 lines
921 B
PHP
34 lines
921 B
PHP
<?php
|
|
|
|
namespace App\Services\Registries;
|
|
|
|
use App\Models\Asset;
|
|
use App\Models\Registries\Registry;
|
|
use App\Services\Documents\DocumentDownloadService;
|
|
use PHPHtmlParser\Dom;
|
|
|
|
class RegistryImportService {
|
|
protected Registry $registry;
|
|
protected string $url;
|
|
protected Dom $dom;
|
|
|
|
protected array $mimes = [
|
|
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
'pdf' => 'application/pdf',
|
|
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
];
|
|
|
|
|
|
public function __construct(Registry $registry, string $url) {
|
|
$this->registry = $registry;
|
|
$this->url = $url;
|
|
$this->dom = new Dom;
|
|
$this->dom->loadFromUrl($url);
|
|
}
|
|
|
|
|
|
public function download($url, $dir = null, $filename = null): ?Asset {
|
|
return (new DocumentDownloadService())->download($url, $dir, $filename);
|
|
}
|
|
|
|
} |