bluzphp /
skeleton
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * @copyright Bluz PHP Team |
||||||
| 4 | * @link https://github.com/bluzphp/skeleton |
||||||
| 5 | */ |
||||||
| 6 | |||||||
| 7 | declare(strict_types=1); |
||||||
| 8 | |||||||
| 9 | namespace Application\Pages; |
||||||
| 10 | |||||||
| 11 | use Application\Users; |
||||||
| 12 | use Bluz\Proxy\Auth; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 13 | use Bluz\Validator\Traits\Validator; |
||||||
|
0 ignored issues
–
show
The type
Bluz\Validator\Traits\Validator was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * Row of Pages |
||||||
| 17 | * |
||||||
| 18 | * @package Application\Pages |
||||||
| 19 | * |
||||||
| 20 | * @property integer $id |
||||||
| 21 | * @property string $title |
||||||
| 22 | * @property string $alias |
||||||
| 23 | * @property string $content |
||||||
| 24 | * @property string $keywords |
||||||
| 25 | * @property string $description |
||||||
| 26 | * @property string $created |
||||||
| 27 | * @property string $updated |
||||||
| 28 | * @property integer $userId |
||||||
| 29 | * |
||||||
| 30 | * @OA\Schema(schema="page", title="page", required={"id", "title", "alias", "content"}) |
||||||
| 31 | * @OA\Property(property="id", type="integer", description="Page UID", |
||||||
| 32 | * example=42) |
||||||
| 33 | * @OA\Property(property="title", type="string", description="Page title", |
||||||
| 34 | * example="The Ultimate Question of Life") |
||||||
| 35 | * @OA\Property(property="alias", type="string", description="SEO URL", |
||||||
| 36 | * example="the-ultimate-question") |
||||||
| 37 | * @OA\Property(property="content", type="string", description="Text", |
||||||
| 38 | * example="The Ultimate Question of Life, the Universe, and Everything") |
||||||
| 39 | * @OA\Property(property="keywords", type="string", description="Meta keywords", |
||||||
| 40 | * example="42, life, universe, everything") |
||||||
| 41 | * @OA\Property(property="description", type="string", description="Meta description", |
||||||
| 42 | * example="The Hitchhiker's Guide to the Galaxy") |
||||||
| 43 | * @OA\Property(property="created", type="string", format="date-time", description="Created date", |
||||||
| 44 | * example="2017-03-17 19:06:28") |
||||||
| 45 | * @OA\Property(property="updated", type="string", format="date-time", description="Last updated date", |
||||||
| 46 | * example="2017-03-17 19:06:28") |
||||||
| 47 | * @OA\Property(property="userId", type="integer", description="Author ID", |
||||||
| 48 | * example=2) |
||||||
| 49 | */ |
||||||
| 50 | class Row extends \Bluz\Db\Row |
||||||
|
0 ignored issues
–
show
The type
Bluz\Db\Row was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 51 | { |
||||||
| 52 | use Validator; |
||||||
| 53 | |||||||
| 54 | /** |
||||||
| 55 | * {@inheritdoc} |
||||||
| 56 | * |
||||||
| 57 | * @throws \Bluz\Validator\Exception\ComponentException |
||||||
| 58 | */ |
||||||
| 59 | public function beforeSave(): void |
||||||
| 60 | { |
||||||
| 61 | // title validator |
||||||
| 62 | $this->addValidator('title') |
||||||
| 63 | ->required(); |
||||||
| 64 | |||||||
| 65 | // alias validator |
||||||
| 66 | $this->addValidator('alias') |
||||||
| 67 | ->required() |
||||||
| 68 | ->slug() |
||||||
| 69 | ->callback( |
||||||
| 70 | function ($input) { |
||||||
| 71 | return !(($row = $this->getTable()::findRowWhere(['alias' => $input])) && $row->id !== $this->id); |
||||||
| 72 | }, |
||||||
| 73 | __('This alias already exists') |
||||||
|
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 74 | ); |
||||||
| 75 | |||||||
| 76 | // content validator |
||||||
| 77 | $this->addValidator('content') |
||||||
| 78 | ->callback( |
||||||
| 79 | function ($input) { |
||||||
| 80 | return !(empty($input) or trim(strip_tags($input, '<img>')) === ''); |
||||||
| 81 | }, |
||||||
| 82 | __('Content can\'t be empty') |
||||||
| 83 | ); |
||||||
| 84 | |||||||
| 85 | $this->addValidator('keywords') |
||||||
| 86 | ->alphaNumeric(', '); |
||||||
| 87 | |||||||
| 88 | $this->addValidator('description') |
||||||
| 89 | ->alphaNumeric(', '); |
||||||
| 90 | } |
||||||
| 91 | |||||||
| 92 | /** |
||||||
| 93 | * {@inheritdoc} |
||||||
| 94 | * |
||||||
| 95 | * @return void |
||||||
| 96 | */ |
||||||
| 97 | public function beforeInsert(): void |
||||||
| 98 | { |
||||||
| 99 | $this->created = gmdate('Y-m-d H:i:s'); |
||||||
| 100 | |||||||
| 101 | /* @var \Application\Users\Row $user */ |
||||||
| 102 | if ($user = Auth::getIdentity()) { |
||||||
| 103 | $this->userId = $user->getId(); |
||||||
| 104 | } else { |
||||||
| 105 | $this->userId = Users\Table::SYSTEM_USER; |
||||||
| 106 | } |
||||||
| 107 | } |
||||||
| 108 | |||||||
| 109 | /** |
||||||
| 110 | * {@inheritdoc} |
||||||
| 111 | * |
||||||
| 112 | * @return void |
||||||
| 113 | */ |
||||||
| 114 | public function beforeUpdate(): void |
||||||
| 115 | { |
||||||
| 116 | $this->updated = gmdate('Y-m-d H:i:s'); |
||||||
| 117 | } |
||||||
| 118 | } |
||||||
| 119 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths