-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplements HtmlParser using Symfony DomCrawler (#21)
Thanks a lot to @JohnathonKoster 🚀
- Loading branch information
1 parent
49a31b8
commit 799b395
Showing
9 changed files
with
438 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace VV\Classify\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class Export extends Command | ||
{ | ||
protected $signature = 'classify:export'; | ||
protected $description = 'Generates a JSON configuration file containing all Classify class names.'; | ||
|
||
/** | ||
* Generates a JavaScript configuration file containing all Classify class names. | ||
*/ | ||
public static function getConfigurationContents(): string | ||
{ | ||
$allConfig = config('classify'); | ||
$classNames = []; | ||
|
||
foreach ($allConfig as $config) { | ||
foreach ($config as $classList) { | ||
$classes = collect(explode(' ', $classList))->reject(function ($class) { | ||
return strlen(trim($class)) == 0; | ||
})->values()->all(); | ||
|
||
foreach ($classes as $class) { | ||
if (! in_array($class, $classNames)) { | ||
$classNames[] = $class; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return 'module.exports.classes = '.json_encode($classNames, JSON_PRETTY_PRINT).';'; | ||
} | ||
|
||
public function handle() | ||
{ | ||
file_put_contents(base_path('classify.config.js'), self::getConfigurationContents()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.