Hello,
I declared a private variable in my component class and it works good, when I get it in a method called in onRun()
.
But when I want to get the value in my JS request method it’s null.
Here’s my getter:
public function getSubjectsTexts() {
return $this->subjectsTexts;
}
And here my on JS request method:
public function onGenerateDataSentences()
{
$subjectsTexts = $this->getSubjectsTexts();
dd($subjectsTexts); // prints null
// ...
}
How can I get $subjectsTexts
in onGenerateDataSentences()
?
The data is just a huge array, which I placed in another file in plugin/acme/data/questionSubjects.php
. I get it in onRun()
like that:
$this->subjectsTexts = require_once(base_path('plugins/maki3000/goodbad/data/questionSubjects.php'));