Jump to content

Class file that includes files with other classes


Firemankurt

Recommended Posts

I am rebuilding a CMS system that I have been developing over the last ~6 years. 

It needs to have many different kinds of modules depending on the installation (Like Drupal or Joomla does)

 

I have a Core class that does the major processing.

 

I am currently developing the part of the system that loads the actual module into the index.php page.

 

While experimenting I came up with an idea that is probably really horrible but I started to wonder if maybe it could actually work well.

 

I am looking for feedback on this Core class function:

 

public function LoadMods($ModsToLoad)
{
foreach ($ModsToLoad as $mod)
{
	$MainFile = ABSPATH.DS.$mod.DS.'main.php';
	if (file_exists($MainFile)) include ($MainFile);
	else $this->_MAIN .= 'Error: The "main" file for "'.$mod.'" module could not be found<br/>';
}
}

 

It will receive an array of Module names and those names correspond to a directory that holds the "main.php" file for that module.

 

Example:

 

index.php?mod=Photos

Will load the "Photos" module.

 

 

Here is the thing that has me concerned...

 

A module might have it's own class or classes and that class will likely get included in the "main.php" file for that module.

What effect is that going to have on my core class because it starts nesting classes inside classes.

Is this an efficiency advantage or am I heading down a road paved by code stink?

 

What's you opinion?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.