public static function getContextValue($ctx, $key, $type) {
    $rval = null;

    // return null for invalid key
    if($key === null) {
      return $rval;
    }

    // get default language
    if($type === '@language' && property_exists($ctx, $type)) {
      $rval = $ctx->{$type};
    }

    // get specific entry information
    if(property_exists($ctx->mappings, $key)) {
      $entry = $ctx->mappings->{$key};
      if($entry === null) {
        return null;
      }

      if($type === null) {
        // return whole entry
        $rval = $entry;
      } else if(property_exists($entry, $type)) {
        // return entry value for type
        $rval = $entry->{$type};
      }
    }

    return $rval;
  }
public static function getContextValue($ctx, $key, $type) {
    $rval = null;

    // return null for invalid key
    if($key === null) {
      return $rval;
    }

    // get default language
    if($type === '@language' && property_exists($ctx, $type)) {
      $rval = $ctx->{$type};
    }

    // get specific entry information
    if(property_exists($ctx->mappings, $key)) {
      $entry = $ctx->mappings->{$key};
      if($entry === null) {
        return null;
      }

      if($type === null) {
        // return whole entry
        $rval = $entry;
      } else if(property_exists($entry, $type)) {
        // return entry value for type
        $rval = $entry->{$type};
      }
    }

    return $rval;
  }
public static function getContextValue ( $ ctx , $ key , $ type ) { $ rval = null ; // return null for invalid key if ( $ key === null ) { return $ rval ; } // get default language if ( $ type === '@language' && property_exists ( $ ctx , $ type ) ) { $ rval = $ ctx -> { $ type } ; } // get specific entry information if ( property_exists ( $ ctx -> mappings , $ key ) ) { $ entry = $ ctx -> mappings -> { $ key } ; if ( $ entry === null ) { return null ; } if ( $ type === null ) { // return whole entry $ rval = $ entry ; } else if ( property_exists ( $ entry , $ type ) ) { // return entry value for type $ rval = $ entry -> { $ type } ; } } return $ rval ; }
Gets the value for the given active context key and type, null if none is
set.

@param stdClass $ctx the active context.
@param string $key the context key.
@param string [$type] the type of value to get (eg: '@id', '@type'), if not
specified gets the entire entry for a key, null if not found.

@return mixed the value.
Gets the value for the given active context key and type null if none is set .