-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUPH-146 | add support for source override behavior #84
Open
jpmarcotte
wants to merge
1
commit into
1.x
Choose a base branch
from
BUPH-146-source-override-behavior-1x
base: 1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
parameters: | ||
env(Neighborhoods_Buphalo_V1_Actor_WriterInterface__SourceOverrideBehavior): !php/const \Neighborhoods\Buphalo\V1\Actor\WriterInterface::SOURCE_OVERRIDE_BEHAVIOR_DEFAULT | ||
Neighborhoods\Buphalo\V1\Actor\WriterInterface.SourceOverrideBehavior: '%env(Neighborhoods_Buphalo_V1_Actor_WriterInterface__SourceOverrideBehavior)%' | ||
services: | ||
Neighborhoods\Buphalo\V1\Actor\WriterInterface: | ||
class: Neighborhoods\Buphalo\V1\Actor\Writer | ||
public: false | ||
shared: false | ||
calls: | ||
- [setFilesystem, ['@Symfony\Component\Filesystem\Filesystem']] | ||
- [setSourceOverrideBehavior, ['%Neighborhoods\Buphalo\V1\Actor\WriterInterface.SourceOverrideBehavior%']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fab/* |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorDefault/control/SourceOverrideBehaviorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTest; | ||
|
||
interface SourceOverrideBehaviorInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
declare(strict_types=1); | ||
error_reporting(E_ALL); | ||
|
||
$PWD = __DIR__; | ||
|
||
// Must load autoloader before including any Annotation Processors | ||
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} elseif (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} else { | ||
throw new RuntimeException('Unable to find the Composer autoloader.'); | ||
} | ||
|
||
// Include Annotation Processors for Buphalo | ||
// None for this test | ||
|
||
// Add exec envs | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest"); | ||
putenv("Neighborhoods_Buphalo_V1_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates"); | ||
|
||
// Include Buphalo | ||
require_once($PWD . '/../../../bin/v1/buphalo.php'); | ||
|
||
// Diff the two directories | ||
exec("diff -r $PWD/control/ $PWD/fab/", $output, $return); | ||
|
||
if ($return) { | ||
echo(implode(PHP_EOL, $output) . PHP_EOL); | ||
die(1); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/v1/SourceOverrideBehaviorDefault/src/SourceOverrideBehavior.buphalo.v1.fabrication.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actors: | ||
<PrimaryActorName>.php: | ||
template: PrimaryActorName.php | ||
<PrimaryActorName>Interface.php: | ||
template: PrimaryActorNameInterface.php |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorDefault/src/SourceOverrideBehavior.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTest; | ||
|
||
class SourceOverrideBehavior | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorDefault/templates/PrimaryActorName.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTemplateTree; | ||
|
||
class PrimaryActorName | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorDefault/templates/PrimaryActorNameInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTemplateTree; | ||
|
||
interface PrimaryActorNameInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fab/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
declare(strict_types=1); | ||
error_reporting(E_ALL); | ||
|
||
$PWD = __DIR__; | ||
|
||
// Must load autoloader before including any Annotation Processors | ||
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} elseif (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} else { | ||
throw new RuntimeException('Unable to find the Composer autoloader.'); | ||
} | ||
|
||
// Include Annotation Processors for Buphalo | ||
// None for this test | ||
|
||
// Add exec envs | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest"); | ||
putenv("Neighborhoods_Buphalo_V1_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates"); | ||
putenv("Neighborhoods_Buphalo_V1_Actor_WriterInterface__SourceOverrideBehavior=invalid"); | ||
|
||
// Include Buphalo | ||
try { | ||
require_once($PWD . '/../../../bin/v1/buphalo.php'); | ||
} catch (LogicException $e) { | ||
exit; | ||
} | ||
|
||
echo "Failed to catch Logic Exception" . PHP_EOL; | ||
die(1); |
3 changes: 3 additions & 0 deletions
3
tests/v1/SourceOverrideBehaviorInvalid/src/SourceOverrideBehavior.buphalo.v1.fabrication.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
actors: | ||
<PrimaryActorName>.php: | ||
template: PrimaryActorName.php |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorInvalid/src/SourceOverrideBehavior.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTest; | ||
|
||
class SourceOverrideBehavior | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorInvalid/templates/PrimaryActorName.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTemplateTree; | ||
|
||
class PrimaryActorName | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fab/* |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorSkip/control/SourceOverrideBehaviorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTest; | ||
|
||
interface SourceOverrideBehaviorInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
declare(strict_types=1); | ||
error_reporting(E_ALL); | ||
|
||
$PWD = __DIR__; | ||
|
||
// Must load autoloader before including any Annotation Processors | ||
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} elseif (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} else { | ||
throw new RuntimeException('Unable to find the Composer autoloader.'); | ||
} | ||
|
||
// Include Annotation Processors for Buphalo | ||
// None for this test | ||
|
||
// Add exec envs | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest"); | ||
putenv("Neighborhoods_Buphalo_V1_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates"); | ||
putenv("Neighborhoods_Buphalo_V1_Actor_WriterInterface__SourceOverrideBehavior=skip"); | ||
|
||
|
||
// Include Buphalo | ||
require_once($PWD . '/../../../bin/v1/buphalo.php'); | ||
|
||
// Diff the two directories | ||
exec("diff -r $PWD/control/ $PWD/fab/", $output, $return); | ||
|
||
if ($return) { | ||
echo(implode(PHP_EOL, $output) . PHP_EOL); | ||
die(1); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/v1/SourceOverrideBehaviorSkip/src/SourceOverrideBehavior.buphalo.v1.fabrication.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actors: | ||
<PrimaryActorName>.php: | ||
template: PrimaryActorName.php | ||
<PrimaryActorName>Interface.php: | ||
template: PrimaryActorNameInterface.php |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorSkip/src/SourceOverrideBehavior.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTest; | ||
|
||
class SourceOverrideBehavior | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorSkip/templates/PrimaryActorName.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTemplateTree; | ||
|
||
class PrimaryActorName | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorSkip/templates/PrimaryActorNameInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTemplateTree; | ||
|
||
interface PrimaryActorNameInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fab/* |
8 changes: 8 additions & 0 deletions
8
tests/v1/SourceOverrideBehaviorThrow/control/SourceOverrideBehaviorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\BuphaloTest; | ||
|
||
interface SourceOverrideBehaviorInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
declare(strict_types=1); | ||
error_reporting(E_ALL); | ||
|
||
$PWD = __DIR__; | ||
|
||
// Must load autoloader before including any Annotation Processors | ||
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} elseif (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) { | ||
/** @noinspection PhpIncludeInspection */ | ||
require_once $autoloaderFilePath; | ||
} else { | ||
throw new RuntimeException('Unable to find the Composer autoloader.'); | ||
} | ||
|
||
// Include Annotation Processors for Buphalo | ||
// None for this test | ||
|
||
// Add exec envs | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab"); | ||
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest"); | ||
putenv("Neighborhoods_Buphalo_V1_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates"); | ||
putenv("Neighborhoods_Buphalo_V1_Actor_WriterInterface__SourceOverrideBehavior=throw"); | ||
|
||
// Include Buphalo | ||
try { | ||
require_once($PWD . '/../../../bin/v1/buphalo.php'); | ||
} catch (RuntimeException $e) { | ||
exit; | ||
} | ||
|
||
echo "Failed to catch Logic Exception" . PHP_EOL; | ||
die(1); |
5 changes: 5 additions & 0 deletions
5
tests/v1/SourceOverrideBehaviorThrow/src/SourceOverrideBehavior.buphalo.v1.fabrication.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actors: | ||
<PrimaryActorName>.php: | ||
template: PrimaryActorName.php | ||
<PrimaryActorName>Interface.php: | ||
template: PrimaryActorNameInterface.php |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it this ensures the default is always being used and line 3 then overrides the default if a variable is provided?
Since it doesn't show in the conversation view, line 3 is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. It's not a super-intuitive notation, but as far as I can tell, this is how Symfony handles defaults for environment variables that might not be set. And it makes it so that the code in Buphalo doesn't really have to rely on a "default" and can instead be explicit and know the value will be set.