Creates a new URL Shortener instance with the given driver name.
Useful for chained calls using the facade when a different driver is to be used for just one request.

@param  string $driverName
@return UrlShortener
508195
public function driver($driverName)
    {
        $shortener = new UrlShortener($this->driverFactory);
        $shortener->setDriver($driverName);
        return $shortener;
    }
77479
private function createYmlDriver($driverName, array $driverConfig, ContainerBuilder $container)
    {
        // Definition directories
        list($modelDir, $mixinDir, $embedDir) = $this->getDefinitionDirs($driverConfig, $container);

        // Set the directories to the dirs container parameter.
        Utility::appendParameter('dirs', sprintf('%s.model_dir', $driverName), $modelDir, $container);
        Utility::appendParameter('dirs', sprintf('%s.mixin_dir', $driverName), $mixinDir, $container);
        Utility::appendParameter('dirs', sprintf('%s.embed_dir', $driverName), $embedDir, $container);

        // File locator
        $locatorName = sprintf('%s.file_locator', $driverName);
        $locatorDef = $this->createFileLocator($modelDir, $mixinDir, $embedDir);
        $container->setDefinition($locatorName, $locatorDef);

        // Driver
        return new Definition(
            Utility::getLibraryClass('Metadata\Driver\YamlFileDriver'),
            [
                new Reference($locatorName),
                new Reference(Utility::getAliasedName('storage_manager')),
            ]
        );
    }
511366
public function driver( $driver = null )
	{
		$driver = strtolower( $driver ?: $this->getDefaultDriver() );

		// If the given driver has not been created before, we will create the instances
		// here and cache it so we can return it next time very quickly. If there is
		// already a driver created by this name, we'll just return that instance.
		if ( !array_key_exists( $driver, $this->drivers ) )
			$this->drivers[$driver] = $this->createDriver( $driver );

		return $this->drivers[$driver];
	}
220231
private function buildDriver($name, array $driver)
    {
        return $this->drivers[$name] = new $driver['driver'](
            Arr::get($driver, 'options.'.$this->getDefaultOption(), [])
        );
    }
99154
public function driver(?string $name = null)
    {
        $name = $name ?: $this->getDefaultDriver();

        return $this->drivers[$name] = $this->get($name);
    }
777054
protected function createDriver($driver)
    {
        if (isset($this->initialDrivers[$driver])) {
            $provider = $this->initialDrivers[$driver];
            $provider = __NAMESPACE__.'\\Providers\\'.$provider.'Provider';

            return $this->buildProvider($provider, $this->formatConfig($this->config->get($driver)));
        }

        if (isset($this->customCreators[$driver])) {
            return $this->callCustomCreator($driver);
        }

        throw new InvalidArgumentException("Driver [$driver] not supported.");
    }
385069
protected function createRuntimeDriver($name)
    {
        $config = Arr::get($this->config, "runtime.{$name}", []);
        return $this->createProvider(new Runtime($name, $config));
    }
413211
public function driver(?string $driver = null): self
    {
        $driver = $driver ? $driver : $this->app->make('config')->get('microservice-client.client');

        $connections = array_keys($this->app->make('config')->get('microservice-client.clients'));
        if (! in_array($driver, $connections, true)) {
            throw new DomainException("The Driver[{$driver}] not exists");
        }

        $this->driver = $driver;

        return $this;
    }
1173723
public function shorten($url)
    {
        $short = $this->bitly->shortenUrl($url);

        $this->save($url, $short);

        return $short;
    }
896271
public static function create($name)
    {
        if (!isset(self::$_pool[$name])) {
            $classname = self::__getClassName($name);
            $path = self::__getDriverPath($name);

            if (!is_file($path)) {
                $errMsg = __('Could not find extension %s at location %s.', array(
                    '<code>' . $name . '</code>',
                    '<code>' . str_replace(DOCROOT . '/', '', $path) . '</code>'
                ));
                try {
                    Symphony::Engine()->throwCustomError(
                        $errMsg,
                        __('Symphony Extension Missing Error'),
                        Page::HTTP_STATUS_ERROR,
                        'missing_extension',
                        array(
                            'name' => $name,
                            'path' => $path
                        )
                    );
                } catch (Exception $ex) {
                    throw new Exception($errMsg, 0, $ex);
                }
            }

            if (!class_exists($classname)) {
                require_once($path);
            }

            // Create the extension object
            self::$_pool[$name] = new $classname(array());
        }

        return self::$_pool[$name];
    }
379685
protected function createFluentDriver(string $name): ProviderContract
    {
        $config = $this->config['fluent'][$name] ?? [];
        $cache = $this->getCacheRepository($config);

        return $this->createProvider(new Fluent($name, $config, $this->app->make('db'), $cache));
    }
456050
public function shortenUrl($url, $provider)
    {
        if (!empty($url) && !empty($provider)) {
            if ($provider == 'tinyurl') {
                $url_data = sprintf($this->_tinyUrlShortApiUrl, $url);
            } elseif ($provider == 'google') {
                $url_data = sprintf('%s/url', $this->_googleShortApiUrl);
            }

            switch ($provider) {
                case 'tinyurl':
                    $ch = curl_init($url_data);  
                    $timeout = 5;  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
                    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
                    $result = curl_exec($ch);  
                    curl_close($ch);

                    return $result; 
                    break;

                case 'google':
                    $ch = curl_init($url_data);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    $requestData = array(
                        'longUrl' => $url
                    );

                    curl_setopt($ch, CURLOPT_POST, true);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
                    $result = json_decode(curl_exec($ch), true);
                    curl_close($ch);

                    return $result['id'];
                    break;
                
                default:
                    return false;
                    break;
            }
        }
        return false;
    }
1186773
public function getLink($presenterName, $parameters = array())
	{
		$url = new \Nette\Http\UrlScript($this->context->parameters['selenium']['baseUrl']);
		$url->scriptPath = $url->path;
		$appRequest = new \Nette\Application\Request($presenterName, 'GET', Utils::strToArray($parameters));
		return $this->context->router->constructUrl($appRequest, $url);
	}
153433
public function getMbShortcode($shortcodeName)
    {
        if (!$this->mbShortCodes->has($shortcodeName)) {
            throw new MbException("The shortcode {$shortcodeName} has not been added to the MocaBonita shortcode list!");
        }

        return $this->mbShortCodes->get($shortcodeName);
    }
347631
protected function controller($controllername)
    {
        if (str_contains($controllername, '/')) {
            $controllername = str_replace('/', '\\', $controllername);
        }

        if (str_contains($controllername, '@')) {
            return ucfirst($controllername);
        }
        return ucfirst($controllername . '@index');
    }
973759
public function create( $serviceName ) {

		if ( is_string( $serviceName ) && isset( $this->aliases[$serviceName] ) ) {
			$serviceName = $this->aliases[$serviceName];
		}

		return $this->getReturnValueFromCallbackHandlerFor( $serviceName, func_get_args() );
	}
629772
public static function driver($name = 'default', $driverName = null)
    {
        if ($name !== null && $driverName === null) {
            $databaseConfig = self::getConnectionConfiguration($name);
            $driverName = $databaseConfig['driver'];
        }

        // Make the driver if we don't have it already this run.
        if (! isset(self::$drivers[$driverName])) {
            // We will make the driver class first, prepare the full class name.
            $driverClass = new \ReflectionClass("\\Arvici\\Heart\\Database\\Driver\\$driverName\\Driver");

            self::$drivers[$driverName] = $driverClass->newInstance();
        }

        return self::$drivers[$driverName];
    }