File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Markdown ;
4
4
5
+ use App \OscaroteroEmbedAdapter ;
5
6
use Embed \Embed ;
6
7
use Embed \Http \Crawler ;
7
8
use Embed \Http \CurlClient ;
8
9
use Illuminate \Support \ServiceProvider ;
9
10
use League \CommonMark \Environment \Environment ;
10
11
use League \CommonMark \Extension \CommonMark \CommonMarkCoreExtension ;
11
- use League \CommonMark \Extension \Embed \Bridge \OscaroteroEmbedAdapter ;
12
12
use League \CommonMark \Extension \Embed \EmbedExtension ;
13
13
use League \CommonMark \Extension \ExternalLink \ExternalLinkExtension ;
14
14
use League \CommonMark \Extension \GithubFlavoredMarkdownExtension ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App ;
4
+
5
+ use Embed \Embed as EmbedLib ;
6
+ use League \CommonMark \Exception \MissingDependencyException ;
7
+ use League \CommonMark \Extension \Embed \Embed ;
8
+
9
+ class OscaroteroEmbedAdapter extends \League \CommonMark \Extension \Embed \Bridge \OscaroteroEmbedAdapter
10
+ {
11
+ private EmbedLib $ embedLib ;
12
+
13
+ public function __construct (?EmbedLib $ embed = null )
14
+ {
15
+ if ($ embed === null ) {
16
+ if (! \class_exists (EmbedLib::class)) {
17
+ throw new MissingDependencyException ('The embed/embed package is not installed. Please install it with Composer to use this adapter. ' );
18
+ }
19
+
20
+ $ embed = new EmbedLib ();
21
+ }
22
+
23
+ $ this ->embedLib = $ embed ;
24
+ }
25
+
26
+ /**
27
+ * {@inheritDoc}
28
+ */
29
+ public function updateEmbeds (array $ embeds ): void
30
+ {
31
+ $ extractors = $ this ->embedLib ->getMulti (...\array_map (static fn (Embed $ embed ) => $ embed ->getUrl (), $ embeds ));
32
+ foreach ($ extractors as $ i => $ extractor ) {
33
+ logger (print_r ($ extractor , true ));
34
+ if ($ extractor ->code !== null ) {
35
+ $ embeds [$ i ]->setEmbedCode ($ extractor ->code ->html );
36
+ }
37
+ }
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments