Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-26885: As a Developer I want to future proof my Field Types by us…
…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
Showing
35 changed files
with
2,885 additions
and
31 deletions.
There are no files selected for viewing
414 changes: 414 additions & 0 deletions
414
eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php
Large diffs are not rendered by default.
Oops, something went wrong.
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
72 changes: 72 additions & 0 deletions
72
eZ/Publish/Core/FieldType/BinaryFile/BinaryFileStorage/Gateway/DoctrineStorage.php
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 | |||
) | |||
; | |||
} | |||
} |
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.