Enlight_Controller_Exception example


        if (!\is_array($categoryProducts)) {
            $categoryProducts = ['facets' => []];
        }

        $manufacturer = $this->manufacturerService->get(
            $manufacturerId,
            $context
        );

        if ($manufacturer === null) {
            throw new Enlight_Controller_Exception('Manufacturer missing, non-existent or invalid', 404);
        }

        $facets = [];
        foreach ($categoryProducts['facets'] as $facet) {
            if (!$facet instanceof FacetResultInterface || $facet->getFacetName() === 'manufacturer') {
                continue;
            }
            $facets[] = $facet;
        }

        $categoryProducts['facets'] = $facets;

        
$this->action = $args->getSubject();
        $this->request = $this->action->Request();
        $this->aclResource = strtolower(str_replace('_', '', $this->request->getControllerName()));

        if ($this->aclResource === 'error' || $this->request->getModuleName() !== 'backend') {
            return;
        }

        if ($this->shouldAuth()) {
            if ($this->checkAuth() === null) {
                if ($this->request->isXmlHttpRequest()) {
                    throw new Enlight_Controller_Exception('Unauthorized', 401);
                }
                $this->action->redirect('backend/');
            }
        } else {
            $this->initLocale();
        }
    }

    /** * @throws Enlight_Controller_Exception * * @return Shopware_Components_Auth|null */

    protected $model = Customer::class;

    protected $alias = 'customer';

    /** * {@inheritdoc} */
    public function deleteAction()
    {
        if (!$this->_isAllowed('delete', 'customer')) {
            throw new Enlight_Controller_Exception('You do not have sufficient rights to delete a customer.', 401);
        }
        parent::deleteAction();
    }

    /** * {@inheritdoc} */
    public function save($data)
    {
        if (!$this->_isAllowed('save', 'customer')) {
            throw new Enlight_Controller_Exception('You do not have sufficient rights to update a customer.', 401);
        }
$page = (int) $this->request->getParam('sPage', 1);
        $page = $page >= 1 ? $page : 1;
        $filterDate = urldecode($this->Request()->getParam('sFilterDate', ''));
        $filterAuthor = urldecode($this->Request()->getParam('sFilterAuthor', ''));
        $filterTags = urldecode($this->Request()->getParam('sFilterTags', ''));

        // Redirect if blog's category is not a child of the current shop's category         $shopCategory = $this->get('shop')->getCategory();
        $category = $this->getCategoryRepository()->findOneBy(['id' => $categoryId, 'active' => true]);
        $isChild = ($shopCategory && $category instanceof Category) ? $category->isChildOf($shopCategory) : false;
        if (!$isChild) {
            throw new Enlight_Controller_Exception('Blog category missing, non-existent or invalid for the current shop', 404);
        }

        $perPage = $this->getPerPage($this->Request()$this->container->get('session'));

        $filter = $this->createFilter($filterDate$filterAuthor$filterTags);

        // Start for Limit         $limitStart = ($page - 1) * $perPage;
        $limitEnd = $perPage;

        // Get all blog articles
public function init()
    {
        $this->sSYSTEM = Shopware()->System();
    }

    public function preDispatch()
    {
        $config = $this->container->get(\Shopware_Components_Config::class);

        if (!$config->get('showTellAFriend')) {
            throw new Enlight_Controller_Exception('Tell a friend is not activated for the current shop', 404);
        }
    }

    public function successAction()
    {
        $this->View()->loadTemplate('frontend/tellafriend/index.tpl');
        $this->View()->assign('sSuccess', true);
    }

    public function indexAction()
    {
        

    public function dispatch(
        Enlight_Controller_Request_Request $request,
        Enlight_Controller_Response_Response $response
    ) {
        $this->setResponse($response);

        if (!$this->isDispatchable($request)) {
            throw new Enlight_Controller_Exception(
                'Controller "' . $request->getControllerName() . '" not found for request url ' . $request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri(),
                Enlight_Controller_Exception::Controller_Dispatcher_Controller_Not_Found
            );
        }

        $class = $this->getControllerClass($request);
        $path = $this->getControllerPath($request);

        if (\is_object($path) || class_exists($path)) {
            $class = $path;
            $path = null;
        }

    public function __call($name$value = null)
    {
        if (substr($name, -6) === 'Action') {
            throw new Enlight_Controller_Exception(
                'Action "' . $this->controller_name . '_' . $name . '" not found failure for request url ' . $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->request->getRequestUri(),
                Enlight_Controller_Exception::ActionNotFound
            );
        }

        return parent::__call($name$value);
    }

    /** * @throws Exception * @throws Enlight_Exception * @throws Enlight_Event_Exception */
/** * Load action for the script renderer. * * @throws Enlight_Controller_Exception * * @return void */
    public function loadAction()
    {
        $auth = $this->auth->checkAuth();
        if ($auth === null) {
            throw new Enlight_Controller_Exception('Unauthorized', 401);
        }
        /** @var ShopwareReleaseStruct $shopwareRelease */
        $shopwareRelease = $this->container->get('shopware.release');

        $this->View()->assign('SHOPWARE_VERSION', $shopwareRelease->getVersion());
        $this->View()->assign('SHOPWARE_VERSION_TEXT', $shopwareRelease->getVersionText());
        $this->View()->assign('SHOPWARE_REVISION', $shopwareRelease->getRevision());
    }

    /** * Load action for the script renderer. * * @throws Enlight_Controller_Exception * * @return void */

    public function load($emotionId, ShopContextInterface $context)
    {
        $landingPage = $this->deviceConfiguration->getLandingPage($emotionId);
        $landingPageShops = $this->deviceConfiguration->getLandingPageShops($emotionId);

        $shopId = $context->getShop()->getId();
        $fallbackId = $context->getShop()->getFallbackId();

        if (!$landingPage || !\in_array($shopId$landingPageShops)) {
            throw new Enlight_Controller_Exception('Landing page missing, non-existent or invalid for the current shop', 404);
        }

        $translation = $this->translationComponent->readWithFallback($shopId$fallbackId, 'emotion', $emotionId);

        if (!empty($translation['name'])) {
            $landingPage['name'] = $translation['name'];
        }

        if (!empty($translation['seoTitle'])) {
            $landingPage['seo_title'] = $translation['seoTitle'];
        }

        
$fields = [];
        $labels = [];

        $shopId = $this->container->get(ContextServiceInterface::class)->getShopContext()->getShop()->getId();

        $modelManager = $this->getModelManager();
        $query = $modelManager->getRepository(Form::class)->getActiveFormQuery($formId$shopId);

        $form = $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);

        if (!$form instanceof Form) {
            throw new Enlight_Controller_Exception(
                'Form not found',
                Enlight_Controller_Exception::Controller_Dispatcher_Controller_Not_Found
            );
        }

        $attributeArray = [];
        if ($form->getAttribute() !== null) {
            $attributeArray = $modelManager->toArray($form->getAttribute());
            $modelManager->detach($form->getAttribute());
        }

        


    public function detailAction(int $id = 1): void
    {
        $criteria = new Criteria();
        $criteria->limit = 1;
        $criteria->filter = [['property' => 'id', 'value' => $id]];

        $result = $this->repository->findAll($criteria);

        if (\count($result->items) === 0) {
            throw new Enlight_Controller_Exception(sprintf('Cannot find element with id %d of type \'%s\'', $id$this->type->getInternalName()));
        }

        $item = current($result->items);

        $this->View()->assign('sItem', $item);
        $this->View()->assign('sBreadcrumb', $this->getBreadcrumb($item));
    }

    public function postDispatch()
    {
        parent::postDispatch();

        

    }

    /** * @throws Enlight_Controller_Exception * * @return void */
    public function loadPresetAction()
    {
        if (!$this->_isAllowed('save', 'emotion')) {
            throw new Enlight_Controller_Exception('You do not have sufficient rights to load a preset.', 401);
        }

        $id = $this->Request()->getParam('id');

        if (!$id) {
            $this->View()->assign([
                'success' => false,
            ]);

            return;
        }

        
/** * Error action method for not found/inactive products * Can throw an exception that is handled by the default error controller * or show a custom page with related products * * @return void */
    public function errorAction()
    {
        $config = $this->container->get(Config::class);
        if (!$config->get('RelatedArticlesOnArticleNotFound')) {
            throw new Enlight_Controller_Exception('Product not found', 404);
        }

        $this->Response()->setStatusCode($config->get('PageNotFoundCode', 404));
        $this->View()->assign('sRelatedArticles', $this->container->get('modules')->Marketing()->sGetSimilarArticles(
            (int) $this->Request()->getParam('sArticle'),
            (int) $config->get('maxcrosssimilar', 4)
        ));
    }

    /** * Index action method * * Read the product details and base rating form data * Loads on demand a custom template * * @return void */
Home | Imprint | This part of the site doesn't use cookies.