Nextras\Orm\Mapper\Dbal\DbalMapper::getManyHasManyParameters PHP Method

getManyHasManyParameters() public method

public getManyHasManyParameters ( PropertyMetadata $sourceProperty, Nextras\Orm\Mapper\IMapper $targetMapper )
$sourceProperty Nextras\Orm\Entity\Reflection\PropertyMetadata
$targetMapper Nextras\Orm\Mapper\IMapper
    public function getManyHasManyParameters(PropertyMetadata $sourceProperty, IMapper $targetMapper)
    {
        return [$this->getStorageReflection()->getManyHasManyStorageName($targetMapper), $this->getStorageReflection()->getManyHasManyStoragePrimaryKeys($targetMapper)];
    }

Usage Example

 public function __construct(Connection $connection, DbalMapper $mapperOne, DbalMapper $mapperTwo, PropertyMetadata $metadata)
 {
     $this->connection = $connection;
     $this->mapperOne = $mapperOne;
     $this->mapperTwo = $mapperTwo;
     $this->metadata = $metadata;
     $parameters = $mapperOne->getManyHasManyParameters($metadata, $mapperTwo);
     $this->joinTable = $parameters[0];
     if ($this->metadata->relationship->isMain) {
         $this->targetRepository = $this->mapperTwo->getRepository();
         list($this->primaryKeyFrom, $this->primaryKeyTo) = $parameters[1];
     } else {
         $this->targetRepository = $this->mapperOne->getRepository();
         list($this->primaryKeyTo, $this->primaryKeyFrom) = $parameters[1];
     }
 }