*/
class CRM_Activity_Form_Task_PDF extends CRM_Activity_Form_Task {
+ use CRM_Contact_Form_Task_PDFTrait;
+
/**
* Build all the data structures needed to build the form.
*/
CRM_Activity_Form_Task_PDFLetterCommon::preProcess($this);
}
- /**
- * Set defaults for the pdf.
- *
- * @return array
- */
- public function setDefaultValues() {
- return CRM_Activity_Form_Task_PDFLetterCommon::setDefaultValues();
- }
-
/**
* Build the form object.
*/
* This class provides the functionality to create PDF letter for a group of contacts.
*/
class CRM_Case_Form_Task_PDF extends CRM_Case_Form_Task {
+
+ use CRM_Contact_Form_Task_PDFTrait;
+
/**
* All the existing templates in the system.
*
$this->setContactIDs();
}
- /**
- * Set defaults for the pdf.
- *
- * @return array
- */
- public function setDefaultValues() {
- return CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
- }
-
/**
* Build the form object.
*/
*/
class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task {
+ use CRM_Contact_Form_Task_PDFTrait;
+
/**
* All the existing templates in the system.
*
* Set default values for the form.
*/
public function setDefaultValues() {
- $defaults = [];
+ $defaults = $this->getPDFDefaultValues();
if (isset($this->_activityId)) {
$params = ['id' => $this->_activityId];
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
$defaults['html_message'] = $defaults['details'] ?? NULL;
}
- $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
return $defaults;
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+/**
+ * This class provides the common functionality for tasks that send emails.
+ */
+trait CRM_Contact_Form_Task_PDFTrait {
+
+ /**
+ * Set defaults for the pdf.
+ *
+ * @return array
+ */
+ public function setDefaultValues(): array {
+ return $this->getPDFDefaultValues();
+ }
+
+ /**
+ * Set default values.
+ */
+ protected function getPDFDefaultValues(): array {
+ $defaultFormat = CRM_Core_BAO_PdfFormat::getDefaultValues();
+ $defaultFormat['format_id'] = $defaultFormat['id'];
+ return $defaultFormat;
+ }
+
+}
*/
class CRM_Contribute_Form_Task_PDFLetter extends CRM_Contribute_Form_Task {
+ use CRM_Contact_Form_Task_PDFTrait;
+
/**
* All the existing templates in the system.
*
* @return array
*/
public function setDefaultValues() {
- $defaults = [];
+ $defaults = $this->getPDFDefaultValues();
if (isset($this->_activityId)) {
$params = ['id' => $this->_activityId];
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
else {
$defaults['thankyou_update'] = 1;
}
- $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
return $defaults;
}
/**
* Set default values.
+ *
+ * @deprecated
*/
public static function setDefaultValues() {
+ CRM_Core_Error::deprecatedFunctionWarning('no alternative');
$defaultFormat = CRM_Core_BAO_PdfFormat::getDefaultValues();
$defaultFormat['format_id'] = $defaultFormat['id'];
return $defaultFormat;
*/
class CRM_Event_Form_Task_PDF extends CRM_Event_Form_Task {
+ use CRM_Contact_Form_Task_PDFTrait;
+
/**
* Are we operating in "single mode", i.e. printing letter to one
* specific participant?
CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this);
}
- /**
- * Set default values for the form.
- *
- * @return void
- */
- public function setDefaultValues() {
- return CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
- }
-
/**
* List available tokens for this form.
*
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
}
- /**
- * Set defaults.
- * (non-PHPdoc)
- * @see CRM_Core_Form::setDefaultValues()
- */
- public function setDefaultValues() {
- return CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
- }
-
/**
* Build the form object.
*