I've built this now in my view-improvements branch, and I somehow don't like
the approach. The main intention was to provide a way to tell whether or not
the file does even exist. This doesn't work currently, since a
ConfigurationException is thrown, but we can't tell whether the file was
just not found or there's an error in the config file (i.e. Exception thrown
by the config handler).

So... I'd say let's create a new Exception, call it "UnreadableException",
for example, and use it with ConfigCache::checkConfig. I'll take care of
that for now and do it in my branch, but I'd appreciate any feedback
(especially on the name of the exception!).

- David

P.S:

try
{
  $config = include(ConfigCache::checkConfig('myconfig.ini'));
}
catch (UnreadableExeption $e)
{
  $config = null;
}

That's the way it would work. Still not sure about the exception name.


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Bob Zoller
> Sent: Saturday, September 10, 2005 7:19 PM
> To: Agavi Development
> Subject: Re: [agavi-dev] "Grace" parameter for ConfigCache::import()
> 
> Fine by me.. makes sense.  Guess you could also just create a second
> method instead of modifying the signature of that one, but then it
> might be difficult to make sure the exception you're catching (and
> ignoring) is the one thrown for the file not existing, and not one for
> the file being poorly formatted..
> 
> public static function checkConfigReturnBool($config)
> {
>   try {
>     return(self::checkConfig($config));
>   } catch (ConfigurationException $ce) {
>     return(false);
>   }
> }
> 
> Second param to checkConfig works for me though... probably makes more
> sense in this case.
> --Bob
> 
> On 9/10/05, David Zülke <[EMAIL PROTECTED]> wrote:
> > Cheers guys,
> >
> > I was working on my CachingExecutionFilter a bit this morning and came
> > across an issue. The general idea is that people just drop a
> "caching.ini"
> > into their modules/modulename/config directory to enable caching for
> certain
> > actions, based on certain parameters and so forth.
> > Obviously, I want everything to work as usual if no config file exists.
> I'll
> > be using ReturnArrayConfigHandler for that ini file, and I'd like to
> avoid
> > checking if the file exists first. Stuff like that leads to too many
> nested
> > if constructs.
> >
> > So... how about
> >
> > public static function checkConfig ($config, $reportFailure = true)
> >
> > ?
> >
> > Setting the second parameter to false would lead to no exception being
> > thrown if the file does not exists. Instead, the method would return
> either
> > null or false (I'd prefer the latter, since the check for the file
> failed,
> > right?)
> >
> > Opinions please.
> >
> > - David
> >
> >
> > _______________________________________________
> > agavi-dev mailing list
> > [email protected]
> > http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev
> >
> _______________________________________________
> agavi-dev mailing list
> [email protected]
> http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev



_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to