-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2298 from dpfaffenbauer/messenger-standalone
- Loading branch information
Showing
8 changed files
with
128 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/CoreShop/Bundle/MessengerBundle/EventListener/StandaloneAdminJavascriptListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* CoreShop | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - CoreShop Commercial License (CCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
namespace CoreShop\Bundle\MessengerBundle\EventListener; | ||
|
||
use Pimcore\Event\BundleManager\PathsEvent; | ||
use Pimcore\Event\BundleManagerEvents; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
final class StandaloneAdminJavascriptListener implements EventSubscriberInterface | ||
{ | ||
public function __construct( | ||
private RouterInterface $router, | ||
) { | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
BundleManagerEvents::JS_PATHS => 'getAdminJavascript', | ||
]; | ||
} | ||
|
||
public function getAdminJavascript(PathsEvent $event): void | ||
{ | ||
$event->setPaths( | ||
array_merge($event->getPaths(), [ | ||
$this->router->generate('coreshop_menu', ['type' => 'coreshop.messenger']), | ||
'/bundles/coreshopmessenger/pimcore/js/resource_standalone.js', | ||
]), | ||
); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
src/CoreShop/Bundle/MessengerBundle/Resources/config/pimcore/admin.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
core_shop_messenger: | ||
pimcore_admin: | ||
js: | ||
resource: '/bundles/coreshopmessenger/pimcore/js/resource.js' | ||
list: '/bundles/coreshopmessenger/pimcore/js/list.js' | ||
css: | ||
index: '/bundles/coreshopmessenger/pimcore/css/messenger.css' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/CoreShop/Bundle/MessengerBundle/Resources/config/services/resource.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
_defaults: | ||
public: true | ||
|
||
CoreShop\Bundle\MessengerBundle\EventListener\AdminJavascriptListener: | ||
tags: | ||
- { name: kernel.event_subscriber } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/CoreShop/Bundle/MessengerBundle/Resources/public/pimcore/js/resource_standalone.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
/* | ||
* CoreShop. | ||
* | ||
* This source file is subject to the GNU General Public License version 3 (GPLv3) | ||
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt | ||
* files that are distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
pimcore.registerNS('coreshop.messenger.resource'); | ||
|
||
coreshop.messenger.resource = Class.create(pimcore.plugin.admin, { | ||
initialize: function () { | ||
var me = this; | ||
|
||
document.addEventListener(pimcore.events.pimcoreReady, (e) => { | ||
if (coreshop.menu.coreshop.messenger) { | ||
new coreshop.menu.coreshop.messenger(); | ||
} | ||
}); | ||
|
||
document.addEventListener(coreshop.events.menu.open, (e) => { | ||
var item = e.detail.item; | ||
var type = e.detail.type; | ||
|
||
if (type === 'coreshop.messenger' && item.attributes.function === 'list') { | ||
me.openList(); | ||
} | ||
}); | ||
}, | ||
|
||
openList: function () { | ||
try { | ||
pimcore.globalmanager.get('coreshop_messenger_list').activate(); | ||
} catch (e) { | ||
pimcore.globalmanager.add('coreshop_messenger_list', new coreshop.messenger.list()); | ||
} | ||
}, | ||
}); | ||
new coreshop.messenger.resource(); |