mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Make public for method Hyperf\ModelCache\Manager::formatModels()
. (#4603)
This commit is contained in:
parent
7d8dd34366
commit
9fa13f8c88
@ -1,4 +1,6 @@
|
||||
# v2.2.28 - TBD
|
||||
# v2.2.29 - TBD
|
||||
|
||||
# v2.2.28 - 2022-03-14
|
||||
|
||||
## Fixed
|
||||
|
||||
@ -9,6 +11,10 @@
|
||||
|
||||
- [#4580](https://github.com/hyperf/hyperf/pull/4580) Added method `Hyperf\Utils\Coroutine\Concurrent::getChannel()`.
|
||||
|
||||
## Optimized
|
||||
|
||||
- [#4602](https://github.com/hyperf/hyperf/pull/4602) Make public for method `Hyperf\ModelCache\Manager::formatModels()`.
|
||||
|
||||
# v2.2.27 - 2022-03-07
|
||||
|
||||
## Optimized
|
||||
|
@ -1,5 +1,20 @@
|
||||
# 版本更新记录
|
||||
|
||||
# v2.2.28 - 2022-03-14
|
||||
|
||||
## 修复
|
||||
|
||||
- [#4588](https://github.com/hyperf/hyperf/pull/4588) 修复 `database` 组件不支持 `bit` 类型的问题。
|
||||
- [#4589](https://github.com/hyperf/hyperf/pull/4589) 修复使用 `Nacos` 时,无法正确的注册临时实例的问题。
|
||||
|
||||
## 新增
|
||||
|
||||
- [#4580](https://github.com/hyperf/hyperf/pull/4580) 新增方法 `Hyperf\Utils\Coroutine\Concurrent::getChannel()`。
|
||||
|
||||
## 优化
|
||||
|
||||
- [#4602](https://github.com/hyperf/hyperf/pull/4602) 将方法 `Hyperf\ModelCache\Manager::formatModels()` 更改为公共方法。
|
||||
|
||||
# v2.2.27 - 2022-03-07
|
||||
|
||||
## 优化
|
||||
|
@ -1,5 +1,20 @@
|
||||
# 版本更新記錄
|
||||
|
||||
# v2.2.28 - 2022-03-14
|
||||
|
||||
## 修復
|
||||
|
||||
- [#4588](https://github.com/hyperf/hyperf/pull/4588) 修復 `database` 組件不支持 `bit` 類型的問題。
|
||||
- [#4589](https://github.com/hyperf/hyperf/pull/4589) 修復使用 `Nacos` 時,無法正確的註冊臨時實例的問題。
|
||||
|
||||
## 新增
|
||||
|
||||
- [#4580](https://github.com/hyperf/hyperf/pull/4580) 新增方法 `Hyperf\Utils\Coroutine\Concurrent::getChannel()`。
|
||||
|
||||
## 優化
|
||||
|
||||
- [#4602](https://github.com/hyperf/hyperf/pull/4602) 將方法 `Hyperf\ModelCache\Manager::formatModels()` 更改為公共方法。
|
||||
|
||||
# v2.2.27 - 2022-03-07
|
||||
|
||||
## 優化
|
||||
|
@ -181,3 +181,41 @@ use Hyperf\Utils\Coordinator\Constants;
|
||||
|
||||
CoordinatorManager::until(Constants::WORKER_EXIT)->resume();
|
||||
```
|
||||
|
||||
|
||||
## ORM 不支持 bit 類型
|
||||
|
||||
若想要使 `ORM` 支持 `bit` 類型,只需要增加以下監聽器代碼即可。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Listener;
|
||||
|
||||
use Hyperf\Database\Connection;
|
||||
use Hyperf\Database\MySqlBitConnection;
|
||||
use Hyperf\Event\Annotation\Listener;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\BootApplication;
|
||||
|
||||
#[Listener]
|
||||
class SupportMySQLBitListener implements ListenerInterface
|
||||
{
|
||||
public function listen(): array
|
||||
{
|
||||
return [
|
||||
BootApplication::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function process(object $event)
|
||||
{
|
||||
Connection::resolverFor('mysql', static function ($connection, $database, $prefix, $config) {
|
||||
return new MySqlBitConnection($connection, $database, $prefix, $config);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -67,6 +67,7 @@ return [
|
||||
'group_name' => 'api',
|
||||
'namespace_id' => 'namespace_id',
|
||||
'heartbeat' => 5,
|
||||
'ephemeral' => false, // 是否註冊臨時實例
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -1,5 +1,20 @@
|
||||
# 版本更新記錄
|
||||
|
||||
# v2.2.28 - 2022-03-14
|
||||
|
||||
## 修復
|
||||
|
||||
- [#4588](https://github.com/hyperf/hyperf/pull/4588) 修復 `database` 元件不支援 `bit` 型別的問題。
|
||||
- [#4589](https://github.com/hyperf/hyperf/pull/4589) 修復使用 `Nacos` 時,無法正確的註冊臨時例項的問題。
|
||||
|
||||
## 新增
|
||||
|
||||
- [#4580](https://github.com/hyperf/hyperf/pull/4580) 新增方法 `Hyperf\Utils\Coroutine\Concurrent::getChannel()`。
|
||||
|
||||
## 優化
|
||||
|
||||
- [#4602](https://github.com/hyperf/hyperf/pull/4602) 將方法 `Hyperf\ModelCache\Manager::formatModels()` 更改為公共方法。
|
||||
|
||||
# v2.2.27 - 2022-03-07
|
||||
|
||||
## 優化
|
||||
|
@ -181,3 +181,41 @@ use Hyperf\Utils\Coordinator\Constants;
|
||||
|
||||
CoordinatorManager::until(Constants::WORKER_EXIT)->resume();
|
||||
```
|
||||
|
||||
|
||||
## ORM 不支援 bit 型別
|
||||
|
||||
若想要使 `ORM` 支援 `bit` 型別,只需要增加以下監聽器程式碼即可。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Listener;
|
||||
|
||||
use Hyperf\Database\Connection;
|
||||
use Hyperf\Database\MySqlBitConnection;
|
||||
use Hyperf\Event\Annotation\Listener;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\BootApplication;
|
||||
|
||||
#[Listener]
|
||||
class SupportMySQLBitListener implements ListenerInterface
|
||||
{
|
||||
public function listen(): array
|
||||
{
|
||||
return [
|
||||
BootApplication::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function process(object $event)
|
||||
{
|
||||
Connection::resolverFor('mysql', static function ($connection, $database, $prefix, $config) {
|
||||
return new MySqlBitConnection($connection, $database, $prefix, $config);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -67,6 +67,7 @@ return [
|
||||
'group_name' => 'api',
|
||||
'namespace_id' => 'namespace_id',
|
||||
'heartbeat' => 5,
|
||||
'ephemeral' => false, // 是否註冊臨時例項
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -244,12 +244,12 @@ class Manager
|
||||
);
|
||||
}
|
||||
|
||||
protected function formatModel(Model $model): array
|
||||
public function formatModel(Model $model): array
|
||||
{
|
||||
return $model->getAttributes();
|
||||
}
|
||||
|
||||
protected function formatModels($models): array
|
||||
public function formatModels($models): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($models as $model) {
|
||||
|
@ -16,11 +16,6 @@ use Hyperf\ModelCache\Handler\HandlerInterface;
|
||||
|
||||
class ManagerStub extends \Hyperf\ModelCache\Manager
|
||||
{
|
||||
public function formatModel(Model $model): array
|
||||
{
|
||||
return parent::formatModel($model);
|
||||
}
|
||||
|
||||
public function getCacheTTL(Model $instance, HandlerInterface $handler)
|
||||
{
|
||||
return parent::getCacheTTL($instance, $handler);
|
||||
|
Loading…
Reference in New Issue
Block a user