Use a fqn prefix for modTransport classes:
$modx->getTableName('modTransportPackage')
to
$modx->getTableName('transport.modTransportPackage')
Replace retrieving the manager_language system setting with a $_SESSION based one:
$language = $this->modx->getOption('manager_language');
to
$language = $this->modx->getOption('manager_language', array(), $this->modx->getOption('manager_language', $_SESSION, 'en'));
If a processor class uses $this->classKey to avoid ambiguous column names, $this->classAlias can be set to the class name in the constructor:
/**
* @var string $classAlias The class alias
*/
protected $classAlias;
/**
* Set the class alias on base of the class key for compatibility between 2.x/3.x
* @param modX $modx
* @param array $properties
*/
public function __construct(modX &$modx, array $properties = array())
{
parent::__construct($modx, $properties);
$this->classAlias = $this->classKey;
if (strpos($this->classAlias, '\\') !== false) {
$explodedAlias = explode('\\', $this->classAlias);
$this->classAlias = array_pop($explodedAlias);
}
}
Later on $this->classKey has to be replaced with $this->classAlias to reference a column:
/**
* {@inheritDoc}
* @param xPDOQuery $c
* @return xPDOQuery
*/
public function prepareQueryBeforeCount(xPDOQuery $c): xPDOQuery
{
$valuesQuery = $this->getProperty('valuesqry');
$query = (!$valuesQuery) ? $this->getProperty('query') : '';
if (!empty($query)) {
$c->where([
$this->classAlias . '.username:LIKE' => '%' . $query . '%',
'Profile.fullname:LIKE' => '%' . $query . '%'
]);
}
$c->leftJoin('modUserProfile', 'Profile');
$c->select($this->modx->getSelectColumns($this->classKey, $this->classAlias, '', [
'id', 'username'
]));
$c->select($this->modx->getSelectColumns('modUserProfile', 'Profile', 'profile_', [
'id', 'fullname'
]));
return $c;
}
If a core processor class was extended and has to be work in both versions:
require_once MODX_PROCESSORS_PATH . 'security/user/getlist.class.php';
to
// Compatibility between 2.x/3.x
if (file_exists(MODX_PROCESSORS_PATH . 'security/user/getlist.class.php')) {
require_once MODX_PROCESSORS_PATH . 'security/user/getlist.class.php';
} elseif (!class_exists('modContextGetListProcessor')) {
class_alias(\MODX\Revolution\Processors\Security\User\GetList::class, \modUserGetListProcessor::class);
}