Sha256: 261906a683d7b113821f5f796e335ad5ea46a77fea97ea8f457da06ff4da5dc3

Contents?: true

Size: 595 Bytes

Versions: 15

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

module Maglev
  # Retrieve a page from a path and a locale
  # (previously extracted by the ExtractLocale service)
  class FetchPage
    include Injectable

    argument :path
    argument :locale
    argument :default_locale
    argument :fallback_to_default_locale, default: false

    def call
      page = fetch_page(path, locale)
      page = fetch_page(path, default_locale) if !page && fallback_to_default_locale
      page
    end

    protected

    def fetch_page(path, locale)
      Maglev::Page.by_path(path || 'index', locale).first
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
maglevcms-1.2.2 app/services/maglev/fetch_page.rb
maglevcms-1.2.1 app/services/maglev/fetch_page.rb
maglevcms-1.2.0 app/services/maglev/fetch_page.rb
maglevcms-1.1.7 app/services/maglev/fetch_page.rb
maglevcms-1.1.6 app/services/maglev/fetch_page.rb
maglevcms-1.1.5 app/services/maglev/fetch_page.rb
maglevcms-1.1.4 app/services/maglev/fetch_page.rb
maglevcms-1.1.3 app/services/maglev/fetch_page.rb
maglevcms-1.1.2 app/services/maglev/fetch_page.rb
maglevcms-1.1.1 app/services/maglev/fetch_page.rb
maglevcms-1.1.0 app/services/maglev/fetch_page.rb
maglevcms-1.0.0 app/services/maglev/fetch_page.rb
maglevcms-1.0.0.rc3 app/services/maglev/fetch_page.rb
maglevcms-1.0.0.rc2 app/services/maglev/fetch_page.rb
maglevcms-1.0.0.rc1 app/services/maglev/fetch_page.rb