forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.inc.php
54 lines (46 loc) · 1.38 KB
/
Map.inc.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
<?php
/**
* @file classes/facade/Map.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2000-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Map
*
* @brief This facade provides access to all of the query classes shared across all applications
*/
namespace PKP\Facade;
use PKP\Core\Map as BaseMap;
use PKP\Announcement\Maps\Schema as AnnouncementSchema;
use PKP\Announcement\Maps\OAI as AnnouncementOAI;
class Map
{
public static array $extensions = [];
public static function announcementToSchema(): AnnouncementSchema
{
return self::withExtensions(new AnnouncementSchema());
}
public static function announcementToOAI(): AnnouncementOAI
{
return self::withExtensions(new AnnouncementOAI());
}
public static function extend(string $map, callable $callback)
{
if (isset(self::$extensions[$map])) {
self::$extensions[$map][] = $callback;
}
self::$extensions[$map] = [$callback];
}
public static function withExtensions(BaseMap $map) : BaseMap
{
foreach (self::$extensions as $name => $extensions) {
if (is_a($map, $name)) {
foreach ($extensions as $extension) {
$map->extend($extension);
}
}
}
return $map;
}
}