Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add jackalope.factory to the DI extension #27

Merged
merged 1 commit into from

3 participants

@aabdou

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 Owner

please revert

@aabdou
aabdou added a note

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 Owner

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.

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

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

@aabdou

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.

@lsmith77
Owner

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.

@dbu dbu commented on the diff
DependencyInjection/DoctrinePHPCRExtension.php
@@ -150,6 +150,18 @@ private function loadJackalopeSession(array $session, ContainerBuilder $containe
if (isset($session['backend']['expect'])) {
$parameters['jackalope.jackalope.jackrabbit_expect'] = $session['backend']['expect'];
}
+ // Factory
+ if (isset($session['backend']['factory'])) {
+ /**
+ * If it is a class, pass the name as is, else assume it is
+ * a service id and get a reference to it
+ */
+ if (class_exists($session['backend']['factory'])) {
+ $parameters['jackalope.factory'] = $session['backend']['factory'];
+ } else {
+ $parameters['jackalope.factory'] = new Reference($session['backend']['factory']);
@dbu Collaborator
dbu added a note

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

@lsmith77 Owner

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

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

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

@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 dbu merged commit 72b15a7 into from
@dbu
Collaborator

thanks for this contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2012
  1. Add the jackalope.factory parameter to the DI

    Amir Abdou authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 0 deletions.
  1. +12 −0 DependencyInjection/DoctrinePHPCRExtension.php
View
12 DependencyInjection/DoctrinePHPCRExtension.php
@@ -150,6 +150,18 @@ private function loadJackalopeSession(array $session, ContainerBuilder $containe
if (isset($session['backend']['expect'])) {
$parameters['jackalope.jackalope.jackrabbit_expect'] = $session['backend']['expect'];
}
+ // Factory
+ if (isset($session['backend']['factory'])) {
+ /**
+ * If it is a class, pass the name as is, else assume it is
+ * a service id and get a reference to it
+ */
+ if (class_exists($session['backend']['factory'])) {
+ $parameters['jackalope.factory'] = $session['backend']['factory'];
+ } else {
+ $parameters['jackalope.factory'] = new Reference($session['backend']['factory']);
@dbu Collaborator
dbu added a note

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

@lsmith77 Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+ }
break;
}
Something went wrong with that request. Please try again.