[TYPO3-mvc] Transition Guide for Persistance Rewrite
Steffen Ritter
info at rs-websystems.de
Sun Jul 19 12:13:10 CEST 2009
Sebastian Kurfürst schrieb:
> Hi Steffen,
>
> just copy/paste your custom methods inside your repository here! We can
> help you how to rewrite this then!
>
> Greets,
> Sebastian
Hi Sebastian,
following two function I have in a class which extends
Tx_Extbase_Persistence_Repository. I think, I just have to adopt the
first, since the second uses the first.
/**
* Returns all objects of this repository with first letter as $index
* @param string $index First letter of the street
* @param string $filterText street name we may search
* @return array An array of objects, empty if no objects found
*/
public function findByIndex($index = '',$searchText = '') {
$whereStatement = ' SUBSTRING(streetname,1,1) LIKE BINARY \''
.strtoupper($index) .'\'';
if ( $searchText != '' ) {
$whereStatement .= ' AND streetname LIKE \'%'. $searchText .'%\'';
}
return $this->findWhere($whereStatement,'','streetname ASC');
}
/**
* Returns all index-Objects with streets filled in
* @param string $filterText street name we may search
* @return array An array of objects, empty if no objects found
*/
public function getIndexedStreets($filterText = '') {
$letters = explode(' ','A Ä B C D E F G H I J K L M N O Ö P Q R S T U Ü
V W X Y Z');
$indexes = array();
foreach($letters AS $letter) {
$streetIndex = Tx_Rsbezirke_Domain_Model_StreetIndex;
$streetIndex =
t3lib_div::makeinstance('Tx_Rsbezirke_Domain_Model_StreetIndex');
$streetIndex->setIndexName($letter);
$streetIndex->setStreets($this->findByIndex($letter,$filterText));
$indexes[] = $streetIndex;
}
return $indexes ;
}
Probably we may add such an Indexed-Wrapper to to the base Repository or
may provide an Tx_Extbase_Indexed_Persistence_Repository since we
often need alpha-browser facilities or grouping of lists by first letter
or sth else...
regards
Steffen
More information about the TYPO3-project-typo3v4mvc
mailing list