Skip to content

Commit

Permalink
Merge pull request #146 from silverleague/controller-fixes
Browse files Browse the repository at this point in the history
Fix when the namespace contains 'Controller'
  • Loading branch information
Firesphere authored Nov 29, 2022
2 parents 0589668 + 134580b commit e0c3915
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Generators/AbstractTagGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected function generateOwnerTags()
if ($reflection->isAbstract()) {
return;
}
if (Injector::inst()->get($this->className) instanceof Extension) {
if ($reflection instanceof Extension) {
$owners = iterator_to_array($this->getOwnerClasses($className));
$owners[] = $this->className;
$tagString = sprintf('\\%s $owner', implode("|\\", array_values($owners)));
Expand Down
7 changes: 6 additions & 1 deletion src/Generators/ControllerTagGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ protected function generateTags()
*/
protected function generateControllerObjectTags()
{
$pageClassname = str_replace(['_Controller', 'Controller'], '', $this->className);
$shortName = ClassInfo::shortName($this->className);
// Strip "Controller" or "_Controller" from the class short name
$shortSansController = str_replace(['_Controller', 'Controller'], '', $shortName);
// And push it back in :)
$pageClassname = str_replace($shortName, $shortSansController, $this->className);

if (class_exists($pageClassname) && $this->isContentController($this->className)) {
$pageClassname = $this->getAnnotationClassName($pageClassname);

Expand Down

0 comments on commit e0c3915

Please sign in to comment.