original_string: public function getAll(Request $request)
    {
      // Get the views' directory
      $viewsPath = base_path() . '/resources/views/';
      if (!is_dir($viewsPath)) {
        error_log("The directory /resources/views/ doesn't exists.");
        throw new PathNotFoundException();
      }
  
      // Get the lang' directory
      $langPath = base_path() . '/resources/lang/';
      if (!is_dir($langPath)) {
        error_log("The directory /resources/lang/ doesn't exists.");
        throw new PathNotFoundException();
      }
  
      // Get the language directory from the current url
      $path = $request->input('path');
      $pathInfo = LocaleService::parsePath($path);
  
      // Set the active language
      LocaleService::setLang($pathInfo->lang);
  
      // Init the response object
      $resp = new \stdClass();
      $resp->langDir = $pathInfo->langDir;
      $resp->pages = null;
  
      // Get last modification time on views or lang's messages
      $pagesLastMod = max(
        self::getLastMod($viewsPath), 
        self::getLastMod($langPath)
      );
  
      // Init current cache keys (language-dependent)
      $pagesKey = "pages.{$pathInfo->lang}";
      $pagesTimestampKey = "pages.{$pathInfo->lang}.timestamp";
  
      // Check if the cache is enabled
      $cacheEnabled = false;
      if (env('CACHE_DRIVER') !== null) {
        $cacheEnabled = true;
      }
  
      // If the cache is valid return the cached value
      if ($cacheEnabled) {
        $pagesLastCache = Cache::get($pagesTimestampKey);
        if ($pagesLastCache !== null && $pagesLastCache >= $pagesLastMod) {
          $resp->pages = Cache::get($pagesKey);
          return response()->json($resp);
        }
      }
  
      // Get the list of views
      $viewsList = self::getViewsList($viewsPath);
  
      // Initialize the LocaleLinkService used inside views to set links
      LocaleLinkService::setLang($pathInfo->lang);
      LocaleLinkService::setLangDir($pathInfo->langDir);
  
      // Fill the $pages array, containing all the pages' content
      $pages = [];
      foreach ($viewsList as $viewName) {
        $page = new \stdClass();
  
        // Page path
        $page->path = ($viewName === 'index') ? '' : $viewName;
        $page->path = '/' . str_replace('.', '/', $page->path);
  
        // Set the page's path inside the LocaleLinkService
        LocaleLinkService::setPagePath($page->path);
  
        // Page title
        $page->title = view(
          $viewName, 
          [
            'benjamin' => 'benjamin::title',
            'activeLang' => LocaleService::getActiveLang(),
          ]
        )->render();
  
        // Page body
        $page->body = view(
          $viewName, 
          [
            'benjamin' => 'benjamin::body',
            'activeLang' => LocaleService::getActiveLang(),
          ]
        )->render();
  
        // bodyClass
        $page->bodyClass = view(
          $viewName, 
          [
            'benjamin' => 'benjamin::bodyClass',
            'activeLang' => LocaleService::getActiveLang(),
          ]
        )->render();
  
        $pages[] = $page;
      }
  
      // Cache the value
      if ($cacheEnabled) {
        Cache::forever($pagesKey, $pages);
        Cache::forever($pagesTimestampKey, time());
      }
  
      // Response
      $resp->pages = $pages;
  
      return response()->json($resp);
    }
code: public function getAll(Request $request)
    {
      // Get the views' directory
      $viewsPath = base_path() . '/resources/views/';
      if (!is_dir($viewsPath)) {
        error_log("The directory /resources/views/ doesn't exists.");
        throw new PathNotFoundException();
      }
  
      // Get the lang' directory
      $langPath = base_path() . '/resources/lang/';
      if (!is_dir($langPath)) {
        error_log("The directory /resources/lang/ doesn't exists.");
        throw new PathNotFoundException();
      }
  
      // Get the language directory from the current url
      $path = $request->input('path');
      $pathInfo = LocaleService::parsePath($path);
  
      // Set the active language
      LocaleService::setLang($pathInfo->lang);
  
      // Init the response object
      $resp = new \stdClass();
      $resp->langDir = $pathInfo->langDir;
      $resp->pages = null;
  
      // Get last modification time on views or lang's messages
      $pagesLastMod = max(
        self::getLastMod($viewsPath), 
        self::getLastMod($langPath)
      );
  
      // Init current cache keys (language-dependent)
      $pagesKey = "pages.{$pathInfo->lang}";
      $pagesTimestampKey = "pages.{$pathInfo->lang}.timestamp";
  
      // Check if the cache is enabled
      $cacheEnabled = false;
      if (env('CACHE_DRIVER') !== null) {
        $cacheEnabled = true;
      }
  
      // If the cache is valid return the cached value
      if ($cacheEnabled) {
        $pagesLastCache = Cache::get($pagesTimestampKey);
        if ($pagesLastCache !== null && $pagesLastCache >= $pagesLastMod) {
          $resp->pages = Cache::get($pagesKey);
          return response()->json($resp);
        }
      }
  
      // Get the list of views
      $viewsList = self::getViewsList($viewsPath);
  
      // Initialize the LocaleLinkService used inside views to set links
      LocaleLinkService::setLang($pathInfo->lang);
      LocaleLinkService::setLangDir($pathInfo->langDir);
  
      // Fill the $pages array, containing all the pages' content
      $pages = [];
      foreach ($viewsList as $viewName) {
        $page = new \stdClass();
  
        // Page path
        $page->path = ($viewName === 'index') ? '' : $viewName;
        $page->path = '/' . str_replace('.', '/', $page->path);
  
        // Set the page's path inside the LocaleLinkService
        LocaleLinkService::setPagePath($page->path);
  
        // Page title
        $page->title = view(
          $viewName, 
          [
            'benjamin' => 'benjamin::title',
            'activeLang' => LocaleService::getActiveLang(),
          ]
        )->render();
  
        // Page body
        $page->body = view(
          $viewName, 
          [
            'benjamin' => 'benjamin::body',
            'activeLang' => LocaleService::getActiveLang(),
          ]
        )->render();
  
        // bodyClass
        $page->bodyClass = view(
          $viewName, 
          [
            'benjamin' => 'benjamin::bodyClass',
            'activeLang' => LocaleService::getActiveLang(),
          ]
        )->render();
  
        $pages[] = $page;
      }
  
      // Cache the value
      if ($cacheEnabled) {
        Cache::forever($pagesKey, $pages);
        Cache::forever($pagesTimestampKey, time());
      }
  
      // Response
      $resp->pages = $pages;
  
      return response()->json($resp);
    }
