protected static function generateIfRequired()
 {
     $fs = new Filesystem();
     if (!isset(static::$values) || !isset(static::$records)) {
         static::$values = json_decode($fs->get(Path::join(__DIR__, 'data/values.json')), true)[0];
         static::$records = json_decode($fs->get(Path::join(__DIR__, 'data/records.json')), true);
     }
 }
 protected function registerViewPaths()
 {
     $view = $this->app->make('view');
     foreach ($this->fs->directories(resources_path('views')) as $dir) {
         $ns = Path::getDirectoryName($dir);
         $view->addNamespace($ns, $dir);
     }
 }
 protected function copyDefaultConfigurationFiles(Application $app)
 {
     $fs = new Filesystem();
     $files = Finder::create()->files()->name('*.php')->in(Path::join(__DIR__, '..', '..', 'app', 'config'))->files();
     foreach ($files as $file) {
         $dest = Path::join($app->configPath(), $file->getRelativePathname());
         $fs->copy($file->getPathname(), $dest);
     }
 }
 /**
  * loadConfiguration method
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function loadConfiguration()
 {
     /** @var \Illuminate\Filesystem\Filesystem $fs */
     $fs = new Filesystem();
     $items = new Repository();
     foreach ($fs->files($this->getConfigDir()) as $file) {
         $items->set(Path::getFilenameWithoutExtension($file), $fs->getRequire($file));
     }
     $this->items = $items;
 }
 /**
  * loadMessages
  *
  * @param array  $extraLocales
  * @param string $langsPath
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function loadMessages(array $extraLocales = [], $langsPath = 'resources/lang')
 {
     $this->messages = [];
     $langs = array_merge([config('app.locale')], $extraLocales, ['en']);
     foreach ($langs as $lang) {
         $path = Path::join($langsPath, $lang, 'validation.php');
         $path = base_path($path);
         if ($this->getFiles()->exists($path)) {
             $this->messages = array_replace_recursive($this->messages, $this->getFiles()->getRequire($path));
         }
     }
 }
Exemple #6
0
 public function render($str, array $vars = [])
 {
     $__tmp_stub_file = Str::random() . uniqid(time(), false);
     !$this->fs->exists($this->cachePath) && $this->fs->makeDirectory($this->cachePath, 0755, true);
     $__tmp_stub_path = Path::join($this->cachePath, $__tmp_stub_file);
     $this->fs->put($__tmp_stub_path, $this->compiler->compileString($str));
     $__env = $this->getViewFactory();
     if (is_array($vars) && 0 !== count($vars)) {
         extract($vars);
     }
     ob_start();
     include $__tmp_stub_path;
     $var = ob_get_contents();
     ob_end_clean();
     $this->fs->delete($__tmp_stub_path);
     return $var;
 }
Exemple #7
0
 public static function bootAsMaster($appPath = null, $basePath = null, $name = null, $version = null)
 {
     $app = static::boot($appPath, $basePath, $name, $version);
     $app->useDatabasePath(Path::join(__DIR__, '..', 'database'));
     $app->singleton(C\Console\Kernel::class, static::$consoleKernel);
     $app->singleton(C\Http\Kernel::class, static::$httpKernel);
     $app->singleton(C\Debug\ExceptionHandler::class, static::$exceptionHandler);
     $kernel = $app->make(C\Console\Kernel::class);
     foreach (static::$bootingCallbacks as $callback) {
         $app->call($callback, ['kernel' => $kernel]);
     }
     $status = $kernel->handle($input = new \Symfony\Component\Console\Input\ArgvInput(), new \Symfony\Component\Console\Output\ConsoleOutput());
     foreach (static::$bootedCallbacks as $callback) {
         $app->call($callback, ['kernel' => $kernel]);
     }
     $kernel->terminate($input, $status);
     exit($status);
 }
 /**
  * bootstrap method
  *
  * @param \Raphaelb\Foundation\Application $app
  *
  * @return mixed
  */
 public function bootstrap(Application $app)
 {
     $items = [];
     /** @var \Illuminate\Filesystem\Filesystem $fs */
     $fs = new Filesystem();
     $app->instance('config', $config = new Repository($items));
     foreach ($fs->files($app->getConfigPath()) as $file) {
         $config->set(Path::getFilenameWithoutExtension($file), $fs->getRequire($file));
     }
     // Foreach loop for .phar file.
     //  foreach (scandir($app->getConfigPath()) as $file )
     //  {
     //      $config->set(
     //          Path::getFilenameWithoutExtension($file),
     //          $fs->getRequire($app->getConfigPath() . '/' .$file)
     //      );
     //  }
     return $config;
 }
 protected function remove($name)
 {
     $tmpDir = storage_path('blade-extensions');
     $path = Path::join($tmpDir, $name);
     $this->files->delete($path);
     return $this;
 }
