Skip to content

Commit

Permalink
Revert "poc of caching"
Browse files Browse the repository at this point in the history
This reverts commit 0114c4c.
  • Loading branch information
ryanmitchell committed May 10, 2024
1 parent 0114c4c commit 4565bde
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 50 deletions.
19 changes: 0 additions & 19 deletions src/Extend/Addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ final class Addon
*/
protected $editions = [];

/**
* Cache of folders.
*
* @var array|null
*/
protected $folderCache = [];

/**
* @param string $id
*/
Expand Down Expand Up @@ -184,7 +177,6 @@ public static function makeFromPackage(array $package)
$keys = [
'id', 'slug', 'editions', 'marketplaceId', 'marketplaceSlug', 'marketplaceUrl', 'marketplaceSellerSlug', 'name', 'namespace',
'autoload', 'provider', 'description', 'package', 'version', 'latestVersion', 'url', 'developer', 'developerUrl', 'isCommercial',
'folderCache',
];

foreach (Arr::only($package, $keys) as $key => $value) {
Expand Down Expand Up @@ -467,15 +459,4 @@ public function editions($editions = null)

return $this;
}

public function folderCache($folderCache = null)
{
if (func_num_args() === 0) {
return collect($this->folderCache);
}

$this->folderCache = $folderCache;

return $this;
}
}
26 changes: 0 additions & 26 deletions src/Extend/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ protected function formatPackage($package)
'autoload' => $autoload,
'provider' => $provider,

// autoload from folders
'folderCache' => [
'tags' => $this->autoloadFilesFromFolder($directory, $autoload, $namespace, 'Tags', \Statamic\Tags\Tags::class),
],

// Local data for marketplace GUI?
'name' => $statamic['name'] ?? Arr::last($providerParts),
'url' => $statamic['url'] ?? null,
Expand All @@ -83,25 +78,4 @@ public function addons()
{
return collect($this->getManifest());
}

protected function autoloadFilesFromFolder($directory, $autoload, $namespace, $folder, $requiredClass)
{
$path = $directory.$autoload.'/'.$folder;

if (! app()['files']->exists($path)) {
return [];
}

$autoloadable = [];

foreach (app()['files']->files($path) as $file) {
$class = $file->getBasename('.php');
$fqcn = $namespace.'\\'.str_replace('/', '\\', $folder).'\\'.$class;
if (is_subclass_of($fqcn, $requiredClass)) {
$autoloadable[] = $fqcn;
}
}

return $autoloadable;
}
}
5 changes: 0 additions & 5 deletions src/Providers/AddonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,6 @@ protected function bootFieldsets()
protected function autoloadFilesFromFolder($folder, $requiredClass)
{
$addon = $this->getAddon();

if ($cache = $addon->folderCache()->get(Str::lower($folder))) {
return $cache;
}

$path = $addon->directory().$addon->autoload().'/'.$folder;

if (! $this->app['files']->exists($path)) {
Expand Down

0 comments on commit 4565bde

Please sign in to comment.