private function loadRelations(\Model\Entity $entity) { $oneToMany = $entity->oneToMany(); if (!empty($oneToMany)) { foreach ($oneToMany as $table => $info) { $this->qb->resetQueryParts(); $this->qb->setParameters(array()); $this->qb->setMaxResults(null); $this->qb->setFirstResult(null); $alias = substr($table, 0, 1); $this->qb->select('*')->from($table, $alias); if (isset($info['middle'])) { $condition = 'middle.' . $info['middle_attribute'] . ' = ' . $alias . '.' . $info['attribute']; $this->qb->innerJoin($alias, $info['middle'], 'middle', $condition)->where('middle.' . $info['relation'] . ' = :attribute')->setParameter('attribute', $entity->getPKValue()); } else { $this->qb->where($info['attribute'] . ' = :attribute')->setParameter('attribute', $entity->getPKValue()); } $entity->{$table} = $this->entitiesFromArray($this->getResults(), false, '\\Model\\' . $info['class']); } } }
private function linkToOthers(\Model\Entity $entity, $rules) { $link = ''; foreach ($rules as $rule) { // $rule has indexes title, url and icon if (preg_match_all('/\\{(\\w+)\\}/', $rule['url'], $parts)) { $link .= $this->getLink('others', $parts[0], array($entity, $parts[1]), $rule); } else { $link .= $this->getLink('others', '?', $entity->getPKValue(), $rule); } $link .= ' '; } return $link; }