Changed name of context class and global variable.

This commit is contained in:
flash 2023-01-06 20:35:03 +00:00
parent e8518fde65
commit 5a7f4765ab
11 changed files with 23 additions and 23 deletions

View file

@ -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'),

2
msz
View file

@ -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,
);

View file

@ -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);

View file

@ -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();

View file

@ -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()]);

View file

@ -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;
}

View file

@ -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;

View file

@ -1,15 +1,15 @@
<?php
namespace Misuzu\Net;
use Misuzu\MszContext;
use Misuzu\MisuzuContext;
// remains for now for backwards compatibility with existing ::create methods
// plan is for those ::create methods to Fucking Die so that's fine for now
final class IPAddress {
private static MszContext $context;
private static MisuzuContext $context;
public static function init(MszContext $ctx): void {
public static function init(MisuzuContext $ctx): void {
self::$context = $ctx;
}

View file

@ -5,7 +5,7 @@ use InvalidArgumentException;
use Twig\Environment as TwigEnvironment;
use Twig_Extensions_Extension_Date;
use Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;
use Misuzu\MszContext;
use Misuzu\MisuzuContext;
final class Template {
private const FILE_EXT = '.twig';
@ -14,7 +14,7 @@ final class Template {
private static $env;
private static $vars = [];
public static function init(MszContext $ctx, ?string $cache = null, bool $debug = false): void {
public static function init(MisuzuContext $ctx, ?string $cache = null, bool $debug = false): void {
self::$loader = new TwigLoaderFilesystem;
self::$env = new TwigEnvironment(self::$loader, [
'cache' => $cache ?? false,

View file

@ -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;
}

View file

@ -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;