3
3
namespace Markup \OEmbedBundle \Command ;
4
4
5
5
use Markup \OEmbedBundle \Exception \OEmbedUnavailableException ;
6
+ use Markup \OEmbedBundle \Service \OEmbedService ;
6
7
use Symfony \Bundle \FrameworkBundle \Command \ContainerAwareCommand ;
7
8
use Symfony \Component \Console \Input \InputArgument ;
8
9
use Symfony \Component \Console \Input \InputInterface ;
13
14
*/
14
15
class FetchOEmbedCommand extends ContainerAwareCommand
15
16
{
17
+ /**
18
+ * @return void
19
+ */
16
20
protected function configure ()
17
21
{
18
22
$ this
@@ -24,18 +28,22 @@ protected function configure()
24
28
25
29
protected function execute (InputInterface $ input , OutputInterface $ output )
26
30
{
31
+ /** @var string $provider */
27
32
$ provider = $ input ->getArgument ('provider ' );
33
+ /** @var string $mediaId */
28
34
$ mediaId = $ input ->getArgument ('media_id ' );
29
35
30
36
$ output ->writeln (sprintf ('Looking up oEmbed data for media ID %s from the provider "%s". ' , $ mediaId , $ provider ));
31
37
32
38
$ startTime = microtime (true );
33
39
try {
34
- $ oEmbed = $ this ->getContainer ()->get ('markup_oembed ' )->fetchOEmbed ($ provider , $ mediaId );
40
+ /** @var OEmbedService $oEmbedService */
41
+ $ oEmbedService = $ this ->getContainer ()->get ('markup_oembed ' );
42
+ $ oEmbed = $ oEmbedService ->fetchOEmbed ($ provider , $ mediaId );
35
43
} catch (OEmbedUnavailableException $ e ) {
36
44
$ output ->writeln (sprintf ('<error>Could not fetch the oEmbed data. Reported error: %s</error> ' , $ e ->getMessage ()));
37
45
38
- return ;
46
+ return 1 ;
39
47
}
40
48
41
49
$ output ->writeln (
@@ -50,5 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
50
58
}
51
59
$ output ->writeln (sprintf ($ format , $ key , $ value ));
52
60
}
61
+
62
+ return 0 ;
53
63
}
54
64
}
0 commit comments