-
-
Couldn't load subscription status.
- Fork 146
-
I see how to modify a class: https://github.com/nette/php-generator?tab=readme-ov-file#generating-from-existing-ones
But I'm missing how to modify an entire namespace, and in particular, and struggling how to copy the use statement.
I feel like I'm missing something simple. For example, I want to inject
namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; final class TestController extends AbstractController { }
I want to inject an entity manager
namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Doctrine\ORM\EntityManagerInterface; final class TestController extends AbstractController { public function __construct(private EntityManagerInterface $em) { } }
I understand how to create this file with PhpGenerator alone and how to load the class with existing bodies, per the instructions above. But how do I get the PhpNamespace instance, so I can tweak the methods and generate the class with the uses and everything else?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment