function __construct(modX & $modx, array $config= array ()) {
/* Import modx as a reference */
$this->modx= & $modx;$grower->sendNotification( new $modx, 'empty_grow_reminder', $params );
<?php
class extUser extends modUser {
function __construct(xPDO & $xpdo) {
parent::__construct($xpdo);
$this->set('class_key','extUser');
}
public function sendNotification( modX & $modx, $type = 'general', $origin = 'system', $params = false ) {
$this->modx = & $modx;
$this->modx->log(modX::LOG_LEVEL_ERROR, 'This class is being called. : extuser.class.php');
$notification = $this->modx->getObject('Notifications', array('type' => $type) );
if ( !is_object($notification) || !($notification instanceof xPDOObject) ) {
$this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to create object of type: Notification: sendNotification() : extuser.class.php');
return false;
}
}
This question has been answered by multiple community members. See the first response.

Take out the 'new' -- hopefully you don't want a new instance of MODX, you want the real one, which should be available in any request.
I think the error is a byproduct of using a 'new' that's not followed by a class name ($modx is not a class name -- it's an instance of the class). new modX (which is the class name) would make sense, but as I said, I don't think you want a new instance of MODX and unless you're running a stand-alone script outside of MODX. In that case you should instantiate *and* initialize MODX earlier in the code.
class extUser extends modUser {
var $modx;
function __construct(xPDO & $xpdo) {
//etc.class extUser extends modUser {
var $modx;
function __construct(&$modx) {
$this->modx =& $modx;
/* parent::__construct($xpdo); */
$this->set('class_key','extUser');
}
public function sendNotification($type = 'general', $origin = 'system', $params = false ) {
$this->modx->log(modX::LOG_LEVEL_ERROR, 'This class is being called. : extuser.class.php');
$notification = $this->modx->getObject('Notifications', array('type' => $type) );
if ( !is_object($notification) || !($notification instanceof xPDOObject) ) {
$this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to create object of type: Notification: sendNotification() : extuser.class.php');
return false;
}
}
return true;
}I don't think that it is a good idea to re-assign the 'global' $modx object to the class $modx object, which is already a reference to the 'global' $modx object, since it is inherited from modUser/modObject. You don't need that, it is already there.
if (!class_exists('Sampleclass')) {
class Sampleclass
{
function __construct(modX & $modx, array $config= array ()) { // modX as a parameter
/* Import modx as a reference */
$this->modx= & $modx; // <--- And this here is where I am getting the overloading error.
/* Establish the environment */
$this->extPath= $modx->getOption('core_path',null, MODX_CORE_PATH).'components/extendeduser/';<?php
class extUser extends modUser {
var $modx;
function __construct(xPDO & $xpdo) {
parent::__construct($xpdo);
$this->set('class_key','extUser');
}
public function sendNotification(&$modx, $type = 'general', $origin = 'system', $params = false ) {
$this->modx = & $modx;
$this->modx->log(modX::LOG_LEVEL_ERROR, 'This class is being called. : extuser.class.php');
$notification = $this->modx->getObject('Notifications', array('type' => $type) );
if ( !is_object($notification) || !($notification instanceof xPDOObject) ) {
$this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to create object of type: Notification: sendNotification() : extuser.class.php');
return false;
}
}
}
public function sendNotification($type = 'general', $origin = 'system', $params = false ) {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'This class is being called. : extuser.class.php');
$notification = $this->xpdo->getObject('Notifications', array('type' => $type) );
if ( !is_object($notification) || !($notification instanceof xPDOObject) ) {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Failed to create object of type: Notification: sendNotification() : extuser.class.php');
return false;
}
}
class extUser extends modUser {
var $modx;
function __construct(xPDO & $xpdo) {
parent::__construct($xpdo);
$this->modx = & $xpdo; // maybe $this->modx = & $this->xpdo could work too, if I am right
$this->set('class_key','extUser');
}