Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3 call a class from controller

I wanna call a seperate Class from my Controller.

The class is found under: Classes/Domain/Services I wanna call only a getter!

The class I wanna call is named TestClass.php

In my controller I tried: $this->view->assign('options', $this->TestClass->getTest());

The Testclass looks like this:

class NoteArrays {
    protected $tests= array(        
       'a' => 'a',        
       'b' => 'b');

    public function getTest() {        
       return $this->tests;   
    }
}

But I've got only a blank page....

like image 734
Felix Avatar asked May 20 '26 18:05

Felix


1 Answers

Soution is:

namespace Test\Test\Services\NestedDirectory; 

class NoteArrays { 

       protected $tests= array( 'a' => 'a', 'b' => 'b'); 

       public function getTest() { 
             return $this->tests; 
       } 
} 

And to create and assign:

$array = new \Test\Test\Services\NestedDirectory\NoteArrays(); 
$this->view->assign('options', $array->getTest()); 
like image 146
Felix Avatar answered May 23 '26 12:05

Felix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!