Controller/Adminhtml/FastlyCdn/Purge/Quick.php
public function execute()
    {
        try {
            if ($this->config->getType() == Config::FASTLY && $this->config->isEnabled()) {
                // check if url is given
                $url = $this->getRequest()->getParam('quick_purge_url', false);

                $zendUri = \Zend_Uri::factory($url);
                $host = $zendUri->getHost();
                $scheme = $zendUri->getScheme();
                $path = $zendUri->getPath();

                // check if host is one of magento's
                if (!$this->isHostInDomainList($host)) {
                    throw new LocalizedException(__('Invalid domain "'.$host.'".'));
                }

                // build uri to purge
                $uri = $scheme . '://' . $host;

                if (isset($path)) {
                    $uri .= $path;
                }

                // purge uri
                $result = $this->purgeCache->sendPurgeRequest($uri);
                if ($result['status']) {
                    $this->messageManager->addSuccessMessage(__('The URL\'s "' . $url . '" cache has been cleaned.'));
                } else {
                    $this->getMessageManager()->addErrorMessage(
                        __('The purge request was not processed successfully. [' . $result['msg'] . ']')
                    );
                }
            }
        } catch (\Exception $e) {
            $this->getMessageManager()->addErrorMessage(
                __('An error occurred while clearing the Fastly CDN: ') . $e->getMessage()
            );
        }
        return $this->_redirect('*/cache/index');
    }
public function execute()
    {
        try {
            if ($this->config->getType() == Config::FASTLY && $this->config->isEnabled()) {
                // check if url is given
                $url = $this->getRequest()->getParam('quick_purge_url', false);

                $zendUri = \Zend_Uri::factory($url);
                $host = $zendUri->getHost();
                $scheme = $zendUri->getScheme();
                $path = $zendUri->getPath();

                // check if host is one of magento's
                if (!$this->isHostInDomainList($host)) {
                    throw new LocalizedException(__('Invalid domain "'.$host.'".'));
                }

                // build uri to purge
                $uri = $scheme . '://' . $host;

                if (isset($path)) {
                    $uri .= $path;
                }

                // purge uri
                $result = $this->purgeCache->sendPurgeRequest($uri);
                if ($result['status']) {
                    $this->messageManager->addSuccessMessage(__('The URL\'s "' . $url . '" cache has been cleaned.'));
                } else {
                    $this->getMessageManager()->addErrorMessage(
                        __('The purge request was not processed successfully. [' . $result['msg'] . ']')
                    );
                }
            }
        } catch (\Exception $e) {
            $this->getMessageManager()->addErrorMessage(
                __('An error occurred while clearing the Fastly CDN: ') . $e->getMessage()
            );
        }
        return $this->_redirect('*/cache/index');
    }
public function execute ( ) { try { if ( $ this -> config -> getType ( ) == Config :: FASTLY && $ this -> config -> isEnabled ( ) ) { // check if url is given $ url = $ this -> getRequest ( ) -> getParam ( 'quick_purge_url' , false ) ; $ zendUri = \ Zend_Uri :: factory ( $ url ) ; $ host = $ zendUri -> getHost ( ) ; $ scheme = $ zendUri -> getScheme ( ) ; $ path = $ zendUri -> getPath ( ) ; // check if host is one of magento's if ( ! $ this -> isHostInDomainList ( $ host ) ) { throw new LocalizedException ( __ ( 'Invalid domain "' . $ host . '".' ) ) ; } // build uri to purge $ uri = $ scheme . '://' . $ host ; if ( isset ( $ path ) ) { $ uri .= $ path ; } // purge uri $ result = $ this -> purgeCache -> sendPurgeRequest ( $ uri ) ; if ( $ result [ 'status' ] ) { $ this -> messageManager -> addSuccessMessage ( __ ( 'The URL\'s "' . $ url . '" cache has been cleaned.' ) ) ; } else { $ this -> getMessageManager ( ) -> addErrorMessage ( __ ( 'The purge request was not processed successfully. [' . $ result [ 'msg' ] . ']' ) ) ; } } } catch ( \ Exception $ e ) { $ this -> getMessageManager ( ) -> addErrorMessage ( __ ( 'An error occurred while clearing the Fastly CDN: ' ) . $ e -> getMessage ( ) ) ; } return $ this -> _redirect ( '*/cache/index' ) ; }
Purge by content type

@return \Magento\Framework\App\ResponseInterface
@throws \Exception
Purge by content type