it_should_replace_input_message_references_by_reference_html_link

@param Lns\SocialFeed\Model\ReferenceInterface $reference1
@param Lns\SocialFeed\Model\ReferenceInterface $reference2
772688
function it_should_replace_input_message_references_by_reference_html_link($reference1, $reference2) {
        $reference1->getStartIndice()->willReturn(5);
        $reference1->getEndIndice()->willReturn(10);
        $reference1->getType()->willReturn(ReferenceType::USER);
        $reference1->getData()->willReturn(array(
            "id"          => 6844292,
            "name"        => "John Doe",
            "type"        => "user",
            "offset"      => 5,
            "length"      => 5
        ));

        $reference2->getStartIndice()->willReturn(12);
        $reference2->getEndIndice()->willReturn(17);
        $reference2->getType()->willReturn(ReferenceType::PAGE);
        $reference2->getData()->willReturn(array(
            "id"          => 32425,
            "name"        => "test",
            "type"        => "page",
            "offset"      => 5,
            "length"      => 5
        ));

        $this->format('test @jdoe, @test bar', [$reference2, $reference1])
            ->shouldReturn('test <a href="https://www.facebook.com/6844292" target="_blank">@jdoe</a>, <a href="https://www.facebook.com/32425" target="_blank">@test</a> bar');

        $this->format('foo #média bar', [])
            ->shouldReturn('foo <a href="https://www.facebook.com/hashtag/média" target="_blank">#média</a> bar');

        $this->format('foo http://test.com bar', [])
            ->shouldReturn('foo <a href="http://test.com" target="_blank">http://test.com</a> bar');
    }
175540
public function resolveReferences(ReferenceContext $context = null)
    {
        foreach ($this->_responses as $k => $response) {
            if ($response instanceof Reference) {
                $this->_responses[$k] = $response->resolve($context);
            } else {
                $response->resolveReferences($context);
            }
        }
    }
100579
public function logReference($type, $ref, $oldRef = null, $method = null, $line = null)
    {
        if (self::getConfig('log', 'reference') || self::getConfig('log', $type . 'Ref')) {
            switch ($type) {
                case 'replace':
                    $this->logMessage('REPLACE REF', 'Replacing Reference From "' . $oldRef . '" to "' . $ref . '"', $method, $line);
                    break;
                case 'load':
                    $this->logMessage('LOAD REF', 'Loading Reference : "' . $ref . '"', $method, $line);
                    break;
                case 'register':
                    $this->logMessage('REGISTER REF', 'Registier Reference Definition : "' . $ref . '"', $method, $line);
                    break;
                case 'drop':
                    $this->logMessage('DROP REF', 'Drop Reference : "' . $ref . '"', $method, $line);
                    break;
            }
        }
    }
1043289
public function describeMachineReference($reference, $field = null)
	{
		if ($field === null) {
			return @ $this->references[$reference];
		} else {
			return @ $this->references[$reference][$field];
		}
	}
315321
protected function normalizeJoins($model, $first = null, $second = null)
    {
        if (is_string($model)) {
            /** @var  Models $model */
            $model = new $model;
        }

        if (!$model instanceof Models) {
            throw new \InvalidArgumentException(sprintf(
                'Expected 1 parameter of %s to be string or %s instance, %s given.',
                __FUNCTION__,
                static::class,
                gettype($model)
            ));
        }

        if (null === $first) {
            $first = $this->primary();
        }

        if (null === $second) {
            $second = $this->table().'_'.$model->primary();
        }

        return [$model, $this->table().'.'.$first, $model->table().'.'.$second];
    }
1117442
public function setReference($reference)
    {
        if (!empty($reference) && ctype_print($reference)) {
            $this->reference = trim($reference);
        }

        return $this;
    }
1276421
private function getCachedDataByReference(Reference $reference)
    {
        return $this->getCachedDataByClassNameAndId($reference->getClassName(), $this->stringify($reference->getId()));
    }
84483
public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null)
    {
        $sourceNode = $this->createNode($sourceId, $sourceValue);
        $destNode = $this->createNode($destId, $destValue);
        $edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference);

        $sourceNode->addOutEdge($edge);
        $destNode->addInEdge($edge);
    }
