0
votes

I created my own (Typo3 6.2) extension with the Extension Builder to extend fe_users and all is working fine but I would like to be able to use the showAction based on the username instead of the uid of the user.

The goal is simply to be able to call the controller on the frontend like this:

my.domain.com/users?tx_crilcq_crilcqmember[username]=johndoe&tx_crilcq_crilcqmember[action]=show

instead of this:

my.domain.com/users?tx_crilcq_crilcqmember[member]=2&tx_crilcq_crilcqmember[action]=show

At first I thought that I had to modify the extended repository (class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository) but it seems that it is used for requests returning an array of entries and not to reference a single instance. Don't know if I'm right about this but my feeling is that the thing I need to modify is somewhere else.

Any clue someone?

1

1 Answers

3
votes

An Extbase repository has magic methods findBy[property], findOneBy[property] and countBy[property], that returns/counts objects by the given property.

You can change your show action as shown below:

/**
 * @param string $username
 * @return void
 */
public function showAction($username) {
    $user = $this->memberClassRepository->findOneByUsername($username);
    $this->view->assign('user', $user);
}