Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/AbstractMySqlGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public function getLinks($method = self::ALL)
{
$links = [];

foreach ($this->links as $key => $pool) {
if ($method & $key) {
/** @var Link $link */
foreach ($pool as $link) {
if ($link->runFilters()) {
$links[] = $link->getLink();
if (is_array($this->links)) {
foreach ($this->links as $key => $pool) {
if ($method & $key) {
/** @var Link $link */
foreach ($pool as $link) {
if ($link->runFilters()) {
$links[] = $link->getLink();
}
}
}
}
Expand All @@ -80,7 +82,13 @@ public function fetchOne($key): EntityInterface
{
$class = $this->getEntityClass() ? $this->getEntityClass() : $this->getDefaultEntityClass();

foreach ($this->getLinks(self::FETCH_ONE) as $link) {
$links = $this->getLinks(self::FETCH_ONE);

if (!$links) {
throw new MySqlGatewayException('No link found to fetch one entity');
}

foreach ($links as $link) {
/** @var EntityInterface $entity */
$entity = new $class;

Expand Down Expand Up @@ -276,6 +284,11 @@ public function fetchAll(ResultSetDescriptorInterface $descriptor): ResultSetInt
{

$links = $this->getLinks(self::READ);

if (!$links) {
throw new MySqlGatewayException('No link found to fetch entities');
}

$query = new Select(new Quoter('`', '`'));
$this->hydrateQuery($query, $descriptor);

Expand Down