App::import('Model', 'User') use in CakePHP 3.9.x

Hello Guys … Pretty new to CakePHP … I have inherited a web application developed in CakePHP 1.2. I am in the process of migrating in to version 3.9.4. I am having an issue in a method in which there is an import for a Model using App::import('Model', 'User'); but due to deprecation it can not be used. Please guide me what will be the best way to handle this in CakePHP 3.9. Looking forward to your guidance. Thank you.

public function login($type = 'guest', $credentials = null)
		$user = array();
		if (is_string($type) && ($type == 'guest' || $type == 'cookie')) {
			App::import("Model", "User");
			$userModel = new User;

			$user = $userModel->authsomeLogin($type, $credentials);
		} elseif (is_array($type)) {
			$user = $type;
		Configure::write($this->configureKey, $user);
		$this->Session->write('UserAuth', $user);
		return $user;

See loading additional models.

1 Like

Thanks @Zuluru … will check and let you know.