Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix root dir deprecation and fix PHP 7.4 deprecation #369

Merged
merged 3 commits into from
Dec 2, 2019
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ matrix:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4snapshot
- php: 7.1
env: SYMFONY_VERSION='3.4.*'
- php: 7.1
Expand Down
15 changes: 5 additions & 10 deletions Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ class DumpCommand extends Command
{
protected static $defaultName = 'fos:js-routing:dump';

/**
* @var string
*/
private $targetPath;

/**
* @var ExposedRoutesExtractorInterface
*/
Expand All @@ -46,18 +41,18 @@ class DumpCommand extends Command
/**
* @var string
*/
private $rootDir;
private $projectDir;

/**
* @var string
*/
private $requestContextBaseUrl;

public function __construct(ExposedRoutesExtractorInterface $extractor, SerializerInterface $serializer, $rootDir, $requestContextBaseUrl = null)
public function __construct(ExposedRoutesExtractorInterface $extractor, SerializerInterface $serializer, $projectDir, $requestContextBaseUrl = null)
{
$this->extractor = $extractor;
$this->serializer = $serializer;
$this->rootDir = $rootDir;
$this->projectDir = $projectDir;
$this->requestContextBaseUrl = $requestContextBaseUrl;

parent::__construct();
Expand Down Expand Up @@ -145,8 +140,8 @@ private function doDump(InputInterface $input, OutputInterface $output)
$serializer = $this->serializer;
$targetPath = $input->getOption('target') ?:
sprintf(
'%s/../web/js/fos_js_routes%s.%s',
$this->rootDir,
'%s/web/js/fos_js_routes%s.%s',
$this->projectDir,
empty($domain) ? '' : ('_' . implode('_', $domain)),
$input->getOption('format')
);
Expand Down
4 changes: 2 additions & 2 deletions Extractor/ExposedRoutesExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ protected function buildPattern($domainPatterns)

foreach ($domainPatterns as $domain => $items) {

$patterns[] = '(?P<' . $domain . '>' . implode($items, '|') . ')';
$patterns[] = '(?P<' . $domain . '>' . implode('|', $items) . ')';
}

return implode($patterns, '|');
return implode('|', $patterns);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<service id="fos_js_routing.dump_command" class="FOS\JsRoutingBundle\Command\DumpCommand">
<argument type="service" id="fos_js_routing.extractor" />
<argument type="service" id="fos_js_routing.serializer" />
<argument>%kernel.root_dir%</argument>
<argument>%kernel.project_dir%</argument>
<argument>%fos_js_routing.request_context_base_url%</argument>
<tag name="console.command" />
</service>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/DumpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testExecuteFormatOption()
public function testExecuteUnableToCreateDirectory()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Unable to create directory /root/dir/../web/js');
$this->expectExceptionMessage('Unable to create directory /root/dir/web/js');
$command = new DumpCommand($this->extractor, $this->serializer, '/root/dir');

$tester = new CommandTester($command);
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
],
"require": {
"php": "^7.1",
"symfony/framework-bundle": "~3.0|^4.0|^5.0",
"symfony/serializer": "~3.0|^4.0|^5.0",
"symfony/console": "~3.0|^4.0|^5.0",
"symfony/framework-bundle": "~3.3|^4.0|^5.0",
"symfony/serializer": "~3.3|^4.0|^5.0",
"symfony/console": "~3.3|^4.0|^5.0",
"willdurand/jsonp-callback-validator": "~1.0"
},
"require-dev": {
"symfony/expression-language": "~3.0|^4.0|^5.0",
"symfony/expression-language": "~3.3|^4.0|^5.0",
"symfony/phpunit-bridge": "^3.3|^4.0"
},
"autoload": {
Expand Down