Skip to content

Commit

Permalink
Add feed links
Browse files Browse the repository at this point in the history
  • Loading branch information
sangnguyenplus committed Sep 9, 2024
1 parent 03c9447 commit b47176e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"provider": "Botble\\RssFeed\\Providers\\RssFeedServiceProvider",
"author": "Botble Technologies",
"url": "https://botble.com",
"version": "1.1.4",
"version": "1.1.5",
"description": "RSS is a web feed that allows users and applications to access updates to websites in a standardized, computer-readable format.",
"minimum_core_version": "7.3.0"
}
8 changes: 4 additions & 4 deletions src/Http/Controllers/RssFeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function show(string $name)
break;

case 'jobs':
if (! is_plugin_active('job-board')) {
if (! is_plugin_active('job-board') || ! class_exists(Job::class)) {
abort(404);
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public function show(string $name)
break;

case 'properties':
if (! is_plugin_active('real-estate')) {
if (! is_plugin_active('real-estate') || ! interface_exists(PropertyInterface::class)) {
abort(404);
}

Expand Down Expand Up @@ -149,7 +149,7 @@ public function show(string $name)
break;

case 'projects':
if (! is_plugin_active('real-estate')) {
if (! is_plugin_active('real-estate') || ! interface_exists(ProjectInterface::class)) {
abort(404);
}

Expand Down Expand Up @@ -191,7 +191,7 @@ public function show(string $name)
break;

case 'products':
if (! is_plugin_active('ecommerce')) {
if (! is_plugin_active('ecommerce') || ! function_exists('get_products')) {
abort(404);
}

Expand Down
36 changes: 33 additions & 3 deletions src/Providers/RssFeedServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Botble\RssFeed\Facades\RssFeed;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Routing\Events\RouteMatched;
use Illuminate\Support\Facades\Route;

class RssFeedServiceProvider extends ServiceProvider
{
Expand All @@ -27,9 +26,40 @@ public function boot(): void
->loadAndPublishViews();

$this->app['events']->listen(RouteMatched::class, function () {
if (is_plugin_active('blog') && Route::has('feeds.posts')) {
RssFeed::addFeedLink(route('feeds.posts'), 'Posts feed');
if (is_plugin_active('blog')) {
RssFeed::addFeedLink(
route('feeds.show', ['name' => 'posts']),
__(':name feed', ['name' => __('Posts')])
);
}

if (is_plugin_active('job-board')) {
RssFeed::addFeedLink(
route('feeds.show', ['name' => 'jobs']),
__(':name feed', ['name' => __('Jobs')])
);
}

if (is_plugin_active('real-estate')) {
RssFeed::addFeedLink(
route('feeds.show', ['name' => 'properties']),
__(':name feed', ['name' => __('Properties')])
);

RssFeed::addFeedLink(
route('feeds.show', ['name' => 'projects']),
__(':name feed', ['name' => __('Projects')])
);
}

if (is_plugin_active('ecommerce')) {
RssFeed::addFeedLink(
route('feeds.show', ['name' => 'products']),
__(':name feed', ['name' => __('Products')])
);
}

do_action('rss_feed.add_feed_link');
});
}
}

0 comments on commit b47176e

Please sign in to comment.