-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to use selected CiviOffice documents for applications via remot…
…e API
- Loading branch information
Dominic Tubach
committed
Feb 22, 2024
1 parent
6c2be1c
commit cf2681c
Showing
31 changed files
with
1,648 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
use Civi\Core\Event\GenericHookEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
// phpcs:disable Generic.Files.LineLength.TooLong | ||
final class CRM_Funding_BAO_ApplicationCiviOfficeTemplate extends CRM_Funding_DAO_ApplicationCiviOfficeTemplate implements EventSubscriberInterface { | ||
// phpcs:enable | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function getSubscribedEvents(): array { | ||
return [ | ||
'civi.afform_admin.metadata' => 'onAfformAdminMetadata', | ||
]; | ||
} | ||
|
||
/** | ||
* Provides Afform metadata about this entity. | ||
* | ||
* @see \Civi\AfformAdmin\AfformAdminMeta::getMetadata() | ||
*/ | ||
public static function onAfformAdminMetadata(GenericHookEvent $event): void { | ||
$entity = 'Funding' . pathinfo(__FILE__, PATHINFO_FILENAME); | ||
$event->entities[$entity] = [ | ||
'entity' => $entity, | ||
'label' => $entity, | ||
'type' => 'primary', | ||
'defaults' => '{}', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,302 @@ | ||
<?php | ||
|
||
/** | ||
* @package CRM | ||
* @copyright CiviCRM LLC https://civicrm.org/licensing | ||
* | ||
* Generated from funding/xml/schema/CRM/Funding/FundingApplicationCiviOfficeTemplate.xml | ||
* DO NOT EDIT. Generated by CRM_Core_CodeGen | ||
* (GenCodeChecksum:472671428774bffe15ead8971243e29b) | ||
*/ | ||
use CRM_Funding_ExtensionUtil as E; | ||
|
||
/** | ||
* Database access object for the ApplicationCiviOfficeTemplate entity. | ||
*/ | ||
class CRM_Funding_DAO_ApplicationCiviOfficeTemplate extends CRM_Core_DAO { | ||
const EXT = E::LONG_NAME; | ||
const TABLE_ADDED = ''; | ||
|
||
/** | ||
* Static instance to hold the table name. | ||
* | ||
* @var string | ||
*/ | ||
public static $_tableName = 'civicrm_funding_application_civioffice_template'; | ||
|
||
/** | ||
* Field to show when displaying a record. | ||
* | ||
* @var string | ||
*/ | ||
public static $_labelField = 'label'; | ||
|
||
/** | ||
* Should CiviCRM log any modifications to this table in the civicrm_log table. | ||
* | ||
* @var bool | ||
*/ | ||
public static $_log = TRUE; | ||
|
||
/** | ||
* Unique FundingApplicationCiviOfficeTemplate ID | ||
* | ||
* @var int|string|null | ||
* (SQL type: int unsigned) | ||
* Note that values will be retrieved from the database as a string. | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* FK to FundingCaseType | ||
* | ||
* @var int|string | ||
* (SQL type: int unsigned) | ||
* Note that values will be retrieved from the database as a string. | ||
*/ | ||
public $case_type_id; | ||
|
||
/** | ||
* CiviOffice document URI | ||
* | ||
* @var string | ||
* (SQL type: varchar(255)) | ||
* Note that values will be retrieved from the database as a string. | ||
*/ | ||
public $document_uri; | ||
|
||
/** | ||
* @var string | ||
* (SQL type: varchar(255)) | ||
* Note that values will be retrieved from the database as a string. | ||
*/ | ||
public $label; | ||
|
||
/** | ||
* Class constructor. | ||
*/ | ||
public function __construct() { | ||
$this->__table = 'civicrm_funding_application_civioffice_template'; | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Returns localized title of this entity. | ||
* | ||
* @param bool $plural | ||
* Whether to return the plural version of the title. | ||
*/ | ||
public static function getEntityTitle($plural = FALSE) { | ||
return $plural ? E::ts('Application Templates') : E::ts('Application Template'); | ||
} | ||
|
||
/** | ||
* Returns foreign keys and entity references. | ||
* | ||
* @return array | ||
* [CRM_Core_Reference_Interface] | ||
*/ | ||
public static function getReferenceColumns() { | ||
if (!isset(Civi::$statics[__CLASS__]['links'])) { | ||
Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); | ||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_type_id', 'civicrm_funding_case_type', 'id'); | ||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); | ||
} | ||
return Civi::$statics[__CLASS__]['links']; | ||
} | ||
|
||
/** | ||
* Returns all the column names of this table | ||
* | ||
* @return array | ||
*/ | ||
public static function &fields() { | ||
if (!isset(Civi::$statics[__CLASS__]['fields'])) { | ||
Civi::$statics[__CLASS__]['fields'] = [ | ||
'id' => [ | ||
'name' => 'id', | ||
'type' => CRM_Utils_Type::T_INT, | ||
'title' => E::ts('ID'), | ||
'description' => E::ts('Unique FundingApplicationCiviOfficeTemplate ID'), | ||
'required' => TRUE, | ||
'usage' => [ | ||
'import' => FALSE, | ||
'export' => FALSE, | ||
'duplicate_matching' => FALSE, | ||
'token' => FALSE, | ||
], | ||
'where' => 'civicrm_funding_application_civioffice_template.id', | ||
'table_name' => 'civicrm_funding_application_civioffice_template', | ||
'entity' => 'ApplicationCiviOfficeTemplate', | ||
'bao' => 'CRM_Funding_DAO_ApplicationCiviOfficeTemplate', | ||
'localizable' => 0, | ||
'html' => [ | ||
'type' => 'Number', | ||
], | ||
'readonly' => TRUE, | ||
'add' => NULL, | ||
], | ||
'case_type_id' => [ | ||
'name' => 'case_type_id', | ||
'type' => CRM_Utils_Type::T_INT, | ||
'title' => E::ts('Case Type ID'), | ||
'description' => E::ts('FK to FundingCaseType'), | ||
'required' => TRUE, | ||
'usage' => [ | ||
'import' => FALSE, | ||
'export' => FALSE, | ||
'duplicate_matching' => FALSE, | ||
'token' => FALSE, | ||
], | ||
'where' => 'civicrm_funding_application_civioffice_template.case_type_id', | ||
'table_name' => 'civicrm_funding_application_civioffice_template', | ||
'entity' => 'ApplicationCiviOfficeTemplate', | ||
'bao' => 'CRM_Funding_DAO_ApplicationCiviOfficeTemplate', | ||
'localizable' => 0, | ||
'FKClassName' => 'CRM_Funding_DAO_FundingCaseType', | ||
'html' => [ | ||
'type' => 'EntityRef', | ||
], | ||
'pseudoconstant' => [ | ||
'table' => 'civicrm_funding_case_type', | ||
'keyColumn' => 'id', | ||
'labelColumn' => 'title', | ||
'prefetch' => 'false', | ||
], | ||
'add' => NULL, | ||
], | ||
'document_uri' => [ | ||
'name' => 'document_uri', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
'title' => E::ts('Document Uri'), | ||
'description' => E::ts('CiviOffice document URI'), | ||
'required' => TRUE, | ||
'maxlength' => 255, | ||
'size' => CRM_Utils_Type::HUGE, | ||
'usage' => [ | ||
'import' => FALSE, | ||
'export' => FALSE, | ||
'duplicate_matching' => FALSE, | ||
'token' => FALSE, | ||
], | ||
'where' => 'civicrm_funding_application_civioffice_template.document_uri', | ||
'table_name' => 'civicrm_funding_application_civioffice_template', | ||
'entity' => 'ApplicationCiviOfficeTemplate', | ||
'bao' => 'CRM_Funding_DAO_ApplicationCiviOfficeTemplate', | ||
'localizable' => 0, | ||
'html' => [ | ||
'type' => 'Select', | ||
], | ||
'pseudoconstant' => [ | ||
'callback' => 'Civi\Funding\DocumentRender\CiviOffice\CiviOfficePseudoConstants::getSharedDocumentUris', | ||
], | ||
'add' => NULL, | ||
], | ||
'label' => [ | ||
'name' => 'label', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
'title' => E::ts('Label'), | ||
'required' => TRUE, | ||
'maxlength' => 255, | ||
'size' => CRM_Utils_Type::HUGE, | ||
'usage' => [ | ||
'import' => FALSE, | ||
'export' => FALSE, | ||
'duplicate_matching' => FALSE, | ||
'token' => FALSE, | ||
], | ||
'where' => 'civicrm_funding_application_civioffice_template.label', | ||
'table_name' => 'civicrm_funding_application_civioffice_template', | ||
'entity' => 'ApplicationCiviOfficeTemplate', | ||
'bao' => 'CRM_Funding_DAO_ApplicationCiviOfficeTemplate', | ||
'localizable' => 0, | ||
'html' => [ | ||
'type' => 'Text', | ||
], | ||
'add' => NULL, | ||
], | ||
]; | ||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); | ||
} | ||
return Civi::$statics[__CLASS__]['fields']; | ||
} | ||
|
||
/** | ||
* Return a mapping from field-name to the corresponding key (as used in fields()). | ||
* | ||
* @return array | ||
* Array(string $name => string $uniqueName). | ||
*/ | ||
public static function &fieldKeys() { | ||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { | ||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | ||
} | ||
return Civi::$statics[__CLASS__]['fieldKeys']; | ||
} | ||
|
||
/** | ||
* Returns the names of this table | ||
* | ||
* @return string | ||
*/ | ||
public static function getTableName() { | ||
return self::$_tableName; | ||
} | ||
|
||
/** | ||
* Returns if this table needs to be logged | ||
* | ||
* @return bool | ||
*/ | ||
public function getLog() { | ||
return self::$_log; | ||
} | ||
|
||
/** | ||
* Returns the list of fields that can be imported | ||
* | ||
* @param bool $prefix | ||
* | ||
* @return array | ||
*/ | ||
public static function &import($prefix = FALSE) { | ||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'funding_application_civioffice_template', $prefix, []); | ||
return $r; | ||
} | ||
|
||
/** | ||
* Returns the list of fields that can be exported | ||
* | ||
* @param bool $prefix | ||
* | ||
* @return array | ||
*/ | ||
public static function &export($prefix = FALSE) { | ||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'funding_application_civioffice_template', $prefix, []); | ||
return $r; | ||
} | ||
|
||
/** | ||
* Returns the list of indices | ||
* | ||
* @param bool $localize | ||
* | ||
* @return array | ||
*/ | ||
public static function indices($localize = TRUE) { | ||
$indices = [ | ||
'UI_case_type_id_label' => [ | ||
'name' => 'UI_case_type_id_label', | ||
'field' => [ | ||
0 => 'case_type_id', | ||
1 => 'label', | ||
], | ||
'localizable' => FALSE, | ||
'unique' => TRUE, | ||
'sig' => 'civicrm_funding_application_civioffice_template::1::case_type_id::label', | ||
], | ||
]; | ||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
use Civi\Funding\Controller\PageControllerInterface; | ||
use Civi\Funding\Controller\ApplicationTemplateRenderController; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
final class CRM_Funding_Page_RemoteApplicationTemplateRender extends CRM_Funding_Page_AbstractRemotePage { | ||
|
||
protected function getController(): PageControllerInterface { | ||
return \Civi::service(ApplicationTemplateRenderController::class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Civi\Api4; | ||
|
||
/** | ||
* FundingApplicationCiviOfficeTemplate entity. | ||
* | ||
* Provided by the Funding Program Manager extension. | ||
* | ||
* @package Civi\Api4 | ||
* | ||
* @phpstan-type applicationCiviOfficeTemplateT array{ | ||
* id: integer, | ||
* case_type_id: integer, | ||
* document_uri: string, | ||
* label: string, | ||
* } | ||
*/ | ||
final class FundingApplicationCiviOfficeTemplate extends Generic\DAOEntity { | ||
|
||
} |
Oops, something went wrong.