XF 2.0 What is the proper way to call a function?

AndyB

Well-known member
What is the proper way to call a function?

PHP:
<?php

namespace Andy\Methods\Pub\Controller;

use XF\Pub\Controller\AbstractController;

class Methods extends AbstractController
{
    public function actionIndex()
    {
        $filesArray = scanAllDir();
    }

    function scanAllDir()
    {
        echo 'hello';
        exit();
    }
}

The above code produces the following error message:

1509312036786.webp
 
Surely you've used $this->functionName() in one of your 280 add-ons :p

But more than likely you'll want to put scanAllDir into a Resository instead of the controller
 
You should probably use it like this:

$this->scanAllDir();

Also it's a good practice to declare a visibility of your function (they're all public by default). I believe you'd want to set it to private.
 
  • Like
Reactions: LPH
I'm interested in what this add-on is actually doing. I see it is called "Methods". What are these methods going to be used for?
 
  • Like
Reactions: LPH
I'm interested in what this add-on is actually doing. I see it is called "Methods". What are these methods going to be used for?

Hi Chris,

The add-on displays each XenForo PHP file in the src/XF/ directory and shows the methods contained in them:

1509341398438.webp
 
Last edited:
Back
Top Bottom