1 | <?php |
||
55 | class RepositoryFacade implements FacadeInterface |
||
56 | { |
||
57 | /** |
||
58 | * Repository |
||
59 | * |
||
60 | * @var RepositoryInterface |
||
61 | */ |
||
62 | protected $repository; |
||
63 | |||
64 | /** |
||
65 | * Repository facade constructor |
||
66 | * |
||
67 | * @param RepositoryInterface $repository |
||
68 | */ |
||
69 | 5 | protected function __construct(RepositoryInterface $repository) |
|
73 | |||
74 | /** |
||
75 | * Register a repository |
||
76 | * |
||
77 | * @param string $url Repository URL (relative or absolute including the apparat base URL) |
||
78 | * @param array $config Repository configuration |
||
79 | * @return RepositoryFacade Repository facade |
||
80 | * @api |
||
81 | */ |
||
82 | 1 | public static function register($url, array $config) |
|
86 | |||
87 | /** |
||
88 | * Instantiate and return an object repository |
||
89 | * |
||
90 | * @param string $url Repository URL (relative or absolute including the apparat base URL) |
||
91 | * @return RepositoryFacade Repository facade |
||
92 | * @api |
||
93 | */ |
||
94 | 4 | public static function instance($url) |
|
98 | |||
99 | /** |
||
100 | * Create a repository |
||
101 | * |
||
102 | * @param string $url Repository URL (relative or absolute including the apparat base URL) |
||
103 | * @param array $config Repository configuration |
||
104 | * @return RepositoryFacade Repository facade |
||
105 | * @api |
||
106 | */ |
||
107 | public static function create($url, array $config) |
||
111 | |||
112 | /** |
||
113 | * Find objects by selector |
||
114 | * |
||
115 | * @param string|SelectorInterface $selector Object selector |
||
116 | * @return array Objects |
||
117 | */ |
||
118 | public function findObjects($selector) |
||
119 | { |
||
120 | if (!($selector instanceof SelectorInterface)) { |
||
121 | $selector = SelectorFactory::createFromString($selector); |
||
122 | } |
||
123 | $objects = []; |
||
124 | /** @var ObjectInterface $object */ |
||
125 | foreach ($this->repository->findObjects($selector) as $object) { |
||
126 | $objects[] = ApparatObjectFactory::create($object); |
||
127 | } |
||
128 | return $objects; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Load an object from this repository |
||
133 | * |
||
134 | * @param string $locator Object locator |
||
135 | * @param int $visibility Object visibility |
||
136 | * @return ApparatObjectInterface Object |
||
137 | */ |
||
138 | 4 | public function loadObject($locator, $visibility = SelectorInterface::ALL) |
|
144 | } |
||
145 |