From 5a7f4765abe91939226e69af4a7148a5e76eef7f Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 6 Jan 2023 20:35:03 +0000 Subject: [PATCH] Changed name of context class and global variable. --- misuzu.php | 6 +++--- msz | 2 +- public/index.php | 4 ++-- public/manage/general/twitter.php | 2 +- public/manage/news/post.php | 2 +- src/Console/Commands/CronCommand.php | 6 +++--- src/{MszContext.php => MisuzuContext.php} | 2 +- src/Net/IPAddress.php | 6 +++--- src/Template.php | 4 ++-- src/TwigMisuzu.php | 6 +++--- src/Twitter/TwitterRoutes.php | 6 +++--- 11 files changed, 23 insertions(+), 23 deletions(-) rename src/{MszContext.php => MisuzuContext.php} (99%) diff --git a/misuzu.php b/misuzu.php index 14cb038..e560aa5 100644 --- a/misuzu.php +++ b/misuzu.php @@ -102,7 +102,7 @@ define('MSZ_STORAGE', $cfg->getValue('storage.path', CfgType::T_STR, MSZ_ROOT . if(!is_dir(MSZ_STORAGE)) mkdir(MSZ_STORAGE, 0775, true); -$ctx = new MszContext($db, $cfg); +$msz = new MisuzuContext($db, $cfg); if(MSZ_CLI) { // Temporary backwards compatibility measure, remove this later if(realpath($_SERVER['SCRIPT_FILENAME']) === __FILE__) { @@ -133,7 +133,7 @@ if(!is_readable(MSZ_STORAGE) || !is_writable(MSZ_STORAGE)) { exit; } -IPAddress::init($ctx); +IPAddress::init($msz); if(!MSZ_DEBUG) { $twigCacheDirSfx = GitInfo::hash(true); @@ -145,7 +145,7 @@ if(!MSZ_DEBUG) { mkdir($twigCache, 0775, true); } -Template::init($ctx, $twigCache ?? null, MSZ_DEBUG); +Template::init($msz, $twigCache ?? null, MSZ_DEBUG); Template::set('globals', [ 'site_name' => $cfg->getValue('site.name', CfgType::T_STR, 'Misuzu'), diff --git a/msz b/msz index 65c5180..e554a74 100755 --- a/msz +++ b/msz @@ -12,7 +12,7 @@ if(!MSZ_CLI) $commands = new CommandCollection; $commands->addCommands( - new \Misuzu\Console\Commands\CronCommand($ctx), + new \Misuzu\Console\Commands\CronCommand($msz), new \Misuzu\Console\Commands\MigrateCommand, new \Misuzu\Console\Commands\NewMigrationCommand, ); diff --git a/public/index.php b/public/index.php index 212d259..9a9db62 100644 --- a/public/index.php +++ b/public/index.php @@ -5,5 +5,5 @@ require_once __DIR__ . '/../misuzu.php'; $request = \Index\Http\HttpRequest::fromRequest(); -$ctx->setUpHttp(str_contains($request->getPath(), '.php')); -$ctx->dispatchHttp($request); +$msz->setUpHttp(str_contains($request->getPath(), '.php')); +$msz->dispatchHttp($request); diff --git a/public/manage/general/twitter.php b/public/manage/general/twitter.php index 3598104..c3c0b2d 100644 --- a/public/manage/general/twitter.php +++ b/public/manage/general/twitter.php @@ -15,7 +15,7 @@ if(!User::hasCurrent() || !perms_check_user(MSZ_PERMS_GENERAL, User::getCurrent( $tCfg = $cfg->scopeTo('twitter'); -$tClient = $ctx->createTwitterClient(); +$tClient = $msz->createTwitterClient(); $tHasClientId = $tClient->hasClientId(); $tHasAccessToken = $tClient->hasAccessToken(); $tHasRefreshToken = $tClient->hasRefreshToken(); diff --git a/public/manage/news/post.php b/public/manage/news/post.php index 83c45e8..862cc75 100644 --- a/public/manage/news/post.php +++ b/public/manage/news/post.php @@ -54,7 +54,7 @@ if(!empty($_POST['post']) && CSRF::validateRequest()) { if(!empty($isNew)) { if($postInfo->isFeatured()) { - $twitter = $ctx->createTwitterClient(); + $twitter = $msz->createTwitterClient(); if($twitter->hasAccessToken()) { $url = url('news-post', ['post' => $postInfo->getId()]); diff --git a/src/Console/Commands/CronCommand.php b/src/Console/Commands/CronCommand.php index f80b633..83aff6d 100644 --- a/src/Console/Commands/CronCommand.php +++ b/src/Console/Commands/CronCommand.php @@ -2,15 +2,15 @@ namespace Misuzu\Console\Commands; use Misuzu\DB; -use Misuzu\MszContext; +use Misuzu\MisuzuContext; use Misuzu\Console\CommandArgs; use Misuzu\Console\CommandInterface; use Misuzu\Twitter\TwitterAccessToken; class CronCommand implements CommandInterface { - private MszContext $context; + private MisuzuContext $context; - public function __construct(MszContext $ctx) { + public function __construct(MisuzuContext $ctx) { $this->context = $ctx; } diff --git a/src/MszContext.php b/src/MisuzuContext.php similarity index 99% rename from src/MszContext.php rename to src/MisuzuContext.php index c69c00f..88ee565 100644 --- a/src/MszContext.php +++ b/src/MisuzuContext.php @@ -16,7 +16,7 @@ use Index\Routing\Router; // this class should function as the root for everything going forward // no more magical static classes that are just kind of assumed to exist // it currently looks Pretty Messy, but most everything else will be holding instances of other classes -class MszContext { +class MisuzuContext { private IDbConnection $dbConn; private IConfig $config; private Users $users; diff --git a/src/Net/IPAddress.php b/src/Net/IPAddress.php index d58862d..d40220a 100644 --- a/src/Net/IPAddress.php +++ b/src/Net/IPAddress.php @@ -1,15 +1,15 @@ $cache ?? false, diff --git a/src/TwigMisuzu.php b/src/TwigMisuzu.php index 2271fd5..9d739c3 100644 --- a/src/TwigMisuzu.php +++ b/src/TwigMisuzu.php @@ -6,13 +6,13 @@ use Twig\TwigFilter; use Twig\TwigFunction; use Twig\Environment as TwigEnvironment; use Misuzu\Parsers\Parser; -use Misuzu\MszContext; +use Misuzu\MisuzuContext; use Index\Environment; final class TwigMisuzu extends AbstractExtension { - private MszContext $ctx; + private MisuzuContext $ctx; - public function __construct(MszContext $ctx) { + public function __construct(MisuzuContext $ctx) { $this->ctx = $ctx; } diff --git a/src/Twitter/TwitterRoutes.php b/src/Twitter/TwitterRoutes.php index 8e04d10..ff8acd1 100644 --- a/src/Twitter/TwitterRoutes.php +++ b/src/Twitter/TwitterRoutes.php @@ -2,7 +2,7 @@ namespace Misuzu\Twitter; use Index\Routing\IRouter; -use Misuzu\MszContext; +use Misuzu\MisuzuContext; use Misuzu\Config\IConfig; use Misuzu\Twitter\TwitterAccessToken; use Misuzu\Twitter\TwitterAuthorisation; @@ -10,11 +10,11 @@ use Misuzu\Twitter\TwitterClient; use Misuzu\Twitter\TwitterClientId; final class TwitterRoutes { - private MszContext $context; + private MisuzuContext $context; private IConfig $config; private ?TwitterClientId $clientId = null; - public function __construct(MszContext $ctx, IRouter $router, IConfig $config) { + public function __construct(MisuzuContext $ctx, IRouter $router, IConfig $config) { $this->context = $ctx; $this->config = $config;