Changed name of context class and global variable.
This commit is contained in:
parent
e8518fde65
commit
5a7f4765ab
11 changed files with 23 additions and 23 deletions
|
@ -102,7 +102,7 @@ define('MSZ_STORAGE', $cfg->getValue('storage.path', CfgType::T_STR, MSZ_ROOT .
|
||||||
if(!is_dir(MSZ_STORAGE))
|
if(!is_dir(MSZ_STORAGE))
|
||||||
mkdir(MSZ_STORAGE, 0775, true);
|
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(MSZ_CLI) { // Temporary backwards compatibility measure, remove this later
|
||||||
if(realpath($_SERVER['SCRIPT_FILENAME']) === __FILE__) {
|
if(realpath($_SERVER['SCRIPT_FILENAME']) === __FILE__) {
|
||||||
|
@ -133,7 +133,7 @@ if(!is_readable(MSZ_STORAGE) || !is_writable(MSZ_STORAGE)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress::init($ctx);
|
IPAddress::init($msz);
|
||||||
|
|
||||||
if(!MSZ_DEBUG) {
|
if(!MSZ_DEBUG) {
|
||||||
$twigCacheDirSfx = GitInfo::hash(true);
|
$twigCacheDirSfx = GitInfo::hash(true);
|
||||||
|
@ -145,7 +145,7 @@ if(!MSZ_DEBUG) {
|
||||||
mkdir($twigCache, 0775, true);
|
mkdir($twigCache, 0775, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Template::init($ctx, $twigCache ?? null, MSZ_DEBUG);
|
Template::init($msz, $twigCache ?? null, MSZ_DEBUG);
|
||||||
|
|
||||||
Template::set('globals', [
|
Template::set('globals', [
|
||||||
'site_name' => $cfg->getValue('site.name', CfgType::T_STR, 'Misuzu'),
|
'site_name' => $cfg->getValue('site.name', CfgType::T_STR, 'Misuzu'),
|
||||||
|
|
2
msz
2
msz
|
@ -12,7 +12,7 @@ if(!MSZ_CLI)
|
||||||
|
|
||||||
$commands = new CommandCollection;
|
$commands = new CommandCollection;
|
||||||
$commands->addCommands(
|
$commands->addCommands(
|
||||||
new \Misuzu\Console\Commands\CronCommand($ctx),
|
new \Misuzu\Console\Commands\CronCommand($msz),
|
||||||
new \Misuzu\Console\Commands\MigrateCommand,
|
new \Misuzu\Console\Commands\MigrateCommand,
|
||||||
new \Misuzu\Console\Commands\NewMigrationCommand,
|
new \Misuzu\Console\Commands\NewMigrationCommand,
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,5 +5,5 @@ require_once __DIR__ . '/../misuzu.php';
|
||||||
|
|
||||||
$request = \Index\Http\HttpRequest::fromRequest();
|
$request = \Index\Http\HttpRequest::fromRequest();
|
||||||
|
|
||||||
$ctx->setUpHttp(str_contains($request->getPath(), '.php'));
|
$msz->setUpHttp(str_contains($request->getPath(), '.php'));
|
||||||
$ctx->dispatchHttp($request);
|
$msz->dispatchHttp($request);
|
||||||
|
|
|
@ -15,7 +15,7 @@ if(!User::hasCurrent() || !perms_check_user(MSZ_PERMS_GENERAL, User::getCurrent(
|
||||||
|
|
||||||
$tCfg = $cfg->scopeTo('twitter');
|
$tCfg = $cfg->scopeTo('twitter');
|
||||||
|
|
||||||
$tClient = $ctx->createTwitterClient();
|
$tClient = $msz->createTwitterClient();
|
||||||
$tHasClientId = $tClient->hasClientId();
|
$tHasClientId = $tClient->hasClientId();
|
||||||
$tHasAccessToken = $tClient->hasAccessToken();
|
$tHasAccessToken = $tClient->hasAccessToken();
|
||||||
$tHasRefreshToken = $tClient->hasRefreshToken();
|
$tHasRefreshToken = $tClient->hasRefreshToken();
|
||||||
|
|
|
@ -54,7 +54,7 @@ if(!empty($_POST['post']) && CSRF::validateRequest()) {
|
||||||
|
|
||||||
if(!empty($isNew)) {
|
if(!empty($isNew)) {
|
||||||
if($postInfo->isFeatured()) {
|
if($postInfo->isFeatured()) {
|
||||||
$twitter = $ctx->createTwitterClient();
|
$twitter = $msz->createTwitterClient();
|
||||||
|
|
||||||
if($twitter->hasAccessToken()) {
|
if($twitter->hasAccessToken()) {
|
||||||
$url = url('news-post', ['post' => $postInfo->getId()]);
|
$url = url('news-post', ['post' => $postInfo->getId()]);
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
namespace Misuzu\Console\Commands;
|
namespace Misuzu\Console\Commands;
|
||||||
|
|
||||||
use Misuzu\DB;
|
use Misuzu\DB;
|
||||||
use Misuzu\MszContext;
|
use Misuzu\MisuzuContext;
|
||||||
use Misuzu\Console\CommandArgs;
|
use Misuzu\Console\CommandArgs;
|
||||||
use Misuzu\Console\CommandInterface;
|
use Misuzu\Console\CommandInterface;
|
||||||
use Misuzu\Twitter\TwitterAccessToken;
|
use Misuzu\Twitter\TwitterAccessToken;
|
||||||
|
|
||||||
class CronCommand implements CommandInterface {
|
class CronCommand implements CommandInterface {
|
||||||
private MszContext $context;
|
private MisuzuContext $context;
|
||||||
|
|
||||||
public function __construct(MszContext $ctx) {
|
public function __construct(MisuzuContext $ctx) {
|
||||||
$this->context = $ctx;
|
$this->context = $ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ use Index\Routing\Router;
|
||||||
// this class should function as the root for everything going forward
|
// this class should function as the root for everything going forward
|
||||||
// no more magical static classes that are just kind of assumed to exist
|
// 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
|
// it currently looks Pretty Messy, but most everything else will be holding instances of other classes
|
||||||
class MszContext {
|
class MisuzuContext {
|
||||||
private IDbConnection $dbConn;
|
private IDbConnection $dbConn;
|
||||||
private IConfig $config;
|
private IConfig $config;
|
||||||
private Users $users;
|
private Users $users;
|
|
@ -1,15 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Misuzu\Net;
|
namespace Misuzu\Net;
|
||||||
|
|
||||||
use Misuzu\MszContext;
|
use Misuzu\MisuzuContext;
|
||||||
|
|
||||||
// remains for now for backwards compatibility with existing ::create methods
|
// 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
|
// plan is for those ::create methods to Fucking Die so that's fine for now
|
||||||
|
|
||||||
final class IPAddress {
|
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;
|
self::$context = $ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use InvalidArgumentException;
|
||||||
use Twig\Environment as TwigEnvironment;
|
use Twig\Environment as TwigEnvironment;
|
||||||
use Twig_Extensions_Extension_Date;
|
use Twig_Extensions_Extension_Date;
|
||||||
use Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;
|
use Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;
|
||||||
use Misuzu\MszContext;
|
use Misuzu\MisuzuContext;
|
||||||
|
|
||||||
final class Template {
|
final class Template {
|
||||||
private const FILE_EXT = '.twig';
|
private const FILE_EXT = '.twig';
|
||||||
|
@ -14,7 +14,7 @@ final class Template {
|
||||||
private static $env;
|
private static $env;
|
||||||
private static $vars = [];
|
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::$loader = new TwigLoaderFilesystem;
|
||||||
self::$env = new TwigEnvironment(self::$loader, [
|
self::$env = new TwigEnvironment(self::$loader, [
|
||||||
'cache' => $cache ?? false,
|
'cache' => $cache ?? false,
|
||||||
|
|
|
@ -6,13 +6,13 @@ use Twig\TwigFilter;
|
||||||
use Twig\TwigFunction;
|
use Twig\TwigFunction;
|
||||||
use Twig\Environment as TwigEnvironment;
|
use Twig\Environment as TwigEnvironment;
|
||||||
use Misuzu\Parsers\Parser;
|
use Misuzu\Parsers\Parser;
|
||||||
use Misuzu\MszContext;
|
use Misuzu\MisuzuContext;
|
||||||
use Index\Environment;
|
use Index\Environment;
|
||||||
|
|
||||||
final class TwigMisuzu extends AbstractExtension {
|
final class TwigMisuzu extends AbstractExtension {
|
||||||
private MszContext $ctx;
|
private MisuzuContext $ctx;
|
||||||
|
|
||||||
public function __construct(MszContext $ctx) {
|
public function __construct(MisuzuContext $ctx) {
|
||||||
$this->ctx = $ctx;
|
$this->ctx = $ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
namespace Misuzu\Twitter;
|
namespace Misuzu\Twitter;
|
||||||
|
|
||||||
use Index\Routing\IRouter;
|
use Index\Routing\IRouter;
|
||||||
use Misuzu\MszContext;
|
use Misuzu\MisuzuContext;
|
||||||
use Misuzu\Config\IConfig;
|
use Misuzu\Config\IConfig;
|
||||||
use Misuzu\Twitter\TwitterAccessToken;
|
use Misuzu\Twitter\TwitterAccessToken;
|
||||||
use Misuzu\Twitter\TwitterAuthorisation;
|
use Misuzu\Twitter\TwitterAuthorisation;
|
||||||
|
@ -10,11 +10,11 @@ use Misuzu\Twitter\TwitterClient;
|
||||||
use Misuzu\Twitter\TwitterClientId;
|
use Misuzu\Twitter\TwitterClientId;
|
||||||
|
|
||||||
final class TwitterRoutes {
|
final class TwitterRoutes {
|
||||||
private MszContext $context;
|
private MisuzuContext $context;
|
||||||
private IConfig $config;
|
private IConfig $config;
|
||||||
private ?TwitterClientId $clientId = null;
|
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->context = $ctx;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue