Gets the unique reference for this collection.

@return string
964498
public function getUniqueReference()
    {
        if ($this->uniqueReference === null) {
            $modelName = basename(str_replace("\\", "/", $this->getModelClassName()));

            if (!isset(self::$uniqueReferencesUsed[$modelName])) {
                self::$uniqueReferencesUsed[$modelName] = 0;
            }

            self::$uniqueReferencesUsed[$modelName]++;

            $this->uniqueReference = $modelName . (self::$uniqueReferencesUsed[$modelName] > 1 ? self::$uniqueReferencesUsed[$modelName] : "");
        }

        return $this->uniqueReference;
    }
1245709
private function getOrderStoreReference()
    {
        return \UOL\PagSeguro\Helper\Data::getOrderStoreReference(
            $this->_scopeConfig->getValue('pagseguro/store/reference'),
            $this->_checkoutSession->getLastRealOrder()->getEntityId()
        );
    }
1040378
public function getRef()
    {
        if (is_null($this->ref)) {
            $tags = $this->tags;
            sort($tags);
            $this->ref = md5(implode('-', $tags));
        }
        return $this->ref;
    }
898407
public function getLinks()
    {

        if( isset( $this->links ) ) {
            return $this->links;
        }

        // build links
        $this->links = array();

        foreach( $this->getAttributes() as $column ) {

            /* This relation has a link if it has a attribute which has all of the following
             *   1. Is unique and is referenced by another attribute
                    TODO. Pete: We don't currently support dual column foreign key constraints
             *   2. This another attribute is one half of a dualcolumn primary key
             *      TODO. Pete: I think this can be relaxed a little. We just need a unique constraint which references two tables
             *   3. The other half of the primary references another unique constraint in another table
             */
            // See 1.
            if( $column->isUnique() and ( $references = $column->getIsReferencedBy() ) ) {

                foreach( $references as $reference ) {

                    // See 2.
                    if( $reference->isPrimaryKey() and count( $primaryKeys = $reference->getRelation()->getPrimaryKeys() ) == 2 ) {

                        $primaryKeys->remove( $reference );
                        $otherHalfofPrimaryKey = $primaryKeys->pop();

                        // See 3.
                        $otherReferences = $otherHalfofPrimaryKey->getReferences();
                        $foreignEntities = new BaseContainer();
                        foreach( $otherReferences as $otherReference ) {

                            // Pete. We might not need the unique check here because foreign keys already have uniqueness enforced
                            if( $otherReference->isUnique() and $otherReference->getRelation() !== $this ) {

                                $foreignEntities[] = $foreignEntities->add( $otherReference->getRelation() );
                                $foreignEntityReference = $otherReference;

                            }

                        }

                        // have we a link?
                        if( $foreignEntities ) {

                            $sourceEntity = $this->getEntityName();
                            $linkEntity = $otherHalfofPrimaryKey->getRelation()->getEntityName();

                            $refSource = array( $column->name, $reference->name );
                            $refForeign = array( $otherHalfofPrimaryKey->name, $foreignEntityReference->name );

                            // get columns and look for a ranking columns
                            $possibleRankingAttributes = $otherHalfofPrimaryKey->getRelation()->getAttributes();
                            $possibleRankingAttributes->remove( $otherHalfofPrimaryKey, $reference );

                            $sortColumn = null;
                            $rankingRegex = "/^{$otherHalfofPrimaryKey->name}_?(r|rank|ranking)$/i";
                            foreach( $possibleRankingAttributes as $ranking ) {

                                if( $ranking->getType()->isNumeric() and preg_match( $rankingRegex, $ranking->name ) ) {
                                    $sortColumn = $ranking->name;
                                    break;
                                }

                            }

                            // sort foreignEntities, we want 'root' entity first then alphabetical
                            $foreignEntities = $foreignEntities
                                ->sort(
                                    function($a, $b){
                                        if( $a->isInherited() and !$b->isInherited() ) {
                                            return 1;
                                        }
                                        return $a->getEntityName() < $b->getEntityName() ? -1 : 1;
                                    }
                                )
                                ->map(function ($e) {
                                    return $e->getEntityName();
                                });

                            $this->links[$linkEntity] = new Link(
                                $sourceEntity,
                                $linkEntity,
                                array_values( $foreignEntities ),
                                $refSource,
                                $refForeign,
                                $sortColumn
                            );

                        }

                    }

                }

            }

        }

        return $this->links;

    }
691729
public function getUniqueIdentifier()
    {
        $formDefinition = $this->getRootForm();
        $uniqueIdentifier = sprintf('%s-%s', $formDefinition->getIdentifier(), $this->identifier);
        $uniqueIdentifier = preg_replace('/[^a-zA-Z0-9-_]/', '_', $uniqueIdentifier);
        return lcfirst($uniqueIdentifier);
    }
214477
protected function allValuesUnique()
    {
        // Init some vars.
        $environment     = $this->getEnvironment();
        $translator      = $environment->getTranslator();
        $dataProvider    = $environment->getDataProvider($this->model->getProviderName());
        $editInformation = $GLOBALS['container']['dc-general.edit-information'];

        // Run each and check the unique flag.
        foreach ($this->getDataDefinition()->getPropertiesDefinition()->getPropertyNames() as $propertyName) {
            $definition = $this->getDataDefinition()->getPropertiesDefinition()->getProperty($propertyName);
            $extra      = $definition->getExtra();
            $value      = $this->model->getProperty($propertyName);

            // Check the flag and the value.
            if (('' !== $value) && $extra['unique'] && isset($extra['unique'])) {
                // Check the database. If return true the value is already in the database.
                if (!$dataProvider->isUniqueValue($propertyName, $value, $this->model->getId())) {
                    $editInformation->setModelError(
                        $this->model,
                        [$translator->translate('not_unique', 'MSC', [$propertyName])],
                        $definition
                    );

                    return false;
                }
            }
        }

        return true;
    }
