Skip to content

Commit

Permalink
EZP-26885: As a Developer I want to future proof my Field Types by us…
Browse files Browse the repository at this point in the history
…ing Doctrine [in external storage] (#1993)

* EZP-26885: Implemented DoctrineStorage for Keyword FT

* EZP-26885: Implemented DoctrineStorage for Url FT

* EZP-26885: Implemented DoctrineStorage for RichText FT

* EZP-26885: Implemented DoctrineStorage for User FT

* [PHPUnit] Added base class for core FT integration tests

* EZP-26885: Added User FT storage GW tests

* EZP-26885: Implemented DoctrineStorage for Page FT

* EZP-26885: Implemented DoctrineStorage for MapLocation FT

* EZP-26885: Implemented DoctrineStorage for Image FT

* EZP-26885: Implemented DoctrineStorage for BinaryFile and Media FTs

* EZP-26885: Added deprecation doc and warnings to LegacyStorage Gateways
  • Loading branch information
alongosz authored and andrerom committed Jul 3, 2017
1 parent bff024a commit d114308
Show file tree
Hide file tree
Showing 35 changed files with 2,885 additions and 31 deletions.

Large diffs are not rendered by default.

Expand Up @@ -15,6 +15,9 @@
use eZ\Publish\Core\Persistence\Database\SelectQuery; use eZ\Publish\Core\Persistence\Database\SelectQuery;
use eZ\Publish\Core\Persistence\Database\InsertQuery; use eZ\Publish\Core\Persistence\Database\InsertQuery;


/**
* @deprecated since 6.11. Use {@see \eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage\Gateway\DoctrineStorage} instead.
*/
abstract class LegacyStorage extends Gateway abstract class LegacyStorage extends Gateway
{ {
/** /**
Expand All @@ -24,6 +27,10 @@ abstract class LegacyStorage extends Gateway


public function __construct(DatabaseHandler $dbHandler) public function __construct(DatabaseHandler $dbHandler)
{ {
@trigger_error(
sprintf('%s is deprecated, use %s instead', self::class, DoctrineStorage::class),
E_USER_DEPRECATED
);
$this->dbHandler = $dbHandler; $this->dbHandler = $dbHandler;
} }


Expand Down
@@ -0,0 +1,72 @@
<?php

/**
* This file is part of the eZ Publish Kernel package.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\FieldType\BinaryFile\BinaryFileStorage\Gateway;

use Doctrine\DBAL\Query\QueryBuilder;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage\Gateway\DoctrineStorage as BaseDoctrineStorage;
use PDO;

/**
* Binary File Field Type external storage DoctrineStorage gateway.
*/
class DoctrineStorage extends BaseDoctrineStorage
{
/**
* {@inheritdoc}
*/
protected function getStorageTable()
{
return 'ezbinaryfile';
}

/**
* {@inheritdoc}
*/
protected function getPropertyMapping()
{
$propertyMap = parent::getPropertyMapping();
$propertyMap['download_count'] = [
'name' => 'downloadCount',
'cast' => 'intval',
];

return $propertyMap;
}

/**
* {@inheritdoc}
*/
protected function setFetchColumns(QueryBuilder $queryBuilder, $fieldId, $versionNo)
{
parent::setFetchColumns($queryBuilder, $fieldId, $versionNo);

$queryBuilder->addSelect(
$this->connection->quoteIdentifier('download_count')
);
}

/**
* {@inheritdoc}
*/
protected function setInsertColumns(QueryBuilder $queryBuilder, VersionInfo $versionInfo, Field $field)
{
parent::setInsertColumns($queryBuilder, $versionInfo, $field);

$queryBuilder
->setValue('download_count', ':downloadCount')
->setParameter(
':downloadCount',
$field->value->externalData['downloadCount'],
PDO::PARAM_INT
)
;
}
}
Expand Up @@ -14,6 +14,9 @@
use eZ\Publish\Core\Persistence\Database\SelectQuery; use eZ\Publish\Core\Persistence\Database\SelectQuery;
use eZ\Publish\Core\Persistence\Database\InsertQuery; use eZ\Publish\Core\Persistence\Database\InsertQuery;


/**
* @deprecated since 6.11. Use {@see \eZ\Publish\Core\FieldType\BinaryFile\BinaryFileStorage\Gateway\DoctrineStorage} instead.
*/
class LegacyStorage extends BaseLegacyStorage class LegacyStorage extends BaseLegacyStorage
{ {
/** /**
Expand Down

0 comments on commit d114308

Please sign in to comment.