-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
200 additions
and
69 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
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
This file was deleted.
Oops, something went wrong.
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,66 @@ | ||
<?php | ||
/** | ||
* SiteModule | ||
* | ||
* @link https://nystudio107.com | ||
* @copyright Copyright (c) 2017 nystudio107 | ||
*/ | ||
|
||
namespace modules\nystudio107\sitemodule; | ||
|
||
use modules\nystudio107\sitemodule\assetbundles\sitemodule\SiteModuleAsset; | ||
|
||
use Craft; | ||
use craft\events\TemplateEvent; | ||
use craft\web\View; | ||
|
||
use yii\base\Event; | ||
use yii\base\InvalidConfigException; | ||
use yii\base\Module; | ||
|
||
/** | ||
* @author nystudio107 | ||
* @package SiteModule | ||
* @since 1.0.0 | ||
* @inheritdoc | ||
*/ | ||
class SiteModule extends Module | ||
{ | ||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
Craft::setAlias('@site-module', $this->getBasePath()); | ||
parent::init(); | ||
|
||
// Only respond to AdminCP requests | ||
$request = Craft::$app->getRequest(); | ||
if ($request->getIsCpRequest()) { | ||
// Handler: View::EVENT_BEFORE_RENDER_TEMPLATE | ||
Event::on( | ||
View::class, | ||
View::EVENT_BEFORE_RENDER_TEMPLATE, | ||
function (TemplateEvent $event) { | ||
Craft::trace( | ||
'View::EVENT_BEFORE_RENDER_TEMPLATE', | ||
__METHOD__ | ||
); | ||
// Add our SiteModule AssetBundle | ||
$view = Craft::$app->getView(); | ||
try { | ||
$view->registerAssetBundle(SiteModuleAsset::class); | ||
} catch (InvalidConfigException $e) { | ||
Craft::error( | ||
'Error registering AssetBundle - '.$e->getMessage(), | ||
__METHOD__ | ||
); | ||
} | ||
} | ||
); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
modules/nystudio107/sitemodule/assetbundles/sitemodule/SiteModuleAsset.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,48 @@ | ||
<?php | ||
/** | ||
* SiteModule AssetBundle | ||
* | ||
* @link https://nystudio107.com | ||
* @copyright Copyright (c) 2017 nystudio107 | ||
*/ | ||
|
||
namespace modules\nystudio107\sitemodule\assetbundles\sitemodule; | ||
|
||
use craft\redactor\assets\redactor\RedactorAsset; | ||
use craft\web\AssetBundle; | ||
use craft\web\assets\cp\CpAsset; | ||
|
||
/** | ||
* @author nystudio107 | ||
* @package SiteModule | ||
* @since 1.0.0 | ||
* @inheritdoc | ||
*/ | ||
class SiteModuleAsset extends AssetBundle | ||
{ | ||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
// Set the path to our AssetBundle source | ||
$this->sourcePath = '@site-module/assetbundles/sitemodule/dist'; | ||
// Declare AssetBundles that must be loaded first | ||
$this->depends = [ | ||
CpAsset::class, | ||
]; | ||
// Add in our CSS | ||
$this->css = [ | ||
'css/SiteModule.css', | ||
]; | ||
// Add in our JS | ||
$this->js = [ | ||
'js/SiteModule.js', | ||
]; | ||
|
||
parent::init(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
modules/nystudio107/sitemodule/assetbundles/sitemodule/dist/css/SiteModule.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* SiteModule CSS | ||
* | ||
* @author nystudio107 | ||
* @copyright Copyright (c) 2017 nystudio107 | ||
* @link https://nystudio107.com | ||
* @package SiteModule | ||
* @since 1.0.0 | ||
*/ |
Empty file.
9 changes: 9 additions & 0 deletions
9
modules/nystudio107/sitemodule/assetbundles/sitemodule/dist/js/SiteModule.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,9 @@ | ||
/** | ||
* SiteModule JS | ||
* | ||
* @author nystudio107 | ||
* @copyright Copyright (c) 2017 nystudio107 | ||
* @link https://nystudio107.com | ||
* @package SiteModule | ||
* @since 1.0.0 | ||
*/ |
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