-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: Cannot instantiate abstract class ExampleUserIdentity #46
Comments
You can't use the example identity provided with the module directly. That's why it has the Example prefix in the name and is abstract. You could create a UserIdentity class that extends it, but really the best way is to copy that class to your components directory and just rename it. Where do you import usr components and models? |
I was tryed copy and rename, but result exactly the same with different class name, regardless of what name of file and class I chose. I was tryed to import with code like Extra, If I use class name 'UserIdentity' I have extra error from NetBeans parser in UserIdentity.php line 30, "Impossible to create abstract class instance \UserIdentity", but no runtime error there. Possible that have some relations to the fact that "UserIdentity" already defined within Gii extension. I have checked with debug dump, $userIdentityClass in ProfileForm.php has correct value. Sime issues with php version/enveronment? Any ideas? |
Yii import runs before modules are registered and doesn't know module aliases. If you want to use it there you have to first define the usr alias yourself. If you copy the code, remove the |
%$#^$$#! I miss that simple thing, sorry a lot! |
No problem, I'm happy to help and see that anybody actually uses my module. As you can see from browsing the issues, there is almost no user feedback. |
Thanks! But I told you that I have to code now after about 15 years of other job? So, I am really stupid as a developer )))))) I fix that problem, but now nothing happens when "register" form is submitted ))) I guess that I need to ancest/copy all classes named starts with "Example" to get user management in my Yii instance up and running? Which way is the best? To move it to corresponding Yii folders? Rename and edit on place? Both approaches leads to future problems with your module update. Think, it's much better if you have "turnkey" module if you wish you module widely deployed. |
The best way is to copy all (three) models and user identity to your app and rename them removing the "Example" prefix and "abstract" keyword if present. Those examples implement all available interfaces that allows using all module features. You probably don't need most of them, so you could strip those example classes after copying them. For example, there's a separate model and table name for used passwords and extra columns for one time passwords. Because the module relies on interfaces it doesn't require a specific implementation of them. Provided identity class doesn't even have to implement all interface, only selected ones. Even if I update the example implementations those changes are not required for the whole module to work. The main reason for me to make the module was to be able to plug it into existing projects without modifying the user table. All other modules used hardcoded column names, like |
Thanks for explanations. Some of topics I guess, some of them new and usefull, so let's have some code :))) |
I must say I haven't had much occasions to use interfaces in my career so I understand. Also, I'd like to improve the docs (readme) to make this more clear. It would be great to use your current experiences as a newcomer to at least figure out the order in which the instructions should be written. If you'd be willing to give it some time you can edit a single file directly on Github. |
Think I am not representative! I'am just have to make some prototype to check how it works and then on success convert the project to the normal mode where each man do right job. I was strong in OOP almost two decades ago, and it's helps, but not enough.
I think at your separate case "Fasttrack" should looks like:
Guess, it's useless for hardcore profi, but valued for newbies like me ;) |
I have done 3 steps like described above and it works ;) Fine! Could you be so kind to explain:
Thanks in advance! |
|
I try to implement the module and use ExampleUserIdentity directly. This lead to runtime error on 'register' action
Fatal error: Cannot instantiate abstract class ExampleUserIdentity in ......\protected\modules\usr\models\RecoveryForm.php on line 58
PHP error table shown after the form fields.
When I try to explicitly import classes via Yii config 'import' block as 'usr.components.', 'usr.models.' i got error: "Alias "usr.components.*" is invalid. Make sure it points to an existing directory or file. "
Any Ideas?
The text was updated successfully, but these errors were encountered: