Skip to content

Commit

Permalink
Merge pull request #261 from andrii-pukhalevych/patch-1
Browse files Browse the repository at this point in the history
Support FQN in belongsToMany through option
  • Loading branch information
dereuromark authored Nov 23, 2021
2 parents a6459de + d886a1f commit b07f881
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Annotator/ModelAnnotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected function entity(string $entityClass, string $entityName, TableSchemaIn
* @return array<string>
*/
protected function parseLoadedBehaviors(string $content): array {
preg_match_all('/\$this-\>addBehavior\(\'([a-z.\/]+)\'/i', $content, $matches);
preg_match_all('/\$this->addBehavior\(\'([a-z.\/]+)\'/i', $content, $matches);
if (empty($matches[1])) {
return [];
}
Expand Down Expand Up @@ -280,6 +280,9 @@ protected function getAssociations(AssociationCollection $tableAssociations): ar

$className = App::className($through, 'Model/Table', 'Table') ?: static::CLASS_TABLE;
[, $throughName] = pluginSplit($through);
if (strpos($throughName, '\\') !== false) {
$throughName = substr($throughName, strrpos($throughName, '\\') + 1, -5);
}
$type = HasMany::class;
if (isset($associations[$type][$throughName])) {
continue;
Expand Down Expand Up @@ -360,9 +363,7 @@ protected function getBehaviors($table): array {
$this->_cache[$parentClass] = $parentBehaviors = $this->extractBehaviors($map);
}

$result = array_diff_key($behaviors, $parentBehaviors);

return $result;
return array_diff_key($behaviors, $parentBehaviors);
}

/**
Expand Down

0 comments on commit b07f881

Please sign in to comment.