Event listener and class name

2 questions. I am currently making a plugin that will extend the user upgrades and send an RCON command to the server specified. I am currently listening to class XenForo_UserUpgradeProcessor_PayPal (or at least I am trying to) . I am using the load_class_controller listener. Am I using the right listener for what I am trying to do? Also for that listener it says:
Called when instantiating a controller. This event can be used to extend the class that will be instantiated dynamically.

Callback signature:

$class, array &$extend
Arguments:

  1. string $class - the name of the class to be created
  2. array &$extend - a modifiable list of classes that wish to extend the class. See below.
To use this event properly, determine if the class is one you want to extend. If so, add a new entry to $extend with the name of the class that should extend it. This class MUST be defined as follows:

class My_Class_Name extends XFCP_My_Class_Name
{
// functionality to extend/override
}
This class must extend the non-existent XFCP_x class. This will be resolved at run time.
My class name is
Code:
RconUpgrade_ControllerPublic_RconUpgrade
so for the class line I put
Code:
class RconUpgrade_ControllerPublic_RconUpgrade extends XFCP_RconUpgrade_ControllerPublic_RconUpgrade
Am I doing that right? I always thought it would be
Code:
class My_Class_Name extends Class_Being_Extended_Name
And finally am I calling my options correctly? Ex:
Code:
$rcon_ip = XenForo_Application::get('options')->rcon_ip;
rcon_ip is the id for the option

The code below is what I am using to test the extension and see if I am calling my options correctly.
Code:
<?php
    class RconUpgrade_ControllerPublic_RconUpgrade extends XFCP_RconUpgrade_ControllerPublic_RconUpgrade
    {
        $rcon_ip = XenForo_Application::get('options')->rcon_ip;
        $rcon_port = XenForo_Application::get('options')->rcon_port;
        $rcon_password = XenForo_Application::get('options')->rcon_password;
        $rcon_command1 = XenForo_Application::get('options')->rcon_command;
        $colon = ":";
        $enter = "\n";
        $File = "Test.txt"; 
        $Handle = fopen($File, 'w'); 
        fwrite($Handle, $rcon_ip);
        fwrite($Handle, $colon);
        fwrite($Handle, $rcon_port);
        fwrite($Handle, $enter);
        fwrite($Handle, $rcon_password);
        fwrite($Handle, $enter);
        fwrite($Handle, $rcon_command1);
        fclose($Handle);
    }
   

?>
I go through an upgrade and if the file "Test.txt" has the info I told it to wright the extension and the option calling is correct. Thanks in advance!
 
Thank you so much. That helped a lot. I just want to be clear about the calling of options. You have your calling of the db
Code:
$db = XenForo_Application::get('db');
I have mine:
Code:
$rcon_ip = XenForo_Application::get('options')->rcon_ip;
Which is correct for calling options? Or is yours not calling an Add-On Option? Because I cannot find options for your plugin.
Basically... If I want to call the option id 'rcon_ip' from my application options how do you do it?

Edit: Oh I see now that you are calling the actual xenforo db. So am I calling my options correctly then?
 
Last edited:
Top Bottom