Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PredefinedArray.php

class PredefinedArray

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#');

Hierarchy

  • class \JsonSchema\Uri\Retrievers\AbstractRetriever implements \JsonSchema\Uri\Retrievers\UriRetrieverInterface
    • class \JsonSchema\Uri\Retrievers\PredefinedArray extends \JsonSchema\Uri\Retrievers\AbstractRetriever

Expanded class hierarchy of PredefinedArray

File

vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php, line 19

Namespace

JsonSchema\Uri\Retrievers
View source
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];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AbstractRetriever::$contentType protected property Media content type
AbstractRetriever::getContentType public function Overrides UriRetrieverInterface::getContentType
PredefinedArray::$schemas private property Contains schemas as URI => JSON
PredefinedArray::retrieve public function Overrides UriRetrieverInterface::retrieve
PredefinedArray::__construct public function Constructor

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal