Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter HMVC error
#1

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
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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.
Reply
#4

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;
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB