addPath example

/** * @param BundleFixture[] $bundles * * @return array{0: Environment, 1: TemplateFinder} */
    private function createFinder(array $bundles): array
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $twig = new Environment($loader['cache' => $this->cache]);

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            ->method('getBundles')
            ->willReturn($bundles);

        $scopeDetector = $this->createMock(TemplateScopeDetector::class);
        

        yield 'name' => [['email'][]];
        yield 'option --format' => [['--format', '']['text', 'json']];
    }

    private function createCommandTester(array $paths = [], array $bundleMetadata = [], string $defaultPath = null, bool $useChainLoader = false, array $globals = []): CommandTester
    {
        $projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
        $loader = new FilesystemLoader([]$projectDir);
        foreach ($paths as $path => $namespace) {
            if (null === $namespace) {
                $loader->addPath($path);
            } else {
                $loader->addPath($path$namespace);
            }
        }

        if ($useChainLoader) {
            $loader = new ChainLoader([$loader]);
        }

        $environment = new Environment($loader);
        foreach ($globals as $name => $value) {
            
// Add namespaced paths for modules and themes.     $namespaces = [];
    foreach ($module_handler->getModuleList() as $name => $extension) {
      $namespaces[$name] = $extension->getPath();
    }
    foreach ($theme_handler->listInfo() as $name => $extension) {
      $namespaces[$name] = $extension->getPath();
    }

    foreach ($namespaces as $name => $path) {
      $this->addPath($path . '/templates', $name);
      // Allow accessing the root of an extension by using the namespace without       // using directory traversal from the `/templates` directory.       $this->addPath($path$name);
    }
    if (!empty($twig_config['allowed_file_extensions'])) {
      // Provide a safe fallback for sites that have not updated their       // services.yml file or rebuilt the container, as well as for child       // classes.       $this->allowedFileExtensions = $twig_config['allowed_file_extensions'];
    }
  }

  
/** * @param Bundle[] $bundles */
    private function createFinder(array $bundles): Environment
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        /** @var BundleFixture $bundle */
        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
            if (file_exists($directory . '/../app/storefront/dist')) {
                $loader->addPath($directory . '/../app/storefront/dist', $bundle->getName());
            }
        }

        $twig = new Environment($loader['cache' => false]);

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            ->method('getBundles')
            

    public function publish(): bool
    {
        // Safeguard against accidental misuse         if ($this->source === ROOTPATH && $this->destination === FCPATH) {
            throw new RuntimeException('Child classes of Publisher should provide their own publish method or a source and destination.');
        }

        return $this->addPath('/')->merge(true);
    }

    // --------------------------------------------------------------------     // Property Accessors     // --------------------------------------------------------------------
    /** * Returns the source directory. */
    final public function getSource(): string
    {
        
/** * @param array<BundleFixture> $bundles */
    private function createFinder(array $bundles): Environment
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        /** @var BundleFixture $bundle */
        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $twig = new Environment($loader['cache' => $this->cache]);

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            ->method('getBundles')
            ->willReturn($bundles);

        $scopeDetector = $this->createMock(TemplateScopeDetector::class);
        


    /** * @param BundleFixture[] $bundles */
    private function initTwig(array $bundles): Environment
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $twig = new TwigEnvironment($loader['cache' => false]);

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            ->method('getBundles')
            ->willReturn($bundles);

        $scopeDetector = $this->createMock(TemplateScopeDetector::class);
        

    private function createFinder(array $bundles): array
    {
        $twig = $this->getContainer()->get('twig');

        $loader = $this->getContainer()->get('twig.loader.native_filesystem');
        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            ->method('getBundles')
            ->willReturn($bundles);

        $scopeDetector = $this->createMock(TemplateScopeDetector::class);
        $scopeDetector->expects(static::any())
            ->method('getScopes')
            
/** * @param string|array $paths A path or an array of paths where to look for templates */
    public function setPaths($paths, string $namespace = self::MAIN_NAMESPACE): void
    {
        if (!\is_array($paths)) {
            $paths = [$paths];
        }

        $this->paths[$namespace] = [];
        foreach ($paths as $path) {
            $this->addPath($path$namespace);
        }
    }

    /** * @throws LoaderError */
    public function addPath(string $path, string $namespace = self::MAIN_NAMESPACE): void
    {
        // invalidate the cache         $this->cache = $this->errorCache = [];

        
Home | Imprint | This part of the site doesn't use cookies.