ColumnSchema
in package
Limits of the real database column behind an entity property.
ColumnLimits reads #[ORM\Column], but the mapping and the schema differ in places: an
unsigned column mapped as signed, a tinyint mapped as smallint, a TEXT mapped as text
without a length (LONGTEXT for Doctrine). A gate measured by the mapping then let through a value the
database refuses ("Out of range", "Data too long"). The mapping still tells which column the property
writes to (table and column name); the limits come from the column itself (SHOW COLUMNS), so the
form gate and the database cannot disagree (ColumnGate::guard()).
The columns of a table are read once per request; a missing table, column or a reading error gives
null (no gate from here, the mapping fallback in ColumnGate applies).
Table of Contents
Properties
- $entityManager : EntityManagerInterface
- $tables : array<string, array<string, string>>
Methods
- __construct() : mixed
- describe() : array{kind: string, length: ?int, min: ?int, max: ?int, precision: ?int, scale: ?int, unsigned: bool}|null
- Returns the limits of the column a property writes to, or null when it is not a mapped scalar column.
- parse() : array{kind: string, length: ?int, min: ?int, max: ?int, precision: ?int, scale: ?int, unsigned: bool}|null
- Parses a MySQL/MariaDB column type (`varchar(45)`, `int(10) unsigned`, `decimal(10,3)`, `text`).
- columns() : array<string, string>
- writingEntity() : class-string
- The entity that actually writes the row: the admin reads and saves through the Api, so an admin entity (`App\UI\Admin\…`) maps to its Api counterpart. Admin entities are not persisted and their table names are not guaranteed (`cms_system_emails_texts` × the real `cms_system_email_texts`).
Properties
$entityManager read-only
private
EntityManagerInterface
$entityManager
$tables
private
array<string, array<string, string>>
$tables
= []
table => column => SQL type (lower case)
Methods
__construct()
public
__construct(EntityManagerInterface $entityManager) : mixed
Parameters
- $entityManager : EntityManagerInterface
describe()
Returns the limits of the column a property writes to, or null when it is not a mapped scalar column.
public
describe(class-string $entity, string $property) : array{kind: string, length: ?int, min: ?int, max: ?int, precision: ?int, scale: ?int, unsigned: bool}|null
Shape: kind = string (max characters), text (max bytes), integer (inclusive min/max) or
decimal (precision/scale/unsigned).
Parameters
- $entity : class-string
- $property : string
Return values
array{kind: string, length: ?int, min: ?int, max: ?int, precision: ?int, scale: ?int, unsigned: bool}|nullparse()
Parses a MySQL/MariaDB column type (`varchar(45)`, `int(10) unsigned`, `decimal(10,3)`, `text`).
public
static parse(string $type) : array{kind: string, length: ?int, min: ?int, max: ?int, precision: ?int, scale: ?int, unsigned: bool}|null
Parameters
- $type : string
Return values
array{kind: string, length: ?int, min: ?int, max: ?int, precision: ?int, scale: ?int, unsigned: bool}|nullcolumns()
private
columns(string $table) : array<string, string>
Parameters
- $table : string
Return values
array<string, string> —column => type
writingEntity()
The entity that actually writes the row: the admin reads and saves through the Api, so an admin entity (`App\UI\Admin\…`) maps to its Api counterpart. Admin entities are not persisted and their table names are not guaranteed (`cms_system_emails_texts` × the real `cms_system_email_texts`).
private
static writingEntity(class-string $entity) : class-string
Parameters
- $entity : class-string