public function add($alias, $id)
    {
        if (isset($this->aliases[$alias])) {
            if ($this->aliases[$alias] === $id) {
                // exactly the same alias for the specified item is already exists
                return $this;
            }

            throw new Exception\AliasAlreadyExistsException(
                sprintf(
                    'The "%s" sting cannot be used as an alias for "%s" item'
                    . ' because it is already used for "%s" item.',
                    $alias,
                    $id,
                    $this->aliases[$alias]
                )
            );
        }

        $this->aliases[$alias] = $id;

        $id               = $this->getId($alias);
        $this->ids[$id][] = $alias;

        return $this;
    }
public function add($alias, $id)
    {
        if (isset($this->aliases[$alias])) {
            if ($this->aliases[$alias] === $id) {
                // exactly the same alias for the specified item is already exists
                return $this;
            }

            throw new Exception\AliasAlreadyExistsException(
                sprintf(
                    'The "%s" sting cannot be used as an alias for "%s" item'
                    . ' because it is already used for "%s" item.',
                    $alias,
                    $id,
                    $this->aliases[$alias]
                )
            );
        }

        $this->aliases[$alias] = $id;

        $id               = $this->getId($alias);
        $this->ids[$id][] = $alias;

        return $this;
    }
public function add ( $ alias , $ id ) { if ( isset ( $ this -> aliases [ $ alias ] ) ) { if ( $ this -> aliases [ $ alias ] === $ id ) { // exactly the same alias for the specified item is already exists return $ this ; } throw new Exception \ AliasAlreadyExistsException ( sprintf ( 'The "%s" sting cannot be used as an alias for "%s" item' . ' because it is already used for "%s" item.' , $ alias , $ id , $ this -> aliases [ $ alias ] ) ) ; } $ this -> aliases [ $ alias ] = $ id ; $ id = $ this -> getId ( $ alias ) ; $ this -> ids [ $ id ] [ ] = $ alias ; return $ this ; }
Registers an alias for the specified identifier

@param string $alias A string that can be used as an alias for the item id
@param string $id    The item identifier or already registered item alias

@return self

@throws Exception\AliasAlreadyExistsException if the alias is used for another item
Registers an alias for the specified identifier