Skip to content

Commit

Permalink
refactor: rename Config::get() to Config::getFromFile() for clarity
Browse files Browse the repository at this point in the history
* Renamed the Config::get() method to Config::getFromFile() to better reflect its purpose of retrieving data from a file.

* The old method name was ambiguous, so the new name improves code readability and clarity by specifying that the data is fetched from a file.
  • Loading branch information
saas786 committed Aug 12, 2024
1 parent f02ad02 commit c2c9624
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/Background/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function boot() {
*/
public function registerDefaultPatterns() {

foreach ( Config::get( 'background-patterns' ) as $name => $pattern ) {
foreach ( Config::getFromFile( 'background-patterns' ) as $name => $pattern ) {
$this->patterns->put( $name, $pattern );
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/Color/Setting/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public function register() {
*/
public function registerDefaultSettings( Settings $settings ) {

$base = Config::get( '_settings-color' );
$config = Config::get( 'settings-color' );
$base = Config::getFromFile( '_settings-color' );
$config = Config::getFromFile( 'settings-color' );

$config = is_array( $config ) ? $config : [];

Expand Down
2 changes: 1 addition & 1 deletion app/Customize/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function registerControls( WP_Customize_Manager $manager ) {

$choices = [ '' => '' ];

foreach ( \Exhale\Tools\Config::get( 'character-entities' ) as $entity ) {
foreach ( \Exhale\Tools\Config::getFromFile( 'character-entities' ) as $entity ) {
$choices[ $entity ] = esc_html( $entity );
}

Expand Down
4 changes: 2 additions & 2 deletions app/Editor/Color/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ public function register() {
*/
public function registerDefaultColors( Colors $colors ) {

$base = Config::get( '_editor-colors' );
$base = Config::getFromFile( '_editor-colors' );

foreach ( Config::get( 'editor-colors' ) as $name => $options ) {
foreach ( Config::getFromFile( 'editor-colors' ) as $name => $options ) {

$name = $this->mapColor( $name );

Expand Down
4 changes: 2 additions & 2 deletions app/Editor/Font/Size/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public function registerDefaultSizes( Sizes $sizes ) {

// Back-compat with child themes that registered a config of
// `config/font-sizes.php` pre-2.0.
$config = is_child_theme() ? Config::get( 'font-sizes' ) : [];
$config = is_child_theme() ? Config::getFromFile( 'font-sizes' ) : [];

$config = $config ?: Config::get( 'editor-font-sizes' );
$config = $config ?: Config::getFromFile( 'editor-font-sizes' );

foreach ( $config as $name => $options ) {
$sizes->put( $name, $options );
Expand Down
2 changes: 1 addition & 1 deletion app/Image/Filter/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static function() use ( $amount ) {
*/
public function registerDefaultFilters( Filters $filters ) {

foreach ( Config::get( 'image-filters' ) as $name => $options ) {
foreach ( Config::getFromFile( 'image-filters' ) as $name => $options ) {
$filters->put( $name, $options );
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Image/Size/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function imageSizeNamesChoose( $sizes ) {
*/
public function registerDefaultSizes( Sizes $sizes ) {

foreach ( Config::get( 'image-sizes' ) as $name => $options ) {
foreach ( Config::getFromFile( 'image-sizes' ) as $name => $options ) {
$sizes->put( $name, $options );
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Layout/App/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function register() {
*/
public function registerDefaultLayouts( $layouts ) {

foreach ( Config::get( 'layouts' ) as $name => $options ) {
foreach ( Config::getFromFile( 'layouts' ) as $name => $options ) {
$layouts->put( $name, new Layout( $name, $options ) );
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Layout/Loop/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function register() {
*/
public function registerDefaultLayouts( $layouts ) {

foreach ( Config::get( 'layouts-loop' ) as $name => $options ) {
foreach ( Config::getFromFile( 'layouts-loop' ) as $name => $options ) {
$layouts->put( $name, new Layout( $name, $options ) );
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Provider extends ServiceProvider {
public function register() {
// Bind a single instance of theme mod defaults.
$this->app->singleton( 'exhale/mods', static fn() => array_merge(
Config::get( '_settings-mods' ),
Config::get( 'settings-mods' )
Config::getFromFile( '_settings-mods' ),
Config::getFromFile( 'settings-mods' )
) );

// Bind a single instance of the WP custom background settings.
Expand All @@ -56,7 +56,7 @@ public function register() {
'default-repeat' => 'repeat',
'default-size' => 'auto',
],
Config::get( 'custom-background' )
Config::getFromFile( 'custom-background' )
) );

// Bind the Laravel Mix manifest for cache-busting.
Expand Down
4 changes: 2 additions & 2 deletions app/Tools/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class Config {
*
* @access public
*/
public static function get( $name ) {
public static function getFromFile( $name, $default = [] ) {

$file = static::path( "{$name}.php" );

return (array) apply_filters(
"exhale/config/{$name}/",
file_exists( $file ) ? include $file : []
file_exists( $file ) ? include $file : $default
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Typography/Font/Family/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function register() {
*/
public function registerDefaultFamilies( $families ) {

foreach ( Config::get( 'font-families' ) as $name => $options ) {
foreach ( Config::getFromFile( 'font-families' ) as $name => $options ) {
$families->put( $name, $options );
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Typography/Font/Style/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function register() {
*/
public function registerDefaultStyles( $styles ) {

foreach ( Config::get( 'font-styles' ) as $name => $options ) {
foreach ( Config::getFromFile( 'font-styles' ) as $name => $options ) {
$styles->put( $name, $options );
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Typography/Font/VariantCaps/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function register() {
*/
public function registerDefaultCaps( $caps ) {

foreach ( Config::get( 'font-variant-caps' ) as $name => $options ) {
foreach ( Config::getFromFile( 'font-variant-caps' ) as $name => $options ) {
$caps->put( $name, $options );
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/Typography/Setting/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ public function register() {
public function registerDefaultSettings( Settings $settings ) {

// Base configuration.
$base = Config::get( '_settings-typography' );
$base = Config::getFromFile( '_settings-typography' );
$config = [];

// Back-compat with child themes that registered a config of
// `config/settings-font-family.php` pre-2.0.
if ( is_child_theme() ) {
$config = Config::get( 'settings-font-family' );
$config = Config::getFromFile( 'settings-font-family' );
}

$config = $config ?: Config::get( 'settings-typography' );
$config = $config ?: Config::getFromFile( 'settings-typography' );

$config = is_array( $config ) ? $config : [];

Expand Down
2 changes: 1 addition & 1 deletion app/Typography/Text/Transform/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function register() {
*/
public function registerDefaultTransforms( $transforms ) {

foreach ( Config::get( 'text-transforms' ) as $name => $options ) {
foreach ( Config::getFromFile( 'text-transforms' ) as $name => $options ) {
$transforms->put( $name, $options );
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/functions-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function nav_menu_social_icons( $item_output, $item, $depth, $args ) {

if ( 'social' === $args->theme_location ) {

foreach ( Config::get( 'social-icons' ) as $url => $icon ) {
foreach ( Config::getFromFile( 'social-icons' ) as $url => $icon ) {

if ( false !== strpos( $item->url, $url ) ) {
$item_output = str_replace(
Expand Down

0 comments on commit c2c9624

Please sign in to comment.