Handles the conversion of references to entities.
181825
protected function doInitialize()
    {
        $this->collection = new FieldCollection();
        $this->collection->setGrouping($this->grouping);

        if ($this->references) {
            $repo = $this->em->getRepository(FieldValue::class);
            $instances = $repo->findBy(['id' => $this->references]);
            if ($instances === false) {
                return;
            }

            /** @var FieldValue $val */
            foreach ($instances as $val) {
                $fieldType = $val->getFieldType();
                $field = $this->em->getFieldManager()->getFieldFor($fieldType);
                $type = $field->getStorageType();
                $typeName = $type->getName();
                $typeCol = 'value_' . $typeName;
                $valCol = 'value_' . $typeName;
                if ($typeName === 'json') {
                    /** @deprecated since 3.3 to be renamed in v4. */
                    $valCol = 'value_json_array';
                }

                // Because there's a potential for custom fields that use json storage to 'double hydrate' this causes
                // json_decode to throw a warning. Here we prevent that by replacing the error handler.
                set_error_handler(
                    function ($errNo, $errStr, $errFile) {},
                    E_WARNING
                );
                $hydratedVal = $this->em->getEntityBuilder($val->getContenttype())->getHydratedValue($val->$typeCol, $val->getName(), $val->getFieldName());
                restore_error_handler();

                // If we do not have a hydrated value returned then we fall back to the one passed in
                if ($hydratedVal) {
                    $val->setValue($hydratedVal);
                } else {
                    $val->setValue($val->$valCol);
                }

                $this->collection->add($val);
            }
        }

        $this->em = null;
    }
197410
protected void serializeEntityReference(
        EntityReference node,
        boolean bStart)
        throws SAXException {
        if (bStart) {
            EntityReference eref = node;
            // entities=true
            if ((fFeatures & ENTITIES) != 0) {
                
                // perform well-formedness and other checking only if 
                // entities = true

                // well-formed=true
                if ((fFeatures & WELLFORMED) != 0) {
                    isEntityReferneceWellFormed(node);
                }

                // check "unbound-prefix-in-entity-reference" [fatal] 
                // Raised if the configuration parameter "namespaces" is set to true
                if ((fFeatures & NAMESPACES) != 0) {
                    checkUnboundPrefixInEntRef(node);
                }

                // The filter should not apply in this case, since the
                // EntityReference is not being expanded.
                // should we pass entity reference nodes to the filter???
            } 
            
            if (fLexicalHandler != null) {

                // startEntity outputs only Text but not Element, Attr, Comment 
                // and PI child nodes.  It does so by setting the m_inEntityRef 
                // in ToStream and using this to decide if a node is to be 
                // serialized or not.
                fLexicalHandler.startEntity(eref.getNodeName());
            } 

        } else {
            EntityReference eref = node;
            // entities=true or false, 
            if (fLexicalHandler != null) {
                fLexicalHandler.endEntity(eref.getNodeName());
            }
        }
    }
1103341
function _treatEntityDetail(fieldErrors) {
    return Object.keys(fieldErrors || {}).reduce(
        (res, field) => {
            res[field] = translate(fieldErrors[field]);
            return res;
        }, {});
}
646201
def reverse_reference(self):
        ''''''
        self.ref_start = self.ref_length - self.ref_start - 1
        self.ref_end = self.ref_length - self.ref_end - 1
1278213
function resolveReferences() {

        for (let key in _variableCollection) {

            let referenceVariables = extractVariables(_variableCollection[key]);

            for (let current = 0; current < referenceVariables.length; current++) {
                if (_.isEmpty(_variableCollection[_.camelCase(referenceVariables[current].variable)]) === false) {
                    _variableCollection[key] = _variableCollection[key].replace(referenceVariables[current].origin, _variableCollection[_.camelCase(referenceVariables[current].variable)]);
                }
            }
        }
    }
357733
private function convertReferenceToValue($reference)
    {
        if (is_scalar($reference)) {
            return $this->convertScalarReference($reference);
        } else {
            return $this->convertObjectReference($reference);
        }
    }
690949
void markReferenceElements(PersistenceBroker broker)
    {
        // these cases will be handled by ObjectEnvelopeTable#cascadingDependents()
        // if(getModificationState().needsInsert() || getModificationState().needsDelete()) return;

        Map oldImage = getBeforeImage();
        Map newImage = getCurrentImage();

        Iterator iter = newImage.entrySet().iterator();
        while (iter.hasNext())
        {
            Map.Entry entry = (Map.Entry) iter.next();
            Object key = entry.getKey();
            // we only interested in references
            if(key instanceof ObjectReferenceDescriptor)
            {
                Image oldRefImage = (Image) oldImage.get(key);
                Image newRefImage = (Image) entry.getValue();
                newRefImage.performReferenceDetection(oldRefImage);
            }
        }
    }
