Extend Repository of a foreign TYPO3 extbase extension -
i have installed extension 'femanager' on typo3 6.2 installation , extended own fields stored , read database.
now there action in controller calls upon userrepository findbyusergroup() method render list of fe_users filter.
i want extend search filter, , therefore must alter method findbyusergroup() extension. possible, , if so, how?
i have been developing lot typo3, not extbase. familiar hooks , signal/slots , these kinds, don't running. hints how make typo3 use repository extends 1 femanager?
<?php namespace ngib\ngibmembers\domain\repository; use in2\femanager\domain\repository\userrepository; /*************************************************************** * copyright notice * * (c) 2013 alex kellner <alexander.kellner@in2code.de>, in2code * * rights reserved * * script part of typo3 project. typo3 project * free software; can redistribute and/or modify * under terms of gnu general public license published * free software foundation; either version 3 of license, or * (at option) later version. * * gnu general public license can found @ * http://www.gnu.org/copyleft/gpl.html. * * script distributed in hope useful, * without warranty; without implied warranty of * merchantability or fitness particular purpose. see * gnu general public license more details. * * copyright notice must appear in copies of script! ***************************************************************/ /** * member repository * * @package ngibmembers * @license http://www.gnu.org/licenses/gpl.html * gnu general public license, version 3 or later */ class memberrepository extends userrepository { /** * find users commaseparated usergroup list * * @param string $usergrouplist commaseparated list of usergroup uids * @param array $settings flexform , typoscript settings * @param array $filter filter array * @return query object */ public function findbyusergroups($usergrouplist, $settings, $filter) { $query = $this->createquery(); // $and = array( $query->greaterthan('uid', 0) ); if (!empty($usergrouplist)) { $selectedusergroups = generalutility::trimexplode(',', $usergrouplist, true); $or = array(); foreach ($selectedusergroups $group) { $or[] = $query->contains('usergroup', $group); } $and[] = $query->logicalor($or); } if (!empty($filter['searchword'])) { $searchwords = generalutility::trimexplode(' ', $filter['searchword'], 1); $fieldstosearch = generalutility::trimexplode(',', $settings['list']['filter']['searchword']['fieldstosearch'], true); foreach ($searchwords $searchword) { $or = array(); foreach ($fieldstosearch $searchfield) { $or[] = $query->like($searchfield, '%' . $searchword . '%'); } $and[] = $query->logicalor($or); } } if(!empty($filter['ngbl'])){ $and[] = $query->greaterthan('ngbl',1); } $query->matching($query->logicaland($and)); // sorting $sorting = queryinterface::order_ascending; if ($settings['list']['sorting'] == 'desc') { $sorting = queryinterface::order_descending; } $field = preg_replace('/[^a-za-z0-9_-]/', '', $settings['list']['orderby']); $query->setorderings( array( $field => $sorting ) ); // set limit if (intval($settings['list']['limit']) > 0) { $query->setlimit(intval($settings['list']['limit'])); } $users = $query->execute(); return $users; } }
you can tell extbase load class instead of original 1 typoscript
config.tx_extbase { objects { in2\femanager\domain\repository\userrepository { classname = ngib\ngibmembers\domain\repository\memberrepository } } }
you still have extend original class, repo should called now.
Comments
Post a Comment