This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
/
CustomExtensionManager.php
57 lines (52 loc) · 2 KB
/
CustomExtensionManager.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @see https://github.com/zendframework/zend-feed for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-feed/blob/master/LICENSE.md New BSD License
*/
namespace ZendTest\Feed\Reader\TestAsset;
use Zend\Feed\Reader\Exception\InvalidArgumentException;
use Zend\Feed\Reader\Extension;
use Zend\Feed\Reader\ExtensionManagerInterface;
/**
* Standalone extension manager that omits any extensions added after the 2.9 series.
*/
class CustomExtensionManager implements ExtensionManagerInterface
{
private $extensions = [
'Atom\Entry' => Extension\Atom\Entry::class,
'Atom\Feed' => Extension\Atom\Feed::class,
'Content\Entry' => Extension\Content\Entry::class,
'CreativeCommons\Entry' => Extension\CreativeCommons\Entry::class,
'CreativeCommons\Feed' => Extension\CreativeCommons\Feed::class,
'DublinCore\Entry' => Extension\DublinCore\Entry::class,
'DublinCore\Feed' => Extension\DublinCore\Feed::class,
'Podcast\Entry' => Extension\Podcast\Entry::class,
'Podcast\Feed' => Extension\Podcast\Feed::class,
'Slash\Entry' => Extension\Slash\Entry::class,
'Syndication\Feed' => Extension\Syndication\Feed::class,
'Thread\Entry' => Extension\Thread\Entry::class,
'WellFormedWeb\Entry' => Extension\WellFormedWeb\Entry::class,
];
/**
* Do we have the extension?
*
* @param string $extension
* @return bool
*/
public function has($extension)
{
return array_key_exists($extension, $this->extensions);
}
/**
* Retrieve the extension
*
* @param string $extension
* @return Extension\AbstractEntry|Extension\AbstractFeed
*/
public function get($extension)
{
$class = $this->extensions[$extension];
return new $class();
}
}