Enlight_Exception example

/** * Returns the instance of the Enlight_Template_Default which will be set by the setTemplate or loadTemplate * function. * * @throws Enlight_Exception * * @return Enlight_Template_Default */
    public function Template()
    {
        if ($this->template === null) {
            throw new Enlight_Exception('Template was not loaded failure');
        }

        return $this->template;
    }

    /** * This function sets the default template directory into the internal instance of the Enlight_Template_Manager * * @param string|array $path * * @return Enlight_View_Default */
$eventName = $arguments->getName();
        $eventName = str_replace('Enlight_Controller_Dispatcher_ControllerPath_', '', $eventName);

        $parts = explode('_', $eventName);

        $module = $parts[0];
        $controller = $parts[1];

        $path = $this->Path() . 'Controllers/' . ucfirst($module) . '/' . ucfirst($controller) . '.php';

        if (!file_exists($path)) {
            throw new Enlight_Exception(sprintf('Controller "%s" can\'t load failure', $controller));
        }

        // register plugin model directory         if (file_exists($this->Path() . 'Models')) {
            $this->registerCustomModels();
        }

        // register plugin views directory         if (file_exists($this->Path() . 'Views')) {
            Shopware()->Template()->addTemplateDir(
                $this->Path() . 'Views/'
            );
Shopware()->Template()->addTemplateDir(__DIR__ . '/../Views/');
        $data = Shopware()->Template()->fetch('frontend/plugins/sepa/email.tpl');

        /** @var array<string, string> $mpdfConfig */
        $mpdfConfig = Shopware()->Container()->getParameter('shopware.mpdf.defaultConfig');
        $mpdf = new Mpdf($mpdfConfig);
        $mpdf->WriteHTML($data);
        $pdfFileContent = $mpdf->Output('', 'S');

        if ($pdfFileContent === false) {
            throw new Enlight_Exception('Could not generate SEPA attachment file');
        }

        $attachmentName = 'SEPA_' . $orderNumber;

        $mail->createAttachment(
            $pdfFileContent,
            'application/pdf',
            Zend_Mime::DISPOSITION_ATTACHMENT,
            Zend_Mime::ENCODING_BASE64,
            $attachmentName . '.pdf'
        );

        