code_tokens: public function getAll ( Request $ request ) { // Get the views' directory $ viewsPath = base_path ( ) . '/resources/views/' ; if ( ! is_dir ( $ viewsPath ) ) { error_log ( "The directory /resources/views/ doesn't exists." ) ; throw new PathNotFoundException ( ) ; } // Get the lang' directory $ langPath = base_path ( ) . '/resources/lang/' ; if ( ! is_dir ( $ langPath ) ) { error_log ( "The directory /resources/lang/ doesn't exists." ) ; throw new PathNotFoundException ( ) ; } // Get the language directory from the current url $ path = $ request -> input ( 'path' ) ; $ pathInfo = LocaleService :: parsePath ( $ path ) ; // Set the active language LocaleService :: setLang ( $ pathInfo -> lang ) ; // Init the response object $ resp = new \ stdClass ( ) ; $ resp -> langDir = $ pathInfo -> langDir ; $ resp -> pages = null ; // Get last modification time on views or lang's messages $ pagesLastMod = max ( self :: getLastMod ( $ viewsPath ) , self :: getLastMod ( $ langPath ) ) ; // Init current cache keys (language-dependent) $ pagesKey = "pages.{$pathInfo->lang}" ; $ pagesTimestampKey = "pages.{$pathInfo->lang}.timestamp" ; // Check if the cache is enabled $ cacheEnabled = false ; if ( env ( 'CACHE_DRIVER' ) !== null ) { $ cacheEnabled = true ; } // If the cache is valid return the cached value if ( $ cacheEnabled ) { $ pagesLastCache = Cache :: get ( $ pagesTimestampKey ) ; if ( $ pagesLastCache !== null && $ pagesLastCache >= $ pagesLastMod ) { $ resp -> pages = Cache :: get ( $ pagesKey ) ; return response ( ) -> json ( $ resp ) ; } } // Get the list of views $ viewsList = self :: getViewsList ( $ viewsPath ) ; // Initialize the LocaleLinkService used inside views to set links LocaleLinkService :: setLang ( $ pathInfo -> lang ) ; LocaleLinkService :: setLangDir ( $ pathInfo -> langDir ) ; // Fill the $pages array, containing all the pages' content $ pages = [ ] ; foreach ( $ viewsList as $ viewName ) { $ page = new \ stdClass ( ) ; // Page path $ page -> path = ( $ viewName === 'index' ) ? '' : $ viewName ; $ page -> path = '/' . str_replace ( '.' , '/' , $ page -> path ) ; // Set the page's path inside the LocaleLinkService LocaleLinkService :: setPagePath ( $ page -> path ) ; // Page title $ page -> title = view ( $ viewName , [ 'benjamin' => 'benjamin::title' , 'activeLang' => LocaleService :: getActiveLang ( ) , ] ) -> render ( ) ; // Page body $ page -> body = view ( $ viewName , [ 'benjamin' => 'benjamin::body' , 'activeLang' => LocaleService :: getActiveLang ( ) , ] ) -> render ( ) ; // bodyClass $ page -> bodyClass = view ( $ viewName , [ 'benjamin' => 'benjamin::bodyClass' , 'activeLang' => LocaleService :: getActiveLang ( ) , ] ) -> render ( ) ; $ pages [ ] = $ page ; } // Cache the value if ( $ cacheEnabled ) { Cache :: forever ( $ pagesKey , $ pages ) ; Cache :: forever ( $ pagesTimestampKey , time ( ) ) ; } // Response $ resp -> pages = $ pages ; return response ( ) -> json ( $ resp ) ; }
docstring: Return a JSON object containing the content of all the pages.
  
  The returned object will have this structure:
  
  {
  langDir: 'en',
  pages: [{
  path: '/',
  title: 'Home',
  body: '<div> ... </div>'
  bodyClass: 'some-class'
  }, {
  path: '/...',
  title: '...',
  body: '...'
  bodyClass: '...'
  },
  ...
  ]
  }
  
  @return JSON
docstring_tokens: Return a JSON object containing the content of all the pages .