1 | <?php |
||
26 | class RouteLoader implements LoaderInterface |
||
27 | { |
||
28 | const SUPPORTED_TYPE = 'route'; |
||
29 | |||
30 | /** |
||
31 | * @var MetaFactoryInterface |
||
32 | */ |
||
33 | protected $metaFactory; |
||
34 | |||
35 | /** |
||
36 | * RouteLoader constructor. |
||
37 | * |
||
38 | * @param MetaFactoryInterface $metaFactory |
||
39 | */ |
||
40 | 73 | public function __construct(MetaFactoryInterface $metaFactory) |
|
44 | |||
45 | /** |
||
46 | * Load meta object by provided type and parameters. |
||
47 | * |
||
48 | * @MetaLoaderDoc( |
||
49 | * description="Article Loader loads articles from Content Repository", |
||
50 | * parameters={ |
||
51 | * route_object="SINGLE|required route object" |
||
52 | * } |
||
53 | * ) |
||
54 | * |
||
55 | * @param string $type object type |
||
56 | * @param array $parameters parameters needed to load required object type |
||
57 | * @param int $responseType response type: single meta (LoaderInterface::SINGLE) |
||
58 | * |
||
59 | * @return Meta|bool false if meta cannot be loaded, a Meta instance otherwise |
||
60 | */ |
||
61 | 8 | public function load($type, $parameters = [], $responseType = LoaderInterface::SINGLE) |
|
62 | { |
||
63 | 8 | $route = isset($parameters['route_object']) ? $parameters['route_object'] : null; |
|
64 | |||
65 | 8 | if (null !== $route) { |
|
66 | 8 | return $this->metaFactory->create($route); |
|
67 | } |
||
68 | |||
69 | return false; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Checks if Loader supports provided type. |
||
74 | * |
||
75 | * @param string $type |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | 8 | public function isSupported(string $type) : bool |
|
83 | } |
||
84 |