info.xml - Parse the `<upgrader>` tag
authorTim Otten <totten@civicrm.org>
Sat, 17 Apr 2021 03:38:14 +0000 (20:38 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 21 Apr 2021 06:28:25 +0000 (23:28 -0700)
CRM/Extension/Info.php
tests/phpunit/CRM/Extension/InfoTest.php

index 55e379caf7fd7c4fec2b9b4b334e13f1c75014d8..8b8ee51143794cc307561b1101f4036bf823c3c7 100644 (file)
@@ -65,6 +65,13 @@ class CRM_Extension_Info {
    */
   public $maintainer = NULL;
 
+  /**
+   * @var string|null
+   *  The name of a class which handles the install/upgrade lifecycle.
+   * @see \CRM_Extension_Upgrader_Interface
+   */
+  public $upgrader = NULL;
+
   /**
    * Load extension info an XML file.
    *
@@ -150,6 +157,7 @@ class CRM_Extension_Info {
     $this->type = (string) $info->attributes()->type;
     $this->file = (string) $info->file;
     $this->label = (string) $info->name;
+    $this->upgrader = (string) $info->upgrader;
 
     // Convert first level variables to CRM_Core_Extension properties
     // and deeper into arrays. An exception for URLS section, since
index 73e577fad86d5aa0c9bf7bf70344d36a93b33cdc..c801435e95a3a01bee7ee3e17d58b29dbdc8bcaf 100644 (file)
@@ -50,6 +50,7 @@ class CRM_Extension_InfoTest extends CiviUnitTestCase {
     $this->assertEquals('test.foo', $info->key);
     $this->assertEquals('foo', $info->file);
     $this->assertEquals('zamboni', $info->typeInfo['extra']);
+    $this->assertEquals(NULL, $info->upgrader);
     $this->assertEquals([], $info->requires);
   }
 
@@ -59,6 +60,7 @@ class CRM_Extension_InfoTest extends CiviUnitTestCase {
         <psr4 prefix=\"Civi\\\" path=\"Civi\"/>
         <psr0 prefix=\"CRM_\" path=\"\"/>
       </classloader>
+      <upgrader>CRM_Foo_Upgrader</upgrader>
       <requires><ext>org.civicrm.a</ext><ext>org.civicrm.b</ext></requires>
     </extension>
     ";
@@ -72,6 +74,7 @@ class CRM_Extension_InfoTest extends CiviUnitTestCase {
     $this->assertEquals('CRM_', $info->classloader[1]['prefix']);
     $this->assertEquals('', $info->classloader[1]['path']);
     $this->assertEquals('psr0', $info->classloader[1]['type']);
+    $this->assertEquals('CRM_Foo_Upgrader', $info->upgrader);
     $this->assertEquals(['org.civicrm.a', 'org.civicrm.b'], $info->requires);
   }