<?php
							 | 
						|
								
							 | 
						|
								namespace App\Helpers;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 *
							 | 
						|
								 *
							 | 
						|
								 *
							 | 
						|
								 *
							 | 
						|
								 */
							 | 
						|
								class NginxTemplateHelper
							 | 
						|
								{
							 | 
						|
								    // path for templates files
							 | 
						|
								    const TEMPLATES_PATH = '/ressources/templates';
							 | 
						|
								
							 | 
						|
								    // path for custom template files
							 | 
						|
								    const CUSTOM_TEMPLATES_PATH = '/ressources/templates/custom';
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     *
							 | 
						|
								     *
							 | 
						|
								     *
							 | 
						|
								     *  @return array
							 | 
						|
								     *
							 | 
						|
								     */
							 | 
						|
								    private function getTemplates()
							 | 
						|
								    {
							 | 
						|
								        $results = [];
							 | 
						|
								
							 | 
						|
								        array_merge(
							 | 
						|
								            scandir(self::TEMPLATES_PATH),
							 | 
						|
								            scandir(self::CUSTOM_TEMPLATES_PATH)
							 | 
						|
								        );
							 | 
						|
								
							 | 
						|
								        return $templates;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     *
							 | 
						|
								     *  @param  [type] $files        [description]
							 | 
						|
								     *  @param  [type] $templatePath [description]
							 | 
						|
								     *  @return [type]               [description]
							 | 
						|
								     */
							 | 
						|
								    private function getTemplates($templatePath)
							 | 
						|
								    {
							 | 
						|
								        $results = [];
							 | 
						|
								
							 | 
						|
								        foreach(scandir(base_dir().$templatePath) as $file) {
							 | 
						|
								            if (!in_array($file, self::IGNORE_FILES)) {
							 | 
						|
								                $results[] = [
							 | 
						|
								                    'filename' => $file,
							 | 
						|
								                    'path' => $templatePath
							 | 
						|
								                ];
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        return $results;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     *  getting templates 
							 | 
						|
								     *
							 | 
						|
								     */
							 | 
						|
								    public function find()
							 | 
						|
								    {
							 | 
						|
								        $results = array_merge(
							 | 
						|
								            $this->getTemplates(self::TEMPLATES_DIR),
							 | 
						|
								            $this->getTemplates(self::TEMPLATES_CUSTOM_DIR)
							 | 
						|
								        );
							 | 
						|
								
							 | 
						|
								        return $results;
							 | 
						|
								    }
							 | 
						|
								}
							 |