Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ on:
pull_request:
push:

permissions:
contents: read

jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.can-fail }}
name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-20.04, php: 7.4, symfony: "5.4.*", composer-flags: "--prefer-stable --prefer-lowest", can-fail: false }
- { os: ubuntu-latest, php: 8.3, symfony: "6.4.*", composer-flags: "--prefer-stable", can-fail: false }
- { os: ubuntu-latest, php: 8.2, symfony: "6.3.*", composer-flags: "--prefer-stable", can-fail: false }
- { os: ubuntu-latest, php: 8.2, symfony: "6.4.*", composer-flags: "--prefer-stable", can-fail: false }
- { os: ubuntu-latest, php: 8.3, symfony: "7.0.*", composer-flags: "--prefer-stable", can-fail: false }
- { os: ubuntu-latest, php: 8.1, symfony: "6.4.*", composer-flags: "--prefer-stable --prefer-lowest" }
- { os: ubuntu-latest, php: 8.2, symfony: "7.4.*", composer-flags: "--prefer-stable" }
- { os: ubuntu-latest, php: 8.4, symfony: "8.1.*", composer-flags: "--prefer-stable" }

steps:
- name: "Checkout"
Expand All @@ -25,22 +26,31 @@ jobs:
fetch-depth: 2

- name: "Cache Composer packages"
uses: "actions/cache@v3"
uses: "actions/cache@v4"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('composer.json') }}-flags-${{ matrix.composer-flags }}"
restore-keys: "php-"
restore-keys: "php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php }}"
tools: "composer:v2,flex"

# Composer >= 2.9 skips vulnerable versions when resolving, which would hide
# vulnerable lower bounds from the audit below
- name: "Allow vulnerable versions to be resolved"
if: contains(matrix.composer-flags, '--prefer-lowest')
run: composer config --global audit.block-insecure false

- name: Install dependencies
run: composer update ${{ matrix.composer-flags }} --prefer-dist
env:
SYMFONY_REQUIRE: "${{ matrix.symfony }}"

- name: "Audit dependencies"
run: composer audit

- name: Run PHPUnit Tests
run: composer test
14 changes: 6 additions & 8 deletions Command/GenerateCronCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,26 @@
use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFileFactory;
use Lexik\Bundle\CronFileGeneratorBundle\Exception\CronEmptyException;
use Lexik\Bundle\CronFileGeneratorBundle\Exception\WrongConsoleBinPathException;
use Symfony\Component\Console\Attribute\AsCommand;
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;

#[AsCommand(name: 'lexik:cron:generate-file', description: 'Generate a cron file')]
class GenerateCronCommand extends Command
{
private DumpFileFactory $dumpFileFactory;

public function __construct(DumpFileFactory $dumpFileFactory, string $name = 'lexik:cron:generate-file')
{
parent::__construct($name);

$this->dumpFileFactory = $dumpFileFactory;
public function __construct(
private readonly DumpFileFactory $dumpFileFactory,
) {
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('Generate a cron file')
->setHelp(<<<'EOPHP'
The <info>%command.name%</info> generates cron file

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('lexik_cron_file_generator');
$rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('lexik_cron_file_generator');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
8 changes: 4 additions & 4 deletions DependencyInjection/LexikCronFileGeneratorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;

class LexikCronFileGeneratorExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

$loader->load('dump_file.xml');
$loader->load('console.xml');
$loader->load('dump_file.php');
$loader->load('console.php');

$container->setParameter('lexik_cron_file_generator.cron.configuration_arguments', $config);
$container->setAlias(DumpFile::class, 'lexik_cron_file_generator.cron.dump_file');
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ LexikCronFileGeneratorBundle

This symfony bundle provides cron file generation utilities.

Requirements
============

* PHP 8.1 or higher
* Symfony 6.4, 7.4 or 8.x
* Twig 3

Using an older PHP or Symfony version? Stick to the `v1.3.x` releases (latest: `v1.3.3`).
Upgrading from 1.x? See [UPGRADE-2.0.md](UPGRADE-2.0.md).

Installation
============

Expand Down
14 changes: 14 additions & 0 deletions Resources/config/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use Lexik\Bundle\CronFileGeneratorBundle\Command\GenerateCronCommand;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container->services()
->set('lexik_bundle_cron_file_generator.command.generate_cron_command', GenerateCronCommand::class)
->public()
->args([service('lexik_bundle_cron_file_generator.cron.dump_file_factory')])
->tag('console.command');
};
14 changes: 0 additions & 14 deletions Resources/config/console.xml

This file was deleted.

24 changes: 24 additions & 0 deletions Resources/config/dump_file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Lexik\Bundle\CronFileGeneratorBundle\Cron\Configuration;
use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFile;
use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFileFactory;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container->services()
->set('lexik_bundle_cron_file_generator.cron.dump_file_factory', DumpFileFactory::class)
->public()
->args([service('lexik_cron_file_generator.cron.dump_file')])

->set('lexik_cron_file_generator.cron.dump_file', DumpFile::class)
->public()
->args([service('twig'), service('lexik_cron_file_generator.cron.configuration')])

->set('lexik_cron_file_generator.cron.configuration', Configuration::class)
->private()
->args([param('lexik_cron_file_generator.cron.configuration_arguments')]);
};
25 changes: 0 additions & 25 deletions Resources/config/dump_file.xml

This file was deleted.

Loading
Loading