Yeah I did,
I have all the files in the model directory. here is my snippet cal the the Sandbox class:
$sandbox = $modx->getService('sandbox','Sandbox',$modx->getOption('sandbox.core_path',null,$modx->getOption('core_path').'components/sandbox/').'model/sandbox/',$scriptProperties);
if (!($sandbox instanceof Sandbox)) return '';
And this is my sandbox.class.php
<?php
class Sandbox {
public $modx;
public $config = array();
function __construct(modX &$modx,array $config = array()) {
$this->modx =& $modx;
$basePath = $this->modx->getOption('sandbox.core_path',$config,$this->modx->getOption('core_path').'components/sandbox/');
$assetsUrl = $this->modx->getOption('sandbox.assets_url',$config,$this->modx->getOption('assets_url').'components/sandbox/');
$this->config = array_merge(array(
'basePath' => $basePath,
'corePath' => $basePath,
'modelPath' => $basePath.'model/',
'processorsPath' => $basePath.'processors/',
'chunksPath' => $basePath.'elements/chunks/',
'jsUrl' => $assetsUrl.'js/',
'cssUrl' => $assetsUrl.'css/',
'assetsUrl' => $assetsUrl,
'connectorUrl' => $assetsUrl.'connector.php',
),$config);
$this->modx->addPackage('sandbox',$this->config['modelPath']);
}
public function getChunk($name,$properties = array()) {
$chunk = null;
if (!isset($this->chunks[$name])) {
$chunk = $this->_getTplChunk($name);
if (empty($chunk)) {
$chunk = $this->modx->getObject('modChunk',array('name' => $name));
if ($chunk == false) return false;
}
$this->chunks[$name] = $chunk->getContent();
} else {
$o = $this->chunks[$name];
$chunk = $this->modx->newObject('modChunk');
$chunk->setContent($o);
}
$chunk->setCacheable(false);
return $chunk->process($properties);
}
private function _getTplChunk($name,$postfix = '.chunk.tpl') {
$chunk = false;
$f = $this->config['chunksPath'].strtolower($name).$postfix;
if (file_exists($f)) {
$o = file_get_contents($f);
$chunk = $this->modx->newObject('modChunk');
$chunk->set('name',$name);
$chunk->setContent($o);
}
return $chunk;
}
}
I tested if it is a instanceof, and it is. So I really don’t know why I have this error.
---- EDIT -----
I can use the chunk function, so the class is working correct, I just wont create a table.
Thanks so far