Merge pull request #15986 from civicrm/5.20
[civicrm-core.git] / Civi / Token / AbstractTokenSubscriber.php
index 69a570f8f380ca1ce5657dc4d03c80f944ed5ed5..9af4ca685442175cfed6d491a546832e9a9e328e 100644 (file)
@@ -1,27 +1,11 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | 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       |
  +--------------------------------------------------------------------+
  */
 
@@ -56,11 +40,11 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
 
   public static function getSubscribedEvents() {
-    return array(
+    return [
       Events::TOKEN_REGISTER => 'registerTokens',
       Events::TOKEN_EVALUATE => 'evaluateTokens',
       \Civi\ActionSchedule\Events::MAILING_QUERY => 'alterActionScheduleQuery',
-    );
+    ];
   }
 
   /**
@@ -88,7 +72,7 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
    * @param array $tokenNames
    *   Array(string $tokenName => string $label).
    */
-  public function __construct($entity, $tokenNames = array()) {
+  public function __construct($entity, $tokenNames = []) {
     $this->entity = $entity;
     $this->tokenNames = $tokenNames;
   }
@@ -110,7 +94,7 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
   /**
    * Register the declared tokens.
    *
-   * @param TokenRegisterEvent $e
+   * @param \Civi\Token\Event\TokenRegisterEvent $e
    *   The registration event. Add new tokens using register().
    */
   public function registerTokens(TokenRegisterEvent $e) {
@@ -118,11 +102,11 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
       return;
     }
     foreach ($this->tokenNames as $name => $label) {
-      $e->register(array(
+      $e->register([
         'entity' => $this->entity,
         'field' => $name,
         'label' => $label,
-      ));
+      ]);
     }
   }
 
@@ -133,7 +117,7 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
    * This is method is not always appropriate, but if you're specifically
    * focused on scheduled reminders, it can be convenient.
    *
-   * @param MailingQueryEvent $e
+   * @param \Civi\ActionSchedule\Event\MailingQueryEvent $e
    *   The pending query which may be modified. See discussion on
    *   MailingQueryEvent::$query.
    */
@@ -143,7 +127,7 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
   /**
    * Populate the token data.
    *
-   * @param TokenValueEvent $e
+   * @param \Civi\Token\Event\TokenValueEvent $e
    *   The event, which includes a list of rows and tokens.
    */
   public function evaluateTokens(TokenValueEvent $e) {
@@ -204,6 +188,6 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
    *   Any data that was returned by the prefetch().
    * @return mixed
    */
-  public abstract function evaluateToken(TokenRow $row, $entity, $field, $prefetch = NULL);
+  abstract public function evaluateToken(TokenRow $row, $entity, $field, $prefetch = NULL);
 
 }