CodeIgniter HMVC object_to_array() error

前端 未结 5 404
陌清茗
陌清茗 2021-01-30 13:40

HMVC : https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads

After downloading CI and copying over the HMVC, I\'m getting the following error:<

相关标签:
5条回答
  • 2021-01-30 14:23

    Just adding this here as the Link provided by Clasyk isn't currently working...

    The short version from that thread boils down to this...

    In application/third_party/MX/Loader.php you can do the following...

    Under public function view($view, $vars = array(), $return = FALSE) Look for... (Line 300)

    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
    

    Replace this with

    if (method_exists($this, '_ci_object_to_array'))
    {
            return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
    } else {
            return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
    }
    

    It's the result of a "little" undocumented change that the CI Devs implemented, which is fine!

    There is a pull request on Wiredesignz awaiting action so he knows about it...

    In the meantime, you can implement the above "diddle" and get back to coding :)

    0 讨论(0)
  • 2021-01-30 14:34

    Found this Use this place in application / core / MY_Loader.php

    From here https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-requests/17/fix-loaderphp-for-ci-313/diff#comment-30560940

    <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
    
    /* load the MX_Loader class */
    require APPPATH."third_party/MX/Loader.php";
    
    class MY_Loader extends MX_Loader
    {
        /** Load a module view **/
        public function view($view, $vars = array(), $return = FALSE)
        {
            list($path, $_view) = Modules::find($view, $this->_module, 'views/');
    
            if ($path != FALSE)
            {
                $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
                $view = $_view;
            }
    
            return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => ((method_exists($this,'_ci_object_to_array')) ? $this->_ci_object_to_array($vars) : $this->_ci_prepare_view_vars($vars)), '_ci_return' => $return));
        }
    }
    
    0 讨论(0)
  • 2021-01-30 14:35

    HMVC doesn't work with 3.1.3 (current version). But works with all versions up to 3.1.2. Just tested this myself from 3.0.0 upwards.

    0 讨论(0)
  • 2021-01-30 14:39

    Add this lines in application/third_party/MX/Loader.php after line 307,

    protected function _ci_object_to_array($object) 
    	{
        return is_object($object) ? get_object_vars($object) : $object;
        }

    However for 3.1.3 HMVC doesn't work.

    better luck.

    0 讨论(0)
  • 2021-01-30 14:43

    I got the solution.this is working for me. On Line 300 of application/third_party/MX/Loader.php

    This line generates an error with CI 3.1.3

    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
    

    Replace with this line.

    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
    }
    
    0 讨论(0)
提交回复
热议问题