Permalink
Browse files

Remove doctrine storage adapters, resolves #538 (#540)

  • Loading branch information...
christeredvartsen committed Apr 26, 2017
1 parent 76eb78f commit 000765b9bf44fe0043bc9f105419818cdc0d4db4
@@ -472,54 +472,6 @@ Examples
// ...
];
-Doctrine
-++++++++
-
-This adapter uses the `Doctrine Database Abstraction Layer <http://www.doctrine-project.org/projects/dbal.html>`_. The options you pass to the constructor of this adapter is passed to the underlying classes, so have a look at the Doctrine DBAL documentation over at `doctrine-project.org <http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/index.html>`_. When using this adapter you need to create the required tables in the RDBMS first, as specified in the :ref:`database-setup` section.
-
-Examples
-^^^^^^^^
-
-Here are some examples on how to use the Doctrine adapter in the configuration file:
-
-1) Use a PDO instance to connect to a SQLite database:
-
-.. code-block:: php
-
- <?php
- return [
- // ...
-
- 'storage' => function() {
- return new Imbo\Storage\Doctrine([
- 'pdo' => new PDO('sqlite:/path/to/database'),
- ]);
- },
-
- // ...
- ];
-
-2) Connect to a MySQL database using PDO:
-
-.. code-block:: php
-
- <?php
- return [
- // ...
-
- 'storage' => function() {
- return new Imbo\Storage\Doctrine([
- 'dbname' => 'database',
- 'user' => 'username',
- 'password' => 'password',
- 'host' => 'hostname',
- 'driver' => 'pdo_mysql',
- ]);
- },
-
- // ...
- ];
-
.. _filesystem-storage-adapter:
Filesystem
@@ -345,7 +345,7 @@ The event listener has two roles, one is to generate the variations when new ima
Imbo ships with MongoDB and Doctrine adapters for storing metadata about these variations. If you want to use a different database, you can implement the ``Imbo\EventListener\ImageVariations\Database\DatabaseInterface`` interface and set the name of the class in the configuration of the event listener.
-In the same way, Imbo ships three different adapters for storing the actual image variation data (the downscaled images): GridFS, Doctrine and Filesystem. See examples of their configuration below.
+In the same way, Imbo ships two different adapters for storing the actual image variation data (the downscaled images): GridFS and Filesystem. See examples of their configuration below.
The event listener supports for following configuration parameters:
@@ -494,7 +494,7 @@ The event listener supports for following configuration parameters:
// ...
];
- The Doctrine adapter is an alternative for storing both metadata and variation data. This adapter uses the `Doctrine Database Abstraction Layer <http://www.doctrine-project.org/projects/dbal.html>`_. When using this adapter you need to create the required tables in the RDBMS first, as specified in the :ref:`database-setup` section. Note that you can either pass a PDO instance (as the ``pdo`` parameter) or specify connection details. Example usage:
+ The Doctrine adapter is an alternative for storing metadata. This adapter uses the `Doctrine Database Abstraction Layer <http://www.doctrine-project.org/projects/dbal.html>`_. When using this adapter you need to create the required tables in the RDBMS first, as specified in the :ref:`database-setup` section. Example usage:
.. code-block:: php
@@ -513,15 +513,11 @@ The event listener supports for following configuration parameters:
'password' => 'imbo_password',
'host' => 'localhost',
'driver' => 'mysql',
- 'tableName' => 'imagevariations',
-
- // OR, pass a PDO instance
- 'pdo' => null,
+ 'tableName' => 'imagevariations', // Default value, can be omitted
]
],
'storage' => [
- 'adapter' => 'Imbo\EventListener\ImageVariations\Storage\Doctrine',
- 'params' => [] // Same as above
+ 'adapter' => 'Imbo\EventListener\ImageVariations\Storage\GridFS',
],
],
],
@@ -530,7 +526,7 @@ The event listener supports for following configuration parameters:
// ...
];
- The third option for the storage adapter is the Filesystem adapter. It's fairly straightforward and uses a similar algorithm when generating file names as the :ref:`filesystem-storage-adapter` storage adapter. Example usage:
+ The other option for the storage adapter is the Filesystem adapter. It's fairly straightforward and uses a similar algorithm when generating file names as the :ref:`filesystem-storage-adapter` storage adapter. Example usage:
.. code-block:: php
@@ -173,12 +173,8 @@ MySQL
.. literalinclude:: ../../setup/doctrine.mysql.sql
:language: sql
-The ``storage_images`` table is only needed if you plan on storing the actual images in the database as well.
-
SQLite
~~~~~~
.. literalinclude:: ../../setup/doctrine.sqlite.sql
:language: sql
-
-The ``storage_images`` table is only needed if you plan on storing the actual images in the database as well.
@@ -18,6 +18,14 @@ Below are the changes you need to be aware of when upgrading to Imbo-3.0.0.
:local:
:depth: 2
+Doctrine-based storage adapters have been removed
++++++++++++++++++++++++++++++++++++++++++++++++++
+
+The following storage adapters have been removed:
+
+- ``Imbo\Storage\Doctrine``
+- ``Imbo\EventListener\ImageVariations\Storage\Doctrine``
+
XML-support has been removed
++++++++++++++++++++++++++++
@@ -41,3 +41,4 @@ gaussian
Mongo
callables
Backblaze
+rethrow
View
@@ -34,22 +34,6 @@ CREATE TABLE IF NOT EXISTS `shorturl` (
KEY `params` (`user`,`imageIdentifier`,`extension`,`query`(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci;
-CREATE TABLE IF NOT EXISTS `storage_images` (
- `user` varchar(255) COLLATE utf8_danish_ci NOT NULL,
- `imageIdentifier` varchar(255) COLLATE utf8_danish_ci NOT NULL,
- `data` blob NOT NULL,
- `updated` int(10) unsigned NOT NULL,
- PRIMARY KEY (`user`,`imageIdentifier`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci;
-
-CREATE TABLE IF NOT EXISTS `storage_image_variations` (
- `user` varchar(255) COLLATE utf8_danish_ci NOT NULL,
- `imageIdentifier` varchar(255) COLLATE utf8_danish_ci NOT NULL,
- `width` int(10) unsigned NOT NULL,
- `data` blob NOT NULL,
- PRIMARY KEY (`user`,`imageIdentifier`,`width`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci;
-
CREATE TABLE IF NOT EXISTS `imagevariations` (
`user` varchar(255) COLLATE utf8_danish_ci NOT NULL,
`imageIdentifier` varchar(255) COLLATE utf8_danish_ci NOT NULL,
View
@@ -36,22 +36,6 @@ CREATE INDEX shorturlparams ON shorturl (
query
);
-CREATE TABLE IF NOT EXISTS storage_images (
- user TEXT NOT NULL,
- imageIdentifier TEXT NOT NULL,
- data BLOB NOT NULL,
- updated INTEGER NOT NULL,
- PRIMARY KEY (user,imageIdentifier)
-);
-
-CREATE TABLE IF NOT EXISTS storage_image_variations (
- user TEXT NOT NULL,
- imageIdentifier TEXT NOT NULL,
- width INTEGER NOT NULL,
- data BLOB NOT NULL,
- PRIMARY KEY (user,imageIdentifier,width)
-);
-
CREATE TABLE IF NOT EXISTS imagevariations (
user TEXT NOT NULL,
imageIdentifier TEXT NOT NULL,
@@ -1,161 +0,0 @@
-<?php
-/**
- * This file is part of the Imbo package
- *
- * (c) Christer Edvartsen <cogo@starzinger.net>
- *
- * For the full copyright and license information, please view the LICENSE file that was
- * distributed with this source code.
- */
-
-namespace Imbo\EventListener\ImageVariations\Storage;
-
-use Doctrine\DBAL\Configuration,
- Doctrine\DBAL\DriverManager,
- Doctrine\DBAL\Connection;
-
-/**
- * Doctrine 2 image variations storage driver
- *
- * Parameters for this driver:
- *
- * - <pre>(string) dbname</pre> Name of the database to connect to
- * - <pre>(string) user</pre> Username to use when connecting
- * - <pre>(string) password</pre> Password to use when connecting
- * - <pre>(string) host</pre> Hostname to use when connecting
- * - <pre>(string) driver</pre> Which driver to use
- *
- * @author Espen Hovlandsdal <espen@hovlandsdal.com>
- * @package Storage
- */
-class Doctrine implements StorageInterface {
- /**
- * Parameters for the Doctrine connection
- *
- * @var array
- */
- private $params = [
- 'dbname' => null,
- 'user' => null,
- 'password' => null,
- 'host' => null,
- 'driver' => null,
- ];
-
- /**
- * Name of the table used for storing the images
- *
- * @var string
- */
- private $tableName = 'storage_image_variations';
-
- /**
- * Doctrine connection
- *
- * @var \Doctrine\DBAL\Connection
- */
- private $connection;
-
- /**
- * Class constructor
- *
- * @param array $params Parameters for the driver
- * @param \Doctrine\DBAL\Connection $connection Optional connection instance
- */
- public function __construct(array $params, Connection $connection = null) {
- $this->params = array_merge($this->params, $params);
-
- if ($connection !== null) {
- $this->setConnection($connection);
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function storeImageVariation($user, $imageIdentifier, $blob, $width) {
- return (boolean) $this->getConnection()->insert($this->getTableName($user, $imageIdentifier), [
- 'user' => $user,
- 'imageIdentifier' => $imageIdentifier,
- 'data' => $blob,
- 'width' => (int) $width,
- ]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getImageVariation($user, $imageIdentifier, $width) {
- $query = $this->getConnection()->createQueryBuilder();
- $query->select('data')
- ->from($this->getTableName($user, $imageIdentifier), 'i')
- ->where('user = :user')
- ->andWhere('imageIdentifier = :imageIdentifier')
- ->andWhere('width = :width')
- ->setParameters([
- ':user' => $user,
- ':imageIdentifier' => $imageIdentifier,
- ':width' => (int) $width,
- ]);
-
- $stmt = $query->execute();
- $row = $stmt->fetch();
-
- return $row ? $row['data'] : null;
- }
-
- /**
- * {@inheritdoc}
- */
- public function deleteImageVariations($user, $imageIdentifier, $width = null) {
- $query = [
- 'user' => $user,
- 'imageIdentifier' => $imageIdentifier
- ];
-
- if ($width !== null) {
- $query['width'] = $width;
- }
-
- $tableName = $this->getTableName($user, $imageIdentifier);
- return (boolean) $this->getConnection()->delete($tableName, $query);
- }
-
- /**
- * Set the connection instance
- *
- * @param \Doctrine\DBAL\Connection $connection The connection instance
- * @return Doctrine
- */
- private function setConnection(Connection $connection) {
- $this->connection = $connection;
-
- return $this;
- }
-
- /**
- * Get the Doctrine connection
- *
- * @return \Doctrine\DBAL\Connection
- */
- private function getConnection() {
- if ($this->connection === null) {
- $this->connection = DriverManager::getConnection($this->params, new Configuration());
- }
-
- return $this->connection;
- }
-
- /**
- * Method that can be overridden to dynamically select table names based on the user and the
- * image identifier. The default implementation does not use them for anything, and simply
- * returns the default table name.
- *
- * @param string $user The user which the image belongs to
- * @param string $imageIdentifier The image identifier to fetch
- * @return string Returns a table name where the image is located
- */
- protected function getTableName($user, $imageIdentifier) {
- return $this->tableName;
- }
-}
Oops, something went wrong.

0 comments on commit 000765b

Please sign in to comment.