How to add modular extension wiredesignz to codeigniter 3.0
Asked Answered
A

5

7

I'm trying to add third party extension to create a HMVC application using Codeigniter 3.0

But when I'm adding MY_Loader and MY_Router files into the core folder and MX folder in the Third_party folder, it generates a fatal error:

Fatal error: Call to undefined method MY_Loader::_ci_object_to_array() in C:\xampp\htdocs\codeigniter\application\third_party\MX\Loader.php on line 300.

When I remove them, the application works perfectly. Are there any additional settings that are needed to get the application running?

Abducent answered 18/1, 2017 at 10:27 Comment(1)
github.com/bcit-ci/CodeIgniter/commit/…Bottle
P
13

It happens because the function used in MX/Loader.php no longer exists in CodeIgniter.

You can add it back to Loader.php

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

Source

Pilgarlic answered 18/1, 2017 at 11:12 Comment(0)
S
3

Open your file application/third_party/MX/Loader.php

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

add above function in Loader class.

Squid answered 12/2, 2017 at 6:56 Comment(0)
D
1

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));
}
Disparity answered 31/3, 2018 at 12:47 Comment(0)
E
0

I've found the following solution

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

Under public function view($view, $vars = array(), $return = FALSE) Look for... (near about 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));
}

Maybe wiredesignz will soon release the update for it. In the meantime, you can implement the above fix and resume coding.

Eavesdrop answered 26/3, 2018 at 7:30 Comment(0)
P
0

I replace on /MX/Loader.php line 300

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

with

return (method_exists($this, '_ci_object_to_array') ? $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)) : $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return)));
Painting answered 23/2, 2019 at 14:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.