public function getMODX($profile = null, array $options = array(), array &$results = array())
    {
        if ($profile === null && !$this->modx instanceof \modX) {
            throw new InvalidMODXException("No profile or MODX instance was provided");
        }
        if (!$this->modx instanceof \modX) {
            try {
                define('MODX_CORE_PATH', $profile->properties->modx->core_path);
                define('MODX_CONFIG_KEY', !empty($profile->properties->modx->config_key)
                    ? $profile->properties->modx->config_key : 'config');

                require MODX_CORE_PATH . 'model/modx/modx.class.php';

                $logTarget = $this->getConfig()->get('log_target', $options, array('target' => 'ARRAY', 'target_options' => array('var' => &$results)));
                $logLevel = $this->getConfig()->get('log_level', $options, \modX::LOG_LEVEL_INFO);
                $config = array(
                    'log_target' => $logTarget,
                    'log_level' => $logLevel,
                    'cache_db' => false,
                );

                $this->modx = new \modX('', $config);
                $this->modx->setLogLevel($config['log_level']);
                $this->modx->setLogTarget($config['log_target']);
                $this->modx->setOption('cache_db', $config['cache_db']);
                $this->modx->getVersionData();
                if (version_compare($this->modx->version['full_version'], '2.2.1-pl', '>=')) {
                    $this->modx->initialize('mgr', $config);
                } else {
                    $this->modx->initialize('mgr');
                }
                $this->modx->setLogLevel($config['log_level']);
                $this->modx->setLogTarget($config['log_target']);
                $this->modx->setOption('cache_db', $config['cache_db']);
            } catch (\Exception $e) {
                throw new InvalidMODXException("Error initializing MODX: " . $e->getMessage(), $e->getCode(), $e);
            }
        }
        return $this->modx;
    }
public function getMODX($profile = null, array $options = array(), array &$results = array())
    {
        if ($profile === null && !$this->modx instanceof \modX) {
            throw new InvalidMODXException("No profile or MODX instance was provided");
        }
        if (!$this->modx instanceof \modX) {
            try {
                define('MODX_CORE_PATH', $profile->properties->modx->core_path);
                define('MODX_CONFIG_KEY', !empty($profile->properties->modx->config_key)
                    ? $profile->properties->modx->config_key : 'config');

                require MODX_CORE_PATH . 'model/modx/modx.class.php';

                $logTarget = $this->getConfig()->get('log_target', $options, array('target' => 'ARRAY', 'target_options' => array('var' => &$results)));
                $logLevel = $this->getConfig()->get('log_level', $options, \modX::LOG_LEVEL_INFO);
                $config = array(
                    'log_target' => $logTarget,
                    'log_level' => $logLevel,
                    'cache_db' => false,
                );

                $this->modx = new \modX('', $config);
                $this->modx->setLogLevel($config['log_level']);
                $this->modx->setLogTarget($config['log_target']);
                $this->modx->setOption('cache_db', $config['cache_db']);
                $this->modx->getVersionData();
                if (version_compare($this->modx->version['full_version'], '2.2.1-pl', '>=')) {
                    $this->modx->initialize('mgr', $config);
                } else {
                    $this->modx->initialize('mgr');
                }
                $this->modx->setLogLevel($config['log_level']);
                $this->modx->setLogTarget($config['log_target']);
                $this->modx->setOption('cache_db', $config['cache_db']);
            } catch (\Exception $e) {
                throw new InvalidMODXException("Error initializing MODX: " . $e->getMessage(), $e->getCode(), $e);
            }
        }
        return $this->modx;
    }
public function getMODX ( $ profile = null , array $ options = array ( ) , array & $ results = array ( ) ) { if ( $ profile === null && ! $ this -> modx instanceof \ modX ) { throw new InvalidMODXException ( "No profile or MODX instance was provided" ) ; } if ( ! $ this -> modx instanceof \ modX ) { try { define ( 'MODX_CORE_PATH' , $ profile -> properties -> modx -> core_path ) ; define ( 'MODX_CONFIG_KEY' , ! empty ( $ profile -> properties -> modx -> config_key ) ? $ profile -> properties -> modx -> config_key : 'config' ) ; require MODX_CORE_PATH . 'model/modx/modx.class.php' ; $ logTarget = $ this -> getConfig ( ) -> get ( 'log_target' , $ options , array ( 'target' => 'ARRAY' , 'target_options' => array ( 'var' => & $ results ) ) ) ; $ logLevel = $ this -> getConfig ( ) -> get ( 'log_level' , $ options , \ modX :: LOG_LEVEL_INFO ) ; $ config = array ( 'log_target' => $ logTarget , 'log_level' => $ logLevel , 'cache_db' => false , ) ; $ this -> modx = new \ modX ( '' , $ config ) ; $ this -> modx -> setLogLevel ( $ config [ 'log_level' ] ) ; $ this -> modx -> setLogTarget ( $ config [ 'log_target' ] ) ; $ this -> modx -> setOption ( 'cache_db' , $ config [ 'cache_db' ] ) ; $ this -> modx -> getVersionData ( ) ; if ( version_compare ( $ this -> modx -> version [ 'full_version' ] , '2.2.1-pl' , '>=' ) ) { $ this -> modx -> initialize ( 'mgr' , $ config ) ; } else { $ this -> modx -> initialize ( 'mgr' ) ; } $ this -> modx -> setLogLevel ( $ config [ 'log_level' ] ) ; $ this -> modx -> setLogTarget ( $ config [ 'log_target' ] ) ; $ this -> modx -> setOption ( 'cache_db' , $ config [ 'cache_db' ] ) ; } catch ( \ Exception $ e ) { throw new InvalidMODXException ( "Error initializing MODX: " . $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } return $ this -> modx ; }
Get a MODX reference for Teleport to operate on.

IMPORTANT: Only one modX instance can be instantiated with Teleport in
a single PHP execution cycle.

@param \stdClass|null $profile An object of properties describing the modX instance.
@param array          $options An array of initialization options.
@param array          &$results An optional results array reference.

@throws InvalidMODXException If the MODX instance could not be initialized.
@return \modX A MODX instance.
Get a MODX reference for Teleport to operate on .