Skip to content

Commit

Permalink
chore: Bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Sep 24, 2024
1 parent 8791a4b commit 49db117
Show file tree
Hide file tree
Showing 21 changed files with 1,194 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.0', '8.1']
steps:
- uses: shivammathur/setup-php@v2
with:
Expand Down
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: php
sudo: required
php:
- 7.4
- 8.0
- 8.1
- nightly
install:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev --no-interaction
script:
- vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src
- vendor/bin/phpstan analyse -c phpstan.neon
jobs:
allow_failures:
- php: nightly
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2024 Ambroise Maupate
Copyright © 2023 Ambroise Maupate

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
31 changes: 15 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@
}
],
"type": "symfony-bundle",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"roadiz/core-bundle": "2.3.*",
"roadiz/openid": "2.3.*",
"symfony/framework-bundle": "6.4.*"
"php": ">=8.0",
"pimple/pimple": "^3.3.1",
"roadiz/core-bundle": "2.1.*",
"roadiz/openid": "2.1.*",
"symfony/framework-bundle": "5.4.*"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.4",
"phpstan/phpstan": "^1.5.3",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-symfony": "^1.1.8",
"roadiz/doc-generator": "2.3.*",
"roadiz/documents": "2.3.*",
"roadiz/dts-generator": "2.3.*",
"roadiz/entity-generator": "2.3.*",
"roadiz/jwt": "2.3.*",
"roadiz/markdown": "2.3.*",
"roadiz/models": "2.3.*",
"roadiz/random": "2.3.*",
"roadiz/doc-generator": "2.1.*",
"roadiz/documents": "2.1.*",
"roadiz/dts-generator": "2.1.*",
"roadiz/entity-generator": "2.1.*",
"roadiz/jwt": "2.1.*",
"roadiz/markdown": "2.1.*",
"roadiz/models": "2.1.*",
"roadiz/random": "2.1.*",
"squizlabs/php_codesniffer": "^3.5"
},
"config": {
Expand All @@ -60,8 +59,8 @@
},
"extra": {
"branch-alias": {
"dev-main": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-main": "2.1.x-dev",
"dev-develop": "2.2.x-dev"
}
}
}
26 changes: 26 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,28 @@ services:
- '../src/Tests/'
- '../src/Event/'

#
# Automatic themes registration
#
Themes\:
resource: '%kernel.project_dir%/themes/'
autowire: true
autoconfigure: true
exclude:
- '%kernel.project_dir%/themes/DependencyInjection/'
- '%kernel.project_dir%/themes/app/'
- '%kernel.project_dir%/themes/public/'
- '%kernel.project_dir%/themes/Resources/'
- '%kernel.project_dir%/themes/Services/'
- '%kernel.project_dir%/themes/static/'
- '%kernel.project_dir%/themes/Entity/'
- '%kernel.project_dir%/themes/Kernel.php'
- '%kernel.project_dir%/themes/Tests/'

# Explicit declaration
RZ\Roadiz\CompatBundle\Controller\AppController: ~
RZ\Roadiz\CompatBundle\Controller\Controller: ~
RZ\Roadiz\CompatBundle\Controller\FrontendController: ~

securityTokenStorage:
alias: security.token_storage
Expand All @@ -38,6 +57,10 @@ services:
rolesBag:
alias: RZ\Roadiz\CoreBundle\Bag\Roles
public: true
assetPackages:
alias: RZ\Roadiz\Documents\Packages
deprecated: ~
public: true
Symfony\Contracts\Translation\TranslatorInterface:
alias: 'translator.default'
public: true
Expand Down Expand Up @@ -71,6 +94,8 @@ services:
roadiz_compat.twig_loader:
class: Twig\Loader\FilesystemLoader
tags: ['twig.loader']
RZ\Roadiz\CompatBundle\Routing\ThemeRoutesLoader:
tags: [ routing.loader ]

