Skip to content

Commit

Permalink
Correctly check if Prism is installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
netcarver committed Nov 26, 2017
1 parent 900299c commit e84e547
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ModuleReleaseNotes.module
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ModuleReleaseNotes extends Process implements ConfigurableModule {

protected $github_read_info = null;
protected $repo_client = null;
protected $prism = null;
protected $taglist = null;


Expand Down Expand Up @@ -208,7 +207,6 @@ class ModuleReleaseNotes extends Process implements ConfigurableModule {
* commit messages to the download confirmation form.
*/
$this->addHookAfter("ProcessModule::buildDownloadConfirmForm", function($event) {
$this->prism = $this->modules->get('TextformatterPrism');
$info = $event->arguments[0];
$module_class = $info['class_name'];
$current_info = $this->modules->getModuleInfo($module_class);
Expand Down Expand Up @@ -439,7 +437,6 @@ class ModuleReleaseNotes extends Process implements ConfigurableModule {
* installation. This allows access to a level of help for modules that wasn't there before.
*/
$this->addHookAfter("ProcessModule::executeEdit", function($event) {
$this->prism = $this->modules->get('TextformatterPrism');
$info = null;
$module_class = '';
$append_info = false;
Expand Down Expand Up @@ -608,8 +605,8 @@ class ModuleReleaseNotes extends Process implements ConfigurableModule {
}
$content = $this->sanitizeString($unsafe_content);
$transforms[] = __('HTML Purifier');
if ($this->prism && $this->usePrismIfAvailable) {
$this->prism->format($content);
if ($this->usePrismIfAvailable && $this->modules->isInstalled('TextformatterPrism')) {
$this->modules->get('TextformatterPrism')->format($content);
$transforms[] = __('Prism Code Highlighter');
}
$content = $this->changeH1toH2($content);
Expand Down Expand Up @@ -833,7 +830,7 @@ class ModuleReleaseNotes extends Process implements ConfigurableModule {
$f->columnWidth = 50;
$module_config->add($f);

if ($modules->get('TextformatterPrism')) {
if ($modules->isInstalled('TextformatterPrism')) {
$f = $modules->get('InputfieldRadios');
$f->attr('name', 'usePrismIfAvailable');
$f->label = __('Use PRISM code formatting - if possible?');
Expand Down

2 comments on commit e84e547

@adrianbj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @netcarver - looks like you feel victim to this: processwire/processwire-requests#135

Not sure what you think about my thoughts there, but wanted to bring it to your attention in case you feel like commenting.

@netcarver
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @adrianbj - yes, the current API isn't particularly intuitive - where a call to get() actually installs a module - but it is documented. Thanks for pointing me to your pull request - will take a look there.

Please sign in to comment.