Skip to content

Commit

Permalink
Fix when the namespace contains 'Controller'
Browse files Browse the repository at this point in the history
Check the reflection instance type instead of instantiating the class. Instantiating throws errors for __construct with arguments
  • Loading branch information
Simon Erkelens committed Nov 28, 2022
1 parent 0589668 commit 134580b
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 134580b

Please sign in to comment.