Skip to content

Commit

Permalink
add entity files
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Mar 23, 2020
1 parent 33d0b51 commit 868ca4b
Show file tree
Hide file tree
Showing 6 changed files with 490 additions and 42 deletions.
26 changes: 26 additions & 0 deletions CRM/Cdntaxreceipts/BAO/CdnAdvantage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
use CRM_Cdntaxreceipts_ExtensionUtil as E;

class CRM_Cdntaxreceipts_BAO_CdnAdvantage extends CRM_Cdntaxreceipts_DAO_CdnAdvantage {

/**
* Create a new CdnAdvantage based on array-data
*
* @param array $params key-value pairs
* @return CRM_Cdntaxreceipts_DAO_CdnAdvantage|NULL
*
public static function create($params) {
$className = 'CRM_Cdntaxreceipts_DAO_CdnAdvantage';
$entityName = 'CdnAdvantage';
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
return $instance;
} */

}
170 changes: 170 additions & 0 deletions CRM/Cdntaxreceipts/DAO/CdnAdvantage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php

/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from /Users/monish/src/civi-extensions/CDNTaxReceipts/xml/schema/CRM/Cdntaxreceipts/CdnAdvantage.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:8f2f9a909d8d4bddeb38db84b7b21d56)
*/

/**
* Database access object for the CdnAdvantage entity.
*/
class CRM_Cdntaxreceipts_DAO_CdnAdvantage extends CRM_Core_DAO {

/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'cdntaxreceipts_advantage';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var bool
*/
public static $_log = TRUE;

/**
* Unique CdnAdvantage ID
*
* @var int
*/
public $id;

/**
* FK to Contact
*
* @var int
*/
public $contact_id;

/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'cdntaxreceipts_advantage';
parent::__construct();
}

/**
* 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(), 'contact_id', 'civicrm_contact', '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,
'description' => ts('Unique CdnAdvantage ID'),
'required' => TRUE,
'where' => 'cdntaxreceipts_advantage.id',
'table_name' => 'cdntaxreceipts_advantage',
'entity' => 'CdnAdvantage',
'bao' => 'CRM_Cdntaxreceipts_DAO_CdnAdvantage',
'localizable' => 0,
],
'contact_id' => [
'name' => 'contact_id',
'type' => CRM_Utils_Type::T_INT,
'description' => ts('FK to Contact'),
'where' => 'cdntaxreceipts_advantage.contact_id',
'table_name' => 'cdntaxreceipts_advantage',
'entity' => 'CdnAdvantage',
'bao' => 'CRM_Cdntaxreceipts_DAO_CdnAdvantage',
'localizable' => 0,
],
];
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__, 'ceipts_advantage', $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__, 'ceipts_advantage', $prefix, []);
return $r;
}

/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}

}
47 changes: 47 additions & 0 deletions api/v3/CdnAdvantage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
use CRM_Cdntaxreceipts_ExtensionUtil as E;

/**
* CdnAdvantage.create API specification (optional)
* This is used for documentation and validation.
*
* @param array $spec description of fields supported by this API call
* @return void
* @see http://wiki.civicrm.org/confluence/display/CRMDOC/API+Architecture+Standards
*/
function _civicrm_api3_cdn_advantage_create_spec(&$spec) {
// $spec['some_parameter']['api.required'] = 1;
}

/**
* CdnAdvantage.create API
*
* @param array $params
* @return array API result descriptor
* @throws API_Exception
*/
function civicrm_api3_cdn_advantage_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* CdnAdvantage.delete API
*
* @param array $params
* @return array API result descriptor
* @throws API_Exception
*/
function civicrm_api3_cdn_advantage_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* CdnAdvantage.get API
*
* @param array $params
* @return array API result descriptor
* @throws API_Exception
*/
function civicrm_api3_cdn_advantage_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
Loading

0 comments on commit 868ca4b

Please sign in to comment.