-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add recomputeSingleDocumentChangeset and document class clear to unit…
… of work
- Loading branch information
Showing
16 changed files
with
722 additions
and
28 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
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,13 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Refugis\ODM\Elastica\Exception; | ||
|
||
use Throwable; | ||
|
||
class DocumentNotManagedException extends InvalidArgumentException | ||
{ | ||
public function __construct(object $document, Throwable $previous = null) | ||
{ | ||
parent::__construct(\sprintf('Document %s is not managed. A document is managed if it\'s fetched from the database or registered as new through DocumentManager#persist', self::objToStr($document)), 0, $previous); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Refugis\ODM\Elastica\Exception; | ||
|
||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface | ||
{ | ||
/** | ||
* Helper method to show an object as string. | ||
* | ||
* @param object $obj | ||
* | ||
* @return string | ||
*/ | ||
protected static function objToStr(object $obj): string | ||
{ | ||
return \method_exists($obj, '__toString') ? (string) $obj : \get_class($obj).'@'.\spl_object_hash($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,30 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Refugis\ODM\Elastica\Exception; | ||
|
||
use Refugis\ODM\Elastica\UnitOfWork; | ||
use Throwable; | ||
|
||
class UnexpectedDocumentStateException extends InvalidArgumentException | ||
{ | ||
public function __construct(int $state, Throwable $previous = null) | ||
{ | ||
parent::__construct(\sprintf('Unexpected document state "%s"', self::getStateAsString($state)), 0, $previous); | ||
} | ||
|
||
/** | ||
* Gets the state string. | ||
*/ | ||
private static function getStateAsString(int $state): string | ||
{ | ||
switch ($state) { | ||
case UnitOfWork::STATE_MANAGED: return 'MANAGED'; | ||
case UnitOfWork::STATE_NEW: return 'NEW'; | ||
case UnitOfWork::STATE_DETACHED: return 'DETACHED'; | ||
case UnitOfWork::STATE_REMOVED: return 'REMOVED'; | ||
|
||
default: | ||
return \sprintf('UNKNOWN (%u)', $state); | ||
} | ||
} | ||
} |
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
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.