class ClassSchema (View source)

A class schema

Constants

MODELTYPE_ENTITY

Available model types

MODELTYPE_VALUEOBJECT

Properties

protected class-string $className

Name of the class this schema is referring to

protected int $modelType

Model type of the class this schema is referring to

protected bool $lazyLoadable

Whether instances of the class can be lazy-loadable

protected string|null $repositoryClassName
protected array $properties

Properties of the class which need to be persisted

protected array $identityProperties

The properties forming the identity of an object

Methods

__construct(class-string $className)

Constructs this class schema

class-string
getClassName()

Returns the class name this schema is referring to

void
setLazyLoadableObject(bool $lazyLoadable)

Marks the class as being lazy-loadable.

bool
isLazyLoadableObject()

Marks the class as being lazy-loadable.

void
addProperty(string $name, string $type, bool $lazy = false, bool $transient = false)

Adds (defines) a specific property and its type.

array
getProperty(string $propertyName)

Returns the given property defined in this schema. Check with hasProperty($propertyName) before!

array
getProperties()

Returns all properties defined in this schema

bool
isMultiValuedProperty(string $propertyName)

Checks if the given property defined in this schema is multi-valued (i.e.

void
setModelType(int $modelType)

Sets the model type of the class this schema is referring to.

int
getModelType()

Returns the model type of the class this schema is referring to.

void
setRepositoryClassName(string $repositoryClassName)

Set the class name of the repository managing an entity.

string
getRepositoryClassName()

No description

bool
isAggregateRoot()

Whether the class is accessible through a repository and therefore an aggregate root.

bool
hasProperty(string $propertyName)

If the class schema has a certain property.

bool
isPropertyLazy(string $propertyName)

If a certain class schema property is to be lazy loaded

bool
isPropertyTransient(string $propertyName)

If a certain class schema property is to disregarded for persistence

bool
isPropertyNullable(string $propertyName)

If a certain class schema property is nullable

void
markAsIdentityProperty(string $propertyName)

Marks the given property as one of properties forming the identity of an object. The property must already be registered in the class schema.

array
getIdentityProperties()

Gets the properties (names and types) forming the identity of an object.

Details

__construct(class-string $className)

Constructs this class schema

Parameters

class-string $className

Name of the class this schema is referring to

class-string getClassName()

Returns the class name this schema is referring to

Return Value

class-string

The class name

void setLazyLoadableObject(bool $lazyLoadable)

Marks the class as being lazy-loadable.

Parameters

bool $lazyLoadable

Return Value

void

bool isLazyLoadableObject()

Marks the class as being lazy-loadable.

Return Value

bool

void addProperty(string $name, string $type, bool $lazy = false, bool $transient = false)

Adds (defines) a specific property and its type.

Parameters

string $name

Name of the property

string $type

Type of the property

bool $lazy

Whether the property should be lazy-loaded when reconstituting

bool $transient

Whether the property should not be considered for persistence

Return Value

void

Exceptions

InvalidArgumentException

array getProperty(string $propertyName)

Returns the given property defined in this schema. Check with hasProperty($propertyName) before!

Parameters

string $propertyName

Return Value

array

array getProperties()

Returns all properties defined in this schema

Return Value

array

bool isMultiValuedProperty(string $propertyName)

Checks if the given property defined in this schema is multi-valued (i.e.

array or SplObjectStorage).

Parameters

string $propertyName

Return Value

bool

void setModelType(int $modelType)

Sets the model type of the class this schema is referring to.

Parameters

int $modelType

The model type, one of the MODELTYPE_* constants.

Return Value

void

Exceptions

InvalidArgumentException

int getModelType()

Returns the model type of the class this schema is referring to.

Return Value

int

The model type, one of the MODELTYPE_* constants.

void setRepositoryClassName(string $repositoryClassName)

Set the class name of the repository managing an entity.

Parameters

string $repositoryClassName

Return Value

void

Exceptions

ClassSchemaConstraintViolationException

string getRepositoryClassName()

No description

Return Value

string

bool isAggregateRoot()

Whether the class is accessible through a repository and therefore an aggregate root.

Return Value

bool true

bool hasProperty(string $propertyName)

If the class schema has a certain property.

Parameters

string $propertyName

Name of the property

Return Value

bool

bool isPropertyLazy(string $propertyName)

If a certain class schema property is to be lazy loaded

Parameters

string $propertyName

Name of the property

Return Value

bool

bool isPropertyTransient(string $propertyName)

If a certain class schema property is to disregarded for persistence

Parameters

string $propertyName

Name of the property

Return Value

bool

bool isPropertyNullable(string $propertyName)

If a certain class schema property is nullable

Parameters

string $propertyName

Return Value

bool

void markAsIdentityProperty(string $propertyName)

Marks the given property as one of properties forming the identity of an object. The property must already be registered in the class schema.

Parameters

string $propertyName

Return Value

void

Exceptions

InvalidArgumentException
ClassSchemaConstraintViolationException

array getIdentityProperties()

Gets the properties (names and types) forming the identity of an object.

Return Value

array

See also

markAsIdentityProperty()