Skip to content

Commit

Permalink
Merge pull request #2 from zunnu/3.x-dev
Browse files Browse the repository at this point in the history
Error handling for association registration
  • Loading branch information
zunnu committed Oct 21, 2022
2 parents b0c478b + bb7c9c5 commit 754ee6a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,16 @@ private function _associations($model, $plugin = null) {
if($associations = $setModel->associations()) {
foreach ($associations->normalizeKeys($associations->getIterator()) as $key => $association) {
$source = $association->source();
$target = $association->target();

try {
$target = $association->target();
} catch (\Exception $e) {
$association->target()->setRegistryAlias(ucfirst($association->getProperty()) . $association->getName());
$association->target()->setAlias(ucfirst($association->getProperty()) . $association->getName());
$association->setName(ucfirst($association->getProperty()) . $association->getName());
$target = $association->target();
}

$sourceRegistery = 'App';
$targetRegistery = 'App';

Expand Down

0 comments on commit 754ee6a

Please sign in to comment.