DynamicFKAuthorization - Fix for PHP 5.3
authorTim Otten <totten@civicrm.org>
Mon, 9 Feb 2015 20:44:30 +0000 (12:44 -0800)
committerTim Otten <totten@civicrm.org>
Mon, 9 Feb 2015 20:44:30 +0000 (12:44 -0800)
Civi/API/Subscriber/DynamicFKAuthorization.php

index 7e674c8b172eb0baf0df1ac0172f361b48d379c0..87b278066beee24e6057e36fcb6dbaf4a54fb1a9 100644 (file)
@@ -60,8 +60,10 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
 
   /**
    * @var \Civi\API\Kernel
+   *
+   * Treat as private. Marked public due to PHP 5.3-compatibility issues.
    */
-  protected $kernel;
+  public $kernel;
 
   /**
    * @var string, the entity for which we want to manage permissions
@@ -219,7 +221,8 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
      * @var \Exception $exception
      */
     $exception = NULL;
-    \CRM_Core_Transaction::create(TRUE)->run(function($tx) use ($entity, $action, $entityId, &$exception) {
+    $self = $this;
+    \CRM_Core_Transaction::create(TRUE)->run(function($tx) use ($entity, $action, $entityId, &$exception, $self) {
       $tx->rollback(); // Just to be safe.
 
       $params = array(
@@ -228,7 +231,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
         'id' => $entityId,
       );
 
-      $result = $this->kernel->run($entity, $this->getDelegatedAction($action), $params);
+      $result = $self->kernel->run($entity, $self->getDelegatedAction($action), $params);
       if ($result['is_error'] || empty($result['values'])) {
         $exception = new \Civi\API\Exception\UnauthorizedException("Authorization failed on ($entity,$entityId)", array(
           'cause' => $result,