class Event extends xPDOSimpleObject {
public function addDate {
$date = $this->modx->newObject('eventDate');
$date->set('title', $title);
$date->save();
}
}class eventDate extends xPDOSimpleObject {
public function addDate {
$this->set('title', $title);
$this->save();
}
}This question has been answered by multiple community members. See the first response.
$eventDate = $modx->newObject('eventDate');
$eventDate->addDate($title); // assuming $title is supposed to be passed in?$eventDate = eventDate::addDate($modx, $title);
public static function addDate(modX $modx, $title) {
$inst = $modx->newObject('eventDate');
$inst->set('title', $title);
$inst->save();
return $inst;
}
$sgf = $modx->getService('signfy','Signfy',$modx->getOption('signfy.core_path',null,$modx->getOption('core_path').'components/signfy/').'model/signfy/',$scriptProperties);
if (!($sgf instanceof Signfy)) return 'Error';
$signfy = new Signfy($modx, array());
return $signfy->test('test');<?php
class Signfy {
public $modx;
public $config = array();
public function __construct(modX &$modx,array $config = array()) {
$this->modx =& $modx;
$basePath = $this->modx->getOption('signfy.core_path',$config,$this->modx->getOption('core_path').'components/signfy/');
$assetsUrl = $this->modx->getOption('signfy.assets_url',$config,$this->modx->getOption('assets_url').'components/signfy/');
$this->config = array_merge(array(
'basePath' => $basePath,
'corePath' => $basePath,
'modelPath' => $basePath.'model/',
'processorsPath' => $basePath.'processors/',
'templatesPath' => $basePath.'templates/',
'chunksPath' => $basePath.'elements/chunks/',
'jsUrl' => $assetsUrl.'js/',
'cssUrl' => $assetsUrl.'css/',
'assetsUrl' => $assetsUrl,
'connectorUrl' => $assetsUrl.'connector.php',
),$config);
$this->modx->addPackage('signfy',$this->config['modelPath']);
}
public function test($title) {
return $title;
}
}
<?php
class sgfEvent extends xPDOSimpleObject {
public function addEvent($title) {
return 'Works';
}
}And now i would like to call a function of the sgfevent.class.php
$event = $modx->getObject('sgfEvent', ['id' => 10]);
$event->addEvent('foo bar');
$event = $modx->newObject('sgfEvent');
$event->set('some_field', 'some value');
$event->addEvent('foo bar');