I need to find certain cues in a string and call functions with these cues
Example
<?php
namespace App\Http\Controllers;
class ModulesController
{
private $modules = [ ['name' => 'someFunction','maxNumber' => 50] ];
public function checkFunctions($strings = NULL)
{
$moduleArrayId = array_search($strings ,array_column($this->modules, 'name');
if($moduleArrayId !== FALSE)
$this->$modules[$moduleArrayId]['name'];
}
public function someFunction()
{
return "it works";
}
}
And resource example
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\ModulesController;
class BlockController extends Controller
{
public function __construct()
{
$this->middleware('auth:members');
}
public function index(Request $request)
{
$string = "someFunction";
$callBack = new ModulesController;
var_dump($callBack->checkFunctions($string)); //Always its NULL
}
}
I have to use this code like this. If I can understand this, I will try to improve it.