Welcome Guest, Not a member yet? Register   Sign In
Modular extensions hmvd bug with same controller name
#1

[eluser]greku13[/eluser]
Hi all,

There is a problem with modular extensions.
When I use
Modules::run($moduleName.'/blocks/'.$methodName, $params);

Because I want to use two controllers that have the same name from two different modules, the second call doesn't work because controller already found (Modules::load - variable alias is the same). Then it doesn't work.

Is there a work around?
#2

[eluser]InsiteFX[/eluser]
You cannot have two classes with the same name! This is a PHP rule.

It is not a HMVC bug.

InsiteFX
#3

[eluser]greku13[/eluser]
Ok, that's true, I forgot about it.
Then, I think it would be a good idea to name all my class in a module with the module name as prefix.
But then my problem is that the urls will be something like
/mymodule/mymodule_classname/controller
with two times mymodule...
Would it be possible to name the class mymodule_classname, but the url be /mymodule/classname/controller

It is of course possible, but could someone give me some help how to make the change in the source code (where)
#4

[eluser]InsiteFX[/eluser]
Why do you not just give them names that mean something?

Blog
News
Pages
Comments
etc.

InsiteFX
#5

[eluser]wiredesignz[/eluser]
Or use module/config/routes.php if you need that functionality.
Code:
$route['mymodule'] = 'mymodule_classname';
#6

[eluser]greku13[/eluser]
[quote author="InsiteFX" date="1299333570"]Why do you not just give them names that mean something?

Blog
News
Pages
Comments
etc.

InsiteFX[/quote]

Just because the guy writting module x doesn't know the name of all controllers in all other modules that exists or will exist in the future...
#7

[eluser]greku13[/eluser]
[quote author="wiredesignz" date="1299333727"]Or use module/config/routes.php if you need that functionality.
Code:
$route['mymodule'] = 'mymodule_classname';
[/quote]

I don't really want to update the route file when there is a new module. Is there a rule I can add if I decide that all module names start with "m_" then for example

/m_modulex/blog/index should be routed to /m_modulex/m_modulex_blog/index

but of course that should not impact url not starting with m_

Edit

Sorry, I've just seen, that is in the module itself, so that should do the trick.
#8

[eluser]wiredesignz[/eluser]
Each module can have it's own routes file separate to application/config/routes.php

In any case it looks like your choice of application structure is just creating unnecessary problems. You'll need to figure that out for yourself.
#9

[eluser]greku13[/eluser]
OK

The problem in my application is that I may need to load controllers from different module for partial views, but I must make sure classes have not the same name. So all I see is to prefix all classes with the module name or is there another way?
#10

[eluser]InsiteFX[/eluser]
And forgive me if you thought I was being rude, I was not. I was just trying to explain that you need some kind of structure for working with modules.

You could create a settings table in your database and add a description etc for modules that are in or added to your application.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB