-
Notifications
You must be signed in to change notification settings - Fork 480
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
Add a hook documentation #1861
Add a hook documentation #1861
Conversation
tleon
commented
Sep 9, 2024
Questions | Answers |
---|---|
Branch? | 9.x |
Description? | Documentation on how to add a new hook |
|
||
## 1) Add a call to Hook::exec() | ||
|
||
As you can see on this [PR](https://github.com/PrestaShop/PrestaShop/pull/34431/files) Adding a simple Hook::exex() statement is enought to add a new hook. In order for it to be complete, there is a couple more steps to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see on this [PR](https://github.com/PrestaShop/PrestaShop/pull/34431/files) Adding a simple Hook::exex() statement is enought to add a new hook. In order for it to be complete, there is a couple more steps to do. | |
As you can see on this [PR](https://github.com/PrestaShop/PrestaShop/pull/34431/files), adding a simple Hook::exex() statement is enough to add a new hook. In order for it to be complete, there is a couple more steps to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be more precise here. In the shown example, you don't write about "adding a hook" but adding code that executes the hook in this place. That doesn't mean the hook is fully added to the system if you add this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only way I was told how to do it maybe you can enlight me ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @kpodemski means that adding the Hook::exec()
(part 1) will trigger the hook, but if you dont do the parts 2 and parts 3 it will work only partially
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to have it as a separate article. I added my feedback.
@@ -0,0 +1,14 @@ | |||
# How To add a new Hook | |||
Adding a new hook is quite a simple process. It can be done in only tree steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a new hook is quite a simple process. It can be done in only tree steps. | |
Adding a new hook is a process that can be done in only three steps. |
We should refrain from using "simple", "easy", etc., in the documentation. It might not be that simple for some :)
|
||
## 1) Add a call to Hook::exec() | ||
|
||
As you can see on this [PR](https://github.com/PrestaShop/PrestaShop/pull/34431/files) Adding a simple Hook::exex() statement is enought to add a new hook. In order for it to be complete, there is a couple more steps to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be more precise here. In the shown example, you don't write about "adding a hook" but adding code that executes the hook in this place. That doesn't mean the hook is fully added to the system if you add this code.
It would be good to add "what happens if X". The hook doesn't have to be in the hooks table to work, it will be added automatically when first module registers on it. However, it can be done only programatically, not by using the backoffice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good for me
Waiting for @kpodemski last check ;)
thanks @tleon :-) |