Welcome Guest, Not a member yet? Register   Sign In
Error Call to a member function seo() on nul
#1
Bug 
(This post was last modified: 10-07-2020, 08:40 AM by guilhermepalange.)

i have one problem 
i am upgrade CI3 x CI4 and receive one error:

PHP Code:
[color=#ffffff][size=xx-large]Error[/size][/color]

[color=#ffffff][size=medium]Call to a member function seo() on null[/size][/color] 
 
My function in Menus.php 

Code:
  public function seo($tag){
    $uri = current_url(true);
    $uri = ((string)$uri == '')? '/' : (string)$uri;
    return $this->listSeo[$uri][$tag];
   
  }

My Controller and My base Controller.

PHP Code:
<?php
namespace App\Controllers;

/**
 * Class BaseController
 *
 * BaseController provides a convenient place for loading components
 * and performing functions that are needed by all your controllers.
 * Extend this class in any new controllers:
 *     class Home extends BaseController
 *
 * For security be sure to declare any new methods as protected or private.
 *
 * @package CodeIgniter
 */

use CodeIgniter\Controller;
use 
App\Libraries\My_parser;
use 
App\Libraries\Preferencia;
use 
App\Models\index_model;
use 
App\Libraries\Traducao;
use 
App\Libraries\Menus;

class 
BaseController extends Controller
{
    protected 
$helpers = [];
    public function 
initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
    {
        
// Do Not Edit This Line
        
parent::initController($request$response$logger);
        
$this->_db = \Config\Database::connect();
        
$this->My_parser = new My_Parser();
        
$this->preferencia = new Preferencia();
        
$this->_model = new \App\Models\index_model();
        
$this->traducao = new Traducao();
        
$this->menus = new \App\Libraries\Menus($this->_db$request);
    }

    
    
  public function output($data$status){
        
$this->output
        
->set_status_header(200)
        ->
set_content_type('application/json''utf-8')
        ->
set_output(
        
  json_encode(
            array(
            
  'status'=> $status,
            
  'response'=> $data    
            
), 
            
JSON_PRETTY_PRINT JSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES
          
)
        )->
_display();
        exit;
    
  }
    } 

PHP Code:
<?php namespace App\Controllers;

use 
App\Libraries\my_parser;
use 
CodeIgniter\Controller;
use 
App\Libraries\Preferencia;
use 
App\Libraries\Menus;

class 
Home extends BaseController
{

    public function 
index()
    {
        
$my_parser = new My_parser;
        
$Preferencia = new Preferencia();
        
$data = array();
        
$data['title']       "Index" ;
        
$data['css']         $this->My_parser->css(array());
        
$data['metatags']    $this->My_parser->metatags(array());
        
$data['js']          $this->My_parser->js(array());

        
$data['empresas_parceiras'] = $this->_model->logosEmpresasParceiras();
        
//$this->load->view("index", $data);

                //echo view('template/head', $data);
                //echo view('menu');
             //   echo view('content', $data);
                //echo view('footer');
        
return view('index'$data);
    }

    public function 
idioma(){

        
$idioma_nome $this->input->get('lang');
        
$idioma_id   $this->input->get('id');
        
$redirect    $this->input->get('uri');

        
$this->session->set_userdata('idioma'$idioma_id);

        
redirect($redirect);
    }
    
//--------------------------------------------------------------------


Reply




Theme © iAndrew 2016 - Forum software by © MyBB