Kraken\Container\ServiceRegister::registerAlias PHP Method

registerAlias() public method

public registerAlias ( $alias, $existing )
    public function registerAlias($alias, $existing)
    {
        if ($this->getAlias($alias) !== null) {
            throw new ResourceOccupiedException("ServiceProvider alias of {$alias} is already registered.");
        }
        $this->serviceAliases[$alias] = $existing;
        if ($this->booted) {
            $ex = null;
            try {
                $this->container->alias($alias, $existing);
            } catch (Error $ex) {
            } catch (Exception $ex) {
            }
            if ($ex !== null) {
                throw new ExecutionException("Alias [{$alias}] could not be registered.", $ex);
            }
        }
    }

Usage Example

Example #1
0
 /**
  * @override
  * @inheritDoc
  */
 public function registerAlias($alias, $interface)
 {
     try {
         $this->serviceRegister->registerAlias($alias, $interface);
         return;
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     throw new ExecutionException("Alias could not be registered.", $ex);
 }