Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Jul 8, 2020
1 parent bf7ec3f commit 23c7f9a
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/Support/ModularServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ protected function bootViews(): void
});
}

/**
* This functionality is likely to go away at some point so don't rely
* on it too much. The package has been abandoned.
*/
protected function bootBreadcrumbs(): void
{
$class_name = 'DaveJamesMiller\\Breadcrumbs\\BreadcrumbsManager';
Expand Down Expand Up @@ -208,7 +212,7 @@ protected function registerPolicies(Gate $gate): void
{
$this->autoDiscoveryHelper()
->modelFileFinder()
->map(function(SplFileInfo $file) {
->each(function(SplFileInfo $file) use ($gate) {
if (!$module = $this->registry()->moduleForPath($file->getPath())) {
throw new RuntimeException("Unable to determine module for '{$file->getPath()}'");
}
Expand All @@ -220,7 +224,7 @@ protected function registerPolicies(Gate $gate): void
$namespaced_model = Str::after($fully_qualified_model, 'Models\\');
$namespaced_policy = rtrim($module->namespaces->first(), '\\').'\\Policies\\'.$namespaced_model.'Policy';
if (class_exists($namespaced_policy)) {
return [$fully_qualified_model, $namespaced_policy];
$gate->policy($fully_qualified_model, $namespaced_policy);
}

// If that doesn't match, try the simple mapping as well
Expand All @@ -230,34 +234,25 @@ protected function registerPolicies(Gate $gate): void
$simple_policy = rtrim($module->namespaces->first(), '\\').'\\Policies\\'.$simple_model.'Policy';

if (class_exists($simple_policy)) {
return [$fully_qualified_model, $simple_policy];
$gate->policy($fully_qualified_model, $simple_policy);
}
}

return null;
})
->filter()
->eachSpread(function($class, $policy) use ($gate) {
$gate->policy($class, $policy);
});
}

protected function registerCommands(Artisan $artisan): void
{
$this->autoDiscoveryHelper()
->commandFileFinder()
->map(function(SplFileInfo $file) {
->each(function(SplFileInfo $file) use ($artisan) {
if (!$module = $this->registry()->moduleForPath($file->getPath())) {
throw new RuntimeException("Unable to determine module for '{$file->getPath()}'");
}

return $this->pathToFullyQualifiedClassName($file->getPathname(), $module);
})
->filter(function($class_name) {
return $this->isInstantiableCommand($class_name);
})
->each(function($command) use ($artisan) {
$artisan->resolve($command);
$class_name = $this->pathToFullyQualifiedClassName($file->getPathname(), $module);
if ($this->isInstantiableCommand($class_name)) {
$artisan->resolve($class_name);
}
});
}

Expand Down

0 comments on commit 23c7f9a

Please sign in to comment.