-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,253 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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,36 @@ | ||
<?php | ||
|
||
namespace Vich\GeographicalBundle\Adapter; | ||
|
||
use Doctrine\Common\EventArgs; | ||
|
||
/** | ||
* AdapterInterface. | ||
* | ||
* @author Dustin Dobervich <ddobervich@gmail.com> | ||
*/ | ||
interface AdapterInterface | ||
{ | ||
/** | ||
* Gets the mapped object from the event arguments. | ||
* | ||
* @param EventArgs $e The event arguments. | ||
* @return object The mapped object. | ||
*/ | ||
function getObjectFromArgs(EventArgs $e); | ||
|
||
/** | ||
* Notifies the ORM layer that a recompute of the entities changeset is necessary. | ||
* | ||
* @param EventArgs $e The event arguments. | ||
*/ | ||
function invokeChangesetRecompute(EventArgs $e); | ||
|
||
/** | ||
* Determines if the specified object is a proxy. | ||
* | ||
* @param mixed $obj The object to test. | ||
* @return boolean True if a proxy object, false otherwise. | ||
*/ | ||
function isProxy($obj); | ||
} |
This file contains 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,44 @@ | ||
<?php | ||
|
||
namespace Vich\GeographicalBundle\Adapter\ORM; | ||
|
||
use Vich\GeographicalBundle\Adapter\AdapterInterface; | ||
use Doctrine\Common\EventArgs; | ||
use Doctrine\ODM\MongoDB\Proxy\Proxy; | ||
|
||
/** | ||
* MongoDBAdapter. | ||
* | ||
* @author Dustin Dobervich <ddobervich@gmail.com> | ||
*/ | ||
class MongoDBAdapter implements AdapterInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getObjectFromArgs(EventArgs $e) | ||
{ | ||
return $e->getDocument(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function invokeChangesetRecompute(EventArgs $e) | ||
{ | ||
$obj = $this->getObjectFromArgs($e); | ||
|
||
$dm = $args->getDocumentManager(); | ||
$uow = $dm->getUnitOfWork(); | ||
$metadata = $dm->getClassMetadata(get_class($obj)); | ||
$uow->recomputeSingleDocumentChangeSet($metadata, $obj); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isProxy($obj) | ||
{ | ||
return $obj instanceof Proxy; | ||
} | ||
} |
This file contains 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,44 @@ | ||
<?php | ||
|
||
namespace Vich\GeographicalBundle\Adapter\ORM; | ||
|
||
use Vich\GeographicalBundle\Adapter\AdapterInterface; | ||
use Doctrine\Common\EventArgs; | ||
use Doctrine\ORM\Proxy\Proxy; | ||
|
||
/** | ||
* DoctrineORMAdapter. | ||
* | ||
* @author Dustin Dobervich <ddobervich@gmail.com> | ||
*/ | ||
class DoctrineORMAdapter implements AdapterInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getObjectFromArgs(EventArgs $e) | ||
{ | ||
return $e->getEntity(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function invokeChangesetRecompute(EventArgs $e) | ||
{ | ||
$obj = $this->getObjectFromArgs($e); | ||
|
||
$em = $args->getEntityManager(); | ||
$uow = $em->getUnitOfWork(); | ||
$metadata = $em->getClassMetadata(get_class($obj)); | ||
$uow->recomputeSingleEntityChangeSet($metadata, $obj); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isProxy($obj) | ||
{ | ||
return $obj instanceof Proxy; | ||
} | ||
} |
This file contains 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 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.