TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-01-2009, 06:11 PM   #1 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default Function overloading for modular system?

Hi!

I'm about to create an open source gallery but I have some isues with the design of the system.

I have two classes which take care of image and folder handling. One to read a folder with items, and a class to represent an item.

http://minna-media.com/files/FiguraC...ram%20v1-1.png

But now I would like modular system for both the PathReader and Item. I was thinking about using __call, __get and __set. Of course this would making it modular pretty easy, but is this the best way to go?

I made allot of CMS etc, but in the end it never was 100% how I wanted it to be, so this time I want to plan it into its tinyest detail. :) (been thinking of the layout for the system for months already)
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
Old 07-01-2009, 06:30 PM   #2 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

Overloading in PHP simply involves not setting any arguments and calling func_get_args within the function.
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 07-01-2009, 06:50 PM   #3 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

I want to use it like this:

PHP Code:
class Foo 
{
  function 
__call($name$args)
  {
    if(
file_exists(MODULE_PATH '/' $name '.php';
    {
      require_once 
MODULE_PATH '/' $name '.php';
      
      
$mObj = new {$name}($args); // Dont know if this will work, but its about the idea
      
return $mObj->result(); 
    }
  }

This is some fast code, not how I would like to build it (e.g. I dont want to check if the module exists every time etc)
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
Old 07-01-2009, 07:49 PM   #4 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

Something along the lines of the Registry pattern will suit you but with the registry pattern you'll need to allow for the object to initiated first without any arguments and than pass them through.
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Timezone Class: Dealing with Timezones the Proper Way Wildhoney General 2 01-10-2011 11:01 PM
Next class project? allworknoplay The Lounge 6 04-18-2009 08:33 PM
Part 2: Giving our Currency Conversion Script some Responsibility Wildhoney General 15 03-17-2009 01:53 PM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM


All times are GMT. The time now is 01:13 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design