Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Moved to a more structured hierarchy #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Doctrine/KeyValueStore/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class Configuration
public function getMappingDriverImpl()
{
if (! isset($this->config['mappingDriver'])) {
throw KeyValueStoreException::mappingDriverMissing();
throw new Exception\Exception(
'No mapping driver was assigned to the configuration. Use $config->setMappingDriverImpl()'
);
}

return $this->config['mappingDriver'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore\Storage;
namespace Doctrine\KeyValueStore;

use Doctrine\KeyValueStore\KeyValueStoreException;

class StorageException extends KeyValueStoreException
interface Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore;
namespace Doctrine\KeyValueStore\Exception;

class KeyValueStoreException extends \Exception
use Doctrine\KeyValueStore\Exception as BaseException;

class Exception extends \Exception implements BaseException
{
public static function mappingDriverMissing()
{
return new self('No mapping driver was assigned to the configuration. Use $config->setMappingDriverImpl()');
}
}
27 changes: 27 additions & 0 deletions lib/Doctrine/KeyValueStore/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore\Exception;

use Doctrine\KeyValueStore\Exception as BaseException;

class InvalidArgumentException extends \InvalidArgumentException implements BaseException
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore;
namespace Doctrine\KeyValueStore\Exception;

class NotFoundException extends KeyValueStoreException
class NotFoundException extends Exception
{
}
27 changes: 27 additions & 0 deletions lib/Doctrine/KeyValueStore/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore\Exception;

use Doctrine\KeyValueStore\Exception as BaseException;

class RuntimeException extends \RuntimeException implements BaseException
{
}
4 changes: 2 additions & 2 deletions lib/Doctrine/KeyValueStore/Id/CompositeIdHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public function normalizeId(ClassMetadata $metadata, $key)
if (! $metadata->isCompositeKey && ! is_array($key)) {
$id = [$metadata->identifier[0] => $key];
} elseif (! is_array($key)) {
throw new \InvalidArgumentException('Array of identifier key-value pairs is expected!');
throw new Exception\InvalidArgumentException('Array of identifier key-value pairs is expected!');
} else {
$id = [];
foreach ($metadata->identifier as $field) {
if (! isset($key[$field])) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
"Missing identifier field $field in request for the primary key."
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore\Id\Exception;

use Doctrine\KeyValueStore\Exception\InvalidArgumentException as BaseInvalidArgumentException;

class InvalidArgumentException extends BaseInvalidArgumentException
{
}
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)

$entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\KeyValueStore\Mapping\Annotations\Entity');
if (! $entityAnnot) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
$metadata->storageName = $entityAnnot->storageName;

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function initialize()

protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
{
throw new \InvalidArgumentException('aliasing is not supported.');
throw new Exception\InvalidArgumentException('aliasing is not supported.');
}

protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
Expand All @@ -64,7 +64,7 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS
}

if (! $class->identifier) {
throw new \InvalidArgumentException('Class ' . $class->name . ' has no identifier.');
throw new Exception\InvalidArgumentException('Class ' . $class->name . ' has no identifier.');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore\Mapping\Exception;

use Doctrine\KeyValueStore\Exception\InvalidArgumentException as BaseInvalidArgumentException;

class InvalidArgumentException extends BaseInvalidArgumentException
{
}
4 changes: 2 additions & 2 deletions lib/Doctrine/KeyValueStore/Mapping/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public function loadMetadataForClass($className, CommonClassMetadata $metadata)
try {
$xmlRoot = $this->getElement($className);
} catch (MappingException $exception) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}

if ($xmlRoot->getName() != 'entity') {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}

$class = new \ReflectionClass($className);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Mapping/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function loadMetadataForClass($className, CommonClassMetadata $metadata)
try {
$element = $this->getElement($className);
} catch (MappingException $exception) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}

$class = new \ReflectionClass($className);
Expand Down
27 changes: 27 additions & 0 deletions lib/Doctrine/KeyValueStore/Query/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\KeyValueStore\Query\Exception;

use Doctrine\KeyValueStore\Exception\RuntimeException as BaseRuntimeException;

class RuntimeException extends BaseRuntimeException
{
}
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Query/RangeQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function execute()
$storage = $this->em->unwrap();

if (! $storage instanceof RangeQueryStorage) {
throw new \RuntimeException(
throw new Exception\RuntimeException(
'The storage backend ' . $storage->getName() . ' does not support range queries.'
);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Doctrine\KeyValueStore\Storage;

use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Exception\NotFoundException;
use Doctrine\KeyValueStore\Query\RangeQuery;
use Doctrine\KeyValueStore\Query\RangeQueryStorage;
use WindowsAzure\Common\ServiceException;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function insert($storageName, $key, array $data)
if ($e->getCode() == 404) {
$this->client->createTable($storageName);
} else {
throw new StorageException(
throw new Exception\Exception(
'Could not save entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(),
$e->getCode(),
$e
Expand All @@ -101,7 +101,7 @@ public function update($storageName, $key, array $data)
try {
$this->client->updateEntity($storageName, $entity);
} catch (ServiceException $e) {
throw new StorageException(
throw new Exception\Exception(
'Could not update entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(),
$e->getCode(),
$e
Expand All @@ -119,7 +119,7 @@ public function delete($storageName, $key)
try {
$this->client->deleteEntity($storageName, $partitonKey, $rowKey);
} catch (ServiceException $e) {
throw new StorageException(
throw new Exception\Exception(
'Could not delete entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(),
$e->getCode(),
$e
Expand All @@ -140,7 +140,7 @@ public function find($storageName, $key)
if ($e->getCode() === 404) {
throw new NotFoundException();
} else {
throw new StorageException(
throw new Exception\Exception(
'Could not find entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(),
$e->getCode(),
$e
Expand Down Expand Up @@ -185,7 +185,7 @@ public function executeRangeQuery(RangeQuery $query, $storageName, $key, \Closur

foreach ($query->getConditions() as $condition) {
if (! in_array($condition[0], ['eq', 'neq', 'le', 'lt', 'ge', 'gt'])) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
'Windows Azure Table only supports eq, neq, le, lt, ge, gt as conditions.'
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Storage/CassandraStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use Cassandra\ExecutionOptions;
use Cassandra\Session;
use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Exception\NotFoundException;

/**
* Cassandra Storage Engine for KeyValueStore.
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/KeyValueStore/Storage/CouchDbStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getName()
/**
* @param string $storageName
* @param array|string $key
*
*
* @return string
*/
private function flattenKey($storageName, $key)
Expand All @@ -128,7 +128,7 @@ private function flattenKey($storageName, $key)
}

if (! is_array($key)) {
throw new \InvalidArgumentException('The key should be a string or a flat array.');
throw new Exception\InvalidArgumentException('The key should be a string or a flat array.');
}

foreach ($key as $property => $value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Storage/CouchbaseStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Doctrine\KeyValueStore\Storage;

use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Exception\NotFoundException;

/**
* @author Simon Schick <simonsimcity@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Storage/DBALStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace Doctrine\KeyValueStore\Storage;

use Doctrine\DBAL\Connection;
use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Exception\NotFoundException;

/**
* Relational databased backed system.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Exception\ResourceNotFoundException;
use Aws\DynamoDb\Iterator\ItemIterator;
use Doctrine\KeyValueStore\NotFoundException;
use Doctrine\KeyValueStore\Exception\NotFoundException;

/**
* DyanmoDb storage
Expand Down
Loading