public function getDriverInstance($sSlug = null)
    {
        $oDriverService = Factory::service('Driver', 'nails/module-geo-ip');
        $sEnabledDriver = appSetting($oDriverService->getSettingKey(), 'nails/module-geo-ip');
        $oEnabledDriver = $oDriverService->getEnabled();

        if (empty($sEnabledDriver) && empty($oEnabledDriver)) {
            //  No configured driver, default to first available driver and hope for the best
            $aDrivers       = $oDriverService->getAll();
            $oEnabledDriver = reset($aDrivers);
        }

        if (empty($sEnabledDriver) && empty($oEnabledDriver)) {
            throw new GeoIpDriverException('No Geo-IP drivers are available.');
        } elseif (empty($oEnabledDriver)) {
            throw new GeoIpDriverException('Driver "' . $sEnabledDriver . '" is not installed');
        }

        $oDriver = $oDriverService->getInstance($oEnabledDriver->slug);

        //  Ensure driver implements the correct interface
        $sInterfaceName = 'Nails\GeoIp\Interfaces\Driver';
        if (!classImplements($oDriver, $sInterfaceName)) {
            throw new GeoIpDriverException(
                '"' . get_class($oDriver) . '" must implement "' . $sInterfaceName . '"'
            );
        }

        return $oDriver;
    }
public function getDriverInstance($sSlug = null)
    {
        $oDriverService = Factory::service('Driver', 'nails/module-geo-ip');
        $sEnabledDriver = appSetting($oDriverService->getSettingKey(), 'nails/module-geo-ip');
        $oEnabledDriver = $oDriverService->getEnabled();

        if (empty($sEnabledDriver) && empty($oEnabledDriver)) {
            //  No configured driver, default to first available driver and hope for the best
            $aDrivers       = $oDriverService->getAll();
            $oEnabledDriver = reset($aDrivers);
        }

        if (empty($sEnabledDriver) && empty($oEnabledDriver)) {
            throw new GeoIpDriverException('No Geo-IP drivers are available.');
        } elseif (empty($oEnabledDriver)) {
            throw new GeoIpDriverException('Driver "' . $sEnabledDriver . '" is not installed');
        }

        $oDriver = $oDriverService->getInstance($oEnabledDriver->slug);

        //  Ensure driver implements the correct interface
        $sInterfaceName = 'Nails\GeoIp\Interfaces\Driver';
        if (!classImplements($oDriver, $sInterfaceName)) {
            throw new GeoIpDriverException(
                '"' . get_class($oDriver) . '" must implement "' . $sInterfaceName . '"'
            );
        }

        return $oDriver;
    }
public function getDriverInstance ( $ sSlug = null ) { $ oDriverService = Factory :: service ( 'Driver' , 'nails/module-geo-ip' ) ; $ sEnabledDriver = appSetting ( $ oDriverService -> getSettingKey ( ) , 'nails/module-geo-ip' ) ; $ oEnabledDriver = $ oDriverService -> getEnabled ( ) ; if ( empty ( $ sEnabledDriver ) && empty ( $ oEnabledDriver ) ) { //  No configured driver, default to first available driver and hope for the best $ aDrivers = $ oDriverService -> getAll ( ) ; $ oEnabledDriver = reset ( $ aDrivers ) ; } if ( empty ( $ sEnabledDriver ) && empty ( $ oEnabledDriver ) ) { throw new GeoIpDriverException ( 'No Geo-IP drivers are available.' ) ; } elseif ( empty ( $ oEnabledDriver ) ) { throw new GeoIpDriverException ( 'Driver "' . $ sEnabledDriver . '" is not installed' ) ; } $ oDriver = $ oDriverService -> getInstance ( $ oEnabledDriver -> slug ) ; //  Ensure driver implements the correct interface $ sInterfaceName = 'Nails\GeoIp\Interfaces\Driver' ; if ( ! classImplements ( $ oDriver , $ sInterfaceName ) ) { throw new GeoIpDriverException ( '"' . get_class ( $ oDriver ) . '" must implement "' . $ sInterfaceName . '"' ) ; } return $ oDriver ; }
Returns an instance of the driver

@param  string $sSlug The driver's slug

@throws GeoIpDriverException
@return \Nails\GeoIp\Interfaces\Driver
Returns an instance of the driver