Plugins - How-To

Discussion for TimeTrex open source community developers.
Locked
visaolive
Posts: 21
Joined: Mon May 20, 2013 5:16 am

Plugins - How-To

Post by visaolive »

I'm looking at plugins, and how to implement these.

I went into root/classes/modules/plugins as suggested.

I opened the UserFactory.plugin.example file.

I then proceeded to change the name from UserFactory.plugin.example to UserFactory.plugin.php

Then, I commented out the postSave function, and left the setLastName function available to run.

I saved this file, and cleared out my cache directory.

However, I don't see this plugin firing, or any reference of it in the Log file.

How do I get the plugins to trigger?

Here are the contents of the UserFactory.plugin.php file:

Code: Select all


<?php

/*$License$*/
/*
 * $Revision: 4034 $
 * $Id: UserFactory.plugin.php 4034 2010-12-15 00:02:50Z ipso $
 * $Date: 2010-12-14 16:02:50 -0800 (Tue, 14 Dec 2010) $
 */

/*
 * Example plugin.
 */


//Extend the "ListFactory" if you want your plugin to affect it AND the base Factory class.
//Extend just the "Factory" if you just want it to affect just it, and not account for objects read/modified through iterators.
class UserFactoryPlugin extends UserListFactory {

    function setLastName( $value ) {
        //Modify last name, so it always has "-Smith" on the end.
        $value .= '-Smith';

        return parent::setLastName( $value );
    }


	/*
    function postSave() {
        parent::postSave(); //Make sure you always call the parents function to maintain proper code operation.

        //User record was saved. We can do all sorts of things here like trigger real-time data exporting.
		Debug::Arr( $this->getObjectAsArray(), 'UserFactory Plugin postSave(): ', __FILE__, __LINE__, __METHOD__,10);

        return TRUE;
    }
    */
    

}

?>


shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Plugins - How-To

Post by shaunw »

Make sure you have plugins enabled in your timetrex.ini.php, under the [other] section:

Code: Select all

[other]
enable_plugins = TRUE
visaolive
Posts: 21
Joined: Mon May 20, 2013 5:16 am

Re: Plugins - How-To

Post by visaolive »

Thanks!
Locked