getTemplate example

foreach ($this->getTables($connection) as $table) {
      $schema = $this->getTableSchema($connection$table);
      // Check for schema only.       if (empty($schema_only_patterns) || preg_replace($schema_only_patterns, '', $table)) {
        $data = $this->getTableData($connection$table);
      }
      else {
        $data = [];
      }
      $tables .= $this->getTableScript($table$schema$data$insert_count);
    }
    $script = $this->getTemplate();
    // Substitute in the version.     $script = str_replace('{{VERSION}}', \Drupal::VERSION, $script);
    // Substitute in the tables.     $script = str_replace('{{TABLES}}', trim($tables)$script);
    return trim($script);
  }

  /** * Returns a list of tables, not including those set to be excluded. * * @param \Drupal\Core\Database\Connection $connection * The database connection to use. * * @return array * An array of table names. */
break;

            default:
                $result = null;
                break;
        }

        if ($result === null) {
            return null;
        }

        if ($facet->getTemplate()) {
            $result->setTemplate($facet->getTemplate());

            return $result;
        }

        $result->setTemplate($this->getTypeTemplate($type$facet->getMode()$result->getTemplate()));

        return $result;
    }

    /** * @return RadioFacetResult|ValueListFacetResult|null */
private function getFields(): array
    {
        $fields = [];

        foreach ($this->type->getFields() as $field) {
            if (!$field->getType() instanceof TemplateProvidingFieldInterface) {
                continue;
            }

            $tmpField = $field->jsonSerialize();
            $tmpField['template'] = $field->getType()::getTemplate();

            $fields[] = $tmpField;
        }

        return $fields;
    }
}

    private function validateShop(Shop $shop): void
    {
        if (!$shop->getCustomerGroup() instanceof CustomerGroup) {
            throw new RuntimeException(sprintf("Shop '%s (id: %s)' has no customer group.", $shop->getName()$shop->getId()));
        }

        $shop->getCurrency();
        $shop->getLocale();

        $mainShop = $shop->getMain() ?? $shop;
        if (!$mainShop->getTemplate()) {
            throw new RuntimeException(sprintf("Shop '%s (id: %s)' has no template.", $shop->getName()$shop->getId()));
        }

        if (!$mainShop->getDocumentTemplate()) {
            throw new RuntimeException(sprintf("Shop '%s (id: %s)' has no document template.", $shop->getName()$shop->getId()));
        }
    }

    private function refreshCart(Shop $shop): void
    {
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
use Twig\Loader\ArrayLoader as TwigArrayLoader;
use Twig\TemplateWrapper;

class TranslationExtensionTest extends TestCase
{
    public function testEscaping()
    {
        $output = $this->getTemplate('{% trans %}Percent: %value%%% (%msg%){% endtrans %}')->render(['value' => 12, 'msg' => 'approx.']);

        $this->assertEquals('Percent: 12% (approx.)', $output);
    }

    /** * @dataProvider getTransTests */
    public function testTrans($template$expected, array $variables = [])
    {
        if ($expected != $this->getTemplate($template)->render($variables)) {
            echo $template."\n";
            
parent::submitConfigurationForm($form$form_state);
    $this->configuration['column_widths'] = $form_state->getValue('column_widths');
  }

  /** * {@inheritdoc} */
  public function build(array $regions) {
    $build = parent::build($regions);
    $build['#attributes']['class'] = [
      'layout',
      $this->getPluginDefinition()->getTemplate(),
      $this->getPluginDefinition()->getTemplate() . '--' . $this->configuration['column_widths'],
    ];
    return $build;
  }

  /** * Gets the width options for the configuration form. * * The first option will be used as the default 'column_widths' configuration * value. * * @return string[] * The width options array where the keys are strings that will be added to * the CSS classes and the values are the human readable labels. */

    public function setPlugin($plugin)
    {
        $this->plugin = $plugin;
    }

    /** * @return string */
    public function toString()
    {
        return $this->getTemplate();
    }

    public function setParent(?Template $parent = null)
    {
        $this->parent = $parent;
    }

    /** * @return Template|null */
    public function getParent()
    {
$path = $category->getPath() ? '|' . implode('|', $category->getPath()) . '|' : '';

        return [
            'id' => $category->getId(),
            'name' => $category->getName(),
            'metaKeywords' => $category->getMetaKeywords(),
            'metaDescription' => $category->getMetaDescription(),
            'cmsHeadline' => $category->getCmsHeadline(),
            'cmsText' => $category->getCmsText(),
            'active' => true,
            'template' => $category->getTemplate(),
            'blog' => $category->isBlog(),
            'path' => $path,
            'external' => $category->getExternalLink(),
            'externalTarget' => $category->getExternalTarget(),
            'hideFilter' => !$category->displayFacets(),
            'hideTop' => !$category->displayInNavigation(),
            'hidetop' => !$category->displayInNavigation(),
            'attribute' => $attribute,
            'media' => $media,
            'description' => $category->getName(),
            'link' => $category->getExternalLink() ?: $url . $category->getId(),
            


        /** @var Emotion $emotion */
        $emotion = reset($emotions);

        if ($emotion->isPreview() && $emotion->getPreviewSecret() !== $this->Request()->getParam('secret')) {
            return;
        }

        $emotions = array_map([$this, 'getLegacyEmotion']$emotions);

        if ($emotion->getTemplate()) {
            $this->View()->loadTemplate('widgets/emotion/' . $emotion->getTemplate()->getFile());
        }

        $this->View()->assign('categoryId', (int) $this->Request()->getParam('categoryId'));
        $this->View()->assign('Controller', (string) $this->Request()->getParam('controllerName'));
        $this->View()->assign('sEmotions', $emotions, true);
    }

    /** * Action that will be triggered by product slider type top seller */
    
$eventManager = Shopware()->Container()->get('events');

        if ($this->getShop() !== null) {
            $defaultContext = [
                'sConfig' => $config,
                'sShop' => $config->get('shopName'),
                'sShopURL' => ($this->getShop()->getSecure() ? 'https://' : 'http://') . $this->getShop()->getHost() . $this->getShop()->getBaseUrl(),
            ];

            // Add theme to the context if given shop (or its main shop) has a template.             $theme = null;
            if ($this->getShop()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getTemplate()$this->getShop(), false);
            } elseif ($this->getShop()->getMain() && $this->getShop()->getMain()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getMain()->getTemplate()$this->getShop(), false);
            }

            if ($theme) {
                $keys = $eventManager->filter(
                    'TemplateMail_CreateMail_Available_Theme_Config',
                    $this->themeVariables,
                    ['theme' => $theme]
                );

                
throw new ModelNotFoundException(Template::class$themeId);
        }

        $shop = $this->getManager()->getRepository(Shop::class)->getActiveById($shopId);

        session_write_close();

        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        $session = $this->get('session');

        $session->template = $theme->getTemplate();
        $session->Admin = true;

        if (!$this->Request()->isXmlHttpRequest()) {
            $this->get('events')->notify('Shopware_Theme_Preview_Starts', [
                'session' => Shopware()->Session(),
                'shop' => $shop,
                'theme' => $theme,
            ]);

            $hash = $this->container->get(OptinServiceInterface::class)->add(OptinServiceInterface::TYPE_THEME_PREVIEW, 300, [
                'sessionName' => session_name(),
                
$criteria->addSorting(new FieldSorting('path', FieldSorting::ASCENDING));
        $templates = $templateRepository->search($criteria$this->context)->getEntities();

        static::assertCount(3, $templates);
        $templates = array_values($templates->getElements());

        /** @var TemplateEntity $template */
        $template = $templates[0];
        static::assertEquals('storefront/layout/header/header.html.twig', $template->getPath());
        static::assertStringEqualsFile(
            __DIR__ . '/../Manifest/_fixtures/test/Resources/views/storefront/layout/header/header.html.twig',
            $template->getTemplate()
        );
        static::assertEquals($active$template->isActive());

        /** @var TemplateEntity $template */
        $template = $templates[1];
        static::assertEquals('storefront/layout/header/logo.html.twig', $template->getPath());
        static::assertStringEqualsFile(
            __DIR__ . '/../Manifest/_fixtures/test/Resources/views/storefront/layout/header/logo.html.twig',
            $template->getTemplate()
        );
        static::assertEquals($active$template->isActive());
    }
return $this->pathResolver->getFrontendThemeDirectory() . DIRECTORY_SEPARATOR . $name;
    }

    /** * Generates the Theme.php file for the theme. */
    private function generateThemePhp(array $data, ?Template $parent = null)
    {
        $source = str_replace('$TEMPLATE$', $data['template']$this->phpSource);

        if ($parent instanceof Template) {
            $source = str_replace('$PARENT$', $parent->getTemplate()$source);
        } else {
            $source = str_replace('$PARENT$', 'null', $source);
        }

        $source = $this->replacePlaceholder('name', $data['name']$source);
        $source = $this->replacePlaceholder('author', $data['author']$source);
        $source = $this->replacePlaceholder('license', $data['license']$source);
        $source = $this->replacePlaceholder('description', $data['description']$source);

        $output = new SplFileObject(
            $this->getThemeDirectory($data['template']) . DIRECTORY_SEPARATOR . 'Theme.php',
            
$data = [
            'id' => $category->getId(),
            'parentId' => $category->getParentId(),
            'name' => $category->getName(),
            'position' => $category->getPosition(),
            'metaTitle' => $category->getMetaTitle(),
            'metaKeywords' => $category->getMetaKeywords(),
            'metaDescription' => $category->getMetaDescription(),
            'cmsHeadline' => $category->getCmsHeadline(),
            'cmsText' => $category->getCmsText(),
            'active' => true,
            'template' => $category->getTemplate(),
            'productBoxLayout' => $this->getProductBoxLayout($category),
            'blog' => $category->isBlog(),
            'path' => $categoryPath,
            'external' => $category->getExternalLink(),
            'externalTarget' => $category->getExternalTarget(),
            'hideFilter' => !$category->displayFacets(),
            'hideTop' => !$category->displayInNavigation(),
            'changed' => null,
            'added' => null,
            'attribute' => $attribute,
            'attributes' => $category->getAttributes(),
            

    public function initTemplate($mailing)
    {
        $template = clone Shopware()->Template();
        $shop = Shopware()->Shop();
        $inheritance = Shopware()->Container()->get('theme_inheritance');

        $config = $inheritance->buildConfig(
            $shop->getTemplate(),
            $shop,
            false
        );

        $user = $this->getMailingUserByEmail(Shopware()->Config()->get('Mail'));
        $template->assign('sUser', $user, true);
        $hash = $this->createHash((int) $user['mailaddressID'](int) $mailing['id']);
        $template->assign('sCampaignHash', $hash, true);
        $template->assign('sRecommendations', $this->getMailingSuggest($mailing['id']$user['userID']), true);
        $template->assign('sVoucher', $this->getMailingVoucher($mailing['id']), true);
        $template->assign('sCampaign', $this->getMailingDetails($mailing['id']), true);
        
Home | Imprint | This part of the site doesn't use cookies.