Plugins - Allow CiviCRM extensions to define plugins/commands for cv#219
Draft
totten wants to merge 3 commits intocivicrm:masterfrom
Draft
Plugins - Allow CiviCRM extensions to define plugins/commands for cv#219totten wants to merge 3 commits intocivicrm:masterfrom
totten wants to merge 3 commits intocivicrm:masterfrom
Conversation
Member
Author
|
Some open todos:
|
117c0f6 to
19b2bc8
Compare
19b2bc8 to
c6b689b
Compare
Member
Author
|
A lot of the base-command shuffling has been merged, so this is smaller now. Still needs work. But I also need to switch over to other things for a while. Just noting - for my local testing of this, I would put this bit of glue-code inside an extension main-file: diff --git a/info.xml b/info.xml
index 946e0c0..fb27a5e 100644
--- a/info.xml
+++ b/info.xml
@@ -34,6 +34,7 @@
<classloader>
<psr0 prefix="CRM_" path=""/>
<psr4 prefix="Civi\" path="Civi"/>
+ <psr4 prefix="CvPlugin\" path="CvPlugin"/>
</classloader>
<mixins>
<mixin>ang-php@1.0.0</mixin>
diff --git a/mosaico.php b/mosaico.php
index 9a2e8ed..ce3a0b4 100644
--- a/mosaico.php
+++ b/mosaico.php
@@ -3,6 +3,26 @@
require_once 'mosaico.civix.php';
use CRM_Mosaico_ExtensionUtil as E;
+Civi::dispatcher()->addListener('&civi.cv-lib.plugins', function (array &$plugins, array $pluginEnv) {
+ if ($pluginEnv['protocol'] !== 1) {
+ return;
+ }
+
+ // Load a single plugin file, eg "myextension.cv-plugin.php"
+ $f = __DIR__ . '/' . E::SHORT_NAME . '.' . $pluginEnv['appName'] . '-plugin.php';
+ if (file_exists($f)) {
+ $plugins[E::SHORT_NAME] = $f;
+ }
+
+ // Load a folder `./CvPlugin` with various classes
+ $appNs = CRM_Utils_String::convertStringToCamel($pluginEnv['appName']) . 'Plugin';
+ $folder = __DIR__ . '/' . $appNs;
+ if (file_exists($folder)) {
+ \Civi\Cv\Cv::app()->add(new \CvPlugin\Command\HelloCommand());
+ // FIXME: Scan $folder and instantiate commands. Maybe similar to ClassScanner::scanFolders()
+ }
+});
+
/**
* Implements hook_civicrm_config().
*With a little more polishing, that could become a suitable basis for implementing |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(draft / description TODO - just checking Jenkins for now - depends on #218)