CRM-13927 - Counties: don't need to find path to county file
[civicrm-core.git] / CRM / Admin / Form / Job.php
index 4a147c31f817e0a7ff2b91524dace92411dd8b34..c9ec3be713e0e7acf0d5f8ed744f048197088034 100644 (file)
@@ -112,13 +112,12 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form {
 
     require_once 'api/api.php';
 
-    $apiRequest = array();
-    $apiRequest['entity']  = CRM_Utils_String::munge($fields['api_entity']);
-    $apiRequest['action']  = CRM_Utils_String::munge($fields['api_action']);
-    $apiRequest['version'] = 3;
-    $apiRequest += _civicrm_api_resolve($apiRequest);    // look up function, file, is_generic
-
-    if( !$apiRequest['function'] ) {
+    /** @var \Civi\API\Kernel $apiKernel */
+    $apiKernel = \Civi\Core\Container::singleton()->get('civi_api_kernel');
+    $apiRequest = $apiKernel->createRequest($fields['api_entity'], $fields['api_action'], array('version' => 3), NULL);
+    try {
+      $apiKernel->resolve($apiRequest);
+    } catch (\Civi\API\Exception\NotImplementedException $e) {
       $errors['api_action'] = ts('Given API command is not defined.');
     }