web-dev-qa-db-fra.com

Erreur fatale: appel d'une fonction membre get () sur un non-objet

J'essaie de dupliquer une vue et de la modifier, mais cela me donne une erreur.

Avant cela, je le faisais avec d'autres vues et tout fonctionnait parfaitement. Tout ce que j'avais à faire, c'était de renommer les vues et de modifier le code.

Mais maintenant, je reçois cette erreur:

Fatal error: Call to a member function get() on a non-object in D:\UniServerZ\vhosts\restaurant\administrator\components\com_restaurant\views\reviews\view.html.php on line 54

La ligne 54 a ce code:

$canDo = RestaurantHelper::getActions($state->get('filter.category_id'));

var_dump($this); me donne ce qui suit ->

    object(RestaurantViewReviews)#156 (18) {
  ["items":protected]=>
  NULL
  ["pagination":protected]=>
  NULL
  ["state":protected]=>
  NULL
  ["_name":protected]=>
  string(7) "reviews"
  ["_models":protected]=>
  array(0) {
  }
  ["_basePath":protected]=>
  string(71) "D:\UniServerZ\vhosts\restaurant\administrator/components/com_restaurant"
  ["_defaultModel":protected]=>
  NULL
  ["_layout":protected]=>
  string(7) "default"
  ["_layoutExt":protected]=>
  string(3) "php"
  ["_layoutTemplate":protected]=>
  string(1) "_"
  ["_path":protected]=>
  array(2) {
    ["template"]=>
    array(2) {
      [0]=>
      string(89) "D:\UniServerZ\vhosts\restaurant\administrator\templates\isis\html\com_restaurant\reviews\"
      [1]=>
      string(91) "D:\UniServerZ\vhosts\restaurant\administrator\components\com_restaurant\views\reviews\tmpl\"
    }
    ["helper"]=>
    array(1) {
      [0]=>
      string(80) "D:\UniServerZ\vhosts\restaurant\administrator\components\com_restaurant\helpers\"
    }
  }
  ["_template":protected]=>
  NULL
  ["_output":protected]=>
  NULL
  ["_escape":protected]=>
  string(16) "htmlspecialchars"
  ["_charset":protected]=>
  string(5) "UTF-8"
  ["_errors":protected]=>
  array(0) {
  }
  ["baseurl"]=>
  string(14) "/administrator"
  ["document"]=>
  object(JDocumentHTML)#122 (32) {
    ["_links"]=>
    array(0) {
    }
    ["_custom"]=>
    array(0) {
    }
    ["template"]=>
    NULL
    ["baseurl"]=>
    NULL
    ["params"]=>
    NULL
    ["_file"]=>
    NULL
    ["_template":protected]=>
    string(0) ""
    ["_template_tags":protected]=>
    array(0) {
    }
    ["_caching":protected]=>
    NULL
    ["_html5":"JDocumentHTML":private]=>
    NULL
    ["title"]=>
    string(27) "Restaurant - Administration"
    ["description"]=>
    string(24) "Restaurant description.."
    ["link"]=>
    string(0) ""
    ["base"]=>
    string(0) ""
    ["language"]=>
    string(5) "en-gb"
    ["direction"]=>
    string(3) "ltr"
    ["_generator"]=>
    string(40) "Joomla! - Open Source Content Management"
    ["_mdate"]=>
    string(0) ""
    ["_tab"]=>
    string(2) "  "
    ["_lineEnd"]=>
    string(1) "
"
    ["_charset"]=>
    string(5) "utf-8"
    ["_mime"]=>
    string(9) "text/html"
    ["_namespace"]=>
    string(0) ""
    ["_profile"]=>
    string(0) ""
    ["_scripts"]=>
    array(0) {
    }
    ["_script"]=>
    array(0) {
    }
    ["_styleSheets"]=>
    array(0) {
    }
    ["_style"]=>
    array(0) {
    }
    ["_metaTags"]=>
    array(2) {
      ["http-equiv"]=>
      array(1) {
        ["content-type"]=>
        string(24) "text/html; charset=utf-8"
      }
      ["standard"]=>
      array(1) {
        ["keywords"]=>
        NULL
      }
    }
    ["_engine"]=>
    NULL
    ["_type"]=>
    string(4) "html"
    ["mediaVersion":protected]=>
    string(32) "5a22c74e31c4742e55ee891853d099a2"
  }
}

Toute aide à ce sujet serait grandement appréciée,

Merci

1
Sameer Nyaupane

$state n'est pas un objet. Cela signifie qu'il n'a pas été correctement initialisé précédemment dans votre méthode. Ou peut-être qu'il devrait être $this->state au lieu de $state.

2
Dmitry Rekun