Add jackalope.factory to the DI extension #27

Merged
merged 1 commit into from Dec 12, 2012

Conversation

Projects
None yet
3 participants

aabdou commented Dec 11, 2012

The Jackalope/Jackrabbit repository factory supports the jackalope.factory factory that could be used to override the factory class the Jackrabbit transport uses. A valid class name or an instance of a class that implements the FactoryInterface are two valid options for the jackalope.factory parameter.

DependencyInjection/DoctrinePHPCRExtension.php
@@ -162,7 +174,7 @@ private function loadJackalopeSession(array $session, ContainerBuilder $containe
}
if (isset($session['backend']['disable_transactions'])) {
$parameters['jackalope.disable_transactions'] = $session['backend']['disable_transactions'];
- }
+ }
@lsmith77

lsmith77 Dec 11, 2012

Member

please revert

@aabdou

aabdou Dec 12, 2012

Sorry, I didn't clearly describe my use case. What I need to override is the factory NOT the RepositoryFactory. The line you highlighted is the one that creates the RepositoryFactory factory service (which could be RepositoryFactoryJackrabbit or the doctrinedbal option). The pull request I submitted overrides the "factory" that the RepositoryFactory uses to build the transport.

If you open the Jackalope\RepositoryFactoryJackrabbit class then navigate to the getRepository method, it takes the following parameters:

  • jackalope.factory
  • jackalope.default_header
  • jackalope.jackrabbit_expect
  • jackalope.check_login_on_server
  • jackalope.disable_stream_wrapper

The DI extension of the bundle has support for some of the parameters, but the "jackalope.factory" is not there.

@lsmith77

lsmith77 Dec 12, 2012

Member

i do understand your use case and i am very much looking forward to what you will enable with this change.
i was asking you to revert the whitespace change.

Member

lsmith77 commented Dec 11, 2012

interesting PR .. aside from the whitespace change it looks good to merge to me. may i ask about your use case?

aabdou commented Dec 11, 2012

I'm trying to switch the Http layer of the Jackalope/Jackrabbit transport to use the Guzzle Http framework. The factory is the one that provides all the Jackalope entities including the transport client and its request. By injecting a custom factory into the RepositoryFatcory through its parameters, the transport changes will be totally transparent to Jacakalope.

Member

lsmith77 commented Dec 11, 2012

ah very cool.

there is a fairly old ticket for this: jackalope/jackalope#33
unfortunately the FIG group has not yet defined an interface for http clients.

+ if (class_exists($session['backend']['factory'])) {
+ $parameters['jackalope.factory'] = $session['backend']['factory'];
+ } else {
+ $parameters['jackalope.factory'] = new Reference($session['backend']['factory']);
@dbu

dbu Dec 12, 2012

Member

does it make sense to create a service implicitly? just asking because i never saw this.

@lsmith77

lsmith77 Dec 12, 2012

Member

it seems OK to me. the error message should be clear enough in case of a misconfigiration. obviously this needs some docs too

Member

dbu commented Dec 12, 2012

definitely +1 on the PR, makes sense.

@aabdou: is the factory itself documented well enough to implement your own? i don't know if we have assumptions somewhere or the interface could be incomplete. but if it works for you, then its already a good sign :-)

aabdou commented Dec 12, 2012

@lsmith77: I reverted the whitespace

@dbu: well, sort of :D You can at least tell that you need to implement a FactoryInterface that provides one method to create an instance of an object and set some params on it.

dbu added a commit that referenced this pull request Dec 12, 2012

Merge pull request #27 from aabdou/master
Add jackalope.factory to the DI extension

@dbu dbu merged commit 72b15a7 into doctrine:master Dec 12, 2012

Member

dbu commented Dec 12, 2012

thanks for this contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment