Create AuthServiceProvider class if not exists

@param  string $routeDirPath Absolute directory path
@param  string $filename     File name to be created

@return string               Absolute path of create route file
772188
protected function makeAuthServiceProvilderFile($routeDirPath, $filename)
    {
        $routeDirPath = $this->makeDirectory($routeDirPath);

        if (!$this->files->exists($routeDirPath.'/'.$filename)) {
            $this->generateFile(
                $routeDirPath.'/'.$filename,
                $this->files->get(__DIR__.'/../stubs/AuthServiceProvider.stub')
            );
        }

        return $routeDirPath.'/'.$filename;
    }
357489
private function createOrUpdateRoute(RoutableBehavior $document, $locale)
    {
        $route = $document->getRoute();

        if (!$route) {
            $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale);
        }

        if ($route) {
            $document->setRoute($route);

            return $this->routeManager->update($document, $document->getRoutePath(), false);
        }

        return $this->routeManager->create($document, $document->getRoutePath(), false);
    }
809068
public function createClassTemplate(String $templateName, String $filename, $savePath=null, Array $templateTags)
	{
		$template = file_get_contents(__DIR__ . '/templates/' . $templateName);
		foreach($templateTags as $key => $tag) {
			if (!preg_match_all('/' . $key . '/', $template)) {
				throw new RuntimeException(sprintf('[%s] tag does not exist in template.', $key));
			}
		}

		if (!is_dir($savePath) || !is_readable($savePath)) {
			throw new RuntimeException(sprintf('[%s] directory is not readable', $savePath));
		}

		$template = str_replace(
			array_keys($templateTags),
			array_values($templateTags),
			$template
		);

		$file = $savePath . '/' . $filename . '.php';
		$handle = fopen($file, 'w+');
		fwrite($handle, $template);
		fclose($handle);

		$this->env->sendOutput(
			sprintf(
				'[%s] class has been generated and placed in [%s]',
				$templateTags['phx:class'],
				$file
			),
			'green',
			'black'
		);
	}
767810
public function createReader($filePath, $delimiter = ReaderInterface::DELIMITER_DEFAULT, $fileCharset = ReaderInterface::CHARSET_DEFAULT, $mode = 'r', $type = null)
    {
        if (null === $type) {
            $type = $this->getDefaultReaderType();
        }

        return $this->getReaderFactory()->createReader($type, $filePath, $delimiter, $fileCharset, $mode);
    }
537285
protected function findOrCreateRoute($path, $locale, CustomUrlBehavior $document, $route)
    {
        try {
            /** @var RouteDocument $routeDocument */
            $routeDocument = $this->documentManager->find($path, $locale);
        } catch (DocumentNotFoundException $ex) {
            return $this->documentManager->create('custom_url_route');
        }

        if (!$routeDocument instanceof RouteDocument
            || $routeDocument->getTargetDocument()->getUuid() !== $document->getUuid()
        ) {
            throw new ResourceLocatorAlreadyExistsException($route, $document->getTitle());
        }

        return $routeDocument;
    }
711697
public function frontControllerPath($sitePath, $siteName, $uri)
    {
        if ($_SERVER['REQUEST_METHOD'] === 'GET' && $this->isActualFile($staticPath = $this->getStaticPath($sitePath))) {
            return $staticPath;
        }

        if ($uri === '/installer.php') {
            return $sitePath.'/installer.php';
        }

        $scriptName = '/index.php';

        if ($this->isActualFile($sitePath.'/index.php')) {
            $indexPath = $sitePath.'/index.php';
        }

        if ($isAboveWebroot = $this->isActualFile($sitePath.'/public/index.php')) {
            $indexPath = $sitePath.'/public/index.php';
        }

        $sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath;

        if ($locale = $this->getUriLocale($uri)) {
            if ($this->isActualFile($localeIndexPath = $sitePathPrefix . '/' . $locale . '/index.php')) {
                // Force trailing slashes on locale roots.
                if ($uri === '/' . $locale) {
                    header('Location: ' . $uri . '/');
                    die;
                }

                $indexPath = $localeIndexPath;
                $scriptName = '/' . $locale . '/index.php';
            }
        }

        $_SERVER['SCRIPT_NAME'] = $scriptName;
        $_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix . $scriptName;

        return $indexPath;
    }
474341
public function frontControllerPath($sitePath, $siteName, $uri)
    {
        $_SERVER['PHP_SELF']    = $uri;
        $_SERVER['SERVER_ADDR'] = '127.0.0.1';
        $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
		
        $dynamicCandidates = [
            $this->asActualFile($sitePath, $uri),
            $this->asPhpIndexFileInDirectory($sitePath, $uri),
            $this->asHtmlIndexFileInDirectory($sitePath, $uri),
        ];

        foreach ($dynamicCandidates as $candidate) {
            if ($this->isActualFile($candidate)) {
                $_SERVER['SCRIPT_FILENAME'] = $candidate;
                $_SERVER['SCRIPT_NAME'] = str_replace($sitePath, '', $candidate);
                $_SERVER['DOCUMENT_ROOT'] = $sitePath;
                return $candidate;
            }
        }

        $fixedCandidatesAndDocroots = [
            $this->asRootPhpIndexFile($sitePath) => $sitePath,
            $this->asPublicPhpIndexFile($sitePath) => $sitePath . '/public',
            $this->asPublicHtmlIndexFile($sitePath) => $sitePath . '/public',
        ];

        foreach ($fixedCandidatesAndDocroots as $candidate => $docroot) {
            if ($this->isActualFile($candidate)) {
                $_SERVER['SCRIPT_FILENAME'] = $candidate;
                $_SERVER['SCRIPT_NAME'] = '/index.php';
                $_SERVER['DOCUMENT_ROOT'] = $docroot;
                return $candidate;
            }
        }
    }
973415
public function route($name, $parameters = array(), $absolute = true, $route = null)
    {
        if($path = $this->getPathFinder()->toRouteName($name, $parameters)){
            if($absolute){
                return $this->to($path);
            }
            return $path;
        }

        return parent::route($name, $parameters, $absolute, $route);
    }
171100
protected function buildSwaggerPathData(
        string $name,
        string $path,
        array $routeData
    ): array {
        $swaggerPathData = [];

        $swaggerConfig = Options::getArray(
            $routeData,
            ConfigKey::SWAGGER,
            []
        );

        $allowedMethods = Options::getArray(
            $routeData,
            'allowed_methods',
            []
        );

        if (is_string($allowedMethods)) {
            $allowedMethods = [$allowedMethods];
        }

        foreach ($allowedMethods as $allowedMethod) {
            $allowedMethod = strtolower($allowedMethod);

            $data = Options::getArray(
                $swaggerConfig,
                $allowedMethod,
                []
            );

            $data['description'] = Options::getString(
                $data,
                'description',
                'Name: ' . $name
            );

            $data['operationId'] = Options::getString(
                $swaggerPathData,
                'operationId',
                '[' . $allowedMethod . ']' . $name
            );

            $data['produces'] = Options::getArray(
                $data,
                'produces',
                ['application/json']
            );

            $parameters = Options::getArray(
                $data,
                'parameters',
                []
            );

            $data['parameters'] = $this->buildPathParameters->__invoke(
                $parameters,
                $path
            );

            $data['responses'] = Options::getArray(
                $data,
                'responses',
                [
                    "default" => [
                        'description' => "undefined"
                    ]
                ]
            );

            $swaggerPathData[$allowedMethod] = $data;
        }

        return $swaggerPathData;
    }
1135668
public static function createSuccess(
        string $routeName,
        array $routeParams = [],
        array $routeAllowedMethods = [],
        array $routeMiddlewares = [],
        array $routeHandler = []
    ):self {
        $result                         = new self();
        $result->routeName              = $routeName;
        $result->routeParams            = $routeParams;
        $result->routeAllowedMethods    = $routeAllowedMethods;
        $result->routeMiddlewares       = $routeMiddlewares;
        $result->routeHandler           = $routeHandler;
        $result->status                 = $result::ROUTE_FOUND;
        return $result;
    }
1245198
public function create($className, $filePath)
    {
        $compiler = new CompilerFile($this->config, new AliasManager(), $this->filesystem);

        $compiler->setClassName($className);
        $compiler->setFilePath($filePath);
        $compiler->setLogger($this->logger);

        return $compiler;
    }
699583
protected function createHandle($filePath)
    {
        if (!$handle = $this->openHandle($filePath)) {
            throw new ResourceNotFoundException("Path '$filePath' cannot be opened");
        }

        $this->applySettings($handle);

        return $handle;
    }
724460
public function save( $filePath ){
		$data	= array();
		foreach( $this->index() as $route ){
			$data[]	= array(
				'controller'	=> $route->getController(),
				'action'		=> $route->getAction(),
				'pattern'		=> $route->getPattern(),
				'method'		=> $route->getMethod(),
			);
		}
		return \FS_File_JSON_Writer::save( $filePath, $data, TRUE );
	}
303047
public function createWriter($filePath, $delimiter = WriterInterface::DELIMITER_DEFAULT, $fileCharset = WriterInterface::CHARSET_DEFAULT, $mode = 'w', $type = null)
    {
        if (null === $type) {
            $type = $this->getDefaultWriterType();
        }

        return $this->getWriterFactory()->createWriter($type, $filePath, $delimiter, $fileCharset, $mode);
    }
17804
public function create($filePath = null, $mode = 'wb')
    {
        $filePath = isset($filePath) ? $filePath : $this->filePath;
        $dir = dirname($filePath);

        if ( ! is_writable($dir)) {
            if ( ! file_exists($dir)) {
                mkdir($dir, 0777, true);
            }
        }

        if ( ! $fp = @fopen($filePath, $mode)) {
            return false;
        }

        parent::__construct($filePath);

        return $fp;
    }
1287276
public static function draftfile_exists($itemid, $filepath, $filename) {
        global $USER;
        $fs = get_file_storage();
        $usercontext = context_user::instance($USER->id);
        return $fs->file_exists($usercontext->id, 'user', 'draft', $itemid, $filepath, $filename);
    }
877780
private function save($fileName, $filePath, $extension)
    {
        $fullPath = rtrim($filePath, '/').DIRECTORY_SEPARATOR.$fileName.$extension;

        $template = $this->renderTemplate($fullPath);

        $tempExecutable = tmpfile();
        fwrite($tempExecutable, $template);
        $tempFileName = stream_get_meta_data($tempExecutable)['uri'];
        $cmd = escapeshellcmd("{$this->binPath} --ssl-protocol=any --ignore-ssl-errors=true ".$tempFileName);
        shell_exec($cmd);
        fclose($tempExecutable);

        if (!file_exists($fullPath))
        {
            throw new TimeoutException('Page load timeout.');
        }

        return $fullPath;
    }