854709
private static void convert(unificationXref uni, Model level2)
	{
		//We can not simply convert a class, so we need to remove the
        //uni and insert a new relationship xref

        //First get all the objects that refers to this uni
        Set<XReferrable> referrables =
			new HashSet<XReferrable>(uni.isXREFof());

        //Create the new relationship xref in the model.
        relationshipXref relationshipXref =
        	level2.addNew(relationshipXref.class, uni.getUri());

        //Copy the fields from uni
		relationshipXref.setCOMMENT(uni.getCOMMENT());
		relationshipXref.setDB(uni.getDB());
		relationshipXref.setDB_VERSION(uni.getDB_VERSION());
		relationshipXref.setID(uni.getID());
		relationshipXref.setID_VERSION(uni.getID_VERSION());
		relationshipXref.setRELATIONSHIP_TYPE(
			"http://www.biopax.org/paxtools/convertedGOUnificationXREF");

        //Create a link to the new xref from all the owners.
        for (XReferrable referrable : referrables)
		{
			referrable.addXREF(relationshipXref);
		}

        //Remove the references to the old uni
        for (XReferrable referrable : referrables)
        {
            referrable.removeXREF(uni);
        }
        //Now remove it from the model.
        level2.remove(uni);

        //We are done!
    }
1004659
protected function resolveReferences()
    {
        $references = $this->config['references'] ?? [];

        if (! is_array($references) || empty($references)) {
            return;
        }

        foreach ($references as $config) {
            $this->resolveReference($config);
        }
    }
418066
protected void handleShowTableName(EntityDesc entityDesc, TableMeta tableMeta) {
    if (showTableName || isNameDifferentBetweenEntityAndTable(entityDesc)) {
      entityDesc.setShowTableName(true);
    }
  }
1249747
private void process() {
    Entity entity = entityClass.getAnnotation(Entity.class);
    ProjectedEntity projectedEntity = entityClass.getAnnotation(ProjectedEntity.class);
    if (entity != null) {
      initEntityMetadata(entity);
    } else if (projectedEntity != null) {
      initEntityMetadata(projectedEntity);
    } else {
      String message = String.format("Class %s must either have %s or %s annotation",
          entityClass.getName(), Entity.class.getName(), ProjectedEntity.class.getName());
      throw new EntityManagerException(message);
    }

    processPropertyOverrides();

    processFields();
    // If we did not find valid Identifier...
    if (entityMetadata.getIdentifierMetadata() == null) {
      throw new EntityManagerException(
          String.format("Class %s requires a field with annotation of %s", entityClass.getName(),
              Identifier.class.getName()));
    }
    entityMetadata.setEntityListenersMetadata(EntityListenersIntrospector.introspect(entityClass));
    entityMetadata.ensureUniqueProperties();
    entityMetadata.cleanup();
  }
1080845
public function saveToEntities()
    {
        $data = $this->transformFromFormData($this->data);

        foreach ($this->entities as $entity) {
            if ($entity['entity'] instanceof EntityInterface) {
                $entity['entity']->setFormData($data, $entity['fields']);
            } else {
                $this->entityProcessor->saveToEntity($entity['entity'], $data, $entity['fields']);
            }
        }
    }
1188425
private Map<String, Object> getPersistedRelations(Object relationEntity)
    {
        return relationEntity != null && relationEntity.getClass().isAssignableFrom(EnhanceEntity.class) ? ((EnhanceEntity) relationEntity)
                .getRelations() : null;
    }
87341
def replace_entities(self, html):
        
        def fixup(text):
            """replace the htmlentities in some text"""
            text = text.group(0)
            if text[:2] == "&#":
                # character reference
                try:
                    if text[:3] == "&#x":
                        return chr(int(text[3:-1], 16))
                    else:
                        return chr(int(text[2:-1]))
                except ValueError:
                    pass
            else:
                # named entity
                try:
                    text = chr(htmlentitydefs.name2codepoint[text[1:-1]])
                except KeyError:
                    pass
            return text  # leave as is
        return re.sub(r"&#?\w+;", fixup, html)
774611
function() {

        if ( !ModelUtil.instance && !getContext('modelUtil') ) {
            self.models             = self.models || {}; // used when getModel(modelName) is called
            self.entities           = {};
            self.entitiesCollection = {}; // used when getEntity(entityName) is called - handles entity relations
            self.files              = {};
            ModelUtil.instance      = self;

            setContext('modelUtil', ModelUtil.instance);

            return self
        } else {
            //if (!ModelUtil.instance) {
            //    ModelUtil.instance = getContext('modelUtil')
            //}
            //self = ModelUtil.instance;
            //ModelUtil.instance = getContext('modelUtil');
            //ModelUtil.instance = ModelUtil.instance || getContext('modelUtil');
            //self = merge(self, ModelUtil.instance, true);
            // return self
            return ModelUtil.instance || getContext('modelUtil')
        }
    }
817434
def fold_references(mapped_external_entity, references, organization)
      references = format_references(references)
      mapped_external_entity = mapped_external_entity.with_indifferent_access

      # Use both record_references and id_references + the id
      (references.values.flatten + ['id']).each do |reference|
        fold_references_helper(mapped_external_entity, reference.split('/'), organization)
      end

      mapped_external_entity
    end
1260287
def references(attributes=nil)
      attributes ||= self.class.domain_attributes
      attributes.map { |pa| send(pa) }.flatten.compact
    end