protected function _removeEmbed($state, $id) {
    // get existing embed
    $embeds = $state->uniqueEmbeds;
    $embed = $embeds->{$id};
    $property = $embed['property'];

    // create reference to replace embed
    $subject = (object)array('@id' => $id);

    // remove existing embed
    if(is_array($embed->parent)) {
      // replace subject with reference
      foreach($embed->parent as $i => $parent) {
        if(self::compareValues($parent, $subject)) {
          $embed->parent[$i] = $subject;
          break;
        }
      }
    } else {
      // replace subject with reference
      $use_array = is_array($embed->parent->{$property});
      self::removeValue($embed->parent, $property, $subject,
        array('propertyIsArray' => $use_array));
      self::addValue($embed->parent, $property, $subject,
        array('propertyIsArray' => $use_array));
    }

    // recursively remove dependent dangling embeds
    $removeDependents = function($id) {
      // get embed keys as a separate array to enable deleting keys in map
      $ids = array_keys((array)$embeds);
      foreach($ids as $next) {
        if(property_exists($embeds, $next) &&
          is_object($embeds->{$next}->parent) &&
          $embeds->{$next}->parent->{'@id'} === $id) {
          unset($embeds->{$next});
          $removeDependents($next);
        }
      }
    };
    $removeDependents($id);
  }
protected function _removeEmbed($state, $id) {
    // get existing embed
    $embeds = $state->uniqueEmbeds;
    $embed = $embeds->{$id};
    $property = $embed['property'];

    // create reference to replace embed
    $subject = (object)array('@id' => $id);

    // remove existing embed
    if(is_array($embed->parent)) {
      // replace subject with reference
      foreach($embed->parent as $i => $parent) {
        if(self::compareValues($parent, $subject)) {
          $embed->parent[$i] = $subject;
          break;
        }
      }
    } else {
      // replace subject with reference
      $use_array = is_array($embed->parent->{$property});
      self::removeValue($embed->parent, $property, $subject,
        array('propertyIsArray' => $use_array));
      self::addValue($embed->parent, $property, $subject,
        array('propertyIsArray' => $use_array));
    }

    // recursively remove dependent dangling embeds
    $removeDependents = function($id) {
      // get embed keys as a separate array to enable deleting keys in map
      $ids = array_keys((array)$embeds);
      foreach($ids as $next) {
        if(property_exists($embeds, $next) &&
          is_object($embeds->{$next}->parent) &&
          $embeds->{$next}->parent->{'@id'} === $id) {
          unset($embeds->{$next});
          $removeDependents($next);
        }
      }
    };
    $removeDependents($id);
  }
protected function _removeEmbed ( $ state , $ id ) { // get existing embed $ embeds = $ state -> uniqueEmbeds ; $ embed = $ embeds -> { $ id } ; $ property = $ embed [ 'property' ] ; // create reference to replace embed $ subject = ( object ) array ( '@id' => $ id ) ; // remove existing embed if ( is_array ( $ embed -> parent ) ) { // replace subject with reference foreach ( $ embed -> parent as $ i => $ parent ) { if ( self :: compareValues ( $ parent , $ subject ) ) { $ embed -> parent [ $ i ] = $ subject ; break ; } } } else { // replace subject with reference $ use_array = is_array ( $ embed -> parent -> { $ property } ) ; self :: removeValue ( $ embed -> parent , $ property , $ subject , array ( 'propertyIsArray' => $ use_array ) ) ; self :: addValue ( $ embed -> parent , $ property , $ subject , array ( 'propertyIsArray' => $ use_array ) ) ; } // recursively remove dependent dangling embeds $ removeDependents = function ( $ id ) { // get embed keys as a separate array to enable deleting keys in map $ ids = array_keys ( ( array ) $ embeds ) ; foreach ( $ ids as $ next ) { if ( property_exists ( $ embeds , $ next ) && is_object ( $ embeds -> { $ next } -> parent ) && $ embeds -> { $ next } -> parent -> { '@id' } === $ id ) { unset ( $ embeds -> { $ next } ) ; $ removeDependents ( $ next ) ; } } } ; $ removeDependents ( $ id ) ; }
Removes an existing embed.

@param stdClass $state the current framing state.
@param string $id the @id of the embed to remove.
Removes an existing embed .