1047023
function getReference($table, $ref = null) {
		if (isset($this->references[$table])) {
			if (!strlen($ref)) {
				return current($this->references[$table]);
			}
			if (isset($this->references[$table][$ref])) {
				return $this->references[$table][$ref];
			}
		}
	}
1262888
public function findElementtypesUsingReferenceElementtype(Elementtype $referenceElementtype)
    {
        $elementtypes = array();
        foreach ($this->elementtypeManager->findAll() as $elementtype) {
            if (!$elementtype->getStructure()->getRootNode()) {
                continue;
            }
            $rii = new \RecursiveIteratorIterator($elementtype->getStructure()->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
            foreach ($rii as $node) {
                /* @var $node ElementtypeStructureNode */
                if ($node->getReferenceElementtypeId() === $referenceElementtype->getId()) {
                    $elementtypes[] = $elementtype;
                    break;
                }
            }
        }

        return $elementtypes;
    }
702000
public void setReference(String reference) {

        m_reference = reference;
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_REFERENCE_1, m_reference));
        }
    }
631606
private function parseRefAsPull($reference): ?string
    {
        if (preg_match(self::REGEX_PULL, $reference, $matches) !== 1) {
            return null;
        }

        return $matches[1];
    }
944872
public function moveInto(NodeInterface $referenceNode, string $newName = null): void
    {
        if ($referenceNode === $this || $referenceNode === $this->getParent()) {
            return;
        }

        if ($this->isRoot()) {
            throw new NodeException('The root node cannot be moved.', 1346769001);
        }

        $name = $newName !== null ? $newName : $this->getName();

        if ($referenceNode !== $this->getParent() && $referenceNode->getNode($name) !== null) {
            throw new NodeExistsException(sprintf('Node with path "%s" already exists.', $name), 1292503470);
        }

        if (($referenceNode instanceof Node && !$referenceNode->willChildNodeBeAutoCreated($name)) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
            throw new NodeConstraintException(sprintf('Cannot move %s into %s', $this, $referenceNode), 1404648124);
        }

        $this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
        $this->setPath(NodePaths::addNodePathSegment($referenceNode->getPath(), $name));
        $this->nodeDataRepository->persistEntities();

        $this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_LAST);
        $this->context->getFirstLevelNodeCache()->flush();
        $this->emitAfterNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
        $this->emitNodeUpdated($this);
    }
569485
public function dropForeignKey($referenceTable, $referenceColumns, array $options = [])
    {
        $schema = isset($options['schema']) ? new Schema($options['schema']) : null;

        $foreignKey = new ForeignKey($this, new Table($referenceTable, $schema));
        $foreignKey->setColumns($referenceColumns);
        $foreignKey->setReferencedColumns($referenceColumns);

        $this->actions[] =  function () use ($foreignKey) {
             return $this->manipulation->drop($foreignKey);
        };

        return $this;
    }
279755
private function addClassProvider($class, Reference $reference)
    {
        if (empty($this->classProviders[$class])) {
            $this->classProviders[$class] = [];
        }
        
        $this->classProviders[$class][] = $reference;
    }
791919
public function updateOne(string $referenceName, string $value) : array {
        return $this->sendPatch(
            sprintf('/profiles/%s/references/%s', $this->userName, $referenceName),
            [],
            [
                'value'     => $value
            ]
        );
    }
1121689
private function updateArgumentReferences(array $replacements, $definitionId, array $arguments)
    {
        foreach ($arguments as $k => $argument) {
            // Handle recursion step
            if (is_array($argument)) {
                $arguments[$k] = $this->updateArgumentReferences($replacements, $definitionId, $argument);
                continue;
            }
            // Skip arguments that don't need replacement
            if (!$argument instanceof Reference) {
                continue;
            }
            $referenceId = (string) $argument;
            if (!isset($replacements[$referenceId])) {
                continue;
            }
            // Perform the replacement
            $newId = $replacements[$referenceId];
            $arguments[$k] = new Reference($newId, $argument->getInvalidBehavior());
            $this->compiler->addLogMessage($this->formatter->formatUpdateReference($this, $definitionId, $referenceId, $newId));
        }

        return $arguments;
    }