<commit_before><?php

/**
 * Generates Redirect routes
 *
 * @package     Nails
 * @subpackage  module-redirect
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */

namespace Nails\Redirect;

use Nails\Common\Interfaces\RouteGenerator;
use Nails\Factory;
use PDO;


class Routes implements RouteGenerator
{
    /**
     * Returns an array of routes for this module
     * @return array
     */
    public static function generate()
    {
        $oDb            = Factory::service('ConsoleDatabase', 'nailsapp/module-console');
        $oRedirectModel = Factory::model('Redirect', 'nailsapp/module-redirect');
        $aRoutes        = [];

        $oRedirects = $oDb->query(
            'SELECT id, old_url FROM ' . $oRedirectModel->getTableName()
        );

        while ($oRow = $oRedirects->fetch(PDO::FETCH_OBJ)) {

            $sUrl = preg_replace('/^\//', '', $oRow->old_url);
            $sUrl = preg_replace('/^' . preg_quote(BASE_URL, '/') . '/', '', $sUrl);
            $sUrl = preg_replace('/^' . preg_quote(SECURE_BASE_URL, '/') . '/', '', $sUrl);

            $aRoutes[$sUrl] = 'redirect/redirect/index/' . $oRow->id;
        }

        return $aRoutes;
    }
}<commit_msg>Switching back to PDODatabase<commit_after><?php

/**
 * Generates Redirect routes
 *
 * @package     Nails
 * @subpackage  module-redirect
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */

namespace Nails\Redirect;

use Nails\Common\Interfaces\RouteGenerator;
use Nails\Factory;
use PDO;


class Routes implements RouteGenerator
{
    /**
     * Returns an array of routes for this module
     * @return array
     */
    public static function generate()
    {
        $oDb            = Factory::service('PDODatabase');
        $oRedirectModel = Factory::model('Redirect', 'nailsapp/module-redirect');
        $aRoutes        = [];

        $oRedirects = $oDb->query(
            'SELECT id, old_url FROM ' . $oRedirectModel->getTableName()
        );

        while ($oRow = $oRedirects->fetch(PDO::FETCH_OBJ)) {

            $sUrl = preg_replace('/^\//', '', $oRow->old_url);
            $sUrl = preg_replace('/^' . preg_quote(BASE_URL, '/') . '/', '', $sUrl);
            $sUrl = preg_replace('/^' . preg_quote(SECURE_BASE_URL, '/') . '/', '', $sUrl);

            $aRoutes[$sUrl] = 'redirect/redirect/index/' . $oRow->id;
        }

        return $aRoutes;
    }
}
{'fraction_non_alphanumeric': 0.16034985422740525, 'fraction_numerical': 0.0, 'mean_word_length': 2.340751043115438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3165622', 'n_tokens_mistral': 771, 'n_tokens_neox': 755, 'n_words': 150}