Fix unit tests to enable components before using them
[civicrm-core.git] / CRM / Import / DataSource.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
6a488035
TO
18/**
19 * This class defines the DataSource interface but must be subclassed to be
20 * useful.
21 */
22abstract class CRM_Import_DataSource {
23
24 /**
fe482240 25 * Provides information about the data source.
6a488035 26 *
a6c01b45 27 * @return array
11749569
TO
28 * Description of this data source, including:
29 * - title: string, translated, required
30 * - permissions: array, optional
31 *
6a488035
TO
32 */
33 abstract public function getInfo();
34
35 /**
fe482240 36 * Set variables up before form is built.
54957108 37 *
38 * @param CRM_Core_Form $form
6a488035
TO
39 */
40 abstract public function preProcess(&$form);
41
42 /**
54957108 43 * This is function is called by the form object to get the DataSource's form snippet.
6a488035 44 *
54957108 45 * It should add all fields necessary to get the data uploaded to the temporary table in the DB.
6c8f6e67 46 *
54957108 47 * @param CRM_Core_Form $form
6a488035
TO
48 */
49 abstract public function buildQuickForm(&$form);
50
51 /**
fe482240 52 * Process the form submission.
54957108 53 *
54 * @param array $params
55 * @param string $db
56 * @param CRM_Core_Form $form
6a488035
TO
57 */
58 abstract public function postProcess(&$params, &$db, &$form);
96025800 59
11749569
TO
60 /**
61 * Determine if the current user has access to this data source.
62 *
63 * @return bool
64 */
65 public function checkPermission() {
66 $info = $this->getInfo();
67 return empty($info['permissions']) || CRM_Core_Permission::check($info['permissions']);
68 }
69
6a488035 70}