Skip to content

Commit

Permalink
Merge pull request #36 from Aqamarine228/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Aqamarine228 authored Jan 11, 2024
2 parents 961b15c + 322dbf9 commit f6daf6c
Show file tree
Hide file tree
Showing 87 changed files with 2,470 additions and 79 deletions.
7 changes: 1 addition & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-latest",
"orchestra/testbench": "^7.6",
"orchestra/testbench": "^7.6 | ^8.0",
"squizlabs/php_codesniffer": "^3.7",
"friendsofphp/php-cs-fixer": "^3.9"
},
Expand All @@ -26,11 +26,6 @@
"Aqamarine\\AlphaNews\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Aqamarine\\AlphaNews\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Aqamarine228",
Expand Down
34 changes: 34 additions & 0 deletions config/alphanews.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

return [

/*
|--------------------------------------------------------------------------
| AlphaNews Default Language
|--------------------------------------------------------------------------
|
| Sets default language to be used inside managing panel, language code needs to be set.
|
*/

'default_language' => 'en',

/*
|--------------------------------------------------------------------------
| AlphaNews Media
Expand Down Expand Up @@ -74,4 +85,27 @@
'advertising' => 2,
]
],

/*
|--------------------------------------------------------------------------
| AlphaNews Posts
|--------------------------------------------------------------------------
|
| Section to manage everything related with posts.
|
*/

'posts' => [

/*
|--------------------------------------------------------------------------
| AlphaNews Preview Images Height
|--------------------------------------------------------------------------
|
| Height of posts preview image.
|
*/

'preview_images_height' => 720,
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ protected function getControllerName(): string

protected function getStubName(): string
{
return '/post-category-controller.stub';
return $this->option('translations')
? '/post-category-translations-controller.stub'
: '/post-category-controller.stub';
}
}
5 changes: 4 additions & 1 deletion src/Console/Controllers/PostControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Aqamarine\AlphaNews\Console\Controllers;

use Aqamarine\AlphaNews\Support\ControllerGeneratorCommand;
use Symfony\Component\Console\Input\InputOption;

class PostControllerMakeCommand extends ControllerGeneratorCommand
{
Expand All @@ -17,6 +18,8 @@ protected function getControllerName(): string

protected function getStubName(): string
{
return '/post-controller.stub';
return $this->option('translations')
? '/post-translations-controller.stub'
: '/post-controller.stub';
}
}
7 changes: 6 additions & 1 deletion src/Console/Controllers/PostTagControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Aqamarine\AlphaNews\Console\Controllers;

use Symfony\Component\Console\Input\InputOption;

class PostTagControllerMakeCommand extends \Aqamarine\AlphaNews\Support\ControllerGeneratorCommand
{
protected $name = 'alphanews:make-post-tag-controller';
Expand All @@ -15,6 +17,9 @@ protected function getControllerName(): string

protected function getStubName(): string
{
return '/post-tag-controller.stub';
return $this->option('translations')
? '/post-tag-translations-controller.stub'
: '/post-tag-controller.stub';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Aqamarine\AlphaNews\Console\Controllers;

use Aqamarine\AlphaNews\Support\ControllerGeneratorCommand;
use Symfony\Component\Console\Input\InputOption;

class PublishPostControllerMakeCommand extends ControllerGeneratorCommand
{
Expand Down
1 change: 0 additions & 1 deletion src/Console/Enums/PostMediaTypeEnumMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Aqamarine\AlphaNews\Console\Enums;

use Aqamarine\AlphaNews\Support\Stub;
use Illuminate\Support\Facades\File;

class PostMediaTypeEnumMakeCommand extends \Nwidart\Modules\Commands\GeneratorCommand
{
Expand Down
33 changes: 29 additions & 4 deletions src/Console/GenerateAllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Aqamarine\AlphaNews\Console;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class GenerateAllCommand extends \Illuminate\Console\Command
{
Expand All @@ -13,11 +14,27 @@ class GenerateAllCommand extends \Illuminate\Console\Command
public function handle(): int
{
$module = $this->argument('module');
$this->call(GenerateControllersCommand::class, ['module' => $module]);
$this->call(GenerateViewsCommand::class, ['module' => $module]);
$this->call(
GenerateControllersCommand::class,
['module' => $module, '--translations' => !$this->option('no-translations')]
);
$this->call(
GenerateViewsCommand::class,
['module' => $module, '--translations' => !$this->option('no-translations')]
);
$this->call(GenerateEnumsCommand::class);
$this->call(GenerateRoutesCommand::class, ['module' => $module]);
$this->call(GenerateModelsCommand::class, ['module' => $module]);
$this->call(
GenerateRoutesCommand::class,
['module' => $module, '--translations' => !$this->option('no-translations')]
);
$this->call(
GenerateModelsCommand::class,
['module' => $module, '--translations' => !$this->option('no-translations')]
);
$this->call(
GenerateMigrationsCommand::class,
['--translations' => !$this->option('no-translations')]
);
return 0;
}

Expand All @@ -27,4 +44,12 @@ protected function getArguments(): array
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
];
}

public function getOptions(): array
{
return [
['no-translations', 'nt', InputOption::VALUE_NONE, 'Wont generate translation files']
];
}

}
28 changes: 24 additions & 4 deletions src/Console/GenerateControllersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Aqamarine\AlphaNews\Console\Controllers\PublishPostControllerMakeCommand;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class GenerateControllersCommand extends Command
{
Expand All @@ -22,10 +23,22 @@ public function handle(): int
$module = $this->argument('module');
$this->call(ImageControllerMakeCommand::class, ['module' => $module]);
$this->call(MediaFolderControllerMakeCommand::class, ['module' => $module]);
$this->call(PostCategoryControllerMakeCommand::class, ['module' => $module]);
$this->call(PostControllerMakeCommand::class, ['module' => $module]);
$this->call(PostTagControllerMakeCommand::class, ['module' => $module]);
$this->call(PublishPostControllerMakeCommand::class, ['module' => $module]);
$this->call(
PostCategoryControllerMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
PostControllerMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
PostTagControllerMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
PublishPostControllerMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
return 0;
}

Expand All @@ -35,4 +48,11 @@ protected function getArguments(): array
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
];
}

public function getOptions(): array
{
return [
['translations', 't', InputOption::VALUE_NONE, 'Generate translations.'],
];
}
}
60 changes: 60 additions & 0 deletions src/Console/GenerateMigrationsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Aqamarine\AlphaNews\Console;

use Aqamarine\AlphaNews\Console\Migrations\ImageMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\MediaFolderMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostCategoryLanguageMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostCategoryMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostLanguageMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostPostTagMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostTagLanguageMigrationMakeCommand;
use Aqamarine\AlphaNews\Console\Migrations\PostTagMigrationMakeCommand;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;

class GenerateMigrationsCommand extends Command
{

protected $name = 'alphanews:generate-migrations';

protected $description = 'Creates all needed migrations.';

public function handle(): int
{
$this->call(PostCategoryMigrationMakeCommand::class, [
'--translations' => $this->option('translations'),
]);
$this->call(PostMigrationMakeCommand::class, [
'--translations' => $this->option('translations'),
]);
$this->call(PostTagMigrationMakeCommand::class, [
'--translations' => $this->option('translations'),
]);

$this->call(MediaFolderMigrationMakeCommand::class);

sleep(1);

if ($this->option('translations')) {
$this->call(PostCategoryLanguageMigrationMakeCommand::class);
$this->call(PostLanguageMigrationMakeCommand::class);
$this->call(PostTagLanguageMigrationMakeCommand::class);
sleep(1);
}

$this->call(PostPostTagMigrationMakeCommand::class);
$this->call(ImageMigrationMakeCommand::class);

return 0;
}

public function getOptions(): array
{
return [
['translations', 't', InputOption::VALUE_NONE, 'Generate translations.'],
];
}

}
37 changes: 32 additions & 5 deletions src/Console/GenerateModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace Aqamarine\AlphaNews\Console;

use Aqamarine\AlphaNews\Console\Models\ImageModelMakeCommand;
use Aqamarine\AlphaNews\Console\Models\LanguageModelMakeCommand;
use Aqamarine\AlphaNews\Console\Models\MediaFolderModelMakeCommand;
use Aqamarine\AlphaNews\Console\Models\PostCategoryModelMakeCommand;
use Aqamarine\AlphaNews\Console\Models\PostModelMakeCommand;
use Aqamarine\AlphaNews\Console\Models\PostTagModelMakeCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class GenerateModelsCommand extends \Illuminate\Console\Command
{
Expand All @@ -18,11 +20,29 @@ class GenerateModelsCommand extends \Illuminate\Console\Command
public function handle(): int
{
$module = $this->argument('module');
$this->call(ImageModelMakeCommand::class, ['module' => $module]);
$this->call(MediaFolderModelMakeCommand::class, ['module' => $module]);
$this->call(PostCategoryModelMakeCommand::class, ['module' => $module]);
$this->call(PostModelMakeCommand::class, ['module' => $module]);
$this->call(PostTagModelMakeCommand::class, ['module' => $module]);
$this->call(
ImageModelMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
MediaFolderModelMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
PostCategoryModelMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
PostModelMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
$this->call(
PostTagModelMakeCommand::class,
['module' => $module, '--translations' => $this->option('translations')]
);
if ($this->option('translations')) {
$this->call(LanguageModelMakeCommand::class, ['module' => $module]);
}
return 0;
}

Expand All @@ -32,4 +52,11 @@ protected function getArguments(): array
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
];
}

public function getOptions(): array
{
return [
['translations', 't', InputOption::VALUE_NONE, 'Generate translations.'],
];
}
}
12 changes: 11 additions & 1 deletion src/Console/GenerateRoutesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Nwidart\Modules\Support\Config\GenerateConfigReader;
use Nwidart\Modules\Traits\ModuleCommandTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class GenerateRoutesCommand extends \Nwidart\Modules\Commands\GeneratorCommand
{
Expand Down Expand Up @@ -35,7 +36,9 @@ protected function getDestinationFilePath(): string

public function getStubName(): string
{
return '/routes.stub';
return $this->option('translations')
? '/routes-translations.stub'
: '/routes.stub';
}

public function getControllersNamespace(): string
Expand All @@ -56,4 +59,11 @@ protected function getArguments(): array
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
];
}

public function getOptions(): array
{
return [
['translations', 't', InputOption::VALUE_NONE, 'Generate translations.'],
];
}
}
Loading

0 comments on commit f6daf6c

Please sign in to comment.