451
public function unique() : Collection
    {
        $acc = [];
        foreach ($this->list as $item) {
            if (!in_array($item, $acc)) {
                $acc[] = $item;
            }
        }

        return self::from(...$acc);
    }
360466
public function getIndexedFilename()
    {
        $extension = strtolower($this->getMimeType());
        $extension = explode('/', $extension);
        $extension = $extension[1];

        return $this->uniqueName . $this->getImageIndex() . '.' . $extension;
    }
86901
public function getPHP() {

        $result = '';

        // The type
        switch ($this->getType()) {
            case XMLDB_KEY_PRIMARY:
                $result .= 'XMLDB_KEY_PRIMARY' . ', ';
                break;
            case XMLDB_KEY_UNIQUE:
                $result .= 'XMLDB_KEY_UNIQUE' . ', ';
                break;
            case XMLDB_KEY_FOREIGN:
                $result .= 'XMLDB_KEY_FOREIGN' . ', ';
                break;
            case XMLDB_KEY_FOREIGN_UNIQUE:
                $result .= 'XMLDB_KEY_FOREIGN_UNIQUE' . ', ';
                break;
        }
        // The fields
        $keyfields = $this->getFields();
        if (!empty($keyfields)) {
            $result .= "['".  implode("', '", $keyfields) . "']";
        } else {
            $result .= 'null';
        }
        // The FKs attributes
        if ($this->getType() == XMLDB_KEY_FOREIGN ||
            $this->getType() == XMLDB_KEY_FOREIGN_UNIQUE) {
            // The reftable
            $reftable = $this->getRefTable();
            if (!empty($reftable)) {
                $result .= ", '" . $reftable . "', ";
            } else {
                $result .= 'null, ';
            }
            // The reffields
            $reffields = $this->getRefFields();
            if (!empty($reffields)) {
                $result .= "['".  implode("', '", $reffields) . "']";
            } else {
                $result .= 'null';
            }
        }
        // Return result
        return $result;
    }
1186761
public function getUniqueJsIncludes()
    {
        $includes = array();
        foreach ($this->getPopups() as $popup) {
            foreach ($popup->getRules() as $rule) {
                $includes[] = $rule->getJsFilePath();
            }
        }

        return array_unique($includes);
    }
29644
public function getUniqueIconsList()
    {
        if ($this->uniqueIconsList === null) {
            $this->uniqueIconsList = $this->fetchUniqueIconsList();
        }

        return $this->uniqueIconsList;
    }
290090
public function getReferenceName()
    {
        $options = $this->getOptions();
        if (!empty($options['tag'])) {
            return 'Tag: ' . $options['tag'];
        } elseif (!empty($options['branch'])) {
            return 'Branch: ' . $options['branch'];
        } elseif (!empty($options['sha1'])) {
            return 'Sha1: ' . $options['sha1'];
        }
        return '';
    }
933784
public function getEntity()
    {

        // primary key only
        $references = $this->getReferences();

        // debug // print_r( $references->map(function($e){ return $e->get('fullyQualifiedName');}) );
        foreach( $references as $reference ) {

            // only manage references where the reference column is the primary key
            if( $reference->isPrimaryKey() ) {
                return array(
                    'entity' => 'normality',
                    'normality' => $reference->getRelation()->getEntityName(),
                );
            }

        }

        // datatypes we understand and have defined objects for
        // have a helper method in Entity::staticHelper
        switch( $this->getType()->name ) {

            case 'StockState':

                return array (
                    'entity' => 'StockState',
                );

            case 'hstore':

                return array(
                    'entity' => 'Hstore',
                );

            case 'json':

                return array(
                    'entity' => 'Json',
                );

            case 'inet':

                return array(
                    'entity' => 'Inet',
                );

            case 'timestamp':

                return array(
                    'entity' => 'DateTime',
                );

            case 'tsrange':

                return array(
                    'entity' => 'DateRange',
                );

            case 'oid':

                return array(
                    'entity' => 'PgLargeObject',
                );

        }

        return array();

    }
543146
public function getUniqueProperties()
    {
        $props = [];
        foreach ($this->properties as $property) {
            if ($property->isUnique()) {
                $props[] = $property;
            }
        }

        return $props;
    }
364295
public function properties() {
        return $this->cache(__METHOD__, function() {
            return array_unique(array_merge(
                $this->publicProperties(),
                $this->protectedProperties(),
                $this->privateProperties(),
                $this->staticProperties()
            ));
        });
    }
1345800
public function methods() {
        return $this->cache(__METHOD__, function() {
            return array_unique(array_merge(
                $this->publicMethods(),
                $this->protectedMethods(),
                $this->privateMethods(),
                $this->staticMethods()
            ));
        });
    }
684990
public function getDistinctString() {
    $distinct = array();
    if (is_array($s = $this->getDistinct()) && !empty($s)) {
      foreach ($s as $distinctAttribute) {
        $item = array();
        if ($distinctAttribute['dist_key'] != 'none_dist') {
          if (is_array($distinctAttribute) && !empty($distinctAttribute)) {
            foreach ($distinctAttribute as $k => $v) {
              $item[] = $k . ":" . $v;
            }
          }
          $distinct[] = implode(",", $item);
        } else {
          $distinct[] = $distinctAttribute['dist_key'];
        }
      }
    }
    return implode(";", $distinct);
  }