getTemplates example

/** * The loadStoresAction function is an ExtJs event listener method of the product backend module. * The function is used to load all required stores for the product detail page in one request. */
    public function loadStoresAction()
    {
        $id = $this->Request()->getParam('articleId');
        $priceGroups = $this->getRepository()->getPriceGroupQuery()->getArrayResult();
        $suppliers = $this->getRepository()->getSuppliersQuery()->getArrayResult();
        $shops = $this->getShopRepository()->createQueryBuilder('shops')->andWhere('shops.active = 1')->getQuery()->getArrayResult();
        $taxes = $this->getRepository()->getTaxesQuery()->getArrayResult();
        $templates = $this->getTemplates();
        $units = $this->getRepository()->getUnitsQuery()->getArrayResult();
        $customerGroups = $this->getCustomerRepository()->getCustomerGroupsQuery()->getArrayResult();
        $properties = $this->getRepository()->getPropertiesQuery()->getArrayResult();
        $configuratorGroups = $this->getRepository()->getConfiguratorGroupsQuery()->getArrayResult();

        if (!empty($id)) {
            $product = $this->getArticle($id);
        } else {
            $product = $this->getNewArticleData();
        }

        
$app = $this->appRepository->search($criteria$this->context)->first();
        static::assertNotNull($app);
        static::assertSame($active$app->isActive());
        $this->assertDefaultTemplate($app);
        $this->assertDefaultPaymentMethods($app);
        $this->assertDefaultScripts($app);
        $this->assertDefaultScriptConditions($app);
    }

    private function assertDefaultTemplate(AppEntity $app): void
    {
        static::assertNotNull($app->getTemplates());
        $template = $app->getTemplates()->first();

        static::assertNotNull($template);
        static::assertSame($app->isActive()$template->isActive());
    }

    private function assertDefaultPaymentMethods(AppEntity $app): void
    {
        static::assertNotNull($app->getPaymentMethods());

        static::assertCount(2, $app->getPaymentMethods());
        
$template = $this->get('models')->getRepository(Template::class)->findOneBy(['template' => $options['template']]);
        if (!$template instanceof Template) {
            $template = new Template();
            if (!isset($options['name'])) {
                $options['name'] = ucfirst($options['template']);
            }
        }

        $template->fromArray($options);
        $plugin = $this->Plugin();
        $plugin->getTemplates()->add($template);
        $template->setPlugin($plugin);

        return $template;
    }

    /** * Create cron job method * * @param string $name * @param string $action * @param int $interval * @param int $active * @param bool $disableOnError */
/** * Controller action to get a list of all defined templates. * You can paginate the list over the request parameters * "start" and "limit". * Use the internal "getTemplates" function. * * @return void */
    public function getTemplatesAction()
    {
        $this->View()->assign(
            $this->getTemplates(
                $this->Request()->getParam('start'),
                $this->Request()->getParam('limit'),
                $this->Request()->getParam('id')
            )
        );
    }

    protected function initAcl()
    {
        $this->addAclPermission('list', 'read', 'Insufficient permissions');
        $this->addAclPermission('detail', 'read', 'Insufficient permissions');
        
public function __construct(
        private readonly AbstractTemplateLoader $templateLoader,
        private readonly EntityRepository $templateRepository,
        private readonly EntityRepository $appRepository
    ) {
    }

    public function updateTemplates(Manifest $manifest, string $appId, Context $context): void
    {
        $app = $this->getAppWithExistingTemplates($appId$context);
        /** @var TemplateCollection $existingTemplates */
        $existingTemplates = $app->getTemplates();
        $templatePaths = $this->templateLoader->getTemplatePathsForApp($manifest);

        $upserts = [];
        foreach ($templatePaths as $templatePath) {
            $payload = [
                'template' => $this->templateLoader->getTemplateContent($templatePath$manifest),
            ];

            /** @var TemplateEntity|null $existing */
            $existing = $existingTemplates->filterByProperty('path', $templatePath)->first();
            if ($existing) {
                
Home | Imprint | This part of the site doesn't use cookies.