Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7440247
PredefinedArray.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PredefinedArray.php
View Options
<?php
namespace
JsonSchema\Uri\Retrievers
;
use
JsonSchema\Validator
;
/**
* URI retrieved based on a predefined array of schemas
*
* @example
*
* $retriever = new PredefinedArray(array(
* 'http://acme.com/schemas/person#' => '{ ... }',
* 'http://acme.com/schemas/address#' => '{ ... }',
* ))
*
* $schema = $retriever->retrieve('http://acme.com/schemas/person#');
*/
class
PredefinedArray
extends
AbstractRetriever
{
/**
* Contains schemas as URI => JSON
*
* @var array
*/
private
$schemas
;
/**
* Constructor
*
* @param array $schemas
* @param string $contentType
*/
public
function
__construct
(
array
$schemas
,
$contentType
=
Validator
::
SCHEMA_MEDIA_TYPE
)
{
$this
->
schemas
=
$schemas
;
$this
->
contentType
=
$contentType
;
}
/**
* {@inheritdoc}
*
* @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve()
*/
public
function
retrieve
(
$uri
)
{
if
(!
array_key_exists
(
$uri
,
$this
->
schemas
))
{
throw
new
\JsonSchema\Exception\ResourceNotFoundException
(
sprintf
(
'The JSON schema "%s" was not found.'
,
$uri
));
}
return
$this
->
schemas
[
$uri
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 15:27 (1 d, 8 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0c/6b/1b6eab29fa28d43bb5796605431f
Default Alt Text
PredefinedArray.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment