Allow Zoop To Add Classes From Different File Names

First off it is great that this site is back up and working because I should have a lot to add a lot to ask. Thanks for making a great framework it has really helped me a great deal in my development.

Normally Zoop can only added classes to the auto load function which are of the same name as the class itself. This does not work for other naming conventions e.g. I have a class called Test I would name the file test.class.php which helps me me later during revision control to quickly understand what different files are for when all listed together since I generally deal with thousands of files. To fix this I changed the function below in the zoop.php file.

Orginal:
function addObject($name)
{
$file = $this->appPath . "/objects/$name.php";
$this->addInclude($name, $file);
//if (file_exists($file))
// include($file);
}

Changed To:

function addObject($name,$file = '') {
if(!empty($file)) {
$file = $this->appPath . "/objects/$file.php";
} else {
$file = $this->appPath . "/objects/$name.php";
}
$name = strtolower($name);
$this->addInclude($name, $file);
}

convenience

While this functionality is available in the form of:

$zoop->addInclude($className, $fileName);

It doesn't have the same convenience feature of assuming the "appPath/objects" directory, so I see value in what you propose.
However, I would prefer something like:

function addObject($name, $file = '')
{
if(!empty($file)) {
$file = $this->appPath . "/objects/$file";
} else {
$file = $this->appPath . "/objects/$name.php";
}
$name = strtolower($name);
$this->addInclude($name, $file);
}

that assumes nothing about the filename. It makes it more obvious that what you're passing is a filename, not just an alias.

$zoop->addObject('SomeClass', 'SomeName');
$zoop->addObject('SomeClass', 'SomeName.php');

In the first example, it's not entirely obvious what the second parameter means. The second makes it more clear.

Thoughts?

Agreed

I agree that your approach makes more sense for the intended use.

Committed

This is now available in svn.