MODX Community

MIGX Configurator Custom Manager Page (CMP) stopped loading

Hey guys,

I had set up MIGX Configurator Custom Manager Page (CMP) using the default class map and it was working in my backend menu bar.

Original class.php
class packageName extends xPDOSimpleObject {}

My Menu Settings
Lexicon Key: My Package
Action: index
Parameters: &configs=packageName
Namespace: migx

I then extended my package and created some public functions. However, it will not load the package in my menu anymore.

class packageName extends xPDOSimpleObject {
    /**
     * @access public
     * @var modX A reference to the modX object.
     */
    public $modx = null;
    /**
     * @access public
     * @var array A collection of properties to adjust SFL Countries behaviour.
     */
    public $config = array();
    
    function __construct(modX & $modx, array $config = array()) {
        $this->modx = &$modx;
        
        $packageName = 'packageName';
        $packagepath = $this->modx->getOption('core_path') . 'components/' . $packageName . '/';
        $modelpath = $packagepath . 'model/';
        $prefix = null;
        $this->modx->addPackage($packageName, $modelpath, $prefix);
        
        $corePath = $this->modx->getOption('packageName.core_path', null, $modx->getOption('core_path') . 'components/' . $packageName . '/');
        
        $defaultconfig['corePath'] = $corePath;
        $defaultconfig['modelPath'] = $corePath . 'model/';
        
        $this->config = array_merge($defaultconfig, $config);
        
    }

    public function slugify($text)
    {
        // replace non letter or digits by -
        $text = preg_replace('~[^\pL\d]+~u', '-', $text);
        
        // transliterate
        $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
        
        // remove unwanted characters
        $text = preg_replace('~[^-\w]+~', '', $text);
        
        // trim
        $text = trim($text, '-');
        
        // remove duplicate -
        $text = preg_replace('~-+~', '-', $text);
        
        // lowercase
        $text = strtolower($text);
        
        if (empty($text)) {
        return 'n-a';
        }
        
        return $text;
    }
}

It seems I’m missing something from my constructor. Can anyone help?

Is anyone ever extended the default MIGX class? For some reason, when I extended it, it will not load my package with the menu bar.

Maybe it works with a call to the parent constructor in your constructor:

function __construct(& $modx) {
	parent::__construct($modx);
	//your code
}

Maybe it is just a better idea to put your code in its own class (that doesn’t extend xPDOSimpleObject).

Well your suggestion “parent::__construct($modx);” works but I don’t know why. I think I will also try your second recommendation.

why are you triying to extend xPDOSimpleObject here?

Apologies for the late response. I wanted to have my own private and public functions with my migx package but it is causing more challenges than results. I will my own separate class and use that instead.