Beispiel #1
0
 /**
  * @param string $entityName
  * @return CriteriaInterface
  */
 public function relation($entityName)
 {
     if (isset($this->relations[$entityName])) {
         return $this->relations[$entityName];
     }
     if ($this->config->isRelationManyToMany($this->entityName, $entityName)) {
         list($linkTable, $mainField, $joinedField) = $this->config->getRelationManyToMany($this->entityName, $entityName);
         $mainTable = $this->config->getTable($this->entityName);
         $joinedTable = $this->config->getTable($entityName);
         $this->select->join($linkTable, "{$linkTable}.{$mainField} = {$mainTable}.id", []);
         $this->select->join($joinedTable, "{$linkTable}.{$joinedField} = {$joinedTable}.id", []);
     } else {
         $table = $this->config->getTable($entityName);
         $this->select->join($table, $this->config->getRelationExpression($this->entityName, $entityName), []);
     }
     $relationCriteria = new self($entityName, $this->config, $this->select);
     $this->relations[$entityName] = $relationCriteria;
     return $relationCriteria;
 }
Beispiel #2
0
 public function testIsRelationManyToManyException()
 {
     $this->setExpectedException(ConfigException::class);
     $this->config->isRelationManyToMany('Task', 'Statistic');
 }