Call to a member function setTemplate() on a non-object