Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 506

Warning: Incorrect key file for table './miphpf_miphpfcom/watchdog.MYI'; try to repair it query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.', 2, '', 'http://www.miphpf.com/controller_plugins.html', '', '18.188.184.186', 1734793447) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Controller Plugin | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Controller Plugin

: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.

miControllerPlugin class defines three methods to extend the functionality of the controller object. These 3 methods are called at specific times during the processing of the request.

Use:
* preProcessAction()  to execute specific code before the action is processed.
* postProcessAction() to implement functionality which is executed after the action is processed.
* processActionStep() to execute code at some step in the processing of actions. Action step can be 'preShowForm', 'postCreate', 'postUpdate', etc., and depend on the specific action.

* Usage of the miControllerPlugin class

<?php
class miWriteToLogPlugin extends miControllerPlugin {
    const
LOG_FILE = '/tmp/debug.log';
    const
DATE_FORMAT = 'Y-m-d H:i:s';
   
   
public function processActionStep($action, $actionStep)
    {
        switch (
$actionStep)
        {
            case
'postCreate':
               
$this->log('Object is being created');
                break;
            case
'postUpdate':
               
$this->log('Object is being updated');
                break;
        }
    }
   
   
public function postProcessAction($action, $actionResult)
    {
        if (
$action instanceof miExecCreateAction)  {
            if (
$actionResult)
               
$this->log('Object created successfuly');
            else
               
$this->log('Error occured while creating the object');
        }
        else if (
$action instanceof miExecEditAction)  {
            if (
$actionResult)
               
$this->log('Object updated successfuly');
            else
               
$this->log('Error occured while updating the object');
        }
    }
   
   
public function log($message)
    {
       
file_put_contents(self::LOG_FILE, date(self::DATE_FORMAT) . ': ' . $message, FILE_APPEND);
    }
}
   
$dataManager->registerPlugin(new miWriteToLogPlugin());
?>