Skip to content
Snippets Groups Projects
Commit 34f3bbd9 authored by Seamus Lee's avatar Seamus Lee
Browse files

(NFC) Upgrade Civi Folder to the new coder version

parent b9e9e8dd
Branches
Tags
No related merge requests found
Showing
with 43 additions and 29 deletions
......@@ -32,6 +32,7 @@ namespace Civi\API\Event;
* @package Civi\API\Event
*/
class PrepareEvent extends Event {
/**
* @param array $apiRequest
* The full description of the API request.
......
......@@ -32,6 +32,7 @@ namespace Civi\API\Event;
* @package Civi\API\Event
*/
class ResolveEvent extends Event {
/**
* @param array $apiRequest
* The full description of the API request.
......
......@@ -8,6 +8,7 @@ require_once 'api/Exception.php';
* @package Civi\API\Exception
*/
class NotImplementedException extends \API_Exception {
/**
* @param string $message
* The human friendly error message.
......
......@@ -8,6 +8,7 @@ require_once 'api/Exception.php';
* @package Civi\API\Exception
*/
class UnauthorizedException extends \API_Exception {
/**
* @param string $message
* The human friendly error message.
......
......@@ -119,7 +119,7 @@ class ExternalBatch {
while (!empty($this->processes)) {
usleep(self::POLL_INTERVAL);
foreach (array_keys($this->processes) as $idx) {
/** @var Process $process */
/** @var \Symfony\Component\Process\Process $process */
$process = $this->processes[$idx];
if (!$process->isRunning()) {
$parsed = json_decode($process->getOutput(), TRUE);
......@@ -179,7 +179,7 @@ class ExternalBatch {
/**
* @param array $apiCall
* Array with keys: entity, action, params.
* @return Process
* @return \Symfony\Component\Process\Process
* @throws \CRM_Core_Exception
*/
public function createProcess($apiCall) {
......
......@@ -31,7 +31,6 @@ use Civi\API\Event\PrepareEvent;
use Civi\API\Event\ExceptionEvent;
use Civi\API\Event\ResolveEvent;
use Civi\API\Event\RespondEvent;
use Civi\API\Provider\ProviderInterface;
/**
* @package Civi
......@@ -217,7 +216,7 @@ class Kernel {
* Array(0 => ProviderInterface, 1 => array $apiRequest).
*/
public function resolve($apiRequest) {
/** @var ResolveEvent $resolveEvent */
/** @var \Civi\API\Event\ResolveEvent $resolveEvent */
$resolveEvent = $this->dispatcher->dispatch(Events::RESOLVE, new ResolveEvent($apiRequest, $this));
$apiRequest = $resolveEvent->getApiRequest();
if (!$resolveEvent->getApiProvider()) {
......@@ -229,14 +228,14 @@ class Kernel {
/**
* Determine if the API request is allowed (under current policy)
*
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @param array $apiRequest
* The full description of the API request.
* @throws Exception\UnauthorizedException
*/
public function authorize($apiProvider, $apiRequest) {
/** @var AuthorizeEvent $event */
/** @var \Civi\API\Event\AuthorizeEvent $event */
$event = $this->dispatcher->dispatch(Events::AUTHORIZE, new AuthorizeEvent($apiProvider, $apiRequest, $this));
if (!$event->isAuthorized()) {
throw new \Civi\API\Exception\UnauthorizedException("Authorization failed");
......@@ -246,7 +245,7 @@ class Kernel {
/**
* Allow third-party code to manipulate the API request before execution.
*
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @param array $apiRequest
* The full description of the API request.
......@@ -254,7 +253,7 @@ class Kernel {
* The revised API request.
*/
public function prepare($apiProvider, $apiRequest) {
/** @var PrepareEvent $event */
/** @var \Civi\API\Event\PrepareEvent $event */
$event = $this->dispatcher->dispatch(Events::PREPARE, new PrepareEvent($apiProvider, $apiRequest, $this));
return $event->getApiRequest();
}
......@@ -262,7 +261,7 @@ class Kernel {
/**
* Allow third-party code to manipulate the API response after execution.
*
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @param array $apiRequest
* The full description of the API request.
......@@ -272,7 +271,7 @@ class Kernel {
* The revised $result.
*/
public function respond($apiProvider, $apiRequest, $result) {
/** @var RespondEvent $event */
/** @var \Civi\API\Event\RespondEvent $event */
$event = $this->dispatcher->dispatch(Events::RESPOND, new RespondEvent($apiProvider, $apiRequest, $result, $this));
return $event->getResponse();
}
......@@ -287,7 +286,7 @@ class Kernel {
// Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher?
$entityNames = [];
foreach ($this->getApiProviders() as $provider) {
/** @var ProviderInterface $provider */
/** @var \Civi\API\Provider\ProviderInterface $provider */
$entityNames = array_merge($entityNames, $provider->getEntityNames($version));
}
$entityNames = array_unique($entityNames);
......@@ -307,7 +306,7 @@ class Kernel {
// Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher?
$actionNames = [];
foreach ($this->getApiProviders() as $provider) {
/** @var ProviderInterface $provider */
/** @var \Civi\API\Provider\ProviderInterface $provider */
$actionNames = array_merge($actionNames, $provider->getActionNames($version, $entity));
}
$actionNames = array_unique($actionNames);
......@@ -345,7 +344,8 @@ class Kernel {
$data['action'] = \CRM_Utils_Array::value('action', $apiRequest);
if (\CRM_Utils_Array::value('debug', \CRM_Utils_Array::value('params', $apiRequest))
&& empty($data['trace']) // prevent recursion
// prevent recursion
&& empty($data['trace'])
) {
$data['trace'] = $e->getTraceAsString();
}
......@@ -459,7 +459,7 @@ class Kernel {
}
/**
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @return Kernel
*/
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* conventions.
*/
class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterface {
/**
* @return array
*/
......@@ -285,7 +286,8 @@ class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterfa
}
// Check for standalone action files; to match _civicrm_api_resolve(), only load the first one
$loaded_files = []; // array($relativeFilePath => TRUE)
// array($relativeFilePath => TRUE)
$loaded_files = [];
$include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
foreach ($include_dirs as $include_dir) {
foreach ([$camelName, 'Generic'] as $name) {
......@@ -299,7 +301,8 @@ class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterfa
foreach ($iterator as $fileinfo) {
$file = $fileinfo->getFilename();
if (array_key_exists($file, $loaded_files)) {
continue; // action provided by an earlier item on include_path
// action provided by an earlier item on include_path
continue;
}
$parts = explode(".", $file);
......
......@@ -27,13 +27,11 @@
namespace Civi\API\Provider;
use Civi\API\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* An API "provider" provides a means to execute API requests.
*/
interface ProviderInterface {
/**
* @param array $apiRequest
* The full description of the API request.
......
......@@ -34,6 +34,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* This class defines operations for inspecting the API's metadata.
*/
class ReflectionProvider implements EventSubscriberInterface, ProviderInterface {
/**
* @return array
*/
......@@ -68,7 +69,8 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface
$this->apiKernel = $apiKernel;
$this->actions = [
'Entity' => ['get', 'getactions'],
'*' => ['getactions'], // 'getfields'
// 'getfields'
'*' => ['getactions'],
];
}
......
......@@ -102,7 +102,7 @@ class StaticProvider extends AdhocProvider {
* @param array $apiRequest
* The full description of the API request.
* @return array
* Formatted API result
* Formatted API result
* @throws \API_Exception
*/
public function doCreate($apiRequest) {
......@@ -131,7 +131,7 @@ class StaticProvider extends AdhocProvider {
* @param array $apiRequest
* The full description of the API request.
* @return array
* Formatted API result
* Formatted API result
* @throws \API_Exception
*/
public function doGet($apiRequest) {
......@@ -142,7 +142,7 @@ class StaticProvider extends AdhocProvider {
* @param array $apiRequest
* The full description of the API request.
* @return array
* Formatted API result
* Formatted API result
* @throws \API_Exception
*/
public function doDelete($apiRequest) {
......
......@@ -25,6 +25,7 @@
+--------------------------------------------------------------------+
*/
namespace Civi\API;
use Civi\API\Exception\UnauthorizedException;
/**
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* and validates that the fields are provided correctly.
*/
class APIv3SchemaAdapter implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -50,6 +50,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* eg Amy's contact_id).
*/
class ChainSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -227,7 +227,8 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
$exception = NULL;
$self = $this;
\CRM_Core_Transaction::create(TRUE)->run(function($tx) use ($entity, $action, $entityId, &$exception, $self) {
$tx->rollback(); // Just to be safe.
// Just to be safe.
$tx->rollback();
$params = [
'version' => 3,
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* @package Civi\API\Subscriber
*/
class I18nSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -36,6 +36,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* Civi\API\Annotation\Permission.
*/
class PermissionCheck implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -44,6 +44,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* @package Civi\API\Subscriber
*/
class TransactionSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -29,7 +29,6 @@ namespace Civi\API\Subscriber;
use Civi\API\Events;
use Civi\API\Event\AuthorizeEvent;
use Civi\API\Event\RespondEvent;
use Civi\API\WhitelistRule;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
......@@ -75,7 +74,7 @@ class WhitelistSubscriber implements EventSubscriberInterface {
public function __construct($rules) {
$this->rules = [];
foreach ($rules as $rule) {
/** @var WhitelistRule $rule */
/** @var \Civi\API\WhitelistRule $rule */
if ($rule->isValid()) {
$this->rules[] = $rule;
}
......@@ -89,7 +88,7 @@ class WhitelistSubscriber implements EventSubscriberInterface {
* Determine which, if any, whitelist rules apply this request.
* Reject unauthorized requests.
*
* @param AuthorizeEvent $event
* @param \Civi\API\Event\AuthorizeEvent $event
* @throws \CRM_Core_Exception
*/
public function onApiAuthorize(AuthorizeEvent $event) {
......@@ -108,7 +107,7 @@ class WhitelistSubscriber implements EventSubscriberInterface {
/**
* Apply any filtering rules based on the chosen whitelist rule.
* @param RespondEvent $event
* @param \Civi\API\Event\RespondEvent $event
*/
public function onApiRespond(RespondEvent $event) {
$apiRequest = $event->getApiRequest();
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* @package Civi\API\Subscriber
*/
class XDebugSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -48,7 +48,7 @@ namespace Civi\API;
*/
class WhitelistRule {
static $IGNORE_FIELDS = [
public static $IGNORE_FIELDS = [
'check_permissions',
'debug',
'offset',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment