Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue when namespace depth > 1 in KunstmaanGenerateCommand #97

Merged

Conversation

tentwofour
Copy link
Contributor

When working with Bundles with a namespace depth greater than 1, the kuma:generate:page command will fail with: (in this example, the root namespace is "Ten24\SaskTheatre\WebsiteBundle")

  [InvalidArgumentException]
  Bundle "Ten24SaskTheatre" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() metho
  d of your AppKernel.php file?

Exception trace:
 () at F:\Users\blair\workspace\sasktheatre\app\bootstrap.php.cache:2386
 Symfony\Component\HttpKernel\Kernel->getBundle() at F:\Users\blair\workspace\sasktheatre\vendor\kunstmaan\bundles-cms\src\Ku
nstmaan\GeneratorBundle\Command\KunstmaanGenerateCommand.php:253
 Kunstmaan\GeneratorBundle\Command\KunstmaanGenerateCommand->askForBundleName() at F:\Users\blair\workspace\sasktheatre\vendo
r\kunstmaan\bundles-cms\src\Kunstmaan\GeneratorBundle\Command\GeneratePageCommand.php:119
 Kunstmaan\GeneratorBundle\Command\GeneratePageCommand->doInteract() at F:\Users\blair\workspace\sasktheatre\vendor\kunstmaan
\bundles-cms\src\Kunstmaan\GeneratorBundle\Command\KunstmaanGenerateCommand.php:38
 Kunstmaan\GeneratorBundle\Command\KunstmaanGenerateCommand->interact() at F:\Users\blair\workspace\sasktheatre\vendor\symfon
y\symfony\src\Symfony\Component\Console\Command\Command.php:244
 Symfony\Component\Console\Command\Command->run() at F:\Users\blair\workspace\sasktheatre\vendor\symfony\symfony\src\Symfony\
Component\Console\Application.php:882
 Symfony\Component\Console\Application->doRunCommand() at F:\Users\blair\workspace\sasktheatre\vendor\symfony\symfony\src\Sym
fony\Component\Console\Application.php:195
 Symfony\Component\Console\Application->doRun() at F:\Users\blair\workspace\sasktheatre\vendor\symfony\symfony\src\Symfony\Bu
ndle\FrameworkBundle\Console\Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at F:\Users\blair\workspace\sasktheatre\vendor\symfony\symfony\s
rc\Symfony\Component\Console\Application.php:126
 Symfony\Component\Console\Application->run() at F:\Users\blair\workspace\sasktheatre\app\console:27

The current code in KunstmaanGenerateCommand::getOwnBundles() limits the depth == 1. This fix simply looks for the wildcard "*Bundle.php" within the /src directory, and builds the bundles list from those found files.

Tested with the sample directory structure(s):

src/Crazy/Long/Namespaced/FunBundle
src/Stuff/SampleBundle
src/Ten24/SaskTheatre/WebsiteBundle

And $bundles is then:

Array
(
    [1] => Array
        (
            [name] => CrazyLongNamespacedFunBundle
            [namespace] => Crazy\Long\Namespaced\FunBundle
            [dir] => F:/Users/blair/workspace/sasktheatre/src\Crazy\Long\Namespaced\FunBundle
        )

    [2] => Array
        (
            [name] => StuffSampleBundle
            [namespace] => Stuff\SampleBundle
            [dir] => F:/Users/blair/workspace/sasktheatre/src\Stuff\SampleBundle
        )

    [3] => Array
        (
            [name] => Ten24SaskTheatreWebsiteBundle
            [namespace] => Ten24\SaskTheatre\WebsiteBundle
            [dir] => F:/Users/blair/workspace/sasktheatre/src\Ten24\SaskTheatre\WebsiteBundle
        )

)

roderik pushed a commit that referenced this pull request Jan 5, 2015
…cedepth

Fix for issue when namespace depth > 1 in KunstmaanGenerateCommand
@roderik roderik merged commit d711204 into Kunstmaan:master Jan 5, 2015
@roderik
Copy link
Contributor

roderik commented Jan 5, 2015

Thx!

@tentwofour
Copy link
Contributor Author

Thanks for a sweet project :)

@tentwofour tentwofour deleted the feature_generatecommandnamespacedepth branch January 5, 2015 22:20
@roderik roderik modified the milestone: Q1 2015 - v3.1 Feb 28, 2015
@roderik roderik modified the milestones: 3.1.0, 3.4.0, 3.0.1 Apr 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants