how does the Yii2 replace the @app/views/layouts/main.php with @app/themes/basic/layouts/main.php when I use view component

If I use view component like the document says




return [

    'components' => [

        'view' => [

            'theme' => [

                'basePath' => '@app/themes/basic',

                'baseUrl' => '@web/themes/basic',

                'pathMap' => [

                    '@app/views' => '@app/themes/basic',

                ],

            ],

        ],

    ],

];



does it means that the main.php in the folder @app/themes/basic/layouts/main.php will replace the main.php in the folder @app/views/layouts/main.php ?

and how yii2 achieve this? I couldn’t figure out though I traced the controller to find something which could help me understand the logic.