/** * Loads the plugin instance of the given plugin name. * * @throws Enlight_Exception * * @return Enlight_Plugin_PluginCollection */
    public function load($name$throwException = true)
    {
        if ($throwException && !$this->plugins->offsetExists($name)) {
            throw new Enlight_Exception('Plugin "' . $name . '" not found failure');
        }

        return $this;
    }

    /** * Removes all stored plugins. * * @return Enlight_Plugin_PluginCollection */
    public function reset()
    {

    public function __call($name$value = null)
    {
        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
        $caller = ($trace['file'] ?? '') . ':' . ($trace['line'] ?? '');

        trigger_error('Shopware()->' . $name . '() is deprecated since version 4.2 and will be removed in 5.8. Use the Container instead. Called by ' . $caller, E_USER_DEPRECATED);

        if (!$this->container->has($name)) {
            throw new Enlight_Exception(
                sprintf('Method "%s::%s" not found failure', \get_class($this)$name),
                Enlight_Exception::METHOD_NOT_FOUND
            );
        }

        return $this->container->get($name);
    }

    /** * Returns the name of the application * * @return string */

    public function loadClass($class$path = null)
    {
        if (\is_array($class) && $class !== []) {
            return min(array_map([$this, __METHOD__]$class));
        }
        if (!\is_string($class)) {
            throw new Enlight_Exception('Class name must be a string');
        }
        $class = ltrim($class, self::DEFAULT_SEPARATOR);
        if (!$this->isLoaded($class)) {
            if ($path !== null) {
                $this->loadFile($path);

                return true;
            }
            $path = $this->getClassPath($class);
            if ($path === null) {
                return false;
            }
'dispatchID' => $dispatchId,
            'currency' => $this->sBasketData[CheckoutKey::CURRENCY_NAME],
            'currencyFactor' => $this->sBasketData[CheckoutKey::CURRENCY_FACTOR],
            'subshopID' => $mainShop->getId(),
            'deviceType' => $this->deviceType,
        ];

        try {
            $affectedRows = $this->db->insert('s_order', $data);
            $orderID = $this->db->lastInsertId();
        } catch (Exception $e) {
            throw new Enlight_Exception(sprintf('##sOrder-sTemporaryOrder-#01:%s', $e->getMessage()), 0, $e);
        }
        if (!$affectedRows || !$orderID) {
            throw new Enlight_Exception('##sOrder-sTemporaryOrder-#01: No rows affected or no order id saved', 0);
        }

        // Create order attributes         $this->attributePersister->persist($this->orderAttributes, 's_order_attributes', $orderID);

        foreach ($this->sBasketData[CartKey::POSITIONS] as $basketRow) {
            if (!$basketRow['price']) {
                $basketRow['price'] = '0,00';
            }
':headline' => $sVoteSummary,
            ':comment' => $sVoteComment,
            ':points' => $sVoteStars,
            ':datum' => $date,
            ':active' => $active,
            ':email' => $sVoteMail,
            ':shopId' => $shopId,
        ]);

        $success = $query->execute();
        if (empty($success)) {
            throw new Enlight_Exception('sSaveComment #00: Could not save comment');
        }

        $insertId = $this->connection->lastInsertId();
        if (!isset($this->session['sArticleCommentInserts'])) {
            $this->session['sArticleCommentInserts'] = new ArrayObject();
        }

        $this->session['sArticleCommentInserts'][$article] = $insertId;
    }

    /** * @deprecated in 5.6, will be removed in 5.8 without replacement * * Get id from all products, that belongs to a specific supplier * * @param int $supplierID Supplier id (s_articles.supplierID) * * @return array */

    protected function sSaveComment($commentData$blogArticleId)
    {
        if (empty($commentData)) {
            throw new Enlight_Exception('sSaveComment #00: Could not save comment');
        }

        $blogCommentModel = new Comment();
        /** @var Blog $blog */
        $blog = $this->getRepository()->find($blogArticleId);
        /** @var Shop $shop */
        $shop = $this->getModelManager()->getReference(Shop::class$this->get('shop')->getId());

        $blogCommentModel->setBlog($blog);
        $blogCommentModel->setCreationDate(new DateTime());
        $blogCommentModel->setActive(false);

        

    public function __construct()
    {
        $class = \get_class($this);
        if ($this instanceof Enlight_Singleton) {
            if (!isset(self::$instances[$class])) {
                self::$instances[$class] = $this;
            } else {
                throw new Enlight_Exception(
                    'Class "' . \get_class($this) . '" is singleton, please use the instance method'
                );
            }
        }
        if ($this instanceof Enlight_Hook
          && !$this instanceof Enlight_Hook_Proxy
          && Shopware()->Hooks()->hasProxy($class)
        ) {
            throw new Enlight_Exception(
                'Class "' . \get_class($this) . '" has hooks, please use the instance method'
            );
        }


    private function getCustomerGroupKey(): ?string
    {
        $customerGroupKey = $this->request->getParam('sValidation');
        $customerGroupId = $this->get(Connection::class)->fetchColumn(
            'SELECT id FROM s_core_customergroups WHERE `groupkey` = ?',
            [$customerGroupKey]
        );

        if ($customerGroupKey && !$customerGroupId) {
            throw new Enlight_Exception('Invalid customergroup');
        }

        $event = Shopware()->Events()->notifyUntil(
            'Shopware_Controllers_Frontend_Register_CustomerGroupRegister',
            ['subject' => $this, 'sValidation' => $customerGroupId]
        );

        if ($event) {
            return $this->get(Shopware_Components_Config::class)->get('defaultCustomerGroup', 'EK');
        }

        
$template = $templateEngine->createTemplate('string:' . $value);
            $template->assign($context);
            $template = $template->fetch();
        } catch (SmartyCompilerException $e) {
            $errorMessage = $e->getMessage();

            if (stripos($errorMessage, 'Syntax Error in template') === 0) {
                // Strip away filepath which is a md5sum                 $errorMessage = sprintf('Syntax Error %s', substr($errorMessage, 69));
            }

            throw new \Enlight_Exception($errorMessage, 0, $e);
        }

        return $template;
    }

    /** * @param string $value * @param array $context * * @return string */
    
use Shopware\Components\Logger;

if (file_exists($this->DocPath() . 'config_' . $this->Environment() . '.php')) {
    $customConfig = $this->loadConfig($this->DocPath() . 'config_' . $this->Environment() . '.php');
} elseif (file_exists($this->DocPath() . 'config.php')) {
    $customConfig = $this->loadConfig($this->DocPath() . 'config.php');
} else {
    $customConfig = [];
}

if (!\is_array($customConfig)) {
    throw new Enlight_Exception('The custom configuration file must return an array.');
}

return array_replace_recursive([
    'custom' => [],

    /* * For more information on working with reverse proxies and trusted headers see * https://symfony.com/doc/current/deployment/proxies.html */
    'trustedproxies' => [],
    'trustedheaderset' => -1,

    
$receivers = array_map('trim', $receivers);

        $mail->setFrom(Shopware()->Config()->get('Mail'));
        $mail->clearRecipients();
        $mail->addTo($receivers);
        $mail->setBodyText($mailBody);
        $mail->setSubject($mailSubject);

        $mail = Shopware()->Events()->filter('Shopware_Controllers_Frontend_Forms_commitForm_Mail', $mail['subject' => $this]);

        if (!$mail->send()) {
            throw new Enlight_Exception('Could not send mail');
        }
    }

    /** * @param int $formId * * @throws Enlight_Exception * @throws Exception * * @return array */
    

                [$orderID]
            );

            if (empty($document->_subshop['doc_template'])) {
                $document->setTemplate($document->_defaultPath);
            }

            if (empty($document->_subshop['id'])) {
                throw new Enlight_Exception(sprintf('Could not load template path for order "%s"', $orderID));
            }
            if (!empty($config['_allowMultipleDocuments'])) {
                $document->_allowMultipleDocuments = $config['_allowMultipleDocuments'];
            }
        } else {
            $document->_subshop = Shopware()->Db()->fetchRow(" SELECT s.id, s.document_template_id as doc_template_id, s.template_id, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = s.document_template_id) as doc_template, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = s.template_id) as template, s.id as isocode, s.locale_id as locale FROM s_core_shops s WHERE s.default = 1 ");
Home | Imprint | This part of the site doesn't use cookies.