Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnBeforeInitSession event #53

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions _build/data/transport.core.events.php
Original file line number Diff line number Diff line change
Expand Up @@ -1208,5 +1208,11 @@
'service' => 2,
'groupname' => 'Package Manager',
), '', true, true);
$events['OnBeforeInitSession']= $xpdo->newObject(modEvent::class);
$events['OnBeforeInitSession']->fromArray([
'name' => 'OnBeforeInitSession',
'service' => 5,
'groupname' => 'System',
], '', true, true);

return $events;
6 changes: 4 additions & 2 deletions core/model/modx/modx.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ protected function _initContext($contextKey, $regenerate = false, $options = nul
}
if ($initialized) {
$this->setLogLevel($this->getOption('log_level', $options, xPDO::LOG_LEVEL_ERROR));

$logTarget = $this->getOption('log_target', $options, 'FILE', true);
if ($logTarget === 'FILE') {
$options = array();
Expand All @@ -2502,7 +2502,7 @@ protected function _initContext($contextKey, $regenerate = false, $options = nul
} else {
$this->setLogTarget($logTarget);
}

$debug = $this->getOption('debug');
if (!is_null($debug) && $debug !== '') {
$this->setDebug($debug);
Expand Down Expand Up @@ -2573,6 +2573,8 @@ protected function _initEventMap($contextKey) {
* @param array|null $options Options to override Settings explicitly.
*/
protected function _initSession($options = null) {
$this->invokeEvent('OnBeforeInitSession', is_array($options) ? $options : []);

$contextKey= $this->context instanceof modContext ? $this->context->get('key') : null;
if ($this->getOption('session_enabled', $options, true) || isset($_GET['preview'])) {
if (!in_array($this->getSessionState(), array(modX::SESSION_STATE_INITIALIZED, modX::SESSION_STATE_EXTERNAL, modX::SESSION_STATE_UNAVAILABLE), true)) {
Expand Down
7 changes: 5 additions & 2 deletions core/model/modx/sources/modmediasource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ public function initialize()
{
$this->setProperties($this->getProperties(true));
$this->getPermissions();
$this->xpdo->lexicon->load('file');

if ($this->xpdo->lexicon) {
$this->xpdo->lexicon->load('file');
}

if (!$this->ctx) {
$this->ctx =& $this->xpdo->context;
Expand Down Expand Up @@ -1370,7 +1373,7 @@ public function parseProperties(array $properties)
public function prepareProperties(array $properties = [])
{
foreach ($properties as &$property) {
if (!empty($property['lexicon'])) {
if (!empty($property['lexicon']) && $this->xpdo->lexicon) {
$this->xpdo->lexicon->load($property['lexicon']);
}
if (!empty($property['name'])) {
Expand Down