tflori/orm

just another orm...

View the Project on GitHub tflori/orm

Build Status Test Coverage Maintainability Latest Stable Version Total Downloads

» API Reference » ORM\Relation\Morphed

ORM\Relation\Morphed

Table of Contents

Abstract

Extends: ORM\Relation\Owner

Owner Relation

Methods

ORM\Relation\Morphed::__construct

public function __construct(string $class, array $reference)
Owner constructor.
Parameters
Parameter Type Description
$class string  
$reference array  

ORM\Relation\Morphed::__construct

↑ top


ORM\Relation\Morphed::addJoin

public function addJoin(
    \ORM\EntityFetcher $fetcher, 
    mixed $join, 
    mixed $alias, 
): mixed
{@inheritdoc}
Returns mixed  
Parameters
Parameter Type Description
$fetcher ORM\EntityFetcher  
$join mixed  
$alias mixed  

ORM\Relation\Morphed::addJoin

↑ top


ORM\Relation\Morphed::addRelated

public function addRelated(
    \ORM\Entity $self, 
    \ORM\Entity[] $entities, 
    \ORM\EntityManager $entityManager, 
): mixed
Add $entities to association table
Returns mixed  
Throws ORM\Exception\InvalidRelation  
Parameters
Parameter Type Description
$self ORM\Entity  
$entities ORM\Entity[]  
$entityManager ORM\EntityManager  

ORM\Relation\Morphed::addRelated

↑ top


ORM\Relation\Morphed::apply

public function apply(\ORM\EntityFetcher $fetcher, \ORM\Entity $entity): mixed
Apply where conditions for $entity on $fetcher

Called from non-owner to find related elements. Example: $user->fetch(‘articles’) creates an EntityFetcher for Article and calls $opponent->apply($fetcher, $user) that will call $fetcher->where(‘authorId’, $user->id)

Returns mixed  
Parameters
Parameter Type Description
$fetcher ORM\EntityFetcher  
$entity ORM\Entity  

ORM\Relation\Morphed::apply

↑ top


ORM\Relation\Morphed::applyJoin

public function applyJoin(
    \ORM\QueryBuilder\Parenthesis $join, 
    string $yourAlias, 
    \ORM\Relation\OneToMany $opponent, 
): mixed
Adds the join clause to the entity fetcher
Returns mixed  
Parameters
Parameter Type Description
$join ORM\QueryBuilder\Parenthesis  
$yourAlias string  
$opponent ORM\Relation\OneToMany  

ORM\Relation\Morphed::applyJoin

↑ top


ORM\Relation\Morphed::createRelation

public static function createRelation(
    string $parent, 
    string $name, 
    array $relDef, 
): \ORM\Relation
Factory for relation definition object
Static   This method is static.
Returns ORM\Relation  
Throws ORM\Exception\InvalidConfiguration  
Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\Morphed::createRelation

↑ top


ORM\Relation\Morphed::deleteRelated

public function deleteRelated(
    \ORM\Entity $self, 
    \ORM\Entity[] $entities, 
    \ORM\EntityManager $entityManager, 
): mixed
Delete $entities from association table
Returns mixed  
Throws ORM\Exception\InvalidRelation  
Parameters
Parameter Type Description
$self ORM\Entity  
$entities ORM\Entity[]  
$entityManager ORM\EntityManager  

ORM\Relation\Morphed::deleteRelated

↑ top


ORM\Relation\Morphed::eagerLoad

public function eagerLoad(\ORM\EntityManager $em, \ORM\Entity $entities): mixed
Load all foreign objects of all $entities with one query
Returns mixed  
Parameters
Parameter Type Description
$em ORM\EntityManager  
$entities ORM\Entity  

ORM\Relation\Morphed::eagerLoad

↑ top


ORM\Relation\Morphed::eagerLoadSelf

public function eagerLoadSelf(
    \ORM\EntityManager $em, 
    \ORM\Entity $foreignObjects, 
): mixed
Returns mixed  
Parameters
Parameter Type Description
$em ORM\EntityManager  
$foreignObjects ORM\Entity  

ORM\Relation\Morphed::eagerLoadSelf

↑ top


ORM\Relation\Morphed::fetch

public function fetch(
    \ORM\Entity $self, 
    \ORM\EntityManager $entityManager, 
): mixed
Fetch the relation
Returns mixed  
Parameters
Parameter Type Description
$self ORM\Entity  
$entityManager ORM\EntityManager  

ORM\Relation\Morphed::fetch

↑ top


ORM\Relation\Morphed::fetchAll

public function fetchAll(
    \ORM\Entity $self, 
    \ORM\EntityManager $entityManager, 
): \ORM\Entity[]|\ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Returns ORM\Entity[]|ORM\Entity  
Parameters
Parameter Type Description
$self ORM\Entity  
$entityManager ORM\EntityManager  

ORM\Relation\Morphed::fetchAll

↑ top


ORM\Relation\Morphed::fromAssoc

public static function fromAssoc(mixed $parent, array $relDef): mixed
{@inheritDoc}
Static   This method is static.
Returns mixed  
Parameters
Parameter Type Description
$parent mixed  
$relDef array  

ORM\Relation\Morphed::fromAssoc

↑ top


ORM\Relation\Morphed::fromShort

public static function fromShort(mixed $parent, array $short): mixed
{@inheritDoc}
Static   This method is static.
Returns mixed  
Parameters
Parameter Type Description
$parent mixed  
$short array  

ORM\Relation\Morphed::fromShort

↑ top


ORM\Relation\Morphed::getReference

public function getReference(): mixed
Returns mixed  

ORM\Relation\Morphed::getReference

↑ top


ORM\Relation\Morphed::setRelated

public function setRelated(\ORM\Entity $self, \ORM\Entity $entity = null): mixed
Set the relation to $entity
Returns mixed  
Throws ORM\Exception\InvalidRelation  
Throws ORM\Exception\IncompletePrimaryKey  
Parameters
Parameter Type Description
$self ORM\Entity  
$entity ORM\Entity  

ORM\Relation\Morphed::setRelated

↑ top