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