Apple_Exporter\Components\Component::get_json PHP Method

get_json() public method

Get a JSON value
public get_json ( string $name ) : mixed
$name string
return mixed
    public function get_json($name)
    {
        return isset($this->json[$name]) ? $this->json[$name] : null;
    }

Usage Example

 /**
  * Given two components, anchor the first one to the second.
  *
  * @param Component $component
  * @param Component $target_component
  * @access private
  */
 private function anchor_together($component, $target_component)
 {
     if ($target_component->is_anchor_target()) {
         return;
     }
     // Get the component's anchor settings, if set
     $anchor_json = $component->get_json('anchor');
     // If the component doesn't have it's own anchor settings, use the defaults.
     if (empty($anchor_json)) {
         $anchor_json = array('targetAnchorPosition' => 'center', 'rangeStart' => 0, 'rangeLength' => 1);
     }
     // Regardless of what the component class specifies,
     // add the targetComponentIdentifier here.
     // There's no way for the class to know what this is before this point.
     $anchor_json['targetComponentIdentifier'] = $target_component->uid();
     // Add the JSON back to the component
     $component->set_json('anchor', $anchor_json);
     // Given $component, find out the opposite position.
     $other_position = null;
     if (Component::ANCHOR_AUTO == $component->get_anchor_position()) {
         $other_position = 'left' == $this->get_setting('body_orientation') ? Component::ANCHOR_LEFT : Component::ANCHOR_RIGHT;
     } else {
         $other_position = Component::ANCHOR_LEFT == $component->get_anchor_position() ? Component::ANCHOR_RIGHT : Component::ANCHOR_LEFT;
     }
     $target_component->set_anchor_position($other_position);
     // The anchor method adds the required layout, thus making the actual
     // anchoring. This must be called after using the UID, because we need to
     // distinguish target components from anchor ones and components with
     // UIDs are always anchor targets.
     $target_component->anchor();
     $component->anchor();
 }