libero - 1 year ago

I try create a Plugin. But I can't return a array to view. I think this will be solution. Below is code. public function getFunctions(){ return [ new \Twig_SimpleFunction( 'get_products', function(){ //return $this->dispatch(new \Anomaly\ProductsPlugin\Products\Command\GetMenuView); $url = ''; $json_string = file_get_contents($url); $json = json_decode($json_string, true); //return $json_string; return $this->view->make('anomaly.plugin.products::menu/getproduct', compact('json')); }) ];

ryanthompson - 1 year ago

I can't make heads or tails of that code - can you format it for us all?

If you dd($value) in your plugin return and it's an array.. that's what's being sent back to the view. Pretty straight forward at this point cause Twig compiles to PHP so arrays are arrays (nothing fancy going on).