[Solar-talk] Solar::loadInterface()?
Antti Holvikari
anttih at gmail.com
Sat Sep 30 09:05:14 PDT 2006
On 9/12/06, Clay Loveless <clay at killersoft.com> wrote:
> On Sep 12, 2006, at 9:05 AM, Antti Holvikari wrote:
>
> > On 9/6/06, Antti Holvikari <anttih at gmail.com> wrote:
> >> Hi!
> >>
> >> ZendFW has it, should Solar have it too? Or is there a reason why
> >> it's
> >> not there? Now I have to use require_once to load my interfaces...
> >
> > Hey you guys at Mashery ;-), what's your opinion on this?
>
> Thanks for reminding me of this thread -- missed it while I was out
> of town.
>
> For what it's worth, this makes sense to me. Half of it is already in
> place with Solar::run(), the rest is here:
>
> public static function loadInterface($interface)
> {
> // did we ask for a non-blank interface?
> if (trim($interface) == '') {
> throw Solar::exception(
> 'Solar',
> 'ERR_LOADINTERFACE_EMPTY',
> 'No interface named for loading',
> array('interface' => $interface)
> );
> }
>
> // pre-empt further searching for the interface
> if (interface_exists($interface, false)) {
> return;
> }
>
> // convert the interface name to a file path.
> $file = str_replace('_', DIRECTORY_SEPARATOR, $interface) . '.php';
>
> // include the file and check for failure. we use run() here
> // instead of require() so we can see the exception backtrace.
> $result = Solar::run($file);
>
> // if the interface was not in the file, we have a problem.
> if (! interface_exists($interface)) {
> throw Solar::exception(
> 'Solar',
> 'ERR_LOADINTERFACE_EXIST',
> 'Interface does not exist in loaded file',
> array('interface' => $interface, 'file' => $file)
> );
> }
> }
Paul, did you take a look at this? :-)
--
Antti Holvikari <http://phphalo.com>
More information about the solar-talk
mailing list