public static function get($alias, array $options = [])
    {
        if (isset(self::$_instances[$alias])) {
            if (!empty($options) && self::$_options[$alias] !== $options) {
                throw new RuntimeException(sprintf(
                    'You cannot configure "%s", it already exists in the registry.',
                    $alias
                ));
            }

            return self::$_instances[$alias];
        }

        list(, $classAlias) = pluginSplit($alias);
        $options = ['alias' => $classAlias] + $options;

        if (empty($options['className'])) {
            $options['className'] = Inflector::camelize($alias);
        }
        $className = App::className($options['className'], 'Model/Endpoint', 'Endpoint');
        if ($className) {
            $options['className'] = $className;
        } else {
            if (!isset($options['endpoint']) && strpos($options['className'], '\\') === false) {
                list(, $endpoint) = pluginSplit($options['className']);
                $options['endpoint'] = Inflector::underscore($endpoint);
            }
            $options['className'] = 'Muffin\Webservice\Model\Endpoint';
        }

        if (empty($options['connection'])) {
            if ($options['className'] !== 'Muffin\Webservice\Model\Endpoint') {
                $connectionName = $options['className']::defaultConnectionName();
            } else {
                $pluginParts = explode('/', pluginSplit($alias)[0]);

                $connectionName = Inflector::underscore(end($pluginParts));
            }

            $options['connection'] = ConnectionManager::get($connectionName);
        }

        $options['registryAlias'] = $alias;
        self::$_instances[$alias] = self::_create($options);
        self::$_options[$alias] = $options;

        return self::$_instances[$alias];
    }
public static function get($alias, array $options = [])
    {
        if (isset(self::$_instances[$alias])) {
            if (!empty($options) && self::$_options[$alias] !== $options) {
                throw new RuntimeException(sprintf(
                    'You cannot configure "%s", it already exists in the registry.',
                    $alias
                ));
            }

            return self::$_instances[$alias];
        }

        list(, $classAlias) = pluginSplit($alias);
        $options = ['alias' => $classAlias] + $options;

        if (empty($options['className'])) {
            $options['className'] = Inflector::camelize($alias);
        }
        $className = App::className($options['className'], 'Model/Endpoint', 'Endpoint');
        if ($className) {
            $options['className'] = $className;
        } else {
            if (!isset($options['endpoint']) && strpos($options['className'], '\\') === false) {
                list(, $endpoint) = pluginSplit($options['className']);
                $options['endpoint'] = Inflector::underscore($endpoint);
            }
            $options['className'] = 'Muffin\Webservice\Model\Endpoint';
        }

        if (empty($options['connection'])) {
            if ($options['className'] !== 'Muffin\Webservice\Model\Endpoint') {
                $connectionName = $options['className']::defaultConnectionName();
            } else {
                $pluginParts = explode('/', pluginSplit($alias)[0]);

                $connectionName = Inflector::underscore(end($pluginParts));
            }

            $options['connection'] = ConnectionManager::get($connectionName);
        }

        $options['registryAlias'] = $alias;
        self::$_instances[$alias] = self::_create($options);
        self::$_options[$alias] = $options;

        return self::$_instances[$alias];
    }
public static function get ( $ alias , array $ options = [ ] ) { if ( isset ( self :: $ _instances [ $ alias ] ) ) { if ( ! empty ( $ options ) && self :: $ _options [ $ alias ] !== $ options ) { throw new RuntimeException ( sprintf ( 'You cannot configure "%s", it already exists in the registry.' , $ alias ) ) ; } return self :: $ _instances [ $ alias ] ; } list ( , $ classAlias ) = pluginSplit ( $ alias ) ; $ options = [ 'alias' => $ classAlias ] + $ options ; if ( empty ( $ options [ 'className' ] ) ) { $ options [ 'className' ] = Inflector :: camelize ( $ alias ) ; } $ className = App :: className ( $ options [ 'className' ] , 'Model/Endpoint' , 'Endpoint' ) ; if ( $ className ) { $ options [ 'className' ] = $ className ; } else { if ( ! isset ( $ options [ 'endpoint' ] ) && strpos ( $ options [ 'className' ] , '\\' ) === false ) { list ( , $ endpoint ) = pluginSplit ( $ options [ 'className' ] ) ; $ options [ 'endpoint' ] = Inflector :: underscore ( $ endpoint ) ; } $ options [ 'className' ] = 'Muffin\Webservice\Model\Endpoint' ; } if ( empty ( $ options [ 'connection' ] ) ) { if ( $ options [ 'className' ] !== 'Muffin\Webservice\Model\Endpoint' ) { $ connectionName = $ options [ 'className' ] :: defaultConnectionName ( ) ; } else { $ pluginParts = explode ( '/' , pluginSplit ( $ alias ) [ 0 ] ) ; $ connectionName = Inflector :: underscore ( end ( $ pluginParts ) ) ; } $ options [ 'connection' ] = ConnectionManager :: get ( $ connectionName ) ; } $ options [ 'registryAlias' ] = $ alias ; self :: $ _instances [ $ alias ] = self :: _create ( $ options ) ; self :: $ _options [ $ alias ] = $ options ; return self :: $ _instances [ $ alias ] ; }
Get a endpoint instance from the registry.

@param string $alias The alias name you want to get.
@param array $options The options you want to build the endpoint with.
@return \Muffin\Webservice\Model\Endpoint
@throws \RuntimeException If the registry alias is already in use.
Get a endpoint instance from the registry .