<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | 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 |
+--------------------------------------------------------------------+
*/
* @param $fields
*/
function _civicrm_api3_extension_install_spec(&$fields) {
- $fields['keys'] = array(
+ $fields['keys'] = [
'title' => 'Extension Key(s)',
- 'api.aliases' => array('key'),
+ 'api.aliases' => ['key'],
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Fully qualified name of one or more extensions',
- );
- $fields['path'] = array(
+ ];
+ $fields['path'] = [
'title' => 'Extension Path',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'The path to the extension. May use wildcard ("*").',
- );
+ ];
}
/**
function civicrm_api3_extension_upgrade() {
CRM_Core_Invoke::rebuildMenuAndCaches(TRUE);
$queue = CRM_Extension_Upgrades::createQueue();
- $runner = new CRM_Queue_Runner(array(
+ $runner = new CRM_Queue_Runner([
'title' => 'Extension Upgrades',
'queue' => $queue,
'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
- ));
+ ]);
try {
$result = $runner->runAll();
throw new API_Exception('Cannot resolve download url for extension. Try adding parameter "url"');
}
- foreach (CRM_Extension_System::singleton()->getDownloader()->checkRequirements() as $requirement) {
+ if (!isset($info)) {
+ $info = NULL;
+ }
+ foreach (CRM_Extension_System::singleton()->getDownloader()->checkRequirements($info) as $requirement) {
return civicrm_api3_create_error($requirement['message']);
}
CRM_Extension_System::singleton()->getCache()->flush();
CRM_Extension_System::singleton(TRUE);
if (CRM_Utils_Array::value('install', $params, TRUE)) {
- CRM_Extension_System::singleton()->getManager()->install(array($params['key']));
+ CRM_Extension_System::singleton()->getManager()->install([$params['key']]);
}
return civicrm_api3_create_success();
* @param $fields
*/
function _civicrm_api3_extension_download_spec(&$fields) {
- $fields['key'] = array(
+ $fields['key'] = [
'title' => 'Extension Key',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Fully qualified name of the extension',
- );
- $fields['url'] = array(
+ ];
+ $fields['url'] = [
'title' => 'Download URL',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Optional as the system can determine the url automatically for public extensions',
- );
- $fields['install'] = array(
+ ];
+ $fields['install'] = [
'title' => 'Auto-install',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Automatically install the downloaded extension',
'api.default' => TRUE,
- );
+ ];
}
/**
if ($params['local']) {
$system->getManager()->refresh();
- $system->getManager()->getStatuses(); // force immediate scan
+ // force immediate scan
+ $system->getManager()->getStatuses();
}
if ($params['remote']) {
if ($system->getBrowser()->isEnabled() && empty($system->getBrowser()->checkRequirements)) {
$system->getBrowser()->refresh();
- $system->getBrowser()->getExtensions(); // force immediate download
+ // force immediate download
+ $system->getBrowser()->getExtensions();
}
}
* @param $fields
*/
function _civicrm_api3_extension_refresh_spec(&$fields) {
- $fields['local'] = array(
+ $fields['local'] = [
'title' => 'Rescan Local',
'api.default' => 1,
'type' => CRM_Utils_Type::T_BOOLEAN,
'description' => 'Whether to rescan the local filesystem (default TRUE)',
- );
- $fields['remote'] = array(
+ ];
+ $fields['remote'] = [
'title' => 'Rescan Remote',
'api.default' => 1,
'type' => CRM_Utils_Type::T_BOOLEAN,
'description' => 'Whether to rescan the remote repository (default TRUE)',
- );
+ ];
}
/**
$keys = array_merge($full_names, $keys);
$statuses = CRM_Extension_System::singleton()->getManager()->getStatuses();
$mapper = CRM_Extension_System::singleton()->getMapper();
- $result = array();
+ $result = [];
$id = 0;
foreach ($statuses as $key => $status) {
try {
$obj = $mapper->keyToInfo($key);
}
catch (CRM_Extension_Exception $ex) {
- CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)));
+ CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', [1 => $key]));
continue;
}
$info = CRM_Extension_System::createExtendedInfo($obj);
- $info['id'] = $id++; // backward compatibility with indexing scheme
+ // backward compatibility with indexing scheme
+ $info['id'] = $id++;
if (!empty($keys)) {
if (in_array($key, $keys)) {
$result[] = $info;
unset($params['keys']);
unset($params['full_name']);
- $filterableFields = array('id', 'type', 'status', 'path');
+ $filterableFields = ['id', 'type', 'status', 'path'];
return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', $filterableFields);
}
*/
function civicrm_api3_extension_getremote($params) {
$extensions = CRM_Extension_System::singleton()->getBrowser()->getExtensions();
- $result = array();
+ $result = [];
$id = 0;
foreach ($extensions as $key => $obj) {
- $info = array();
- $info['id'] = $id++; // backward compatibility with indexing scheme
+ $info = [];
+ // backward compatibility with indexing scheme
+ $info['id'] = $id++;
$info = array_merge($info, (array) $obj);
$result[] = $info;
}
- return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', CRM_Utils_Array::value('return', $params, array()));
+ return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', CRM_Utils_Array::value('return', $params, []));
}
/**
return $params[$key];
}
if ($params[$key] == '') {
- return array();
+ return [];
}
return explode(API_V3_EXTENSION_DELIMITER, $params[$key]);
}
else {
- return array();
+ return [];
}
}