|
@@ -5,8 +5,6 @@ declare(strict_types=1);
|
|
namespace ForkBB\Models\Censorship;
|
|
namespace ForkBB\Models\Censorship;
|
|
|
|
|
|
use ForkBB\Models\Method;
|
|
use ForkBB\Models\Method;
|
|
-use ForkBB\Models\Censorship\Model as Censorship;
|
|
|
|
-use RuntimeException;
|
|
|
|
|
|
|
|
class Refresh extends Method
|
|
class Refresh extends Method
|
|
{
|
|
{
|
|
@@ -14,7 +12,7 @@ class Refresh extends Method
|
|
* Заполняет модель данными из БД
|
|
* Заполняет модель данными из БД
|
|
* Создает кеш
|
|
* Создает кеш
|
|
*/
|
|
*/
|
|
- public function refresh(): Censorship
|
|
|
|
|
|
+ public function refresh(): array
|
|
{
|
|
{
|
|
$query = 'SELECT ce.id, ce.search_for, ce.replace_with
|
|
$query = 'SELECT ce.id, ce.search_for, ce.replace_with
|
|
FROM ::censoring AS ce';
|
|
FROM ::censoring AS ce';
|
|
@@ -28,17 +26,10 @@ class Refresh extends Method
|
|
. ')(?![\p{L}\p{N}])%iu';
|
|
. ')(?![\p{L}\p{N}])%iu';
|
|
$replace[$row['id']] = $row['replace_with'];
|
|
$replace[$row['id']] = $row['replace_with'];
|
|
}
|
|
}
|
|
- $this->model->searchList = $search;
|
|
|
|
- $this->model->replaceList = $replace;
|
|
|
|
- $result = $this->c->Cache->set('censorship', [
|
|
|
|
|
|
+
|
|
|
|
+ return [
|
|
'searchList' => $search,
|
|
'searchList' => $search,
|
|
'replaceList' => $replace,
|
|
'replaceList' => $replace,
|
|
- ]);
|
|
|
|
-
|
|
|
|
- if (true !== $result) {
|
|
|
|
- throw new RuntimeException('Unable to write value to cache - censorship');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $this->model;
|
|
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
}
|
|
}
|