Skip to content
This repository was archived by the owner on Jan 6, 2020. It is now read-only.
Closed
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
114 changes: 2 additions & 112 deletions Composer/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,116 +241,6 @@ public static function removeSymfonyStandardFiles(CommandEvent $event)
$fs->remove($appDir.'/SymfonyStandard');
}

public static function installAcmeDemoBundle(CommandEvent $event)
{
$rootDir = getcwd();
$options = static::getOptions($event);

if (file_exists($rootDir.'/src/Acme/DemoBundle')) {
return;
}

if (!getenv('SENSIOLABS_FORCE_ACME_DEMO')) {
if (!$event->getIO()->askConfirmation('Would you like to install Acme demo bundle? [y/N] ', false)) {
return;
}
}

$event->getIO()->write('Installing the Acme demo bundle.');

$appDir = $options['symfony-app-dir'];

$kernelFile = $appDir.'/AppKernel.php';

$fs = new Filesystem();
$fs->mirror(__DIR__.'/../Resources/skeleton/acme-demo-bundle', $rootDir.'/src', null, array('override' => true));

$ref = '$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();';
$bundleDeclaration = "\$bundles[] = new Acme\\DemoBundle\\AcmeDemoBundle();";
$content = file_get_contents($kernelFile);

if (false === strpos($content, $bundleDeclaration)) {
$updatedContent = str_replace($ref, $bundleDeclaration."\n ".$ref, $content);
if ($content === $updatedContent) {
throw new \RuntimeException('Unable to patch %s.', $kernelFile);
}
$fs->dumpFile($kernelFile, $updatedContent);
}

static::patchAcmeDemoBundleConfiguration($appDir, $fs);
}

private static function patchAcmeDemoBundleConfiguration($appDir, Filesystem $fs)
{
$routingFile = $appDir.'/config/routing_dev.yml';
$securityFile = $appDir.'/config/security.yml';

$routingData = file_get_contents($routingFile).<<<EOF

# AcmeDemoBundle routes (to be removed)
_acme_demo:
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
EOF;
$fs->dumpFile($routingFile, $routingData);

$securityData = <<<EOF
# you can read more about security in the related section of the documentation
# http://symfony.com/doc/current/book/security.html
security:
# http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password
encoders:
Symfony\Component\Security\Core\User\User: plaintext

# http://symfony.com/doc/current/book/security.html#hierarchical-roles
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
in_memory:
memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

# the main part of the security, where you can set up firewalls
# for specific sections of your app
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
# the login page has to be accessible for everybody
demo_login:
pattern: ^/demo/secured/login$
security: false

# secures part of the application
demo_secured_area:
pattern: ^/demo/secured/
# it's important to notice that in this case _demo_security_check and _demo_login
# are route names and that they are specified in the AcmeDemoBundle
form_login:
check_path: _demo_security_check
login_path: _demo_login
logout:
path: _demo_logout
target: _demo
#anonymous: ~
#http_basic:
# realm: "Secured Demo Area"

# with these settings you can restrict or allow access for different parts
# of your application based on roles, ip, host or methods
# http://symfony.com/doc/current/cookbook/security/access_control.html
access_control:
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
EOF;

$fs->dumpFile($securityFile, $securityData);
}

public static function doBuildBootstrap($bootstrapDir, $autoloadDir = null, $useNewDirectoryStructure = false)
{
$file = $bootstrapDir.'/bootstrap.php.cache';
Expand Down Expand Up @@ -398,7 +288,7 @@ public static function doBuildBootstrap($bootstrapDir, $autoloadDir = null, $use

if ($useNewDirectoryStructure) {
$cacheDir = $fs->makePathRelative($bootstrapDir, $autoloadDir);
$bootstrapContent = str_replace(array("return \$this->rootDir.'/logs", "return \$this->rootDir.'/cache"), array("return \$this->rootDir.'/".$cacheDir."logs", "return \$this->rootDir.'/".$cacheDir."cache"), $bootstrapContent);
$bootstrapContent = str_replace(array("return \$this->rootDir.'/logs", "return \$this->rootDir.'/cache"), array("return \$this->rootDir.'/".$cacheDir.'logs', "return \$this->rootDir.'/".$cacheDir.'cache'), $bootstrapContent);
}

if ($autoloadDir) {
Expand Down Expand Up @@ -505,7 +395,7 @@ protected static function updateDirectoryStructure(CommandEvent $event, $rootDir
</php>
EOF;
$phpunit = str_replace(array('<directory>../src', '"bootstrap.php.cache"', $phpunitKernelBefore), array('<directory>src', '"'.$varDir.'/bootstrap.php.cache"', $phpunitKernelAfter), file_get_contents($rootDir.'/phpunit.xml.dist'));
$composer = str_replace("\"symfony-app-dir\": \"app\",", "\"symfony-app-dir\": \"app\",\n \"symfony-bin-dir\": \"bin\",\n \"symfony-var-dir\": \"var\",", file_get_contents($rootDir.'/composer.json'));
$composer = str_replace('"symfony-app-dir": "app",', "\"symfony-app-dir\": \"app\",\n \"symfony-bin-dir\": \"bin\",\n \"symfony-var-dir\": \"var\",", file_get_contents($rootDir.'/composer.json'));

$fs->dumpFile($webDir.'/app.php', str_replace($appDir.'/bootstrap.php.cache', $varDir.'/bootstrap.php.cache', file_get_contents($webDir.'/app.php')));
$fs->dumpFile($webDir.'/app_dev.php', str_replace($appDir.'/bootstrap.php.cache', $varDir.'/bootstrap.php.cache', file_get_contents($webDir.'/app_dev.php')));
Expand Down
3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ when running an install or an update:

* Updated the requirements file;

* Install the Acme Demo bundle by setting the ``SENSIOLABS_FORCE_ACME_DEMO``
environment variable to ``true`` (and only when creating a new project);

* Switch to the Symfony 3.0 directory structure by setting the
``SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE`` environment variable to
``true`` (and only when creating a new project).
Expand Down
1 change: 0 additions & 1 deletion Resources/bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ fi
# avoid the creation of ._* files
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
export COPYFILE_DISABLE=true
export SENSIOLABS_FORCE_ACME_DEMO=true

# Temp dir
rm -rf /tmp/Symfony
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading