APIv4 - Deprecate unnecessary constants
authorColeman Watts <coleman@civicrm.org>
Fri, 10 Mar 2023 20:25:46 +0000 (15:25 -0500)
committerColeman Watts <coleman@civicrm.org>
Fri, 10 Mar 2023 20:28:48 +0000 (15:28 -0500)
Civi/Api4/Event/Events.php
Civi/Api4/Event/Subscriber/ActivitySchemaMapSubscriber.php
Civi/Api4/Event/Subscriber/ContactSchemaMapSubscriber.php
Civi/Api4/Event/Subscriber/MessageTemplateSchemaMapSubscriber.php
Civi/Api4/Service/Schema/SchemaMapBuilder.php

index 70b54400854791c82dbff585c62af91c217a6627..1701f51fa0b92a51a00708015a7dcb0e042279c6 100644 (file)
 
 namespace Civi\Api4\Event;
 
+/**
+ * @deprecated
+ */
 class Events {
 
   /**
-   * Build the database schema, allow adding of custom joins and tables.
+   * @deprecated
+   * Just use the string instead of the constant when listening for this event
    */
   const SCHEMA_MAP_BUILD = 'api.schema_map.build';
 
   /**
-   * Add back POST_SELECT_QUERY const due to Joomla upgrade failure
+   * @deprecated
+   * Unused - there is no longer an event with this name
    * https://lab.civicrm.org/dev/joomla/-/issues/28#note_39487
    */
   const POST_SELECT_QUERY = 'api.select_query.post';
index bf32edb1e414fb6bfff1d2af7c22bd7bb81801fc..66b8fee472ac28fafe4a960955d424493dbb260d 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Civi\Api4\Event\Subscriber;
 
-use Civi\Api4\Event\Events;
 use Civi\Api4\Event\SchemaMapBuildEvent;
 use Civi\Api4\Service\Schema\Joinable\ExtraJoinable;
 use Civi\Api4\Service\Schema\Joinable\Joinable;
@@ -18,7 +17,7 @@ class ActivitySchemaMapSubscriber extends \Civi\Core\Service\AutoService impleme
    */
   public static function getSubscribedEvents() {
     return [
-      Events::SCHEMA_MAP_BUILD => 'onSchemaBuild',
+      'api.schema_map.build' => 'onSchemaBuild',
     ];
   }
 
index e5ef8156638f6bde05ca3f61667e9a4546a0d1dd..c73b581cba8aabbeb33c87316395a92c55ef65d3 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Civi\Api4\Event\Subscriber;
 
-use Civi\Api4\Event\Events;
 use Civi\Api4\Event\SchemaMapBuildEvent;
 use Civi\Api4\Service\Schema\Joinable\Joinable;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -17,7 +16,7 @@ class ContactSchemaMapSubscriber extends \Civi\Core\Service\AutoService implemen
    */
   public static function getSubscribedEvents() {
     return [
-      Events::SCHEMA_MAP_BUILD => 'onSchemaBuild',
+      'api.schema_map.build' => 'onSchemaBuild',
     ];
   }
 
index 3f218f31c65be7b1880e3e2225de1c804a67d018..108c322f2fdb455103b5846147153ba80576fc4c 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Civi\Api4\Event\Subscriber;
 
-use Civi\Api4\Event\Events;
 use Civi\Api4\Event\SchemaMapBuildEvent;
 use Civi\Api4\Service\Schema\Joinable\Joinable;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -17,7 +16,7 @@ class MessageTemplateSchemaMapSubscriber extends \Civi\Core\Service\AutoService
    */
   public static function getSubscribedEvents() {
     return [
-      Events::SCHEMA_MAP_BUILD => 'onSchemaBuild',
+      'api.schema_map.build' => 'onSchemaBuild',
     ];
   }
 
index 7401539fe25e34a4e37aa593b5b67033feecbb05..1db48f17fbc05c4a33303d29c7131b7ba3e837c9 100644 (file)
@@ -13,7 +13,6 @@
 namespace Civi\Api4\Service\Schema;
 
 use Civi\Api4\Entity;
-use Civi\Api4\Event\Events;
 use Civi\Api4\Event\SchemaMapBuildEvent;
 use Civi\Api4\Service\Schema\Joinable\CustomGroupJoinable;
 use Civi\Api4\Service\Schema\Joinable\Joinable;
@@ -52,7 +51,7 @@ class SchemaMapBuilder extends AutoService {
     $this->loadTables($map);
 
     $event = new SchemaMapBuildEvent($map);
-    $this->dispatcher->dispatch(Events::SCHEMA_MAP_BUILD, $event);
+    $this->dispatcher->dispatch('api.schema_map.build', $event);
 
     return $map;
   }