Exemple #10
0
 public function getBranchesToSync()
 {
     $allowedBranches = $this->setting('sync.constraints.branches');
     if (count($allowedBranches) === 0) {
         return [];
     }
     $this->fire('git.syncer.branches.start', [$allowedBranches]);
     $branchesToSync = [];
     $remote = $this->client($this->setting('remote'));
     $repo = $this->setting('repository');
     $owner = $this->setting('owner');
     $branches = $remote->getBranches($repo, $owner);
     foreach ($branches as $branch => $sha) {
         if (!in_array('*', $allowedBranches, true) and !in_array($branch, $allowedBranches, true)) {
             continue;
         }
         $cacheKey = md5($this->project->getName() . $branch);
         $cached = $this->cache->get($cacheKey, false);
         $destinationPath = Path::join($this->project->getPath(), $branch);
         if ($cached !== $sha || $cached === false || !$this->files->exists($destinationPath)) {
             $branchesToSync[] = $branch;
         }
     }
     $this->fire('git.syncer.branches.finish', [$branchesToSync]);
     return $branchesToSync;
 }
 public function storagePath()
 {
     return $this->storagePath ?: Path::join($this->appPath(), 'storage');
 }
Exemple #12
0
 /**
  * Returns the menu for this project
  *
  * @return \Codex\Core\Menus\Menu
  */
 public function getSidebarMenu()
 {
     $path = Path::join($this->getPath(), $this->getRef(), 'menu.yml');
     $yaml = $this->files->get($path);
     $array = Yaml::parse($yaml);
     $this->codex->getMenus()->forget('sidebar');
     $menu = $this->setupSidebarMenu($array['menu']);
     $this->runHook('project:documents-menu', [$this, $menu]);
     return $menu;
 }
Exemple #13
0
 /**
  * Scans the configured documentation root directory for projects and resolves them and puts them into the projects collection
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function resolveProjects()
 {
     if (!$this->projects->isEmpty()) {
         return;
     }
     /**
      * @var \Codex\Core\Menus\Node $projectsMenu
      */
     #$projectsMenu = $this->menus->add('projects_menu');
     $finder = new Finder();
     $projects = $finder->in($this->rootDir)->files()->name('config.php')->depth('<= 1')->followLinks();
     foreach ($projects as $projectDir) {
         /** @var \SplFileInfo $projectDir */
         $name = Path::getDirectoryName($projectDir->getPath());
         $config = $this->getContainer()->make('fs')->getRequire($projectDir->getRealPath());
         $config = array_replace_recursive($this->config('default_project_config'), $config);
         $project = $this->getContainer()->make(Project::class, ['codex' => $this, 'name' => $name, 'config' => $config]);
         $this->runHook('project:make', [$this, $project]);
         $this->projects->put($name, $project);
         //            $projectsMenu->add($name, $name, 'root', [ ], [
         //                'href' => $this->url($project)
         //            ]);
     }
 }