Skip to content
Snippets Groups Projects
  • Jared Hancock's avatar
    orm: Migrate create functionality to the constructor · 1ba40e35
    Jared Hancock authored
    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.
    1ba40e35