run content modifiers on given file content.

@param SplFileInfo $generatedFile
@param SplFileInfo $templateFile
@param array       $modifiers
@param Inflector   $inflector

@return string
193533
public function modify(SplFileInfo $generatedFile, SplFileInfo $templateFile, array $modifiers, Inflector $inflector)
    {
        foreach ($modifiers as $modifierAlias => $modifierData) {
            if ($modifier = $this->contentModifiers->get($modifierAlias)) {
                $this->filesystem->dumpFile(
                    $generatedFile->getRealPath(),
                    $modifier->modify(
                        $generatedFile,
                        is_array($modifierData) ? $modifierData : array(),
                        $inflector,
                        $templateFile
                    )
                );
            }
        }
    }
1041043
private static List<String> parseModifiers(int modifiers) {
        List<String> result = new ArrayList<String>();
        if (Modifier.isPrivate(modifiers)) {
            result.add("private");
        }
        if (Modifier.isProtected(modifiers)) {
            result.add("protected");
        }
        if (Modifier.isPublic(modifiers)) {
            result.add("public");
        }
        if (Modifier.isAbstract(modifiers)) {
            result.add("abstract");
        }
        if (Modifier.isFinal(modifiers)) {
            result.add("final");
        }
        if (Modifier.isNative(modifiers)) {
            result.add("native");
        }
        if (Modifier.isStatic(modifiers)) {
            result.add("static");
        }
        if (Modifier.isStrict(modifiers)) {
            result.add("strict");
        }
        if (Modifier.isSynchronized(modifiers)) {
            result.add("synchronized");
        }
        if (Modifier.isTransient(modifiers)) {
            result.add("transient");
        }
        if (Modifier.isVolatile(modifiers)) {
            result.add("volatile");
        }
        if (Modifier.isInterface(modifiers)) {
            result.add("interface");
        }
        return result;
    }
786024
private function validateFile(\SplFileInfo $file)
    {
        if (!$file->isReadable()) {
            throw new InvalidConfigurationException('Configuration file is not readable');
        }
        $validExtensions = $this->configFileExtensions();
        if (!in_array($file->getExtension(), $validExtensions, true)) {
            throw new InvalidConfigurationException('Invalid configuration file type provided');
        }
    }
1208992
public function createEditForm(ContentNode $contentNode, Node $rootNode = null)
    {

        $templateVars = array(
            'action' => $this->get('router')->generate('mm_cmf_content_node_update', array(
                'id' => $contentNode->getId()
            ))
        );

        if ($rootNode)
            $templateVars['root_node'] = $rootNode;

        return $this->createForm(
            ContentNodeType::class,
            $contentNode,
            $templateVars
        );
    }
482332
protected function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') {
        $this->view->display($templateFile,$charset,$contentType,$content,$prefix);
    }
340595
protected function getModificatorSelector($modificator_name = null, $modificator_value = null)
	{
		if ( isset($modificator_name) && isset($modificator_value) ) {
			return '_' . $modificator_name . '_' . $modificator_value;
		}

		return '';
	}
1009324
public function generateFile($filename, $templateData, $templatePath = null)
    {
        $this->makeDirectory($this->rootPath);

        $path = $this->rootPath.$filename;

        if (is_null($templatePath)) {
            $templatePath = $this->templatePath;
        }
        
        $content = $this->generateContent($templatePath, $templateData);

        if (! file_exists($path)) {
            $this->fileHelper->put($path, $content);
            $this->command->info($filename.' created successfully.');
        } else {
            $this->command->info($filename.' already exists ... skipping.');
        }
    }
1224635
protected function replacement($value, array $modifiers)
    {
        if (is_array($value)) {
            throw new DataInvalidFormat('', 'required scalar given');
        }
        return $this->valueModification($value, $modifiers);
    }
226101
protected function applyModifiers($expr, array $modifiers, array $values){
		foreach($modifiers as &$mod){
			$mod = preg_quote("/$mod/");
		}
		$expr = $this->tryDelimite($expr);
		return preg_replace($modifiers, $values, $expr, 1);
	}
84816
public function generate(
        $vendor,
        $namespace,
        $entity,
        $skeletonsPath = null,
        $targetPath    = null,
        array $excludedSkeletons
    )
    {
        $skeletonsPath = $skeletonsPath ?: $this->skeletonsPath;
        $targetPath    = $targetPath ?: $this->targetPath;
        $finder        = new Finder();
        $inflector     = new Inflector(array(
            'MajoraVendor'    => $vendor,
            'MajoraNamespace' => $namespace,
            'MajoraEntity'    => $entity,
        ));
        $modifiersStack = array();

        // create file tree
        $finder->in($skeletonsPath);
        array_map(
            function($excludedSkeleton) use ($finder) {
                $finder->notPath($excludedSkeleton);
            },
            $excludedSkeletons
        );
        foreach ($finder as $templateFile) {

            $generatedFile = new SplFileInfo(
                $generatedFilePath = $this->generatePath(
                    $templateFile,
                    realpath($skeletonsPath),
                    realpath($targetPath),
                    $inflector
                ),
                '',
                ''
            );

            // directory ---------------------------------------------------------
            if ($templateFile->isDir()) {
                $this->generateDir($generatedFilePath);

                continue;
            }

            // file --------------------------------------------------------------
            $fileContent = $inflector->translate($templateFile->getContents());

            // always read template file metadata
            $metadata    = $this->getMetadata($fileContent);

            $forceGeneration = !empty($metadata['force_generation']);
            unset($metadata['force_generation']);

            $modifyContent = count($metadata);

            $alreadyGenerated = $this->filesystem->exists($generatedFilePath);

            // contents needs to be updated ?
            if ($alreadyGenerated && $modifyContent) {
                $fileContent = $generatedFile->getContents();
            }

            // stack content modifiers
            $modifiersStack[] = array(
                array($this, 'modify'),
                array($generatedFile, $templateFile, $metadata, $inflector)
            );

            // have to touch existing file ?
            if ($alreadyGenerated && !$forceGeneration) {
                continue;
            }

            $this->filesystem->dumpFile($generatedFilePath, $fileContent);

            $this->logger->info(sprintf('file %s: %s',
                $forceGeneration ? 'forced' : 'created',
                $generatedFilePath
            ));
        }

        // unstack all modifiers
        foreach ($modifiersStack as $modifierCallback) {
            call_user_func_array($modifierCallback[0], $modifierCallback[1]);
        }
    }
225977
protected function generateType(FileGenerator $file, TypeGenerator $generator, Type $type, SplFileInfo $fileInfo)
    {
        $code = $generator->generate($file, $type);
        $this->filesystem->putFileContents($fileInfo->getPathname(), $code);
    }
894141
public function iterate($specification, ResultModifier $modifier = null)
    {
        foreach ($this->getQuery($specification, $modifier)->iterate() as $row) {
            yield current($row);
        }
    }
1158231
public function preProcessSource($templateSource)
    {
        $matches = [];
        preg_match_all(self::$SCAN_PATTERN_ESCAPINGMODIFIER, $templateSource, $matches, PREG_SET_ORDER);
        if ($matches === []) {
            return $templateSource;
        }
        if (count($matches) > 1) {
            throw new Exception('There is more than one escaping modifier defined. There can only be one {escapingEnabled=...} per template.', 1407331080);
        }
        if (strtolower($matches[0]['enabled']) === 'false') {
            $this->renderingContext->getTemplateParser()->setEscapingEnabled(false);
        }
        $templateSource = preg_replace(self::$SCAN_PATTERN_ESCAPINGMODIFIER, '', $templateSource);

        return $templateSource;
    }
359718
private function generateTemplateMapper($cacheDir)
    {
        $files = $this->templateUtil->getAllTemplates();

        if (empty($files)) {
            return;
        }

        $this->filesystem->dumpFile(
            $cacheDir.'/contao/config/twig-templates.php',
            sprintf("<?php\n\nreturn %s;\n", var_export($files, true))
        );
    }
1134509
public static function parse(\SplFileInfo $file, ContainerBuilder $container, array $configs = []): array
    {
        return self::proccessFile($file, $container, $configs);
    }
580762
public static function getTemplate(
        string $filename,
        array $tokens = [],
        string $defaultContent = '',
        string $extension = 'tpl'
    ): string {
        if (!Str::endsWith($filename, '.' . $extension)) {
            $filename .= '.' . $extension;
        }
        if (!self::exist($filename)) {
            return $defaultContent;
        }
        $template = self::get($filename, $defaultContent);
        if ($template !== '' && count($tokens) > 0) {
            foreach ($tokens as $token => $value) {
                $template = str_replace('{' . $token . '}', $value, $template);
            }
        }
        return $template;
    }
546410
public function mutateFile(File &$file)
    {
        //
        // If the HTML file has a template then we should pass it on to the plates renderer
        //
        if ($template = $file->getData('template')) {
            $templateRelativePath = '_templates'.DIRECTORY_SEPARATOR.$template.'.phtml';
            $templatePath = $this->project->sourceDirectory.DIRECTORY_SEPARATOR.$templateRelativePath;
            if (file_exists($templatePath)) {
                $fileName = $file->getFilename();
                $filePath = $file->getPath();

                $file->setRendered(false);
                $file->setData(['content' => $file->getContent()]);
                $file->setFileInfo(new SplFileInfo($templatePath, '_templates', $templateRelativePath));
                $file->setContent($file->getFileContent());
                $file->setFilename($fileName);
                $file->setPath($filePath);
            }
        }
    }