HEX
Server: Apache
System: Linux cpanelx.inxs.ro 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: crowdandsafety (1041)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/cwd/wp-content/plugins/cornerstone/includes/integration/Twig/src/StateExtension.php
<?php

/**
 * Extension for state
 */

namespace Cornerstone\TwigIntegration;

use Twig\TwigFunction;

class StateExtension extends \Twig\Extension\AbstractExtension
{
  private $state = [];

  public function getFunctions()
  {
    return [
      new TwigFunction('set_state', [$this, 'setState']),
      new TwigFunction('set_state_key', [$this, 'setStateKey']),
      new TwigFunction('get_state', [$this, 'getState']),
      new TwigFunction('get_state_key', [$this, 'getStateKey']),
    ];
  }

  public function setState($data) {
    $this->state = $data;
  }

  /**
   * Set key in state
   */
  public function setStateKey($key, $data) {
    // Errors
    if (!is_array($this->state)) {
      trigger_error('You have changed the state from an array to something else, you therefore cannot use set_state_key');
      return;
    }

    // Set key
    $this->state[$key] = $data;
  }

  public function getState() {
    return $this->state;
  }

  public function getStateKey($key) {
    return cs_get_path($this->state, $key);
  }
}