new files
This commit is contained in:
23
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ClearInstances.php
vendored
Executable file
23
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ClearInstances.php
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace think\swoole\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\swoole\contract\ResetterInterface;
|
||||
use think\swoole\Sandbox;
|
||||
|
||||
class ClearInstances implements ResetterInterface
|
||||
{
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
$instances = ['log', 'session', 'view', 'response', 'cookie'];
|
||||
|
||||
$instances = array_merge($instances, $sandbox->getConfig()->get('swoole.instances', []));
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
$app->delete($instance);
|
||||
}
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
18
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetConfig.php
vendored
Executable file
18
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetConfig.php
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace think\swoole\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\swoole\contract\ResetterInterface;
|
||||
use think\swoole\Sandbox;
|
||||
|
||||
class ResetConfig implements ResetterInterface
|
||||
{
|
||||
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
$app->instance('config', clone $sandbox->getConfig());
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
26
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetEvent.php
vendored
Executable file
26
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetEvent.php
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace think\swoole\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\swoole\concerns\ModifyProperty;
|
||||
use think\swoole\contract\ResetterInterface;
|
||||
use think\swoole\Sandbox;
|
||||
|
||||
/**
|
||||
* Class ResetEvent
|
||||
* @package think\swoole\resetters
|
||||
*/
|
||||
class ResetEvent implements ResetterInterface
|
||||
{
|
||||
use ModifyProperty;
|
||||
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
$event = clone $sandbox->getEvent();
|
||||
$this->modifyProperty($event, $app);
|
||||
$app->instance('event', $event);
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
21
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetModel.php
vendored
Normal file
21
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetModel.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace think\swoole\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\Model;
|
||||
use think\swoole\contract\ResetterInterface;
|
||||
use think\swoole\Sandbox;
|
||||
|
||||
class ResetModel implements ResetterInterface
|
||||
{
|
||||
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
if (class_exists(Model::class)) {
|
||||
Model::setInvoker(function (...$args) use ($sandbox) {
|
||||
return $sandbox->getApplication()->invoke(...$args);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
30
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetPaginator.php
vendored
Normal file
30
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetPaginator.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace think\swoole\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\Paginator;
|
||||
use think\swoole\contract\ResetterInterface;
|
||||
use think\swoole\Sandbox;
|
||||
|
||||
class ResetPaginator implements ResetterInterface
|
||||
{
|
||||
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
Paginator::currentPathResolver(function () use ($sandbox) {
|
||||
return $sandbox->getApplication()->request->baseUrl();
|
||||
});
|
||||
|
||||
Paginator::currentPageResolver(function ($varPage = 'page') use ($sandbox) {
|
||||
|
||||
$page = $sandbox->getApplication()->request->param($varPage);
|
||||
|
||||
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
|
||||
return (int) $page;
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
37
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetService.php
vendored
Executable file
37
pro_v3.5.1/vendor/topthink/think-swoole/src/resetters/ResetService.php
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace think\swoole\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\swoole\concerns\ModifyProperty;
|
||||
use think\swoole\contract\ResetterInterface;
|
||||
use think\swoole\Sandbox;
|
||||
|
||||
/**
|
||||
* Class ResetService
|
||||
* @package think\swoole\resetters
|
||||
*/
|
||||
class ResetService implements ResetterInterface
|
||||
{
|
||||
use ModifyProperty;
|
||||
|
||||
/**
|
||||
* "handle" function for resetting app.
|
||||
*
|
||||
* @param App $app
|
||||
* @param Sandbox $sandbox
|
||||
*/
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
foreach ($sandbox->getServices() as $service) {
|
||||
$this->modifyProperty($service, $app);
|
||||
if (method_exists($service, 'register')) {
|
||||
$service->register();
|
||||
}
|
||||
if (method_exists($service, 'boot')) {
|
||||
$app->invoke([$service, 'boot']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user