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

NFR: Add module name to module class name format in Application::registerModules #12252

Closed
dschissler opened this issue Sep 25, 2016 · 7 comments
Labels
new feature request Planned Feature or New Feature Request

Comments

@dschissler
Copy link
Contributor

dschissler commented Sep 25, 2016

Currently Phalcon module setup is a bit hacky because there is some overlap of concerns between the Loader and Application and modules. The Application class has been doing a poor man's loading to get the module definitions loaded up when the normal Loader class is fully capable of being used with the Loader::registerClasses method.

Currently if one wants to use the more correct approach then the following format must be used:

$application = new Application($di);
$application->registerModules([
    'org'   => ['className' => 'Project\Modules\Org\Module'],
    'site'  => ['className' => 'Project\Modules\Site\Module'],
    'admin' => ['className' => 'Project\Modules\Admin\Module'],
    'api'   => ['className' => 'Project\Modules\Api\Module']
]);

I propose that this could be made to look like the following while maintaining BC with the semver 3 series.

$application = new Application($di);
$application->registerModules([
    'org'   => 'Project\Modules\Org\Module',
    'site'  => 'Project\Modules\Site\Module',
    'admin' => 'Project\Modules\Admin\Module',
    'api'   => 'Project\Modules\Api\Module'
]);

Then I propose that late into 3.* series (1-2 years from now) that the className => ... format should throw a deprecation warning and then this format should be removed in the 4.0 series for a breaking change.

Update This is also possible:

$application = new Application($di);
$application->registerModules([
    'org'   => OrgModule::class,
    'site'  => SiteModule::class,
    'admin' => AdminModule::class,
    'api'   => Api::Module,
]);
@sergeyklay sergeyklay modified the milestones: 3.0.x, 3.x.x Sep 25, 2016
@dschissler

This comment was marked as abuse.

@Jurigag
Copy link
Contributor

Jurigag commented Oct 28, 2016

Also what about adding option to load whole module on bootstraping ? Like execute registerNamespaces and registerServices always so certain module can be used across all modules ?

@dschissler

This comment was marked as abuse.

@Jurigag
Copy link
Contributor

Jurigag commented Oct 28, 2016

Yea i know, but what if someone need such a feature ? Right now you need to do some nasty things like create module class on your own and call methods, or register namespaces from other module and set proper services in other module and such stuff.

@dschissler

This comment was marked as abuse.

@sergeyklay sergeyklay modified the milestones: 3.x.x, 3.2.x Apr 5, 2017
@sergeyklay sergeyklay modified the milestones: 3.2.x, 4.0.0 Jun 18, 2017
@stale stale bot added the stale Stale issue - automatically closed label Apr 16, 2018
@sergeyklay sergeyklay reopened this May 2, 2018
@stale stale bot removed the stale Stale issue - automatically closed label May 2, 2018
@dschissler

This comment was marked as abuse.

@niden
Copy link
Member

niden commented Feb 23, 2019

Closing in favor of #13855. Will revisit if the community votes for it, or in later versions.

@niden niden closed this as completed Feb 23, 2019
@phalcon phalcon deleted a comment from stale bot Feb 23, 2019
@niden niden removed this from the 4.0.0 milestone Dec 9, 2019
@niden niden added the new feature request Planned Feature or New Feature Request label Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

4 participants