CodeIgniter Forums
CodeIgniter HMVC error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: CodeIgniter HMVC error (/showthread.php?tid=70851)



CodeIgniter HMVC error - azmath - 06-08-2018

1st time setup CodeIgniter HMVC. when i run code i face this error. 

An uncaught Exception was encountered Type: Error
Message: Call to undefined method MY_Loader::_ci_object_to_array()
Filename: C:\xampp\htdocs\ciall\hmvc\application\third_party\MX\Loader.php
Line Number: 300
Backtrace:
File: C:\xampp\htdocs\ciall\hmvc\application\modules\foo\controllers\foo.php Line: 23 Function: view
File: C:\xampp\htdocs\ciall\hmvc\index.php Line: 315 Function: require_once


RE: CodeIgniter HMVC error - InsiteFX - 06-09-2018

Are you using the newest version of Wiredesignz HMVC?

Wiredesignz - HMVC - codeigniter-modular-extensions-hmvc

Also search the forums, there were some bug fixes being done.

If you can get it to work I have a working copy you can download.

You would need to upgrade the CodeIgniter version to the newest.


RE: CodeIgniter HMVC error - TamasD - 07-15-2018

(06-08-2018, 10:01 PM)azmath Wrote: 1st time setup CodeIgniter HMVC. when i run code i face this error. 

An uncaught Exception was encountered Type: Error
Message: Call to undefined method MY_Loader::_ci_object_to_array()
Filename: C:\xampp\htdocs\ciall\hmvc\application\third_party\MX\Loader.php
Line Number: 300
Backtrace:
File: C:\xampp\htdocs\ciall\hmvc\application\modules\foo\controllers\foo.php Line: 23 Function: view
File: C:\xampp\htdocs\ciall\hmvc\index.php Line: 315 Function: require_once

You need to add this code to Loader.php

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

Then it will work.


RE: CodeIgniter HMVC error - InsiteFX - 07-17-2018

Place in a CodeIgniter Help file.

PHP Code:
// -----------------------------------------------------------------------

if ( ! function_exists('objectToArray'))
{
    
/**
     * objectToArray ()
     * -------------------------------------------------------------------
     *
     * @param  $data
     * @return array
     */
    
function objectToArray($data)
    {
        if (
is_object($data))
        {
            
/**
             * Gets the properties of the given object
             * with get_object_vars function
             */
            
$data get_object_vars($data);
        }

        
/**
         * Return array converted to object Using __FUNCTION__ (Magic constant)
         * for recursive call
         */
        
return (is_array($data))
            ? 
array_map(__FUNCTION__$data)
            : 
$data;
    }
}

// -----------------------------------------------------------------------

if ( ! function_exists('arrayToObject'))
{
    
/**
     * arrayToObject ()
     * -------------------------------------------------------------------
     *
     * @param  $data
     * @return object
     */
    
function arrayToObject($data)
    {
        
/**
         * Return array converted to object Using __FUNCTION__ (Magic constant)
         * for recursive call
         */
        
return (is_array($data))
            ? (object) 
array_map(__FUNCTION__$data)
            : 
$data;
    }