[Solar-talk] Solar::loadInterface()?
Paul M Jones
pmjones at ciaweb.net
Mon Oct 16 07:04:18 PDT 2006
Hi Antti,
On Sep 12, 2006, at 11:20 AM, Antti Holvikari wrote:
> 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)
>> );
>> }
>> }
>
> Exactly :-), Paul? Commit? :-)
Catching up on queued Solar email here; the loadInterface() method is
now part of the SVN version of Solar. Thanks for your patience on my
replies. :-)
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the solar-talk
mailing list