Cannot override properties from extension


use Kmergen\User\UserModuleInterface;
use Kmergen\User\UserModule;

/** @var array $params */

return [
    UserModuleInterface::class => [
        'class' => UserModule::class,
        // The username should be case sensitive.
        // The time in seconds within which the user should confirm the account.
        'tokenConfirmWithin()' => [7689],
        // The time in seconds within which the user should recover the password.
        'tokenRecoverWithin()' => [4500],




 * @var WebView $this
 * @var TranslatorInterface $translator
 * @var ApplicationParameters $applicationParameters

use App\ApplicationParameters;
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\View\WebView;
use Kmergen\User\UserModuleInterface;


<div class="mil-banner">
    <div class="container">
        <div class="mil-banner-content-frame">
            <div class="mil-banner-content">
                <h1><?= $applicationParameters->getName() ?></h1>
                <h2><?= $newCon ?></h2>
                <h2><?= $module->getTokenConfirmWithin() ?></h2>

The output is 86400 and not how expected 7689.
The 86400 is the default value of kmergen/User/UserModule

Should be property name not function 'tokenConfirmWithin' => 7689,

No. that is a private property. Need setter function to set value.

Look at app-parameters, there it works as expected.

Looks good to me.
Could it be that somehow Yii is not recognizing your configuration?
Am not too much yet into Yii3, but If you can provide a sample app I can look into it

Seems, problem in module:

Need use $new->tokenConfirmWithin = $tokenConfirmWithin; insted of $this->....

1 Like

That’s it, thank you.

The solution here:


public function tokenConfirmWithin(int $tokenConfirmWithin): self
        $new = clone $this;
        $this->tokenConfirmWithin = $tokenConfirmWithin;
        return $new;


public function tokenConfirmWithin(int $tokenConfirmWithin): self
        $new = clone $this;
        $new->tokenConfirmWithin = $tokenConfirmWithin;
        return $new;

One question about the following behavior:

Is it normal that you cannot set the value on runtim for e.g in a controller action class

final class RegistrationAction extends AbstractAction

    public function index(
        UserModuleInterface $module,
        ServerRequestInterface $request,
        Validator $validator,
        RegistrationFormModel $form
    ): ResponseInterface {
         $hydrator = new Hydrator();

        // $parsedBody = $request->getParsedBody([$form->getFormName()]);
        if ($request->getMethod() === Method::POST) {
            $hydrator->hydrate($form, $request->getParsedBody()[$form->getFormName()]);
        $newCon = $module->getTokenConfirmWithin();
        return $this->viewRenderer->withViewPath($this->module->getViewPath() ?: __DIR__ . '/view')->render('index', ['newCon' => $newCon, 'form' => $form]);

Then the $newCon is not 34092, it has the value from setting in configuration.

I see, didn’t paid attention to property scope.