SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/ColModifierContentSubscription.php

  1. <?php
  2. namespace Sprout\Helpers;
  3.  
  4. use InvalidArgumentException;
  5.  
  6. use Sprout\Helpers\Pdb;
  7. USE Sprout\Helpers\Sprout;
  8.  
  9.  
  10. class ColModifierContentSubscription extends ColModifier
  11. {
  12. /**
  13.   * Renders user friendly settings for given subscription record
  14.   *
  15.   * @param int $record_id
  16.   */
  17. public function modify($subscription_id, $field_name)
  18. {
  19. $subscription = Pdb::get('content_subscriptions', $subscription_id);
  20.  
  21. try {
  22. $inst = Sprout::instance($subscription['handler_class'], 'Sprout\\Helpers\\Subscribe');
  23. } catch (InvalidArgumentException $ex) {
  24. return sprintf('Error: %s', $ex->getMessage());
  25. }
  26.  
  27. return $inst->getName(json_decode($subscription['handler_settings'], true));
  28. }
  29. }
  30.