#
# Made routers theme aware
Expand All @@ -95,4 +120,5 @@ services:
RZ\Roadiz\CompatBundle\EventSubscriber\ExceptionSubscriber:
arguments:
- '@RZ\Roadiz\CompatBundle\Theme\ThemeResolverInterface'
- '@RZ\Roadiz\CoreBundle\Exception\ExceptionViewer'
- '@service_container'
6 changes: 2 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ parameters:
- */bower_components/*
- */static/*
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Call to an undefined method RZ\\Roadiz\\CoreBundle\\Repository#'
- '#Call to an undefined method RZ\\Roadiz\\UserBundle\\Repository#'
- '#Call to an undefined method Doctrine\\Persistence\\ObjectRepository#'
Expand All @@ -28,10 +26,10 @@ parameters:
- '#Doctrine\\ORM\\Mapping\\GeneratedValue constructor expects#'
- '#type mapping mismatch: property can contain Doctrine\\Common\\Collections\\Collection<int, [^\>]+> but database expects Doctrine\\Common\\Collections\\Collection&iterable<[^\>]+>#'
- '#should return Doctrine\\Common\\Collections\\Collection<int, [^\>]+Interface> but returns Doctrine\\Common\\Collections\\Collection<int, [^\>]+>#'
- '#but returns Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'
- '#does not accept Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'

reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-doctrine/rules.neon
8 changes: 7 additions & 1 deletion src/Aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static function getAliases(): array
return [
\RZ\Roadiz\CompatBundle\Controller\AppController::class => \RZ\Roadiz\CMS\Controllers\AppController::class,
\RZ\Roadiz\CompatBundle\Controller\Controller::class => \RZ\Roadiz\CMS\Controllers\Controller::class,
\RZ\Roadiz\CompatBundle\Controller\FrontendController::class => \RZ\Roadiz\CMS\Controllers\FrontendController::class,
\RZ\Roadiz\CompatBundle\Theme\ThemeResolverInterface::class => \RZ\Roadiz\Utils\Theme\ThemeResolverInterface::class,
\RZ\Roadiz\CoreBundle\Bag\NodeTypes::class => \RZ\Roadiz\Core\Bags\NodeTypes::class,
\RZ\Roadiz\CoreBundle\Bag\Roles::class => \RZ\Roadiz\Core\Bags\Roles::class,
Expand Down Expand Up @@ -64,7 +65,8 @@ public static function getAliases(): array
\RZ\Roadiz\CoreBundle\Entity\Folder::class => \RZ\Roadiz\Core\Entities\Folder::class,
\RZ\Roadiz\CoreBundle\Entity\FolderTranslation::class => \RZ\Roadiz\Core\Entities\FolderTranslation::class,
\RZ\Roadiz\CoreBundle\Entity\Group::class => \RZ\Roadiz\Core\Entities\Group::class,
\RZ\Roadiz\CoreBundle\Logger\Entity\Log::class => \RZ\Roadiz\Core\Entities\Log::class,
\RZ\Roadiz\CoreBundle\Entity\Log::class => \RZ\Roadiz\Core\Entities\Log::class,
\RZ\Roadiz\CoreBundle\Entity\LoginAttempt::class => \RZ\Roadiz\Core\Entities\LoginAttempt::class,
\RZ\Roadiz\CoreBundle\Entity\Node::class => \RZ\Roadiz\Core\Entities\Node::class,
\RZ\Roadiz\CoreBundle\Entity\NodeType::class => \RZ\Roadiz\Core\Entities\NodeType::class,
\RZ\Roadiz\CoreBundle\Entity\NodeTypeField::class => \RZ\Roadiz\Core\Entities\NodeTypeField::class,
Expand Down Expand Up @@ -167,6 +169,8 @@ public static function getAliases(): array
\RZ\Roadiz\CoreBundle\Form\Constraint\RecaptchaValidator::class => \RZ\Roadiz\CMS\Forms\Constraints\RecaptchaValidator::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\SimpleLatinString::class => \RZ\Roadiz\CMS\Forms\Constraints\SimpleLatinString::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\SimpleLatinStringValidator::class => \RZ\Roadiz\CMS\Forms\Constraints\SimpleLatinStringValidator::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\UniqueEntity::class => \RZ\Roadiz\CMS\Forms\Constraints\UniqueEntity::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\UniqueEntityValidator::class => \RZ\Roadiz\CMS\Forms\Constraints\UniqueEntityValidator::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\UniqueFilename::class => \RZ\Roadiz\CMS\Forms\Constraints\UniqueFilename::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\UniqueFilenameValidator::class => \RZ\Roadiz\CMS\Forms\Constraints\UniqueFilenameValidator::class,
\RZ\Roadiz\CoreBundle\Form\Constraint\UniqueNodeName::class => \RZ\Roadiz\CMS\Forms\Constraints\UniqueNodeName::class,
Expand Down Expand Up @@ -238,6 +242,8 @@ public static function getAliases(): array
\RZ\Roadiz\CoreBundle\ListManager\Paginator::class => \RZ\Roadiz\Core\ListManagers\Paginator::class,
\RZ\Roadiz\CoreBundle\ListManager\QueryBuilderListManager::class => \RZ\Roadiz\Core\ListManagers\QueryBuilderListManager::class,
\RZ\Roadiz\CoreBundle\ListManager\TagListManager::class => \RZ\Roadiz\Core\ListManagers\TagListManager::class,
\RZ\Roadiz\CoreBundle\Mailer\ContactFormManager::class => \RZ\Roadiz\Utils\ContactFormManager::class,
\RZ\Roadiz\CoreBundle\Mailer\EmailManager::class => \RZ\Roadiz\Utils\EmailManager::class,
\RZ\Roadiz\CoreBundle\Node\NodeDuplicator::class => \RZ\Roadiz\Utils\Node\NodeDuplicator::class,
\RZ\Roadiz\CoreBundle\Node\NodeFactory::class => \RZ\Roadiz\Utils\Node\NodeFactory::class,
\RZ\Roadiz\CoreBundle\Node\NodeMover::class => \RZ\Roadiz\Utils\Node\NodeMover::class,
Expand Down
106 changes: 106 additions & 0 deletions src/Console/ThemeGenerateCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\CompatBundle\Console;

use RZ\Roadiz\CompatBundle\Theme\ThemeGenerator;
use RZ\Roadiz\CompatBundle\Theme\ThemeInfo;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class ThemeGenerateCommand extends Command
{
protected string $projectDir;
protected ThemeGenerator $themeGenerator;

public function __construct(string $projectDir, ThemeGenerator $themeGenerator)
{
parent::__construct();
$this->projectDir = $projectDir;
$this->themeGenerator = $themeGenerator;
}

protected function configure(): void
{
$this->setName('themes:generate')
->setDescription('Generate a new theme based on BaseTheme boilerplate. <info>Requires "find", "sed" and "git" commands.</info>')
->addArgument(
'name',
InputArgument::REQUIRED,
'Theme name (without the "Theme" suffix)'
)
->addOption(
'develop',
'd',
InputOption::VALUE_NONE,
'Use BaseTheme develop branch instead of master.'
)
->addOption(
'branch',
'b',
InputOption::VALUE_REQUIRED,
'Choose BaseTheme branch.'
)
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the theme assets instead of copying it')
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$branch = 'master';
if ($input->getOption('develop')) {
$branch = 'develop';
}
if ($input->getOption('branch')) {
$branch = $input->getOption('branch');
}
if ($input->getOption('relative')) {
$expectedMethod = ThemeGenerator::METHOD_RELATIVE_SYMLINK;
} elseif ($input->getOption('symlink')) {
$expectedMethod = ThemeGenerator::METHOD_ABSOLUTE_SYMLINK;
} else {
$expectedMethod = ThemeGenerator::METHOD_COPY;
}

$name = str_replace('/', '\\', $input->getArgument('name'));
$themeInfo = new ThemeInfo($name, $this->projectDir);

if (
$io->confirm(
'Are you sure you want to generate a new theme called: "' . $themeInfo->getThemeName() . '"' .
' using ' . $branch . ' branch and installing its assets with ' . $expectedMethod . ' method?',
false
)
) {
if (!$themeInfo->exists()) {
$this->themeGenerator->downloadTheme($themeInfo, $branch);
$io->success('BaseTheme cloned into ' . $themeInfo->getThemePath());
}

$this->themeGenerator->renameTheme($themeInfo);
$this->themeGenerator->installThemeAssets($themeInfo, $expectedMethod);

$io->note([
'Register your theme into your config/packages/roadiz_core.yaml configuration file',
'---',
'themes:',
' - classname: ' . $themeInfo->getClassname(),
]);
$io->success($themeInfo->getThemeName() . ' has been regenerated and is ready to be installed, have fun!');
}

return 0;
}
}
18 changes: 10 additions & 8 deletions src/Console/ThemeInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

/**
* Command line utils for managing themes from terminal.
*
* @deprecated Use RZ\Roadiz\CoreBundle\Console\AppInstallCommand instead.
*/
class ThemeInstallCommand extends Command
{
Expand Down Expand Up @@ -147,7 +145,7 @@ protected function importThemeData(?ThemeInfo $themeInfo, string $themeConfigPat
{
$data = $this->getThemeConfig($themeConfigPath);

if (isset($data["importFiles"])) {
if (false !== $data && isset($data["importFiles"])) {
if (isset($data["importFiles"]['groups'])) {
foreach ($data["importFiles"]['groups'] as $filename) {
$this->importFile($themeInfo, $filename, $this->groupsImporter);
Expand Down Expand Up @@ -178,6 +176,14 @@ protected function importThemeData(?ThemeInfo $themeInfo, string $themeConfigPat
$this->importFile($themeInfo, $filename, $this->attributeImporter);
}
}
if ($this->io->isVeryVerbose()) {
$this->io->note(
'You should do a `bin/console generate:nsentities`' .
' to regenerate your node-types source classes, ' .
'and a `bin/console doctrine:schema:update --dump-sql --force` ' .
'to apply your changes into database.'
);
}
} else {
$this->io->warning('Config file "' . $themeConfigPath . '" has no data to import.');
}
Expand Down Expand Up @@ -229,10 +235,6 @@ protected function getThemeConfig(string $themeConfigPath): array
if (false === $fileContent = file_get_contents($themeConfigPath)) {
throw new \RuntimeException($themeConfigPath . ' file is not readable');
}
$data = Yaml::parse($fileContent);
if (!\is_array($data)) {
throw new \RuntimeException($themeConfigPath . ' file is not a valid YAML file');
}
return $data;
return Yaml::parse($fileContent);
}
}
Loading

0 comments on commit 49db117

Please sign in to comment.