Commit 932c2b76 authored by nahakyuu's avatar nahakyuu

add Discuz template renderer demo & application view injection demo

parent 39c4717e
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "44c30f2908958d905c354f1c41d950e1", "content-hash": "25043a8b80a8f9e0777afe2188b29d30",
"packages": [ "packages": [
{ {
"name": "alexkart/curl-builder", "name": "alexkart/curl-builder",
...@@ -1439,6 +1439,91 @@ ...@@ -1439,6 +1439,91 @@
], ],
"time": "2023-01-12T12:04:12+00:00" "time": "2023-01-12T12:04:12+00:00"
}, },
{
"name": "yiisoft/cache",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/cache.git",
"reference": "67ae4b40d3aefd193dfd9a3f458f3e145adb0d84"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/cache/zipball/67ae4b40d3aefd193dfd9a3f458f3e145adb0d84",
"reference": "67ae4b40d3aefd193dfd9a3f458f3e145adb0d84",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"php": "^8.0",
"psr/simple-cache": "^2.0|^3.0"
},
"provide": {
"psr/simple-cache-implementation": "2.0|3.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.2",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
"yiisoft/di": "^1.2"
},
"suggest": {
"yiisoft/cache-apcu": "Allows to store cache using APCu PECL extension",
"yiisoft/cache-db": "Allows storing cache to the database",
"yiisoft/cache-file": "Allows storing cache to the files",
"yiisoft/cache-memcached": "Allows to store cache using Memcached PECL extension",
"yiisoft/cache-redis": "Allows storing cache to the Redis",
"yiisoft/cache-wincache": "Allows to store cache using WinCache PECL extension"
},
"type": "library",
"extra": {
"config-plugin-options": {
"source-directory": "config"
},
"config-plugin": {
"di": "di.php"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\Cache\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii Caching Library",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"cache",
"psr-16",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/cache/issues?state=open",
"source": "https://github.com/yiisoft/cache",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-02-15T14:30:56+00:00"
},
{ {
"name": "yiisoft/config", "name": "yiisoft/config",
"version": "1.3.0", "version": "1.3.0",
...@@ -2383,6 +2468,68 @@ ...@@ -2383,6 +2468,68 @@
], ],
"time": "2021-10-26T21:43:25+00:00" "time": "2021-10-26T21:43:25+00:00"
}, },
{
"name": "yiisoft/html",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/html.git",
"reference": "384ffe3a428a766a270cbbf1b4f4704a18d2f8ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/html/zipball/384ffe3a428a766a270cbbf1b4f4704a18d2f8ba",
"reference": "384ffe3a428a766a270cbbf1b4f4704a18d2f8ba",
"shasum": ""
},
"require": {
"php": "^8.0",
"yiisoft/arrays": "^2.0|^3.0",
"yiisoft/json": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^3.3",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.1",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Yiisoft\\Html\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Handy library to generate HTML",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"html"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://forum.yiiframework.com/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/html/issues?state=open",
"source": "https://github.com/yiisoft/html",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-01-17T08:25:30+00:00"
},
{ {
"name": "yiisoft/http", "name": "yiisoft/http",
"version": "1.2.0", "version": "1.2.0",
...@@ -3247,6 +3394,88 @@ ...@@ -3247,6 +3394,88 @@
], ],
"time": "2023-01-16T22:17:52+00:00" "time": "2023-01-16T22:17:52+00:00"
}, },
{
"name": "yiisoft/view",
"version": "8.0.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/view.git",
"reference": "85d0e4b222c0b59f04315567ab59504c60e00e09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/view/zipball/85d0e4b222c0b59f04315567ab59504c60e00e09",
"reference": "85d0e4b222c0b59f04315567ab59504c60e00e09",
"shasum": ""
},
"require": {
"php": "^8.0",
"psr/event-dispatcher": "1.0.0",
"psr/event-dispatcher-implementation": "1.0.0",
"yiisoft/arrays": "^2.0|^3.0",
"yiisoft/cache": "^1.0|^2.0|^3.0",
"yiisoft/files": "^1.0|^2.0",
"yiisoft/html": "^2.5|^3.0",
"yiisoft/json": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.0",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.1",
"yiisoft/aliases": "^3.0",
"yiisoft/di": "^1.2",
"yiisoft/psr-dummy-provider": "^1.0",
"yiisoft/test-support": "^1.4|^3.0"
},
"type": "library",
"extra": {
"config-plugin-options": {
"source-directory": "config"
},
"config-plugin": {
"params": "params.php",
"di": "di.php",
"di-web": "di-web.php"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\View\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii View Rendering Library",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"view",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/view/issues",
"source": "https://github.com/yiisoft/view",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-02-16T13:21:29+00:00"
},
{ {
"name": "yiisoft/yii-event", "name": "yiisoft/yii-event",
"version": "2.0.0", "version": "2.0.0",
...@@ -3509,54 +3738,136 @@ ...@@ -3509,54 +3738,136 @@
"httpsoft/http-message": "^1.0", "httpsoft/http-message": "^1.0",
"maglnet/composer-require-checker": "^4.2", "maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.1", "rector/rector": "^0.15.1",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.2",
"yiisoft/middleware-dispatcher": "^5.0",
"yiisoft/test-support": "^3.0"
},
"type": "library",
"extra": {
"config-plugin-options": {
"build-merge-plan": false
}
},
"autoload": {
"psr-4": {
"Yiisoft\\Yii\\Runner\\Http\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "HTTP application runner",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"http",
"runner",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/yii-runner-http/issues?state=open",
"source": "https://github.com/yiisoft/yii-runner-http",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-02-19T10:56:58+00:00"
},
{
"name": "yiisoft/yii-view",
"version": "6.0.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii-view.git",
"reference": "e04324d8228e987c5e9f74513caf15fecfa63b44"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii-view/zipball/e04324d8228e987c5e9f74513caf15fecfa63b44",
"reference": "e04324d8228e987c5e9f74513caf15fecfa63b44",
"shasum": ""
},
"require": {
"php": "^8.0",
"yiisoft/aliases": "^2.0|^3.0",
"yiisoft/csrf": "^1.2|^2.0",
"yiisoft/data-response": "^1.0|^2.0",
"yiisoft/friendly-exception": "^1.0",
"yiisoft/html": "^2.5|^3.0",
"yiisoft/strings": "^2.0",
"yiisoft/view": "^6.0|^7.0|^8.0"
},
"require-dev": {
"httpsoft/http-message": "^1.0",
"maglnet/composer-require-checker": "^4.3",
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.0",
"roave/infection-static-analysis-plugin": "^1.25", "roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23", "spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.2", "vimeo/psalm": "^4.30|^5.6",
"yiisoft/middleware-dispatcher": "^5.0", "yiisoft/di": "^1.2",
"yiisoft/psr-dummy-provider": "^1.0",
"yiisoft/test-support": "^3.0" "yiisoft/test-support": "^3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"config-plugin-options": { "config-plugin-options": {
"build-merge-plan": false "source-directory": "config"
},
"config-plugin": {
"params": "params.php",
"di-web": "di-web.php"
} }
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Yiisoft\\Yii\\Runner\\Http\\": "src" "Yiisoft\\Yii\\View\\": "src"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
"description": "HTTP application runner", "description": "Yii View Extension",
"homepage": "https://www.yiiframework.com/", "homepage": "https://www.yiiframework.com/",
"keywords": [ "keywords": [
"http", "view",
"runner",
"yii" "yii"
], ],
"support": { "support": {
"chat": "https://t.me/yii3en", "chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/", "forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/yii-runner-http/issues?state=open", "issues": "https://github.com/yiisoft/yii-view/issues?state=open",
"source": "https://github.com/yiisoft/yii-runner-http", "source": "https://github.com/yiisoft/yii-view",
"wiki": "https://www.yiiframework.com/wiki/" "wiki": "https://www.yiiframework.com/wiki/"
}, },
"funding": [ "funding": [
{ {
"url": "https://github.com/sponsors/yiisoft", "url": "https://github.com/yiisoft",
"type": "github" "type": "github"
}, },
{ {
"url": "https://opencollective.com/yiisoft", "url": "https://opencollective.com/yiisoft",
"type": "opencollective" "type": "open_collective"
} }
], ],
"time": "2023-02-19T10:56:58+00:00" "time": "2023-02-16T14:05:24+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
...@@ -5198,153 +5509,6 @@ ...@@ -5198,153 +5509,6 @@
], ],
"time": "2023-02-16T09:57:23+00:00" "time": "2023-02-16T09:57:23+00:00"
}, },
{
"name": "yiisoft/cache",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/cache.git",
"reference": "67ae4b40d3aefd193dfd9a3f458f3e145adb0d84"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/cache/zipball/67ae4b40d3aefd193dfd9a3f458f3e145adb0d84",
"reference": "67ae4b40d3aefd193dfd9a3f458f3e145adb0d84",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"php": "^8.0",
"psr/simple-cache": "^2.0|^3.0"
},
"provide": {
"psr/simple-cache-implementation": "2.0|3.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.2",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
"yiisoft/di": "^1.2"
},
"suggest": {
"yiisoft/cache-apcu": "Allows to store cache using APCu PECL extension",
"yiisoft/cache-db": "Allows storing cache to the database",
"yiisoft/cache-file": "Allows storing cache to the files",
"yiisoft/cache-memcached": "Allows to store cache using Memcached PECL extension",
"yiisoft/cache-redis": "Allows storing cache to the Redis",
"yiisoft/cache-wincache": "Allows to store cache using WinCache PECL extension"
},
"type": "library",
"extra": {
"config-plugin-options": {
"source-directory": "config"
},
"config-plugin": {
"di": "di.php"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\Cache\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii Caching Library",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"cache",
"psr-16",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/cache/issues?state=open",
"source": "https://github.com/yiisoft/cache",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-02-15T14:30:56+00:00"
},
{
"name": "yiisoft/html",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/html.git",
"reference": "384ffe3a428a766a270cbbf1b4f4704a18d2f8ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/html/zipball/384ffe3a428a766a270cbbf1b4f4704a18d2f8ba",
"reference": "384ffe3a428a766a270cbbf1b4f4704a18d2f8ba",
"shasum": ""
},
"require": {
"php": "^8.0",
"yiisoft/arrays": "^2.0|^3.0",
"yiisoft/json": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^3.3",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.1",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Yiisoft\\Html\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Handy library to generate HTML",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"html"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://forum.yiiframework.com/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/html/issues?state=open",
"source": "https://github.com/yiisoft/html",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-01-17T08:25:30+00:00"
},
{ {
"name": "yiisoft/i18n", "name": "yiisoft/i18n",
"version": "1.1.0", "version": "1.1.0",
...@@ -5850,88 +6014,6 @@ ...@@ -5850,88 +6014,6 @@
], ],
"time": "2023-02-22T11:52:18+00:00" "time": "2023-02-22T11:52:18+00:00"
}, },
{
"name": "yiisoft/view",
"version": "8.0.0",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/view.git",
"reference": "85d0e4b222c0b59f04315567ab59504c60e00e09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/view/zipball/85d0e4b222c0b59f04315567ab59504c60e00e09",
"reference": "85d0e4b222c0b59f04315567ab59504c60e00e09",
"shasum": ""
},
"require": {
"php": "^8.0",
"psr/event-dispatcher": "1.0.0",
"psr/event-dispatcher-implementation": "1.0.0",
"yiisoft/arrays": "^2.0|^3.0",
"yiisoft/cache": "^1.0|^2.0|^3.0",
"yiisoft/files": "^1.0|^2.0",
"yiisoft/html": "^2.5|^3.0",
"yiisoft/json": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.0",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.1",
"yiisoft/aliases": "^3.0",
"yiisoft/di": "^1.2",
"yiisoft/psr-dummy-provider": "^1.0",
"yiisoft/test-support": "^1.4|^3.0"
},
"type": "library",
"extra": {
"config-plugin-options": {
"source-directory": "config"
},
"config-plugin": {
"params": "params.php",
"di": "di.php",
"di-web": "di-web.php"
}
},
"autoload": {
"psr-4": {
"Yiisoft\\View\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Yii View Rendering Library",
"homepage": "https://www.yiiframework.com/",
"keywords": [
"view",
"yii"
],
"support": {
"chat": "https://t.me/yii3en",
"forum": "https://www.yiiframework.com/forum/",
"irc": "irc://irc.freenode.net/yii",
"issues": "https://github.com/yiisoft/view/issues",
"source": "https://github.com/yiisoft/view",
"wiki": "https://www.yiiframework.com/wiki/"
},
"funding": [
{
"url": "https://github.com/sponsors/yiisoft",
"type": "github"
},
{
"url": "https://opencollective.com/yiisoft",
"type": "opencollective"
}
],
"time": "2023-02-16T13:21:29+00:00"
},
{ {
"name": "yiisoft/yii-console", "name": "yiisoft/yii-console",
"version": "2.0.1", "version": "2.0.1",
......
...@@ -7,6 +7,7 @@ use Yiisoft\Definitions\Reference; ...@@ -7,6 +7,7 @@ use Yiisoft\Definitions\Reference;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher; use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Yii\Http\Handler\NotFoundHandler; use Yiisoft\Yii\Http\Handler\NotFoundHandler;
use Yiisoft\ErrorHandler\Middleware\ErrorCatcher;
use Yiisoft\Session\SessionMiddleware; use Yiisoft\Session\SessionMiddleware;
use Yiisoft\Csrf\CsrfMiddleware; use Yiisoft\Csrf\CsrfMiddleware;
use Yiisoft\Router\Middleware\Router; use Yiisoft\Router\Middleware\Router;
...@@ -18,6 +19,7 @@ return [ ...@@ -18,6 +19,7 @@ return [
'class' => MiddlewareDispatcher::class, 'class' => MiddlewareDispatcher::class,
'withMiddlewares()' => [ 'withMiddlewares()' => [
[ [
ErrorCatcher::class,
SessionMiddleware::class, SessionMiddleware::class,
CsrfMiddleware::class, CsrfMiddleware::class,
Router::class, Router::class,
......
<?php <?php
declare(strict_types=1);
use Yiisoft\Router\Group; use Yiisoft\Router\Group;
use Yiisoft\Router\RouteCollection; use Yiisoft\Router\RouteCollection;
use Yiisoft\Router\RouteCollectionInterface; use Yiisoft\Router\RouteCollectionInterface;
......
<?php
declare(strict_types=1);
use Yiisoft\Definitions\DynamicReference;
use Yiisoft\Definitions\Reference;
use Yiisoft\Aliases\Aliases;
use Yiisoft\View\WebView;
use NMForce\PHPDTS\View\DiscuzTemplateRenderer;
/** @var array $params */
return [
WebView::class => [
'__construct()' => [
'basePath' => DynamicReference::to(
static fn (Aliases $aliases) => $aliases->get($params['yiisoft/view']['basePath'])
),
],
'withDefaultExtension()' => [
'htm',
],
'withRenderers()' => [['htm' => Reference::to(DiscuzTemplateRenderer::class)]],
'setParameters()' => [
$params['yiisoft/view']['parameters'],
],
'reset' => function () use ($params) {
/** @var WebView $this */
$this->clear();
$this->setParameters($params['yiisoft/view']['parameters']);
},
],
];
...@@ -4,6 +4,8 @@ declare(strict_types=1); ...@@ -4,6 +4,8 @@ declare(strict_types=1);
use Yiisoft\Definitions\Reference; use Yiisoft\Definitions\Reference;
use NMForce\PHPDTS\ViewInjection\ApplicationViewInjection;
return [ return [
'yiisoft/aliases' => [ 'yiisoft/aliases' => [
'aliases' => [ 'aliases' => [
...@@ -13,4 +15,10 @@ return [ ...@@ -13,4 +15,10 @@ return [
'@views' => '@root/templates/default', '@views' => '@root/templates/default',
], ],
], ],
'yiisoft/yii-view' => [
'layout' => null,
'injections' => [
Reference::to(ApplicationViewInjection::class),
],
],
]; ];
<?php
declare(strict_types=1);
namespace NMForce\PHPDTS\View;
use Throwable;
use function extract;
use function func_get_arg;
use function ob_end_clean;
use function ob_get_clean;
use function ob_get_level;
use function ob_implicit_flush;
use function ob_start;
use Yiisoft\Aliases\Aliases;
use Yiisoft\View\ViewInterface;
use Yiisoft\View\TemplateRendererInterface;
final class DiscuzTemplateRenderer implements TemplateRendererInterface
{
public function __construct(private Aliases $aliases)
{
}
public function render(ViewInterface $view, string $template, array $parameters): string
{
defined('IN_GAME') or define('IN_GAME', TRUE);
defined('GAME_ROOT') or define('GAME_ROOT', "{$this->aliases->get('@root')}/");
defined('TPLDIR') or define('TPLDIR', './templates/default');
defined('TEMPLATEID') or define('TEMPLATEID', 1);
defined('CURSCRIPT') or define('CURSCRIPT', 'index');
$tplrefresh = 1;
require_once GAME_ROOT . './include/global.func.php';
$renderer = function (): void {
extract(func_get_arg(1), EXTR_OVERWRITE);
require template(basename(func_get_arg(0), '.htm'));
};
$obInitialLevel = ob_get_level();
ob_start();
ob_implicit_flush(false);
try {
$renderer->bindTo($view)($template, $parameters);
return ob_get_clean();
} catch (Throwable $e) {
while (ob_get_level() > $obInitialLevel) {
ob_end_clean();
}
throw $e;
}
}
}
<?php
declare(strict_types=1);
namespace NMForce\PHPDTS\ViewInjection;
use Yiisoft\Yii\View\CommonParametersInjectionInterface;
use Yiisoft\Aliases\Aliases;
final class ApplicationViewInjection implements CommonParametersInjectionInterface
{
public function __construct(
private Aliases $aliases
) {
}
public function getCommonParameters(): array
{
defined('IN_GAME') or define('IN_GAME', TRUE);
defined('GAME_ROOT') or define('GAME_ROOT', "{$this->aliases->get('@root')}/");
require GAME_ROOT . './include/global.func.php';
$vars = get_defined_vars();
require GAME_ROOT . './config.inc.php';
require GAME_ROOT . './gamedata/system.php';
require GAME_ROOT . './gamedata/gameinfo.php';
require GAME_ROOT . './gamedata/combatinfo.php';
$adminmsg = file_get_contents(GAME_ROOT . './gamedata/adminmsg.htm');
$systemmsg = file_get_contents(GAME_ROOT . './gamedata/systemmsg.htm');
$cuser = '苹果';
$error = '';
require config('resources');
require config('gamecfg');
$vars = array_diff(get_defined_vars(), $vars);
return $vars;
// return [
// // 'charset' => $this->charset,
// // 'allowcsscache' => 1,
// // 'homepage' => 'http://www.amarilloviridian.com/',
// // 'gameversion'=> 'GE942 ~TORONTO',
// ];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment