getDirectory example

// Ensure the source file exists, if it's a local URI or path.     if (!file_exists($source)) {
      throw new MigrateException("File '$source' does not exist");
    }

    // If the start and end file is exactly the same, there is nothing to do.     if ($this->isLocationUnchanged($source$destination)) {
      return $destination;
    }

    // Check if a writable directory exists, and if not try to create it.     $dir = $this->getDirectory($destination);
    // If the directory exists and is writable, avoid     // \Drupal\Core\File\FileSystemInterface::prepareDirectory() call and write     // the file to destination.     if (!is_dir($dir) || !is_writable($dir)) {
      if (!$this->fileSystem->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
        throw new MigrateException("Could not create or write to directory '$dir'");
      }
    }

    $final_destination = $this->writeFile($source$destination$this->configuration['file_exists']);
    if ($final_destination) {
      

        return str_replace('\\', \DIRECTORY_SEPARATOR, $this->namespace);
    }

    public function getFilename(): string
    {
        return $this->name.'.php';
    }

    public function build(): string
    {
        $rootPath = explode(\DIRECTORY_SEPARATOR, $this->getDirectory());
        $require = '';
        foreach ($this->require as $class) {
            // figure out relative path.             $path = explode(\DIRECTORY_SEPARATOR, $class->getDirectory());
            $path[] = $class->getFilename();
            foreach ($rootPath as $key => $value) {
                if ($path[$key] !== $value) {
                    break;
                }
                unset($path[$key]);
            }
            
return function D) use ($path$rootClass) {
            require_once $path;
            $className = $rootClass->getFqcn();

            return new $className();
        };
    }

    private function getFullPath(ClassBuilder $class): string
    {
        $directory = $this->outputDir.\DIRECTORY_SEPARATOR.$class->getDirectory();
        if (!is_dir($directory)) {
            @mkdir($directory, 0777, true);
        }

        return $directory.\DIRECTORY_SEPARATOR.$class->getFilename();
    }

    private function writeClasses(): void
    {
        foreach ($this->classes as $class) {
            $this->buildConstructor($class);
            
yield ['C:webmozart', ''];

        yield ['D:/Folder/Aééé/Subfolder', 'D:/Folder/Aééé'];
    }

    /** * @dataProvider provideGetDirectoryTests */
    public function testGetDirectory(string $path, string $directory)
    {
        $this->assertSame($directory, Path::getDirectory($path));
    }

    public static function provideGetFilenameWithoutExtensionTests(): \Generator
    {
        yield ['/webmozart/symfony/style.css.twig', null, 'style.css'];
        yield ['/webmozart/symfony/style.css.', null, 'style.css'];
        yield ['/webmozart/symfony/style.css', null, 'style'];
        yield ['/webmozart/symfony/.style.css', null, '.style'];
        yield ['/webmozart/symfony/', null, 'symfony'];
        yield ['/webmozart/symfony', null, 'symfony'];
        yield ['/', null, ''];
        

    private function removeDeletedThemes()
    {
        $themes = $this->repository->createQueryBuilder('templates');
        $themes->where('templates.version = 3')
            ->andWhere('templates.pluginId IS NULL');

        $themes = $themes->getQuery()->getResult(AbstractQuery::HYDRATE_OBJECT);

        /** @var Template $theme */
        foreach ($themes as $theme) {
            $directory = $this->pathResolver->getDirectory($theme);
            if (!file_exists($directory)) {
                $this->entityManager->remove($theme);
            }
        }

        $this->entityManager->flush();
    }

    /** * Helper function which resolves the theme parent for each * passed theme * * @throws Exception */

    public function getThemeByTemplate(Template $template)
    {
        $namespace = 'Shopware\\Themes\\' . $template->getTemplate();
        /** @var class-string<Theme> $class */
        $class = $namespace . '\\Theme';

        $directory = $this->pathResolver->getDirectory($template);

        $file = $directory . DIRECTORY_SEPARATOR . 'Theme.php';

        if (!file_exists($file)) {
            throw new Exception(sprintf('Theme directory %s contains no Theme.php', $directory));
        }

        require_once $file;

        return new $class();
    }

    
$shop = $this->getManager()->find(Shop::class$wholeParams['shopId']);

        foreach ($data['data'] as &$theme) {
            $instance = $this->getRepository()->find($theme['id']);
            if (!$instance instanceof Template) {
                continue;
            }

            $theme['screen'] = $this->container->get(Util::class)->getPreviewImage($instance);

            $theme['path'] = $this->container->get(PathResolver::class)->getDirectory($instance);

            $theme = $this->get(Service::class)->translateTheme($instance$theme);

            if ($shop instanceof Shop && $shop->getTemplate() instanceof Template) {
                $theme['enabled'] = $theme['id'] === $shop->getTemplate()->getId();
            }
        }

        return $this->get('events')->filter('Shopware_Theme_Listing_Loaded', $data[
            'shop' => $shop,
        ]);
    }
Home | Imprint | This part of the site doesn't use cookies.