Set callback for loading content dynamically.
Callback will reveive a view attach to this popup
for adding content to it.

@param $fx

@throws Exception
779804
public function set($fx = null, $arg2 = null)
    {
        if (!is_object($fx) && !($fx instanceof Closure)) {
            throw new Exception('Error: Need to pass a function to Popup::set()');
        }

        if ($arg2) {
            throw new Exception('Only one argument is needed by Popup::set()');
        }

        $this->cb = $this->add('Callback');

        if (!$this->minWidth) {
            $this->minWidth = '120px';
        }

        if (!$this->minHeight) {
            $this->minHeight = '60px';
        }

        if ($this->cb->triggered()) {
            //create content view to pass to callback.
            $content = $this->add($this->dynamicContent);
            $this->cb->set($fx, [$content]);
            //only render our content view.
            //PopupService will replace content with this one.
            $this->app->terminate($content->renderJSON());
        }
    }
826410
public function setCallbackUrl($value)
    {
        $this->callbackUrl = filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);

        if (!$this->callbackUrl) {
            throw new \Exception('Invalid URL.');
        }

        return $this;
    }
21324
function setProtocol($protocol)
    {
        if (!($protocol instanceof Swoole\IFace\Protocol))
        {
            throw new \Exception("The protocol is not instanceof \\Swoole\\IFace\\Protocol");
        }
        $this->protocol = $protocol;
        $protocol->server = $this;
    }
15787
public function loadUrl($url, $curl = false) {
        if ($curl) {
            $content = self::loadContent($url);
            if (empty($content)) {
                throw new Exception("Can't get content from " . $url);
            }
            $this->loadString($content);
        } else {
            $this->load_file($url);
        }
    }
384371
public function addTab( $label, $content, $fragmentKey = NULL )
	{
		if( is_null( $fragmentKey ) )
		{
			$this->tabs[]	= $label;
			$this->divs[]	= $content;
		}
		else
		{
			if( isset( $this->tabs[$fragmentKey] ) )
				throw new Exception( 'Tab with Fragment ID "'.$fragmentKey.'" is already set' );
			$this->tabs[$fragmentKey]	= $label;
			$this->divs[$fragmentKey]	= $content;
		}
	}
380425
public function addToSection($section, $test, $filePath, $lineNumber, $codeLine) {
		if (empty($section)) {
			throw new \Exception(__METHOD__.": The section can not be empty.");
		}
		$this->sectionBuffers[$section][$filePath][$test][] = [$lineNumber, $codeLine];
	}
804393
public function submitContentForm() {
    $element = $this->getSession()->getPage();
    $submit = $element->findButton($this->getDrupalText('node_submit_label'));
    if (empty($submit)) {
      throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl()));
    }
    // Submit the form.
    $submit->click();
  }
952854
public function setUrl($url)
    {
        if (filter_var($url, FILTER_VALIDATE_URL) !== $url) {
            throw new \Exception('Invalid URL: '.$url);
        }
        $this->url = $url;
    }
258621
public function addAfter($key, callable $callback)
    {
        if ($this->addItem($key, $callback, true)) {
            return $this;
        }

        throw new \Exception(htmlspecialchars("The item $key was not found."));
    }
401366
public function load($param = null)
    {
        try {
            if (empty($param[self::FILE_INDEX])) {
                throw new ExceptionConfig(
                    _('No config file was given, please make sure one is provided in the param array'),
                    0,
                    1,
                    __METHOD__,
                    __LINE__
                );
            }

            $this->configFileSet = $this->getConfigFileSet($param[self::FILE_INDEX]);


            if (isset($param[self::PROCESS_SECTION_INDEX])) {
                $this->processSections = (bool)$param[self::PROCESS_SECTION_INDEX];
            }
            if (isset($param[self::SCANNER_MODE_INDEX])) {
                $this->scannerMode = (int)$param[self::SCANNER_MODE_INDEX];
            }

            $this->populateEngine(
                $this->parseConfigSet()
            );
        } catch (ExceptionConfig $e) {
            throw $e;
        }
    }
9461
private function loadView(bool $try = false) : void
  {
    // configure view component
    Accessor::$viewsExtension = config('view.extension');
    Accessor::$viewsEngine    = config('view.engine');
    Accessor::$viewsCache     = config('app.dir') . config('view.compiled');
    Accessor::$viewsDirectory = config('app.dir') . config('view.views');

    // load component
    Accessor::requireView();
  }
926928
public function setReadOnly($f)
    {
        if ($f instanceof PhingFile) {
            $strPath = (string) $f->getPath();
            $perms = (int) (@fileperms($strPath) & 0444);

            FileSystem::getFileSystem()->chmod($strPath, $perms);
        } else {
            throw new Exception("IllegalArgumentType: Argument is not File");
        }
    }
391844
public function attachCallback($channel, $callback)
    {
        $callbackName = $this->getPrefixKeys().$channel;

        $this->assertCallback($callback);
        $this->callbacks[$callbackName] = $callback;
        $this->pubsub->subscribe($channel);
    }
15172
protected function _actionRender(AnCommandContext $context)
    {
        if ($context->data instanceof Exception) {
            $this->getView()->content($context->data);
        } else {
            $this->getView()->content($context->response->getContent());
        }

        $content = $this->getView()->display();

        $context->response->setContent($content);
        $context->response->setContentType($this->getView()->mimetype);
    }
603275
public function setCallback($callback)
    {
        if (!is_callable($callback)) {
            throw new Exception\InvalidArgumentException('Invalid callback provided');
        }

        $this->options['callback'] = $callback;
        return $this;
    }
314793
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $exception = $event->getException();

        if (!$exception instanceof AccessDeniedException) {
            return;
        }

        $event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
    }
1248464
public function set($fx)
    {
        /** @type VirtualPage $p */
        $p = $this->add('VirtualPage');
        $p->set($fx);

        $this->setURL($p->getURL());

        return $this;
    }