Commit d04264c1 authored by Bastian Waidelich's avatar Bastian Waidelich
Browse files

[TASK] Remove deprecated methods & properties

This removes some deprecated methods and calls to them.
Namely Tx_Extbase_Persistence_Query::withUid()
and Tx_Extbase_Utility_TypeHandling::*().
Besides this fixes a doc comment and removes the obsolete
TypeHandlingTest.

Change-Id: I1d08783053c348e34efbc602af57b72f37afe6b8
Resolves: #13745
parent e00137c8
......@@ -407,7 +407,7 @@ class Tx_Extbase_MVC_Controller_ActionController extends Tx_Extbase_MVC_Controll
* Override this method to solve assign variables common for all actions
* or prepare the view in another way before the action is called.
*
* @param Tx_Extbase_View_ViewInterface $view The view to be initialized
* @param Tx_Extbase_MVC_View_ViewInterface $view The view to be initialized
* @return void
* @api
*/
......
......@@ -79,6 +79,11 @@ class Tx_Extbase_MVC_Controller_Argument {
*/
protected $reflectionService;
/**
* @var Tx_Extbase_Service_TypeHandlingService
*/
protected $typeHandlingService;
/**
* Name of this argument
* @var string
......@@ -164,7 +169,7 @@ class Tx_Extbase_MVC_Controller_Argument {
if (!is_string($name)) throw new InvalidArgumentException('$name must be of type string, ' . gettype($name) . ' given.', 1187951688);
if (strlen($name) === 0) throw new InvalidArgumentException('$name must be a non-empty string, ' . strlen($name) . ' characters given.', 1232551853);
$this->name = $name;
$this->dataType = Tx_Extbase_Utility_TypeHandling::normalizeType($dataType);
$this->dataType = $dataType;
}
/**
......@@ -246,6 +251,16 @@ class Tx_Extbase_MVC_Controller_Argument {
public function initializeObject() {
$this->propertyMappingConfiguration = $this->propertyMappingConfigurationBuilder->build('Tx_Extbase_MVC_Controller_MvcPropertyMappingConfiguration');
}
/**
* @param Tx_Extbase_Service_TypeHandlingService $typeHandlingService
* @return void
*/
public function injectTypeHandlingService(Tx_Extbase_Service_TypeHandlingService $typeHandlingService) {
$this->typeHandlingService = $typeHandlingService;
$this->dataType = $this->typeHandlingService->normalizeType($this->dataType);
}
/**
* Returns the name of this argument
*
......
......@@ -273,7 +273,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
} else {
$query = $this->queryFactory->create($className);
return $query->matching(
$query->withUid($identifier))
$query->equals('uid', $identifier))
->execute()
->getFirst();
}
......@@ -470,26 +470,6 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
}
}
/**
* Returns the current field value of the given object property from the storage backend.
*
* @param Tx_Extbase_DomainObject_DomainObjectInterface $object The object
* @param string $propertyName The property name
* @return mixed The field value
*/
protected function getCurrentFieldValue(Tx_Extbase_DomainObject_DomainObjectInterface $object, $propertyName) {
$className = get_class($object);
$columnMap = $this->dataMapper->getDataMap($className)->getColumnMap($propertyName);
$query = $this->queryFactory->create($className);
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
$currentRow = $query->matching(
$query->withUid($object->getUid()))
->execute()
->getFirst();
$fieldValue = $currentRow[$columnMap->getColumnName()];
return $fieldValue;
}
/**
* Returns the removed objects determined by a comparison of the clean property value
* with the actual property value.
......
......@@ -439,22 +439,6 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
return $this->qomFactory->not($constraint);
}
/**
* Matches against the (internal) uid.
*
* @param int $uid The uid to match against
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
* @deprecated since Extbase 1.2.0; was removed in FLOW3; will be removed in Extbase 1.4.0; use equals() instead
*/
public function withUid($operand) {
t3lib_div::logDeprecatedFunction();
return $this->qomFactory->comparison(
$this->qomFactory->propertyValue('uid', $this->getSelectorName()),
Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
$operand
);
}
/**
* Returns an equals criterion used for matching objects against a query
*
......
......@@ -196,15 +196,6 @@ interface Tx_Extbase_Persistence_QueryInterface {
*/
public function logicalNot($constraint);
/**
* Matches against the (internal) identifier.
*
* @param string $uid An identifier to match against
* @return object
* @deprecated since Extbase 1.2.0; was removed in FLOW3; will be removed in Extbase 1.4.0; use equals() instead
*/
public function withUid($uid);
/**
* Returns an equals criterion used for matching objects against a query
*
......
......@@ -28,6 +28,19 @@
*/
class Tx_Extbase_Property_TypeConverter_ObjectStorageConverter extends Tx_Extbase_Property_TypeConverter_AbstractTypeConverter implements t3lib_Singleton {
/**
* @var Tx_Extbase_Service_TypeHandlingService
*/
protected $typeHandlingService;
/**
* @param Tx_Extbase_Service_TypeHandlingService $typeHandlingService
* @return void
*/
public function injectTypeHandlingService(Tx_Extbase_Service_TypeHandlingService $typeHandlingService) {
$this->typeHandlingService = $typeHandlingService;
}
/**
* @var array<string>
*/
......@@ -86,7 +99,8 @@ class Tx_Extbase_Property_TypeConverter_ObjectStorageConverter extends Tx_Extbas
* @api
*/
public function getTypeOfChildProperty($targetType, $propertyName, Tx_Extbase_Property_PropertyMappingConfigurationInterface $configuration) {
$parsedTargetType = Tx_Extbase_Utility_TypeHandling::parseType($targetType);
$parsedTargetType = $this->typeHandlingService->parseType($targetType);
return $parsedTargetType['elementType'];
}
}
......
<?php
/* *
* This script belongs to the Extbase framework. *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License, or (at your *
* option) any later version. *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
* General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with the script. *
* If not, see http://www.gnu.org/licenses/lgpl.html *
* *
* The TYPO3 project - inspiring people to share! *
* */
/**
* Testcase for the Utility\TypeHandling class
*
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
* @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0. Please use Tx_Extbase_Tests_Unit_Service_TypeHandlingServiceTest instead
*/
class Tx_Extbase_Tests_Unit_Utility_TypeHandlingTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
/**
* @test
* @expectedException InvalidArgumentException
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function parseTypeThrowsExceptionOnInvalidType() {
Tx_Extbase_Utility_TypeHandling::parseType('something not a type');
}
/**
* @test
* @expectedException InvalidArgumentException
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function parseTypeThrowsExceptionOnInvalidElementTypeHint() {
Tx_Extbase_Utility_TypeHandling::parseType('string<integer>');
}
/**
* data provider for parseTypeReturnsArrayWithInformation
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function types() {
return array(
array('int', array('type' => 'integer', 'elementType' => NULL)),
array('string', array('type' => 'string', 'elementType' => NULL)),
array('DateTime', array('type' => 'DateTime', 'elementType' => NULL)),
array('Tx_Extbase_Bar', array('type' => 'Tx_Extbase_Bar', 'elementType' => NULL)),
array('Tx_Extbase_Bar', array('type' => 'Tx_Extbase_Bar', 'elementType' => NULL)),
array('array<integer>', array('type' => 'array', 'elementType' => 'integer')),
array('ArrayObject<string>', array('type' => 'ArrayObject', 'elementType' => 'string')),
array('SplObjectStorage<Tx_Extbase_Bar>', array('type' => 'SplObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
array('SplObjectStorage<Tx_Extbase_Bar>', array('type' => 'SplObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
);
}
/**
* @test
* @dataProvider types
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function parseTypeReturnsArrayWithInformation($type, $expectedResult) {
$this->assertEquals(
Tx_Extbase_Utility_TypeHandling::parseType($type),
$expectedResult
);
}
/**
* data provider for normalizeTypesReturnsNormalizedType
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function normalizeTypes() {
return array(
array('int', 'integer'),
array('double', 'float'),
array('bool', 'boolean'),
array('string', 'string')
);
}
/**
* @test
* @dataProvider normalizeTypes
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function normalizeTypesReturnsNormalizedType($type, $normalized) {
$this->assertEquals(Tx_Extbase_Utility_TypeHandling::normalizeType($type), $normalized);
}
}
?>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment