Skip to content

Commit

Permalink
Migration Installer (#77)
Browse files Browse the repository at this point in the history
* #74: introduce migration installer

* #74: add initial migration version

* #74: fix docs
  • Loading branch information
solverat authored Dec 20, 2018
1 parent b7fb7dc commit 57510fb
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 162 deletions.
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,26 @@ Please read the installation instructions before going deep with Members!

```json
"require" : {
"dachcom-digital/members" : "~2.1.0"
"dachcom-digital/members" : "~2.3.0"
}
```

2.1 Activate & install it through backend.
2.2 Via CLI:
### Installation via Extension Manager
After you have installed the Members Bundle via composer, open pimcore backend and go to `Tools` => `Extension`:
- Click the green `+` Button in `Enable / Disable` row
- Click the green `+` Button in `Install/Uninstall` row

### Installation via CommandLine
After you have installed the Members Bundle via composer:
- Execute: `$ bin/console pimcore:bundle:enable MembersBundle`
- Execute: `$ bin/console pimcore:bundle:install MembersBundle`

#### Optional: Class Installation

> Read more about the required classes [below](./README.md#class-installation)).
```bash
bin/console pimcore:bundle:enable MembersBundle
bin/console pimcore:bundle:install MembersBundle
# optional:
bin/console members:install:class
# optional to be sure assets are symlinked:
bin/console assets:install --symlink --relative
```

### Route Installation
Expand Down
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Upgrade Notes
![upgrade](https://user-images.githubusercontent.com/700119/31535145-3c01a264-affa-11e7-8d86-f04c33571f65.png)

***

After every update you should check the pimcore extension manager.
Just click the "update" button or execute the migration command to finish the bundle update.

#### Update from Version 2.2.x to Version 2.3.0
- **[ATTENTION]**: Installer has moved to the [MigrationBundle](https://github.com/dachcom-digital/pimcore-members/issues/74). After updating to this version you need to enable this extension again!

#### Update from Version 2.2.0 to Version 2.2.1
- implemented [PackageVersionTrait](https://github.com/pimcore/pimcore/blob/master/lib/Extension/Bundle/Traits/PackageVersionTrait.php)
Expand Down
25 changes: 0 additions & 25 deletions src/MembersBundle/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ class Configuration
{
const SYSTEM_CONFIG_DIR_PATH = PIMCORE_PRIVATE_VAR . '/bundles/MembersBundle';

const SYSTEM_CONFIG_FILE_PATH = PIMCORE_PRIVATE_VAR . '/bundles/MembersBundle/config.yml';

/**
* @var array
*/
protected $config;

/**
* @var array
*/
protected $systemConfig;

/**
* @var PimcoreBundleManager
*/
Expand Down Expand Up @@ -97,24 +90,6 @@ public function getLocalizedPath($slot, $locale = null)
return $url;
}

/**
* @param array $config
*/
public function setSystemConfig($config = [])
{
$this->systemConfig = $config;
}

/**
* @param null $slot
*
* @return mixed
*/
public function getSystemConfig($slot = null)
{
return $this->systemConfig[$slot];
}

/**
* @param string $bundleName
*
Expand Down
2 changes: 1 addition & 1 deletion src/MembersBundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public function getConfigTreeBuilder()
->booleanNode('send_admin_mail_after_register')->end()
->booleanNode('send_user_mail_after_confirmed')->end()
->scalarNode('post_register_type')->end()
->scalarNode('storage_path')->cannotBeEmpty()->defaultValue('/members')->end()
->arrayNode('user')
->addDefaultsIfNotSet()
->isRequired()
->children()
->scalarNode('storage_path')->defaultValue('/members')->end()
->arrayNode('adapter')
->children()
->scalarNode('class_name')->end()
Expand Down
10 changes: 2 additions & 8 deletions src/MembersBundle/DependencyInjection/MembersExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MembersBundle\DependencyInjection;

use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
Expand All @@ -14,6 +13,8 @@ class MembersExtension extends Extension
/**
* @param array $configs
* @param ContainerBuilder $container
*
* @throws \Exception
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand All @@ -22,16 +23,10 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../Resources/config']));
$loader->load('services.yml');
//$loader->load('profiler.yml');

$configManagerDefinition = $container->getDefinition(BundleConfiguration::class);
$configManagerDefinition->addMethodCall('setConfig', [$config]);

if (file_exists(BundleConfiguration::SYSTEM_CONFIG_FILE_PATH)) {
$bundleConfig = Yaml::parse(file_get_contents(BundleConfiguration::SYSTEM_CONFIG_FILE_PATH));
$configManagerDefinition->addMethodCall('setSystemConfig', [$bundleConfig]);
}

$container->setParameter('members.registration.event.type', $config['post_register_type']);
$container->setParameter('members.resetting.retry_ttl', $config['relations']['resetting']['retry_ttl']);
$container->setParameter('members.resetting.token_ttl', $config['relations']['resetting']['token_ttl']);
Expand Down Expand Up @@ -63,6 +58,5 @@ public function load(array $configs, ContainerBuilder $container)
foreach ($config['relations']['delete_account']['form'] as $confName => $confValue) {
$container->setParameter('members_user.delete_account.form.' . $confName, $confValue);
}

}
}
7 changes: 3 additions & 4 deletions src/MembersBundle/Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class UserManager implements UserManagerInterface
*/
protected $memberStorageId;


/**
* {@inheritdoc}
*/
Expand All @@ -34,9 +33,9 @@ public function __construct(Configuration $configuration, ClassManagerInterface
$this->configuration = $configuration;
$this->classManager = $classManager;

$storagePath = $configuration->getConfig('user')['storage_path'];
if (!empty($storagePath) && ($membersStorePath = DataObject::getByPath($storagePath)) instanceof DataObject\Folder) {
$this->memberStorageId = $membersStorePath->getId();
$storagePath = $configuration->getConfig('storage_path');
if (($membersStoreObject = DataObject::getByPath($storagePath)) instanceof DataObject\Folder) {
$this->memberStorageId = $membersStoreObject->getId();
}
}

Expand Down
33 changes: 33 additions & 0 deletions src/MembersBundle/Migrations/Version00000001.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace MembersBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Pimcore\Migrations\Migration\AbstractPimcoreMigration;

class Version00000001 extends AbstractPimcoreMigration
{
/**
* @return bool
*/
public function doesSqlMigrations(): bool
{
return false;
}

/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this is the installation version and has no further meaning.
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this is the installation version and has no further meaning.
}
}
8 changes: 7 additions & 1 deletion src/MembersBundle/Resources/config/services/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ services:
public: true

# tool: installer
MembersBundle\Tool\Install: ~
MembersBundle\Tool\Install:
arguments:
$bundle: "@=service('kernel').getBundle('MembersBundle')"
calls:
- [setTokenStorageUserResolver, ['@Pimcore\Bundle\AdminBundle\Security\User\TokenStorageUserResolver']]
- [setSerializer, ['@serializer']]
- [setConfiguration, ['@MembersBundle\Configuration\Configuration']]

# tool: installer
MembersBundle\Tool\TokenGenerator: ~
Expand Down
Loading

0 comments on commit 57510fb

Please sign in to comment.