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

Breadcrumb

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

function ObjectConstraint::getProperty

retrieves a property from an object or array

Parameters

mixed $element Element to validate:

string $property Property to retrieve:

mixed $fallback Default value if property is not found:

Return value

mixed

2 calls to ObjectConstraint::getProperty()
ObjectConstraint::validateElement in vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php
Validates the element properties
ObjectConstraint::validateProperties in vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php
Validates the definition properties

File

vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php, line 159

Class

ObjectConstraint
The ObjectConstraint Constraints, validates an object against a given schema

Namespace

JsonSchema\Constraints

Code

protected function &getProperty(&$element, $property, $fallback = null) {
    if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element))) {
        return $element[$property];
    }
    elseif (is_object($element) && property_exists($element, $property)) {
        return $element->{$property};
    }
    return $fallback;
}

API Navigation

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