3

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....

2
  • 1
    i've also tried it this way: namespace Test\Test\Services\NestedDirectory; class NoteArrays { protected $tests= array( 'a' => 'a', 'b' => 'b'); public function getTest() { return $this->tests; } } $array = new \Test\Test\Services\NestedDirectory\NoteArrays(); $this->view->assign('options', $array->getTest()); Commented Dec 20, 2014 at 23:06
  • 1
    IT WORKS!!!!! like in the comment! Commented Dec 20, 2014 at 23:10

1 Answer 1

2

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()); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.