On Mar 11, 2014 2:26 PM, "Demian Katz" <demian.k...@villanova.edu> wrote:
>
> I've just run into an odd situation - wondering if I'm doing something
wrong or if anyone has a recommended workaround.
>
> For a long time, my application has had tons of closures in its
module.config.php file. Since this is bad practice, I've refactored
everything to rely on static factory methods, and I've replaced all the
closures with callable arrays... e.g. array('VuFind\Driver\Factory',
'getMyDriver').
>
> So far, so good.
>
> The problem is that for my local instance of my application, I have a
custom module which overrides some of the factories from the base module. I
just updated this to also use callable arrays instead of closures, and the
configuration merging code is merging the arrays together, so I end up with
something like:
>
> array('VuFind\Driver\Factory', 'getMyDriver', 'VuFindLocal\Factory',
'getMyLocalDriver')
>
> and then, of course, is_callable() fails, and the whole process blows up.
>
> I'm guessing I should be doing something differently somewhere. Any
suggestion to which bit I should change?

Use classes that implement __invoke() instead, and reference the class
name. The SM is smart enough to autoload these when requested, making them
a more robust solution than array callbacks - particularly for the use car
of overriding.

Reply via email to