Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Setup
Declaration
Schema
Declaration
ValidationRules
PrimaryKeyCanBeCreated.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationRules
;
7
8
use
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationInterface
;
9
use
Magento\Framework\Setup\Declaration\Schema\Dto\Columns\ColumnNullableAwareInterface
;
10
use
Magento\Framework\Setup\Declaration\Schema\Dto\Schema
;
11
17
class
PrimaryKeyCanBeCreated
implements
ValidationInterface
18
{
22
const
ERROR_TYPE
=
'primary_key_cant_be_applied'
;
23
27
const
ERROR_MESSAGE
=
'Primary key can`t be applied on table "%s". '
;
28
32
public
function
validate
(
Schema
$schema
)
33
{
34
$errors
= [];
35
foreach
(
$schema
->getTables() as
$table
) {
36
$primaryConstraint =
$table
->getPrimaryConstraint();
37
38
if
(!$primaryConstraint) {
39
continue
;
40
}
41
42
foreach
($primaryConstraint->getColumns() as $column) {
43
if
($column instanceof
ColumnNullableAwareInterface
&&
44
$column->
isNullable
()
45
) {
46
$errors
[] = [
47
'column'
=> $column->getName(),
48
'message'
=> sprintf(self::ERROR_MESSAGE,
$table
->getName()) .
49
"All columns should be not nullable"
50
];
51
}
52
}
53
}
54
55
return
$errors
;
56
}
57
}
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationInterface
Definition:
ValidationInterface.php:13
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationRules\PrimaryKeyCanBeCreated
Definition:
PrimaryKeyCanBeCreated.php:17
Magento\Framework\Setup\Declaration\Schema\Dto\Columns\ColumnNullableAwareInterface
Definition:
ColumnNullableAwareInterface.php:12
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationRules
Definition:
AutoIncrementColumnValidation.php:6
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationRules\PrimaryKeyCanBeCreated\ERROR_MESSAGE
const ERROR_MESSAGE
Definition:
PrimaryKeyCanBeCreated.php:27
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationRules\PrimaryKeyCanBeCreated\validate
validate(Schema $schema)
Definition:
PrimaryKeyCanBeCreated.php:32
Magento\Framework\Setup\Declaration\Schema\Dto\Schema
Definition:
Schema.php:15
$schema
$schema
Definition:
configured_price.phtml:9
Magento\Framework\Setup\Declaration\Schema\Declaration\ValidationRules\PrimaryKeyCanBeCreated\ERROR_TYPE
const ERROR_TYPE
Definition:
PrimaryKeyCanBeCreated.php:22
$table
$table
Definition:
trigger.php:14
$errors
$errors
Definition:
overview.phtml:9
Magento\Framework\Setup\Declaration\Schema\Dto\Columns\ColumnNullableAwareInterface\isNullable
isNullable()