I am tryin to call a function from my controller and return the $todolist to my controller. But i get this error, when i leave this function inside the controller it works fine, but i don't want it to be in the controller.
This is my controller
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configurationoute;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use AppBundle\Entity\Todo;
use AppBundle\Model\TodoModel;
class TodoController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function ShowList()
{
$todolist = TodoModel::getTodolist();
$html = $this->container->get('templating')->render(
'todolist/todolist.html.twig',
array('todolist' => $todolist)
);
return new response($html);
}
}
This is my model
namespace AppBundle\Model;
use AppBundle\Entity\Todo;
class TodoModel
{
public function getTodolist()
{
$repository = $this->getDoctrine()
->getRepository('AppBundle:Todo');
$todolist = $repository->findAll();
return $todolist;
}
}