<?php
$output = '';
$flowcore = $modx->getOption('core_path').'components/modflowthrough/model/';
$flow = $modx->getService('modflowthrough', 'modFlowThrough', $flowcore, $scriptProperties);
if (!$flow instanceof modFlowThrough){
return 'Insantiation failed';
}else{
foreach($_GET as $key => $value){
$scriptProperties[$key] = $value;
}
$scriptProperties['currentResourceId'] = $modx->resource->get('id');
$hook = isset($hook) ? $hook : '';
$output = $flow->$scriptProperties['function']($scriptProperties, $hook);
}
return $output;class modFlowThrough {
function __construct(modX & $modx,array $config = array()) {
$this->modx =& $modx;
$this->modx->setLogLevel(xPDO::LOG_LEVEL_DEBUG);
$this->modx->setLogTarget('ECHO');
$basePath = $this->modx->getOption('modflowthrough.core_path', $config, $this->modx->getOption('core_path').'components/modflowthrough/', true);
$this->config = array_merge(array(
'flowBasePath' => $basePath,
'flowCorePath' => $basePath,
),$config);
if (!$this->modx->addPackage('modflowthrough',$this->config['flowCorePath'].'model/','flow_')) {
return '<br />There was a problem adding your package.<br />';exit();
}
// Load the package lexicon
if(!$this->modx->getService('lexicon','modLexicon')){
echo 'error loading lexicon';
}else{
$this->modx->lexicon->load('modflowthrough:default');
}
echo $this->modx->lexicon('modflowthrough.add_Program_failed');exit();
}This question has been answered by BobRay. See the first response.
The lexicon calculates the path from the core path field of the namespace.
Check in System -> Namespaces. Make sure your package has a namespace there, that the core path entry is correct, and ends with a slash.
$builder = new modPackageBuilder($modx);
$builder->createPackage(PKG_NAME_LOWER, PKG_VERSION, PKG_RELEASE);
$builder->registerNamespace(PKG_NAME_LOWER, false, true,
'{core_path}components/' . PKG_NAME_LOWER . '/',
'{assets_path}components/' . PKG_NAME_LOWER . '/');
Yes it is, but for a typical extra, the namespace is one of the first things created when the transport package is installed. MyComponent, for example, does this automatically for you, but you can do it yourself pretty easily in the build.transport.php file that creates your extra package.
$builder = new modPackageBuilder($modx); $builder->createPackage(PKG_NAME_LOWER, PKG_VERSION, PKG_RELEASE); $assetsPath = '{assets_path}components/' . PKG_NAME_LOWER . '/'; $builder->registerNamespace(PKG_NAME_LOWER, false, true, '{core_path}components/' . PKG_NAME_LOWER . '/', $assetsPath);
// check the namespace
$namespace = 'mynamespace';
$path = '{core_path}components/mynamespace/';
$query = $modx->query("SELECT * FROM `modx_namespaces` where `name` = '".$namespace."'");
if(!$query->fetch(PDO::FETCH_OBJ)){
$newNamespace = "insert into `modx_namespaces` (name,path) values ('".$namespace."','".$path ."');";
$query = $modx->query($newNamespace);
}$nameSpace = $modx->getObject('modNamespace', array('name' => 'mynamespace'));
if (!$nameSpace) {
$nameSpace = $modx->newObject('modNamespace');
$nameSpace->set('name', 'mynamespace');
$nameSpace->set('path', '{core_path}components/mynamespace/');
$nameSpace->save();
}$modx =& $object->xpdo;
Using xPDO would make it a little cleaner:
$nameSpace = $modx->getObject('modNamespace', array('name' => 'mynamespace')); if (!$nameSpace) { $nameSpace = $modx->newObject('modNamespace'); $nameSpace->set('name', 'mynamespace'); $nameSpace->set('path', '{core_path}components/mynamespace/'); $nameSpace->save(); }
If it's in a package resolver, you have to add this at the top:
$modx =& $object->xpdo;