-
Notifications
You must be signed in to change notification settings - Fork 76
move document to model #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a3dfd9
move document to model
dbu 12f5436
fix service name
dbu 7896ad8
refactor configuration to prepare for orm. fix #105
dbu 5b613d7
default manager_name is null, solve TODO about phpcr enabled
dbu 3a8cebc
using interface for the id prefix listener
dbu 11152d3
Merge remote-tracking branch 'origin/master' into create-models
dbu f576865
make tests work with latest phpcr-bundle, adding upgrade file
dbu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine; | ||
|
||
use Doctrine\Common\Persistence\ManagerRegistry; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
|
||
/** | ||
* Abstract class for doctrine based content repository and route provider | ||
* implementations. | ||
* | ||
* @author Uwe Jäger | ||
* @author David Buchmann <mail@davidbu.ch> | ||
*/ | ||
abstract class DoctrineProvider | ||
{ | ||
/** | ||
* If this is null, the manager registry will return the default manager. | ||
* | ||
* @var string|null Name of object manager to use | ||
*/ | ||
protected $managerName; | ||
|
||
/** | ||
* @var ManagerRegistry | ||
*/ | ||
protected $managerRegistry; | ||
|
||
/** | ||
* Class name of the object class to find, null for PHPCR-ODM as it can | ||
* determine the class on its own. | ||
* | ||
* @var string|null | ||
*/ | ||
protected $className; | ||
|
||
/** | ||
* @param ManagerRegistry $managerRegistry | ||
*/ | ||
public function __construct(ManagerRegistry $managerRegistry, $className = null) | ||
{ | ||
$this->managerRegistry = $managerRegistry; | ||
} | ||
|
||
/** | ||
* Set the object manager name to use for this loader. If not set, the | ||
* default manager as decided by the manager registry will be used. | ||
* | ||
* @param string|null $managerName | ||
*/ | ||
public function setManagerName($managerName) | ||
{ | ||
$this->managerName = $managerName; | ||
} | ||
|
||
/** | ||
* Get the object manager named $managerName from the registry. | ||
* | ||
* @return ObjectManager | ||
*/ | ||
protected function getObjectManager() | ||
{ | ||
return $this->managerRegistry->getManager($this->managerName); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr; | ||
|
||
use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; | ||
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; | ||
|
||
/** | ||
* Implement ContentRepositoryInterface for PHPCR-ODM | ||
* | ||
* This is <strong>NOT</strong> not a doctrine repository but just the content | ||
* provider for the NestedMatcher. (you could of course implement this | ||
* interface in a repository class, if you need that) | ||
* | ||
* @author Uwe Jäger | ||
*/ | ||
class ContentRepository extends DoctrineProvider implements ContentRepositoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function findById($id) | ||
{ | ||
return $this->getObjectManager()->find(null, $id); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getContentId($content) | ||
{ | ||
if (! is_object($content)) { | ||
return null; | ||
} | ||
try { | ||
return $this->getObjectManager()->getUnitOfWork()->getDocumentId($content); | ||
} catch (\Exception $e) { | ||
return null; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
Listener/LocaleUpdater.php → Doctrine/Phpcr/LocaleListener.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is one of the drawbacks of not having multiple inheritance/traits to build the document classes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand, why can't they at least implement an interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well then we would define a PhpcrPathPrefixInterface or something, just sounds weird as its just an implementation detail. if this was a Trait, we could check the class for having the trait. (but until php 5.3 can be dropped, i guess we are at least in Symfony3...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Why would such an interface be a bad idea? Although, the only problem I can see here is if/when the user wants another type of Routing object à la "RedirectRoute". They would have to override this class - creating a little interface in the Doctrine/PHPCR namespace seems like a painless solution?
If we were to implement the interface I guess we would also have to determine the ID from either the DM or the metadata also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, convinced. i added the interface