namespace Civi\API\Event;
+/**
+ * Class AuthorizeEvent
+ * @package Civi\API\Event
+ */
class AuthorizeEvent extends Event {
/**
* @var bool
namespace Civi\API\Event;
+/**
+ * Class Event
+ * @package Civi\API\Event
+ */
class Event extends \Symfony\Component\EventDispatcher\Event {
/**
* @var \Civi\API\Provider\ProviderInterface
*/
protected $apiRequest;
+ /**
+ * @param $apiProvider
+ * @param $apiRequest
+ */
function __construct($apiProvider, $apiRequest) {
$this->apiProvider = $apiProvider;
$this->apiRequest = $apiRequest;
namespace Civi\API\Event;
+/**
+ * Class ExceptionEvent
+ * @package Civi\API\Event
+ */
class ExceptionEvent extends Event {
/**
*/
private $exception;
+ /**
+ * @param $exception
+ * @param $apiProvider
+ * @param $apiRequest
+ */
function __construct($exception, $apiProvider, $apiRequest) {
$this->exception = $exception;
parent::__construct($apiProvider, $apiRequest);
namespace Civi\API\Event;
+/**
+ * Class PrepareEvent
+ * @package Civi\API\Event
+ */
class PrepareEvent extends Event {
/**
* @param array $apiRequest
namespace Civi\API\Event;
+/**
+ * Class ResolveEvent
+ * @package Civi\API\Event
+ */
class ResolveEvent extends Event {
+ /**
+ * @param $apiRequest
+ */
function __construct($apiRequest) {
parent::__construct(NULL, $apiRequest);
}
namespace Civi\API\Event;
+/**
+ * Class RespondEvent
+ * @package Civi\API\Event
+ */
class RespondEvent extends Event {
/**
* @var mixed
*/
private $response;
+ /**
+ * @param $apiProvider
+ * @param $apiRequest
+ * @param $response
+ */
function __construct($apiProvider, $apiRequest, $response) {
$this->response = $response;
parent::__construct($apiProvider, $apiRequest);
namespace Civi\API\Exception;
require_once 'api/Exception.php';
+
+/**
+ * Class NotImplementedException
+ * @package Civi\API\Exception
+ */
class NotImplementedException extends \API_Exception {
+ /**
+ * @param string $message
+ * @param array $extraParams
+ * @param Exception $previous
+ */
public function __construct($message, $extraParams = array(), Exception $previous = NULL) {
parent::__construct($message, \API_Exception::NOT_IMPLEMENTED, $extraParams, $previous);
}
-}
\ No newline at end of file
+}
namespace Civi\API\Exception;
require_once 'api/Exception.php';
+
+/**
+ * Class UnauthorizedException
+ * @package Civi\API\Exception
+ */
class UnauthorizedException extends \API_Exception {
+ /**
+ * @param string $message
+ * @param array $extraParams
+ * @param Exception $previous
+ */
public function __construct($message, $extraParams = array(), Exception $previous = NULL) {
parent::__construct($message, \API_Exception::UNAUTHORIZED, $extraParams, $previous);
}
-}
\ No newline at end of file
+}
*/
protected $apiProviders;
+ /**
+ * @param $dispatcher
+ * @param array $apiProviders
+ */
function __construct($dispatcher, $apiProviders = array()) {
$this->apiProviders = $apiProviders;
$this->dispatcher = $dispatcher;
$this->dispatcher = $dispatcher;
return $this;
}
-}
\ No newline at end of file
+}
*/
class AdhocProvider implements EventSubscriberInterface, ProviderInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::RESOLVE => array(
return $this;
}
+ /**
+ * @param \Civi\API\Event\ResolveEvent $event
+ */
public function onApiResolve(\Civi\API\Event\ResolveEvent $event) {
$apiRequest = $event->getApiRequest();
if ($this->matchesRequest($apiRequest)) {
}
}
+ /**
+ * @param \Civi\API\Event\AuthorizeEvent $event
+ */
public function onApiAuthorize(\Civi\API\Event\AuthorizeEvent $event) {
$apiRequest = $event->getApiRequest();
if ($this->matchesRequest($apiRequest) && \CRM_Core_Permission::check($this->actions[strtolower($apiRequest['action'])]['perm'])) {
}
}
+ /**
+ * @param $apiRequest
+ *
+ * @return bool
+ */
public function matchesRequest($apiRequest) {
return $apiRequest['entity'] == $this->entity && $apiRequest['version'] == $this->version && isset($this->actions[strtolower($apiRequest['action'])]);
}
-}
\ No newline at end of file
+}
* conventions.
*/
class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::RESOLVE => array(
*/
private $cache;
+ /**
+ *
+ */
function __construct() {
$this->cache = array();
}
+ /**
+ * @param \Civi\API\Event\ResolveEvent $event
+ */
public function onApiResolve(\Civi\API\Event\ResolveEvent $event) {
$apiRequest = $event->getApiRequest();
$resolved = $this->resolve($apiRequest);
* This class defines operations for inspecting the API's metadata.
*/
class ReflectionProvider implements EventSubscriberInterface, ProviderInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::RESOLVE => array(
);
}
+ /**
+ * @param \Civi\API\Event\ResolveEvent $event
+ */
public function onApiResolve(\Civi\API\Event\ResolveEvent $event) {
$apiRequest = $event->getApiRequest();
$actions = isset($this->actions[$apiRequest['entity']]) ? $this->actions[$apiRequest['entity']] : $this->actions['*'];
}
}
+ /**
+ * @param \Civi\API\Event\AuthorizeEvent $event
+ */
public function onApiAuthorize(\Civi\API\Event\AuthorizeEvent $event) {
$apiRequest = $event->getApiRequest();
if (isset($apiRequest['is_metadata'])) {
function getActionNames($version, $entity) {
return isset($this->actions[$entity]) ? $this->actions[$entity] : $this->actions['*'];
}
-}
\ No newline at end of file
+}
*/
namespace Civi\API;
+/**
+ * Class Request
+ * @package Civi\API
+ */
class Request {
private static $nextId = 1;
* and validates that the fields are provided correctly.
*/
class APIv3SchemaAdapter implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::PREPARE => array(
);
}
+ /**
+ * @param \Civi\API\Event\PrepareEvent $event
+ *
+ * @throws \API_Exception
+ */
public function onApiPrepare(\Civi\API\Event\PrepareEvent $event) {
$apiRequest = $event->getApiRequest();
if ($apiRequest['version'] > 3) {
$event->setApiRequest($apiRequest);
}
+ /**
+ * @param \Civi\API\Event\Event $event
+ *
+ * @throws \Exception
+ */
public function onApiPrepare_validate(\Civi\API\Event\Event $event) {
$apiRequest = $event->getApiRequest();
// Not sure why this is omitted for generic actions. It would make sense to omit 'getfields', but that's only one generic action.
}
return $required;
}
-}
\ No newline at end of file
+}
* API call (and passes some extra context -- eg Amy's contact_id).
*/
class ChainSubscriber implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::RESPOND => array('onApiRespond', Events::W_EARLY),
);
}
+ /**
+ * @param \Civi\API\Event\RespondEvent $event
+ *
+ * @throws \Exception
+ */
public function onApiRespond(\Civi\API\Event\RespondEvent $event) {
$apiRequest = $event->getApiRequest();
$result = $event->getResponse();
}
}
-}
\ No newline at end of file
+}
use Civi\API\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+/**
+ * Class I18nSubscriber
+ * @package Civi\API\Subscriber
+ */
class I18nSubscriber implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::PREPARE => array('onApiPrepare', Events::W_MIDDLE)
);
}
+ /**
+ * @param \Civi\API\Event\Event $event
+ *
+ * @throws \API_Exception
+ */
public function onApiPrepare(\Civi\API\Event\Event $event) {
$apiRequest = $event->getApiRequest();
* permissions specified in Civi\API\Annotation\Permission.
*/
class PermissionCheck implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::AUTHORIZE => array(
);
}
+ /**
+ * @param \Civi\API\Event\AuthorizeEvent $event
+ *
+ * @throws \Civi\API\Exception\UnauthorizedException
+ */
public function onApiAuthorize(\Civi\API\Event\AuthorizeEvent $event) {
$apiRequest = $event->getApiRequest();
if ($apiRequest['version'] < 4) {
$event->stopPropagation();
}
}
-}
\ No newline at end of file
+}
use Civi\API\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+/**
+ * Class TransactionSubscriber
+ * @package Civi\API\Subscriber
+ */
class TransactionSubscriber implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::PREPARE => array('onApiPrepare', Events::W_EARLY),
unset($this->transactions[$apiRequest['id']]);
}
}
-}
\ No newline at end of file
+}
*/
class WrapperAdapter implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::PREPARE => array('onApiPrepare', Events::W_MIDDLE),
*/
protected $defaults;
+ /**
+ * @param array $defaults
+ */
function __construct($defaults = array()) {
$this->defaults = $defaults;
}
+ /**
+ * @param \Civi\API\Event\PrepareEvent $event
+ */
public function onApiPrepare(\Civi\API\Event\PrepareEvent $event) {
$apiRequest = $event->getApiRequest();
$event->setApiRequest($apiRequest);
}
+ /**
+ * @param \Civi\API\Event\RespondEvent $event
+ */
public function onApiRespond(\Civi\API\Event\RespondEvent $event) {
$apiRequest = $event->getApiRequest();
$result = $event->getResponse();
}
return $apiRequest['wrappers'];
}
-}
\ No newline at end of file
+}
use Civi\API\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+/**
+ * Class XDebugSubscriber
+ * @package Civi\API\Subscriber
+ */
class XDebugSubscriber implements EventSubscriberInterface {
+ /**
+ * @return array
+ */
public static function getSubscribedEvents() {
return array(
Events::RESPOND => array('onApiRespond', Events::W_LATE),
);
}
+ /**
+ * @param \Civi\API\Event\RespondEvent $event
+ */
function onApiRespond(\Civi\API\Event\RespondEvent $event) {
$apiRequest = $event->getApiRequest();
$result = $event->getResponse();
$event->setResponse($result);
}
}
-}
\ No newline at end of file
+}
// TODO use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+/**
+ * Class Container
+ * @package Civi\Core
+ */
class Container {
const SELF = 'civi_container_factory';