View example

use Shopware\Models\Customer\Customer;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response;

class Shopware_Controllers_Frontend_Register extends Enlight_Controller_Action
{
    /** * Will be called from the dispatcher before an action is processed */
    public function preDispatch()
    {
        $this->View()->setScope(Enlight_Template_Manager::SCOPE_PARENT);
    }

    /** * Will be called when no action is supplied */
    public function indexAction()
    {
        $sTarget = $this->Request()->getParam('sTarget', 'account');
        $sTargetAction = $this->Request()->getParam('sTargetAction', 'index');

        $this->View()->assign([
            
/** * Returns the list of active widgets for the current logged * in user as an JSON string. * * @return void */
    public function getListAction()
    {
        $auth = $this->get('auth');

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

            return;
        }

        $identity = $auth->getIdentity();
        $userID = (int) $identity->id;

        $builder = $this->get(ModelManager::class)->createQueryBuilder();
        $builder->select(['widget', 'view', 'plugin'])
            ->from(Widget::class, 'widget')
            ->leftJoin('widget.views', 'view', 'WITH', 'view.authId = ?1')
            

        $categoryTree = $this->getCategoryTree();
        $additionalTrees = $this->getAdditionalTrees();

        $additionalTrees = $this->container->get('events')->filter(
            'Shopware_Modules_Sitemap_indexAction',
            $additionalTrees,
            ['subject' => $this]
        );

        $categoryTree = array_merge($categoryTree$additionalTrees);
        $this->View()->assign('sCategoryTree', $categoryTree);
    }

    private function getCategoryTree(): array
    {
        $shop = $this->container->get('shop');
        if (!$shop instanceof Shop) {
            throw new RuntimeException('Shop is not initialized correctly in DI container');
        }
        $categoryTree = $this->container->get('modules')->Categories()->sGetWholeCategoryTree(null, null, $shop->getId());

        $categoryTranslations = $this->fetchTranslations('category', $this->getTranslationKeys(
            
$paginator = $this->getModelManager()->createPaginator($query);
        // Returns the total count of the query         $totalResult = $paginator->count();
        $shippingCosts = iterator_to_array($paginator);
        $shippingCosts = $this->convertShippingCostsDates($shippingCosts);

        if ($totalResult > 0) {
            $shippingCosts = $this->translateDispatchMethods($shippingCosts);
        }

        $this->View()->assign(['success' => true, 'data' => $shippingCosts, 'total' => $totalResult]);
    }

    /** * Returns all Shipping Costs with basic data * * @return void */
    public function getListAction()
    {
        $limit = $this->Request()->getParam('limit', 20);
        $offset = $this->Request()->getParam('start', 0);
        


    /** * Topseller action for getting topsellers * by category with perPage filtering * * @return void */
    public function topSellerAction()
    {
        $perPage = (int) $this->Request()->getParam('perPage', 4);
        $this->View()->assign('sCharts', $this->container->get('modules')->Articles()->sGetArticleCharts(
            $this->Request()->getParam('sCategory')
        ));
        $this->View()->assign('perPage', $perPage);
    }

    /** * @return void */
    public function productsAction()
    {
        $numbers = $this->Request()->getParam('numbers');
        
$query = $this->getRepository()->getListQuery($filter$order$offset$limit);

        // returns the total count of the query         $totalResult = $this->getManager()->getQueryCount($query);

        $forms = $query->getArrayResult();

        foreach ($forms as &$form) {
            $form['shopIds'] = $this->explodeShopIds($form['shopIds']);
        }

        $this->View()->assign(['success' => true, 'data' => $forms, 'total' => $totalResult]);
    }

    /** * Creates new form * * @throws OptimisticLockException * @throws ORMInvalidArgumentException */
    public function createFormAction()
    {
        $params = $this->Request()->getParams();

        
/** * @return void */
    public function init()
    {
        $this->blogBaseUrl = Shopware()->Config()->get('baseFile');
    }

    public function preDispatch()
    {
        $this->View()->setScope(Enlight_Template_Manager::SCOPE_PARENT);
    }

    /** * Helper Method to get access to the blog repository. * * @return BlogRepository */
    public function getRepository()
    {
        if ($this->repository === null) {
            $this->repository = $this->get('models')->getRepository(Blog::class);
        }
$connection->executeUpdate(
            'UPDATE s_search_custom_facet SET position = position - 1 WHERE position <= :position',
            [':position' => $position]
        );

        $connection->executeUpdate(
            'UPDATE s_search_custom_facet SET position = :position WHERE id = :id',
            [':position' => $position, ':id' => $id]
        );

        $this->View()->assign('success', true);
    }

    public function copyCategorySettingsAction()
    {
        $categoryId = (int) $this->Request()->getParam('categoryId');

        $connection = $this->container->get(\Doctrine\DBAL\Connection::class);

        $data = $connection->fetchAssoc(
            'SELECT `hidefilter`, `facet_ids` FROM s_categories WHERE id = :id',
            [':id' => $categoryId]
        );

        return [
            'label' => 'Schlagwortwolke',
        ];
    }

    /** * @return void */
    public function onPostDispatch(Enlight_Event_EventArgs $args)
    {
        $view = $args->getSubject()->View();
        $request = $args->getSubject()->Request();
        $response = $args->getSubject()->Response();

        if (!$request->isDispatched()
            || $response->isException()
            || $request->getModuleName() !== 'frontend'
        ) {
            return;
        }

        $config = $this->Config();
        

        }

        $statusNodes['data'][] = $paymentNodes;
        $statusNodes['data'][] = $orderNodes;

        $nodes[] = $statusNodes;
        $nodes[] = $systemNodes;
        $nodes[] = $userNodes;
        $nodes[] = $documentNodes;

        $this->View()->assign(['success' => true, 'data' => $nodes]);
    }

    /** * Creates new mail */
    public function createMailAction()
    {
        $params = $this->Request()->getParams();

        $mail = new Mail();
        $params['dirty'] = 1;
        
class CacheIdCollector
{
    /** * Returns an array of affected cache ids for this $controller * * @return array */
    public function getCacheIdsFromController(Controller $controller, ShopContextInterface $context)
    {
        $request = $controller->Request();
        $view = $controller->View();
        $controllerName = $this->getControllerRoute($request);

        switch ($controllerName) {
            case 'frontend/blog':
                return $this->getBlogCacheIds($request$view);

            case 'widgets/listing':
                return $this->getAjaxListingCacheIds($request$view);

            case 'frontend/index':
                return $this->getHomePageCacheIds($context);

            
$plugins = $pluginCheck->checkInstalledPluginsAvailableForNewVersion($this->getVersion());

        $updatable = array_filter($pluginsfunction D$plugin) {
            return $plugin['updatable'];
        });

        $notUpdatable = array_filter($pluginsfunction D$plugin) {
            return $plugin['inStore'] == false;
        });

        $this->View()->assign([
            'success' => true,
            'result' => $result,
            'plugins' => array_values($plugins),
            'updatable' => array_values($updatable),
            'notUpdatable' => array_values($notUpdatable),
        ]);
    }

    /** * @return string */
    

        $sourceStreamId = $this->Request()->getParam('sourceStreamId');
        $targetStreamId = $this->Request()->getParam('targetStreamId');

        $persister = Shopware()->Container()->get(DataPersister::class);
        $persister->cloneAttribute(
            's_product_streams_attributes',
            $sourceStreamId,
            $targetStreamId
        );

        $this->View()->assign('success', true);
    }

    /** * @return void */
    public function loadPreviewAction()
    {
        try {
            $streamRepo = $this->get(ProductStreamRepository::class);
            $criteria = new Criteria();

            


    /** * Get list of caches * * GET /api/caches/ */
    public function indexAction(): void
    {
        $result = $this->resource->getList();

        $this->View()->assign($result);
        $this->View()->assign('success', true);
    }

    /** * Get one cache * * GET /api/caches/{id} */
    public function getAction(): void
    {
        $id = $this->Request()->getParam('id');

        

    public static function renderer(?string $viewPath = null, ?ViewConfig $config = null, bool $getShared = true)
    {
        if ($getShared) {
            return static::getSharedInstance('renderer', $viewPath$config);
        }

        $viewPath = $viewPath ?: (new Paths())->viewDirectory;
        $config ??= config(ViewConfig::class);

        return new View($config$viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger());
    }

    /** * Returns the current Request object. * * createRequest() injects IncomingRequest or CLIRequest. * * @return CLIRequest|IncomingRequest * * @deprecated The parameter $config and $getShared are deprecated. */
    
Home | Imprint | This part of the site doesn't use cookies.