Closed YuriyKvit closed 7 years ago
We don't have any issue with incorrect store comments. So, you can override the CommentModel property in the Comment module class and implement your own fumctionality
Decrypted value used in the DefaultController class
After fetching it from db, i have something like "ecf003be" so i can`t decrypt it by my self. Thanks for reply.
Sorry for the late response to a closed issue but I found this while looking for a solution to a similar problem. I'll post my findings in case anyone else comes upon this thread.
@YuriyKvit It's not practical to decrypt the entity value because the yii2mod/yii2-comments module uses a hashing function to create it. If you're in a situation similar to me, and you want to find the entity type (your model) that the comment is on, then you can do a quick comparison using the same hash function yii2mod/yii2-comments uses. In my case, I'm accessing the afterCreate function to create notifications based on the type of model that was commented on:
'onAfterCreate' => function ($event) {
$comment = $event->getCommentModel();
if(hash('crc32', YourModelHere::className()) == $comment->entity) {
// logic based on model type here
}
else {
// logic for a different model
}
}
We have an entity field in the database with char(10) and when the module name encrypting the length was bigger than it can store, so it`s trimmed. So how i can get fully entity name like "posts", "news" etc ...