Skip to content

Commit

Permalink
artesaos#171: remove "illuminate/config" dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
klimov-paul committed Aug 13, 2019
1 parent 98aaabd commit 6fe114c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"require": {
"php": ">=7.1",
"ext-json": "*",
"illuminate/config": "5.8.*",
"illuminate/support": "5.8.*"
},
"require-dev": {
Expand Down
10 changes: 0 additions & 10 deletions src/SEOTools/Contracts/MetaTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@

namespace Artesaos\SEOTools\Contracts;

use Illuminate\Config\Repository as Config;

interface MetaTags
{
/**
* Configuration.
*
* @param \Illuminate\Config\Repository $config
* @return void
*/
public function __construct(Config $config);

/**
* Generates meta tags.
*
Expand Down
3 changes: 1 addition & 2 deletions src/SEOTools/Providers/SEOToolsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Artesaos\SEOTools\OpenGraph;
use Artesaos\SEOTools\TwitterCards;
use Illuminate\Support\ServiceProvider;
use Illuminate\Config\Repository as Config;
use Illuminate\Contracts\Support\DeferrableProvider;

class SEOToolsServiceProvider extends ServiceProvider implements DeferrableProvider
Expand Down Expand Up @@ -41,7 +40,7 @@ public function boot()
public function register()
{
$this->app->singleton('seotools.metatags', function($app) {
return new SEOMeta(new Config($app['config']->get('seotools.meta', [])));
return new SEOMeta($app['config']->get('seotools.meta', []));
});

$this->app->singleton('seotools.opengraph', function($app) {
Expand Down
23 changes: 11 additions & 12 deletions src/SEOTools/SEOMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Artesaos\SEOTools;

use Illuminate\Support\Arr;
use Illuminate\Config\Repository as Config;
use Artesaos\SEOTools\Contracts\MetaTags as MetaTagsContract;

class SEOMeta implements MetaTagsContract
Expand Down Expand Up @@ -100,7 +99,7 @@ class SEOMeta implements MetaTagsContract
protected $robots;

/**
* @var Config
* @var array
*/
protected $config;

Expand All @@ -118,9 +117,9 @@ class SEOMeta implements MetaTagsContract
];

/**
* @param \Illuminate\Config\Repository $config
* @param array $config
*/
public function __construct(Config $config)
public function __construct(array $config = [])
{
$this->config = $config;
}
Expand Down Expand Up @@ -401,7 +400,7 @@ public function getTitle()
public function getDefaultTitle()
{
if (empty($this->title_default)) {
return $this->config->get('defaults.title', null);
return Arr::get($this->config, 'defaults.title', null);
}

return $this->title_default;
Expand All @@ -420,15 +419,15 @@ public function getTitleSession()
*/
public function getTitleSeparator()
{
return $this->title_separator ?: $this->config->get('defaults.separator', ' - ');
return $this->title_separator ?: Arr::get($this->config, 'defaults.separator', ' - ');
}

/**
* {@inheritdoc}
*/
public function getKeywords()
{
return $this->keywords ?: $this->config->get('defaults.keywords', []);
return $this->keywords ?: Arr::get($this->config, 'defaults.keywords', []);
}

/**
Expand All @@ -448,15 +447,15 @@ public function getDescription()
return;
}

return $this->description ?: $this->config->get('defaults.description', null);
return $this->description ?: Arr::get($this->config, 'defaults.description', null);
}

/**
* {@inheritdoc}
*/
public function getCanonical()
{
$canonical_config = $this->config->get('defaults.canonical', false);
$canonical_config = Arr::get($this->config, 'defaults.canonical', false);

return $this->canonical ?: (($canonical_config === null) ? app('url')->full() : $canonical_config);
}
Expand Down Expand Up @@ -502,7 +501,7 @@ public function getAlternateLanguages()
*/
public function getRobots()
{
return $this->robots ?: $this->config->get('defaults.robots', null);
return $this->robots ?: Arr::get($this->config, 'defaults.robots', null);
}

/**
Expand Down Expand Up @@ -536,7 +535,7 @@ protected function parseTitle($title)
if (empty($default)) {
return $title;
}
$defaultBefore = $this->config->get('defaults.titleBefore', false);
$defaultBefore = Arr::get($this->config, 'defaults.titleBefore', false);

return $defaultBefore ? $default.$this->getTitleSeparator().$title : $title.$this->getTitleSeparator().$default;
}
Expand All @@ -546,7 +545,7 @@ protected function parseTitle($title)
*/
protected function loadWebMasterTags()
{
foreach ($this->config->get('webmaster_tags', []) as $name => $value) {
foreach (Arr::get($this->config, 'webmaster_tags', []) as $name => $value) {
if (!empty($value)) {
$meta = Arr::get($this->webmasterTags, $name, $name);
$this->addMeta($meta, $value);
Expand Down

0 comments on commit 6fe114c

Please sign in to comment.