Update Models\BBCodeList

This commit is contained in:
Visman 2021-12-02 22:04:15 +07:00
parent 5f1da4f110
commit 9c4722ff22
6 changed files with 23 additions and 11 deletions

View file

@ -11,11 +11,17 @@ declare(strict_types=1);
namespace ForkBB\Models\BBCodeList;
use ForkBB\Core\Container;
use ForkBB\Models\Model as ParentModel;
use ForkBB\Models\Model;
use RuntimeException;
class Model extends ParentModel
class BBCodeList extends Model
{
/**
* Ключ модели для контейнера
* @var string
*/
protected $cKey = 'BBCodeList';
public function __construct(string $file, Container $container)
{
parent::__construct($container);
@ -27,7 +33,7 @@ class Model extends ParentModel
/**
* Загружает массив сгенерированных bbcode
*/
public function init(): Model
public function init(): BBCodeList
{
if (! \is_file($this->fileCache)) {
$this->generate();
@ -41,7 +47,7 @@ class Model extends ParentModel
/**
* Очищает кеш сгенерированных bbcode
*/
public function reset(): Model
public function reset(): BBCodeList
{
if (\is_file($this->fileCache)) {
if (\unlink($this->fileCache)) {
@ -57,7 +63,7 @@ class Model extends ParentModel
/**
* Очищает opcache/apc от закэшированного файла
*/
public function invalidate(): Model
public function invalidate(): BBCodeList
{
if (\function_exists('\\opcache_invalidate')) {
\opcache_invalidate($this->fileCache, true);

View file

@ -11,7 +11,7 @@ declare(strict_types=1);
namespace ForkBB\Models\BBCodeList;
use ForkBB\Models\Method;
use ForkBB\Models\BBCodeList\Model as BBCodeList;
use ForkBB\Models\BBCodeList\BBCodeList;
use PDO;
class Delete extends Method

View file

@ -11,7 +11,7 @@ declare(strict_types=1);
namespace ForkBB\Models\BBCodeList;
use ForkBB\Models\Method;
use ForkBB\Models\BBCodeList\Model as BBCodeList;
use ForkBB\Models\BBCodeList\BBCodeList;
use RuntimeException;
class Generate extends Method

View file

@ -11,7 +11,7 @@ declare(strict_types=1);
namespace ForkBB\Models\BBCodeList;
use ForkBB\Models\Method;
use ForkBB\Models\BBCodeList\Model as BBCodeList;
use ForkBB\Models\BBCodeList\BBCodeList;
use PDO;
class Load extends Method

View file

@ -11,17 +11,23 @@ declare(strict_types=1);
namespace ForkBB\Models\BBCodeList;
use ForkBB\Core\Container;
use ForkBB\Models\Model as ParentModel;
use ForkBB\Models\Model;
use RuntimeException;
use Throwable;
class Structure extends ParentModel
class Structure extends Model
{
const TAG_PATTERN = '%^(?:ROOT|[a-z\*][a-z\d-]{0,10})$%D';
const ATTR_PATTERN = '%^[a-z-]{2,15}$%D';
const JSON_OPTIONS = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR;
/**
* Ключ модели для контейнера
* @var string
*/
protected $cKey = 'BBStructure';
public function __construct(Container $container)
{
parent::__construct($container);

View file

@ -11,7 +11,7 @@ declare(strict_types=1);
namespace ForkBB\Models\BBCodeList;
use ForkBB\Models\Method;
use ForkBB\Models\BBCodeList\Model as BBCodeList;
use ForkBB\Models\BBCodeList\BBCodeList;
use ForkBB\Models\BBCodeList\Structure;
use RuntimeException;