Skip to content
Snippets Groups Projects
Commit 1ba40e35 authored by Jared Hancock's avatar Jared Hancock
Browse files

orm: Migrate create functionality to the constructor

Previously, the create method was used to create a new instance of an orm
model (which would later result in an INSERT when persisted); however, some
classes require or utilize varying parameters to their create() method,
which PHP7 considers an error. Methods in subclasses must be defined with a
calling signature compatible with the parent class.

This patch shifts the concept of model creation to the constructor. Now, the
constructor of ORM models is required to be compatible with that of
ModelBase class. Now that most models do not define a constructor, this is
much easier to control, and much more logical.

Also, remove an issue where assignments on a relationship field to an
instance of a super class of the foreign model would raise an error. This
was previously addressed by re-classing the instance in the
ModelInstanceManager::getOrBuild(); however that design would create
multiple instances of the same object in memory, which defeats one of the
primary design concepts of the ORM. This patch addresses the issue by
allowing super-classes of the declared foreign model in relationship
assignments.
parent 9616a61d
No related branches found
No related tags found
Loading
Showing
with 124 additions and 99 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment