Skip to content

Commit

Permalink
[TASK] Support Neos/Flow class compiler
Browse files Browse the repository at this point in the history
With 2.7.3, we extracted all logic from bin/fluid
to src/Tools/ConsoleRunner.php and src/Tools/console.php,
where ConsoleRunner contains the worker class and
console.php the autoload and instantiation logic
as global code.

This works, but one could argue it's ugly having
code within a source directory that is supposed to
contain classes only.

More importantly, it turns out Neos/Flow can not deal
with global code that just "runs" in a folder that
expects to contain all code being encapsulated in
classes only. The proxy mechanism of Neos/Flow stumbles:

Undefined variable $argv in Packages/Libraries/typo3fluid/fluid/src/Tools/console.php line 22

The patch moves the global scope code back into bin/fluid.

Additionally, the Heredoc in ConsoleRunner gets a
minor update because the Neos/Flow class compiler
interpretes 'name' of the phrase 'class name' as a
class name which leads to another exception:

The name of the class "name" is not the same as the filename which is "ConsoleRunner.php".

Resolves: #691
  • Loading branch information
Christoph Lehmann authored and lolli42 committed Mar 23, 2023
1 parent 449e5c7 commit 24f4494
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
25 changes: 24 additions & 1 deletion bin/fluid
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
#!/usr/bin/env php
<?php

require __DIR__ . '/../src/Tools/console.php';
declare(strict_types=1);

/*
* This file belongs to the package "TYPO3 Fluid".
* See LICENSE.txt that was shipped with this package.
*/

use TYPO3Fluid\Fluid\Tools\ConsoleRunner;

if (file_exists(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
} elseif (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
require_once __DIR__ . '/../../../autoload.php';
}

$runner = new ConsoleRunner();
try {
echo $runner->handleCommand($argv);
} catch (InvalidArgumentException $error) {
echo PHP_EOL . 'ERROR! ' . $error->getMessage() . PHP_EOL . PHP_EOL;
echo $runner->dumpSupportedParameters();
}
4 changes: 2 additions & 2 deletions src/Tools/ConsoleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ public function dumpusageExample()
./bin/fluid --templateRootPaths /path/to/first/ /path/to/second/ "/path/with spaces/"
To specify variables, use any JSON source - string of JSON, local file or URI, or
class name of a PHP class implementing DataProviderInterface:
To specify variables, use any JSON source - string of JSON, local file or URI, or class
name of a PHP class implementing DataProviderInterface:
./bin/fluid --variables /path/to/fluidvariables.json
Expand Down
26 changes: 0 additions & 26 deletions src/Tools/console.php

This file was deleted.

0 comments on commit 24f4494

Please sign in to comment.