removeSpecialCharacters example



    /** * Sets the name of the media, also used as file name * * @param string $name * * @return Media */
    public function setName($name)
    {
        $this->name = $this->removeSpecialCharacters($name);

        return $this;
    }

    /** * Returns the name of the media, also used as file name * * @return string */
    public function getName()
    {
        
if (strpos($size, 'x') === false) {
                $size = sprintf('%sx%s', $size$size);
            }

            $projectDir = $this->container->getParameter('shopware.app.rootDir');

            if (!\is_string($projectDir)) {
                throw new RuntimeException('Parameter shopware.app.rootDir has to be an string');
            }

            $thumbnailDir = $projectDir . 'media' . DIRECTORY_SEPARATOR . strtolower($media['type']) . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR;
            $path = $thumbnailDir . $this->removeSpecialCharacters($media['name']) . '_' . $size . '.' . $media['extension'];

            $path = str_replace(Shopware()->DocPath(), '', $path);
            if (DIRECTORY_SEPARATOR !== '/') {
                $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
            }
            $thumbnails[(string) $size] = $path;
        }

        return $thumbnails;
    }

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