-
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 all commits
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
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
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,23 @@ | ||
<?php | ||
|
||
namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr; | ||
|
||
/** | ||
* An interface for PHPCR route documents. | ||
* | ||
* We use the repository path as static part of the URL, but the documents | ||
* need to know what their base path is to remove that from the URL. | ||
*/ | ||
interface PrefixInterface | ||
{ | ||
/** | ||
* @return string the full path of this document in the repository. | ||
*/ | ||
public function getId(); | ||
|
||
/** | ||
* @param string $prefix The path in the repository to the routing root | ||
* document. | ||
*/ | ||
public function setPrefix($prefix); | ||
} |
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.
Why remove the defaults for
content_repository_service_id
androute_provider_service_id
?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.
because if you enable phpcr, the DI extension will set those alias to the phpcr route provider + content repository now. these options are to override the automatic alias that happens because of your choice of backend.