Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01e93ae
commit 1586af5
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Getting started with Hooks | ||
|
||
A hook is a place that allows you to insert additional customized programming. For example, you might want to run some specific code every time a new user is created. You would achive this by registering a hook in the framework. | ||
|
||
## Hook Types | ||
|
||
Each hook accepts an input type, there are a couple of different types of hooks that are used within the framework, these can be seen below: | ||
|
||
| Type | Example | Description | | ||
| ---------------- | ------- | -------------------------------------------------------------------------------------------------- | | ||
| Text | Boolean | Status of the SQL query (`true` if successfully run, `false` otherwise) | | ||
| JSON | String | The compiled SQL statement that was run | | ||
| Model | Integer | The ID of the newly inserted row (on `INSERT` queries only) | | ||
|
||
## Register and Canceling a hooks | ||
|
||
Hooks can be registered and canceled at any point using a line of PHP. The hook can either be perminent in which case it will be sotred in the database and used every time the hook is called or it can be runtime which will only last for the current scripts execution. | ||
|
||
To register a hook you will need to enter four things, hook key, a unique identifier, the hook itself and decide if to make the hook permanent. | ||
```php | ||
<?php | ||
|
||
\Twist::framework()->hooks()->register('TWIST_EMAIL_PROTOCOLS','phpmailer',array('model' => 'Packages\phpmailer\Models\Send'),true); | ||
|
||
``` | ||
|
||
To remove a hook from the system you will need the hook key and its unique identifier, simply call the cancel function of the hooks model and pass in the two parameters. An example can be seen below: | ||
|
||
```php | ||
<?php | ||
|
||
\Twist::framework()->hooks()->cancel('TWIST_EMAIL_PROTOCOLS','phpmailer-email-protocol',true); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# TwistPHP Core Hooks | ||
|
||
The framework comes with a range of hooks that can be expanded upon, a list of these hooks and thier types can be found below: | ||
|
||
| Key | Type | Description | | ||
| ------------------------- | ----------- | -------------------------------------------------------------------------------------------------- | | ||
| TWIST_EMAIL_PROTOCOLS | Model | Status of the SQL query (`true` if successfully run, `false` otherwise) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Manager Hooks | ||
|
||
When working with the TwistPHP Manager either by created a packages that extends the manager or within your application you can register any of the following. | ||
|
||
| Key | Type | Description | | ||
| ------------------------- | ----------- | -------------------------------------------------------------------------------------------------- | | ||
| TWIST_MANAGER_ROUTE | Route | Status of the SQL query (`true` if successfully run, `false` otherwise) | | ||
| TWIST_MANAGER_MENU | JSON | Status of the SQL query (`true` if successfully run, `false` otherwise) | |