Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
62
vendor/barryvdh/laravel-ide-helper/src/Console/EloquentCommand.php
vendored
Normal file
62
vendor/barryvdh/laravel-ide-helper/src/Console/EloquentCommand.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator - Eloquent Model Mixin
|
||||
*
|
||||
* @author Charles A. Peterson <artistan@gmail.com>
|
||||
* @copyright 2017 Charles A. Peterson / Fruitcake Studio (http://www.fruitcakestudio.nl)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/barryvdh/laravel-ide-helper
|
||||
*/
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||
|
||||
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* A command to add \Eloquent mixin to Eloquent\Model
|
||||
*
|
||||
* @author Charles A. Peterson <artistan@gmail.com>
|
||||
*/
|
||||
class EloquentCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'ide-helper:eloquent';
|
||||
|
||||
/**
|
||||
* @var Filesystem $files
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Add \Eloquent helper to \Eloquent\Model';
|
||||
|
||||
/**
|
||||
* @param Filesystem $files
|
||||
*/
|
||||
public function __construct(Filesystem $files)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->files = $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Eloquent::writeEloquentModelHelper($this, $this->files);
|
||||
}
|
||||
}
|
||||
174
vendor/barryvdh/laravel-ide-helper/src/Console/GeneratorCommand.php
vendored
Normal file
174
vendor/barryvdh/laravel-ide-helper/src/Console/GeneratorCommand.php
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
* @author Barry vd. Heuvel <barryvdh@gmail.com>
|
||||
* @copyright 2014 Barry vd. Heuvel / Fruitcake Studio (http://www.fruitcakestudio.nl)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/barryvdh/laravel-ide-helper
|
||||
*/
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||
|
||||
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||
use Barryvdh\LaravelIdeHelper\Generator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* A command to generate autocomplete information for your IDE
|
||||
*
|
||||
* @author Barry vd. Heuvel <barryvdh@gmail.com>
|
||||
*/
|
||||
class GeneratorCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'ide-helper:generate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate a new IDE Helper file.';
|
||||
|
||||
/** @var \Illuminate\Config\Repository */
|
||||
protected $config;
|
||||
|
||||
/** @var \Illuminate\Filesystem\Filesystem */
|
||||
protected $files;
|
||||
|
||||
/** @var \Illuminate\View\Factory */
|
||||
protected $view;
|
||||
|
||||
protected $onlyExtend;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Illuminate\Config\Repository $config
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\View\Factory $view
|
||||
*/
|
||||
public function __construct(
|
||||
/*ConfigRepository */
|
||||
$config,
|
||||
Filesystem $files,
|
||||
/* Illuminate\View\Factory */
|
||||
$view
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->files = $files;
|
||||
$this->view = $view;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (
|
||||
file_exists(base_path() . '/vendor/compiled.php') ||
|
||||
file_exists(base_path() . '/bootstrap/cache/compiled.php') ||
|
||||
file_exists(base_path() . '/storage/framework/compiled.php')
|
||||
) {
|
||||
$this->error(
|
||||
'Error generating IDE Helper: first delete your compiled file (php artisan clear-compiled)'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = $this->argument('filename');
|
||||
|
||||
// Add the php extension if missing
|
||||
// This is a backwards-compatible shim and can be removed in the future
|
||||
if (substr($filename, -4, 4) !== '.php') {
|
||||
$filename .= '.php';
|
||||
}
|
||||
|
||||
if ($this->option('memory')) {
|
||||
$this->useMemoryDriver();
|
||||
}
|
||||
|
||||
|
||||
$helpers = '';
|
||||
if ($this->option('helpers') || ($this->config->get('ide-helper.include_helpers'))) {
|
||||
foreach ($this->config->get('ide-helper.helper_files', []) as $helper) {
|
||||
if (file_exists($helper)) {
|
||||
$helpers .= str_replace(['<?php', '?>'], '', $this->files->get($helper));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$helpers = '';
|
||||
}
|
||||
|
||||
$generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
|
||||
$content = $generator->generate();
|
||||
$written = $this->files->put($filename, $content);
|
||||
|
||||
if ($written !== false) {
|
||||
$this->info("A new helper file was written to $filename");
|
||||
|
||||
if ($this->option('write_mixins')) {
|
||||
Eloquent::writeEloquentModelHelper($this, $this->files);
|
||||
}
|
||||
} else {
|
||||
$this->error("The helper file could not be created at $filename");
|
||||
}
|
||||
}
|
||||
|
||||
protected function useMemoryDriver()
|
||||
{
|
||||
//Use a sqlite database in memory, to avoid connection errors on Database facades
|
||||
$this->config->set(
|
||||
'database.connections.sqlite',
|
||||
[
|
||||
'driver' => 'sqlite',
|
||||
'database' => ':memory:',
|
||||
]
|
||||
);
|
||||
$this->config->set('database.default', 'sqlite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
$filename = $this->config->get('ide-helper.filename');
|
||||
|
||||
return [
|
||||
[
|
||||
'filename', InputArgument::OPTIONAL, 'The path to the helper file', $filename,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$writeMixins = $this->config->get('ide-helper.write_eloquent_model_mixins');
|
||||
|
||||
return [
|
||||
['write_mixins', 'W', InputOption::VALUE_OPTIONAL, 'Write mixins to Laravel Model?', $writeMixins],
|
||||
['helpers', 'H', InputOption::VALUE_NONE, 'Include the helper files'],
|
||||
['memory', 'M', InputOption::VALUE_NONE, 'Use sqlite memory driver'],
|
||||
];
|
||||
}
|
||||
}
|
||||
187
vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php
vendored
Normal file
187
vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
* @author Barry vd. Heuvel <barryvdh@gmail.com>
|
||||
* @copyright 2015 Barry vd. Heuvel / Fruitcake Studio (http://www.fruitcakestudio.nl)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/barryvdh/laravel-ide-helper
|
||||
*/
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||
|
||||
use Barryvdh\LaravelIdeHelper\Factories;
|
||||
use Illuminate\Console\Command;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* A command to generate phpstorm meta data
|
||||
*
|
||||
* @author Barry vd. Heuvel <barryvdh@gmail.com>
|
||||
*/
|
||||
class MetaCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'ide-helper:meta';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate metadata for PhpStorm';
|
||||
|
||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||
protected $files;
|
||||
|
||||
/** @var \Illuminate\Contracts\View\Factory */
|
||||
protected $view;
|
||||
|
||||
/** @var \Illuminate\Contracts\Config\Repository */
|
||||
protected $config;
|
||||
|
||||
protected $methods = [
|
||||
'new \Illuminate\Contracts\Container\Container',
|
||||
'\Illuminate\Container\Container::makeWith(0)',
|
||||
'\Illuminate\Contracts\Container\Container::get(0)',
|
||||
'\Illuminate\Contracts\Container\Container::make(0)',
|
||||
'\Illuminate\Contracts\Container\Container::makeWith(0)',
|
||||
'\App::get(0)',
|
||||
'\App::make(0)',
|
||||
'\App::makeWith(0)',
|
||||
'\app(0)',
|
||||
'\resolve(0)',
|
||||
'\Psr\Container\ContainerInterface::get(0)',
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Illuminate\Contracts\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\Contracts\View\Factory $view
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*/
|
||||
public function __construct($files, $view, $config)
|
||||
{
|
||||
$this->files = $files;
|
||||
$this->view = $view;
|
||||
$this->config = $config;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Needs to run before exception handler is registered
|
||||
$factories = $this->config->get('ide-helper.include_factory_builders') ? Factories::all() : [];
|
||||
|
||||
$ourAutoloader = $this->registerClassAutoloadExceptions();
|
||||
|
||||
$bindings = [];
|
||||
foreach ($this->getAbstracts() as $abstract) {
|
||||
// Validator and seeder cause problems
|
||||
if (in_array($abstract, ['validator', 'seeder'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$concrete = $this->laravel->make($abstract);
|
||||
|
||||
if ($concrete === null) {
|
||||
throw new RuntimeException("Cannot create instance for '$abstract', received 'null'");
|
||||
}
|
||||
|
||||
$reflectionClass = new \ReflectionClass($concrete);
|
||||
if (is_object($concrete) && !$reflectionClass->isAnonymous()) {
|
||||
$bindings[$abstract] = get_class($concrete);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
|
||||
$this->comment("Cannot make '$abstract': " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->unregisterClassAutoloadExceptions($ourAutoloader);
|
||||
|
||||
$content = $this->view->make('meta', [
|
||||
'bindings' => $bindings,
|
||||
'methods' => $this->methods,
|
||||
'factories' => $factories,
|
||||
])->render();
|
||||
|
||||
$filename = $this->option('filename');
|
||||
$written = $this->files->put($filename, $content);
|
||||
|
||||
if ($written !== false) {
|
||||
$this->info("A new meta file was written to $filename");
|
||||
} else {
|
||||
$this->error("The meta file could not be created at $filename");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of abstracts from the Laravel Application.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAbstracts()
|
||||
{
|
||||
$abstracts = $this->laravel->getBindings();
|
||||
|
||||
// Return the abstract names only
|
||||
$keys = array_keys($abstracts);
|
||||
|
||||
sort($keys);
|
||||
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an autoloader the throws exceptions when a class is not found.
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
protected function registerClassAutoloadExceptions(): callable
|
||||
{
|
||||
$autoloader = function ($class) {
|
||||
throw new \ReflectionException("Class '$class' not found.");
|
||||
};
|
||||
spl_autoload_register($autoloader);
|
||||
return $autoloader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$filename = $this->config->get('ide-helper.meta_filename');
|
||||
|
||||
return [
|
||||
['filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the meta file', $filename],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove our custom autoloader that we pushed onto the autoload stack
|
||||
*
|
||||
* @param callable $ourAutoloader
|
||||
*/
|
||||
private function unregisterClassAutoloadExceptions(callable $ourAutoloader): void
|
||||
{
|
||||
spl_autoload_unregister($ourAutoloader);
|
||||
}
|
||||
}
|
||||
1604
vendor/barryvdh/laravel-ide-helper/src/Console/ModelsCommand.php
vendored
Normal file
1604
vendor/barryvdh/laravel-ide-helper/src/Console/ModelsCommand.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user