Welcome Guest, Not a member yet? Register   Sign In
Ci4 Learn with Myth
#1

Hello,
This is my first post. I try o learn ci4. I have some big project working on ci3.
Now i have to improve them and also move on ci4.
I have fresh install on centos 8 with composer.
Because i need a complex system admin with roles and many more i decide to use myth. I need to extend Myth because i need to do a phone verification with sms and also mail verification.

I am stuck on how to extend Myth controller with a new method. I don`t want to modify myth\auth\src\controllers\AuthController.php.
I understande i can create app\controllers\AuthController.php but is not working:

PHP Code:
<?php namespace App\Controllers;

use 
Myth\Auth\Controllers\AuthController as MyAuth;

class 
AuthController extends MyAuth
{
  public function pregister() {
echo 
"a";
//return $this->_render($this->config->views['pregister'], ['config' => $this->config]);
}

I also modify 
PHP Code:
public $views = [
 
'login'   => 'Myth\Auth\Views\login',
 
'register' => 'Myth\Auth\Views\register',
 
'pregister' => 'Myth\Auth\Views\register',
 
'forgot'   => 'Myth\Auth\Views\forgot',
 
'reset'   => 'Myth\Auth\Views\reset',
 
'emailForgot' => 'Myth\Auth\Views\emails\forgot',
 
'emailActivation' => 'Myth\Auth\Views\emails\activation',
 ]; 
Why is not working? What i am doind wrong?
Reply
#2

Try this
PHP Code:
use Myth\Auth\Controllers\AuthController;

class 
MyAuth extends AuthController 
{
    public function __construct()
    {
        parent::__construct();
    }


What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Calling the parent constructor is unnecessary unless you are providing additional functionality - it will be called automatically. @cuculetea can you elaborate on what’s not working? Your setup looks correct - though will also need to add a route to your app/Config/Routes.php in order to reach your new method.
Reply
#4

why not just publish it (use cli), it make sense and easier.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB