Class bedezign\yii2\audit\Audit
Inheritance | bedezign\yii2\audit\Audit » yii\base\Module |
---|
Audit main module.
This module is also responsible for starting the audit process. To configure it you need to do 2 things:
- add a module configuration entry:
'modules' => [
'audit' => 'bedezign\yii2\audit\Audit',
] or optionally with configuration: 'modules' => [
'audit' => [ 'class' => 'bedezign\yii2\audit\Audit', 'ignoreActions' => ['debug/*']
]
- If you want to auto track actions, be sure to add the module to the application bootstrapping: 'bootstrap' => ['audit'],
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$accessIps | string[] | IP address or list of IP addresses with access to the viewer, null for everyone (if the IP matches)
An IP address can contain the wildcard * at the end so that it matches IP addresses with the same prefix. |
bedezign\yii2\audit\Audit |
$accessRoles | string[] | Role or list of roles with access to the viewer, null for everyone (if the user matches) | bedezign\yii2\audit\Audit |
$accessUsers | int | User ID or list of user IDs with access to the viewer, null for everyone (if the role matches) | bedezign\yii2\audit\Audit |
$batchSave | bool | The module does batch saving of the data records by default. | bedezign\yii2\audit\Audit |
$compressData | bool | Compress extra data generated or just keep in text? For people who don't like binary data in the DB | bedezign\yii2\audit\Audit |
$db | string | Name of the component to use for database access | bedezign\yii2\audit\Audit |
$ignoreActions | string[] | Action or list of actions to ignore. | bedezign\yii2\audit\Audit |
$layout | string|boolean | The layout that should be applied for views within this module. | bedezign\yii2\audit\Audit |
$logTarget | bedezign\yii2\audit\LogTarget | bedezign\yii2\audit\Audit | |
$maxAge | int | Maximum age (in days) of the audit entries before they are truncated | bedezign\yii2\audit\Audit |
$panels | array|bedezign\yii2\audit\components\panels\Panel[] | List of panels that should be active/tracking/available during the auditing phase. | bedezign\yii2\audit\Audit |
$panelsMerge | Everything you add in here will be merged with the basic panel configuration. | bedezign\yii2\audit\Audit | |
$trackActions | string[] | Action or list of actions to track. | bedezign\yii2\audit\Audit |
$userFilterCallback | string | Will be called to translate text in the user filter into a (or more) user id's | bedezign\yii2\audit\Audit |
$userIdentifierCallback | string | The callback to use to convert a user id into an identifier (username, email, . | bedezign\yii2\audit\Audit |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | bedezign\yii2\audit\Audit | |
findModuleIdentifier() | bedezign\yii2\audit\Audit | |
findPanelIdentifier() | bedezign\yii2\audit\Audit | |
getDb() | bedezign\yii2\audit\Audit | |
getEntry() | bedezign\yii2\audit\Audit | |
getPanel() | bedezign\yii2\audit\Audit | |
getPanelIdentifiers() | Returns a list of all available panel identifiers | bedezign\yii2\audit\Audit |
getUserIdentifier() | bedezign\yii2\audit\Audit | |
init() | bedezign\yii2\audit\Audit | |
loadPanels() | Tries to assemble the configuration for the panels that the user wants for auditing | bedezign\yii2\audit\Audit |
onAfterRequest() | bedezign\yii2\audit\Audit | |
onBeforeAction() | Called to evaluate if the current request should be logged | bedezign\yii2\audit\Audit |
registerFunction() | Allows panels to register functions that can be called directly on the module | bedezign\yii2\audit\Audit |
registerPanel() | bedezign\yii2\audit\Audit |
Protected Methods
Method | Description | Defined By |
---|---|---|
normalizePanelConfiguration() | Make sure the configured panels array is a uniform set of |
bedezign\yii2\audit\Audit |
routeMatches() | Verifies a route against a given list and returns whether it matches or not. | bedezign\yii2\audit\Audit |
Property Details
IP address or list of IP addresses with access to the viewer, null for everyone (if the IP matches)
An IP address can contain the wildcard *
at the end so that it matches IP addresses with the same prefix.
For example, '192.168.*' matches all IP addresses in the segment '192.168.'.
Role or list of roles with access to the viewer, null for everyone (if the user matches)
User ID or list of user IDs with access to the viewer, null for everyone (if the role matches)
The module does batch saving of the data records by default. You can disable this if you are experiencing
max_allowed_packet
errors when logging huge data quantities. Records will be saved per piece instead of all at once
Compress extra data generated or just keep in text? For people who don't like binary data in the DB
Name of the component to use for database access
Action or list of actions to ignore. '' is allowed as the last character to use as wildcard (eg 'debug/').
The layout that should be applied for views within this module. This refers to a view name relative to \bedezign\yii2\audit\layoutPath. If this is not set, it means the layout value of the \bedezign\yii2\audit\module will be taken. If this is false, layout will be disabled within this module.
Maximum age (in days) of the audit entries before they are truncated
List of panels that should be active/tracking/available during the auditing phase.
If the value is a simple string, it is the identifier of an internal panel to activate (with default settings)
If the entry is a '
Please note:
- If you just want to change the configuration for a core panel, use the
$panelConfiguration
, it will be merged into this one - If you add custom panels, please namespace them ("mynamespace/panelname").
This gives you an easy way to just add or modify panels/configurations without having to re-specify every panel.
This only accepts regular definitions ('
Action or list of actions to track. '*' is allowed as the last character to use as wildcard.
Will be called to translate text in the user filter into a (or more) user id's
The callback to use to convert a user id into an identifier (username, email, ...). Can also be html.
Method Details
public mixed __call ( $name, $params ) | ||
$name | string | |
$params | array |
public static int|null|string findModuleIdentifier ( ) |
public static bool|string findPanelIdentifier ( $className ) | ||
$className | string |
public \yii\db\Connection getDb ( ) | ||
return | \yii\db\Connection | The database connection. |
---|
public bedezign\yii2\audit\models\AuditEntry|static getEntry ( $create = false, $new = false ) | ||
$create | bool | |
$new | bool |
public null|bedezign\yii2\audit\components\panels\Panel getPanel ( $identifier ) | ||
$identifier | string | |
throws | \yii\base\InvalidConfigException |
---|
Returns a list of all available panel identifiers
public string[] getPanelIdentifiers ( ) |
public string getUserIdentifier ( $user_id ) | ||
$user_id |
public void init ( ) | ||
throws | \yii\base\InvalidConfigException |
---|
Tries to assemble the configuration for the panels that the user wants for auditing
public bedezign\yii2\audit\components\panels\Panel[] loadPanels ( $list ) | ||
$list |
Make sure the configured panels array is a uniform set of
protected void normalizePanelConfiguration ( ) | ||
throws | \yii\base\InvalidConfigException |
---|
public void onAfterRequest ( ) |
Called to evaluate if the current request should be logged
public void onBeforeAction ( $event ) | ||
$event | \yii\base\ActionEvent |
Allows panels to register functions that can be called directly on the module
public void registerFunction ( $name, $callback ) | ||
$name | string | |
$callback | callable |
public void registerPanel ( \yii\debug\Panel $panel ) | ||
$panel | \yii\debug\Panel |
Verifies a route against a given list and returns whether it matches or not.
Entries in the list are allowed to end with a '*', which means that a substring will be used for the match instead of a full compare.
protected bool routeMatches ( $route, $list ) | ||
$route | string | An application rout |
$list | string[] | List of routes to compare against. |