Merge pull request #14356 from civicrm/5.14
[civicrm-core.git] / CRM / Contact / ActionMapping.php
index 75ac0d489651148157592057c958043d5784cb0b..2f5f7b28d7deef350738befebc51102d7ed030a2 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -25,7 +25,6 @@
  +--------------------------------------------------------------------+
  */
 
-use Civi\ActionSchedule\RecipientBuilder;
 
 /**
  * Class CRM_Contact_ActionMapping
@@ -51,7 +50,7 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
    * @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations
    */
   public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) {
-    $registrations->register(CRM_Contact_ActionMapping::create(array(
+    $registrations->register(CRM_Contact_ActionMapping::create([
       'id' => CRM_Contact_ActionMapping::CONTACT_MAPPING_ID,
       'entity' => 'civicrm_contact',
       'entity_label' => ts('Contact'),
@@ -60,14 +59,14 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
       'entity_status' => 'contact_date_reminder_options',
       'entity_status_label' => ts('Annual Options'),
       'entity_date_start' => 'date_field',
-    )));
+    ]));
   }
 
-  private $contactDateFields = array(
+  private $contactDateFields = [
     'birth_date',
     'created_date',
     'modified_date',
-  );
+  ];
 
   /**
    * Determine whether a schedule based on this mapping is sufficiently
@@ -79,7 +78,7 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
    *   List of error messages.
    */
   public function validateSchedule($schedule) {
-    $errors = array();
+    $errors = [];
     if (CRM_Utils_System::isNull($schedule->entity_value) || $schedule->entity_value === '0') {
       $errors['entity'] = ts('Please select a specific date field.');
     }
@@ -119,30 +118,31 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping {
     elseif (in_array($selectedValues[0], $this->contactDateFields)) {
       $dateDBField = $selectedValues[0];
       $query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams);
-      $query->param(array(
+      $query->param([
         'casAddlCheckFrom' => 'civicrm_contact e',
         'casContactIdField' => 'e.id',
         'casEntityIdField' => 'e.id',
         'casContactTableAlias' => 'e',
-      ));
+      ]);
       $query->where('e.is_deleted = 0 AND e.is_deceased = 0');
     }
     else {
       //custom field
-      $customFieldParams = array('id' => substr($selectedValues[0], 7));
-      $customGroup = $customField = array();
+      $customFieldParams = ['id' => substr($selectedValues[0], 7)];
+      $customGroup = $customField = [];
       \CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField);
       $dateDBField = $customField['column_name'];
-      $customGroupParams = array('id' => $customField['custom_group_id'], $customGroup);
+      $customGroupParams = ['id' => $customField['custom_group_id'], $customGroup];
       \CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup);
       $query = \CRM_Utils_SQL_Select::from("{$customGroup['table_name']} e")->param($defaultParams);
-      $query->param(array(
+      $query->param([
         'casAddlCheckFrom' => "{$customGroup['table_name']} e",
         'casContactIdField' => 'e.entity_id',
         'casEntityIdField' => 'e.id',
         'casContactTableAlias' => NULL,
-      ));
-      $query->where('1'); // possible to have no "where" in this case
+      ]);
+      // possible to have no "where" in this case
+      $query->where('1');
     }
 
     $query['casDateField'] = 'e.' . $dateDBField;