Sorry for the late reply.

No, factories are NOT passed to initializers, and shouldn't.

Think of a factory as a named callback. Nothing else.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/


On 9 December 2013 17:06, Xander Guzman <thesha...@shadowpedia.info> wrote:

> It does
>
> /**
>  * Defines an initializer that knows how to inject a configuration object
>  */
> class ConfigInitializer implements InitializerInterface
> {
>     /**
>      * Initialize
>      *
>      * @param $instance
>      * @param ServiceLocatorInterface $serviceLocator
>      *
>      * @return mixed
>      */
>     public function initialize($instance, ServiceLocatorInterface
> $serviceLocator)
>     {
>         if ($instance instanceof ConfigAwareInterface) {
>             $config = $serviceLocator->get('Config');
>             $instance->setConfig($config);
>         }
>     }
> }
>
>
> On Mon, Dec 9, 2013 at 8:52 AM, franz de leon <kelmad...@gmail.com> wrote:
>
> > Your factory should implement the interface in your initializer.
> >
> > array(
> >     'factories' => array(
> >         'solrconfig' => 'Solr\Config\ConfigInitializer',
> >     ),
> >     'initializers' => array(
> >          function ($instance, $sm) {
> >               if ($instance instanceof Configaware) {
> >                    $instance->setConfig($sm->get('solrconfig'));
> >               }
> >          }
> >     )
> > )
> >
> >
> > On Mon, Dec 9, 2013 at 10:24 AM, Xander Guzman
> > <thesha...@shadowpedia.info>wrote:
> >
> > > Like the database configurations I have multiple Solr configurations so
> > I'm
> > > trying to create a factory that can return the connection to the one
> > > specified.
> > >
> > > return array(
> > >     "solr" => array(
> > >         'media' => array( /** config */ ),
> > >         'vendors' => array( /** config */ ),
> > >     ),
> > > );
> > >
> > > Right now, in my module, I have the Following configuration for the
> > > getServiceConfig method
> > >
> > > return array(
> > >     'factories' => array(
> > >         'Solr\Service' => 'Solr\Service\Factory',
> > >         'Solr\Client' => 'Solr\Client\Factory',
> > >     ),
> > >     'initializers' => array(
> > >         'SolrConfig' => 'Solr\Config\ConfigInitializer',
> > >     ),
> > > );
> > >
> > > Here is how things are working.
> > >
> > > The factories work and are getting called and the initializer is being
> > > called, but the initializer isn't being called on the factories.
> > >
> > > So first, why? Is this by design? Am I misunderstanding how this
> > > relationship works?
> > >
> > > How can I get the same kind of multiple configurations to work I tried
> > > digging through the DB ones but I don't think I've found the class that
> > yet
> > > reads the config to pass off to a specific adapter.
> > >
> > > Any help is appreciated.
> > >
> > > Cheers!
> > >
> > > Xander
> > >
> >
>

Reply via email to