Skip to content

Commit

Permalink
MIG-23: Update standard to next version
Browse files Browse the repository at this point in the history
  • Loading branch information
anaelChardan committed Aug 7, 2017
1 parent b62df69 commit 35db819
Show file tree
Hide file tree
Showing 22 changed files with 472 additions and 933 deletions.
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ app/file_storage/*
app/bootstrap.php.cache
build/
vendor
bin
/bin/*
!/bin/docker
/bin/docker/*
!/bin/docker/pim-initialize.sh
!/bin/docker/pim-front.sh
!/bin/merge-coverage
!bin/console
composer.phar
composer.lock

var/cache/*
var/logs/*
var/bootstrap.php.cache

node_modules
web/dist/*
web/cache/*
npm-debug.log

/docker/*
!/docker/akeneo.conf
!/docker/httpd.conf
docker-compose.yml
422 changes: 0 additions & 422 deletions UPGRADE-1.7.md

Large diffs are not rendered by default.

126 changes: 103 additions & 23 deletions UPGRADE-1.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TODO

```bash
export PIM_DIR=/path/to/your/pim/installation
cp app/SymfonyRequirements.php $PIM_DIR/app
cp var/SymfonyRequirements.php $PIM_DIR/app
cp app/PimRequirements.php $PIM_DIR/app

mv $PIM_DIR/app/config/pim_parameters.yml $PIM_DIR/app/config/pim_parameters.yml.bak
Expand Down Expand Up @@ -74,11 +74,13 @@ rm -rf $PIM_DIR/upgrades/schema
* [Optional] If you had added dependencies to your project, you will need to do it again in your `composer.json`.
You can display the differences of your previous composer.json in `$PIM_DIR/composer.json.bak`.

```JSON
```json
{
"require": {
"your/dependency": "version",
"your/other-dependency": "version",
"your/dependency": "version",
"your/other-dependency": "version"
}
}
```

* Then run the command to update your dependencies:
Expand All @@ -94,8 +96,8 @@ In this case, go to the chapter "Migrate your custom code" before running the da
6. Then you can migrate your database using:

```bash
rm -rf app/cache
php app/console doctrine:migration:migrate --env=prod
rm -rf var/cache
php bin/console doctrine:migration:migrate --env=prod
```

7. Then, generate JS translations and re-generate the PIM assets:
Expand All @@ -106,16 +108,94 @@ TODO

## Migrate your custom code

TODO
We extracted the "values" logic outside of products. It means that any entity having the `EntityWithValuesInterface`
would be able to be processed. As a reminder, a value is composed of an attribute, a locale, a scope, and a data. As values are not only
for product anymore, we decided to rename `ProductValueInterface` to `ValueInterface`. This impacts a lot of classes too.

The following commands help to migrate references to these classes or services.

```bash
## Classes
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Bundle\\VersioningBundle\\Normalizer\\Flat\\AbstractProductValueDataNormalizer/Pim\\Bundle\\VersioningBundle\\Normalizer\\Flat\\AbstractValueDataNormalizer/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Bundle\\VersioningBundle\\Normalizer\\Flat\\ProductValueNormalizer/Pim\\Bundle\\VersioningBundle\\Normalizer\\Flat\\ValueNormalizer/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Completeness\\Checker\\ProductValueCompleteChecker/Pim\\Component\\Catalog\\Completeness\\Checker\\ValueCompleteChecker/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Completeness\\Checker\\ProductValueCompleteCheckerInterface/Pim\\Component\\Catalog\\Completeness\\Checker\\ValueCompleteCheckerInterface/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\DateProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\DateValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\MediaProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\MediaValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\MetricProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\MetricValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\OptionProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\OptionValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\OptionsProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\OptionsValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\PriceCollectionProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\PriceCollectionValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\ProductValueFactoryInterface/Pim\\Component\\Catalog\\Factory\\Value\\ValueFactoryInterface/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValue\\ScalarProductValueFactory/Pim\\Component\\Catalog\\Factory\\Value\\ScalarValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValueCollectionFactory/Pim\\Component\\Catalog\\Factory\\ProductValueCollectionFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\Factory\\ProductValueFactory/Pim\\Component\\Catalog\\Factory\\ValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\ProductValue\\DateProductValue/Pim\\Component\\Catalog\\Value\\DateValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\ProductValue\\MediaProductValue/Pim\\Component\\Catalog\\Value\\MediaValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\ProductValue\\MetricProductValue/Pim\\Component\\Catalog\\Value\\MetricValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\ProductValue\\OptionProductValue/Pim\\Component\\Catalog\\Value\\OptionValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Catalog\\ProductValue\\OptionsProductValue/Pim\\Component\\Catalog\\Value\\OptionsValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Connector\\ArrayConverter\\FlatToStandard\\ProductValue/Pim\\Component\\Connector\\ArrayConverter\\FlatToStandard\\Value/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Enrich\\Converter\\EnrichToStandard\\ProductValueConverter/Pim\\Component\\Enrich\\Converter\\EnrichToStandard\\ValueConverter/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\Enrich\\Converter\\StandardToEnrich\\ProductValueConverter/Pim\\Component\\Enrich\\Converter\\StandardToEnrich\\ValueConverter/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\ReferenceData\\Factory\\ProductValue\\ReferenceDataCollectionProductValueFactory/Pim\\Component\\ReferenceData\\Factory\\Value\\ReferenceDataCollectionValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\ReferenceData\\Factory\\ProductValue\\ReferenceDataProductValueFactory/Pim\\Component\\ReferenceData\\Factory\\Value\\ReferenceDataValueFactory/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\ReferenceData\\ProductValue\\ReferenceDataCollectionProductValue/Pim\\Component\\ReferenceData\\Value\\ReferenceDataCollectionValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Component\\ReferenceData\\ProductValue\\ReferenceDataProductValue/Pim\\Component\\ReferenceData\\Value\\ReferenceDataValue/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/Pim\\Bundle\\CatalogBundle\\DependencyInjection\\Compiler\\RegisterProductValueValueFactoryPass/Pim\\Bundle\\CatalogBundle\\DependencyInjection\\Compiler\\RegisterValueFactoryPass/g'

## Services
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value/pim_catalog\.factory\.value/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value_collection/pim_catalog\.factory\.value_collection/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.text/pim_catalog\.factory\.value\.text/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.textarea/pim_catalog\.factory\.value\.textarea/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.number/pim_catalog\.factory\.value\.number/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.boolean/pim_catalog\.factory\.value\.boolean/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.identifier/pim_catalog\.factory\.value\.identifier/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.metric/pim_catalog\.factory\.value\.metric/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.price_collection/pim_catalog\.factory\.value\.price_collection/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.option/pim_catalog\.factory\.value\.option/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.options/pim_catalog\.factory\.value\.options/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.file/pim_catalog\.factory\.value\.file/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.image/pim_catalog\.factory\.value\.image/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.date/pim_catalog\.factory\.value\.date/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.model\.product_value\.interface/pim_catalog\.model\.value\.interface/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_versioning\.serializer\.normalizer\.flat\.product_value/pim_versioning\.serializer\.normalizer\.flat\.value/g'

## Parameters
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value_collection\.class/pim_catalog\.factory\.value_collection\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.class/pim_catalog\.factory\.value\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.scalar\.class/pim_catalog\.factory\.value\.scalar\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.metric\.class/pim_catalog\.factory\.value\.metric\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.price_collection\.class/pim_catalog\.factory\.value\.price_collection\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.option\.class/pim_catalog\.factory\.value\.option\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.options\.class/pim_catalog\.factory\.value\.options\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.media\.class/pim_catalog\.factory\.value\.media\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.factory\.product_value\.date\.class/pim_catalog\.factory\.value\.date\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_serializer\.normalizer\.flat\.product_value\.class/pim_serializer\.normalizer\.flat\.value\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.scalar\.class/pim_catalog\.entity\.value\.scalar\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.media\.class/pim_catalog\.entity\.value\.media\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.metric\.class/pim_catalog\.entity\.value\.metric\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.option\.class/pim_catalog\.entity\.value\.option\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.options\.class/pim_catalog\.entity\.value\.options\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.date\.class/pim_catalog\.entity\.value\.date\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_catalog\.entity\.product_value\.price_collection\.class/pim_catalog\.entity\.value\.price_collection\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_enrich\.converter\.standard_to_enrich\.product_value\.class/pim_enrich\.converter\.standard_to_enrich\.value\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_enrich\.converter\.enrich_to_standard\.product_value\.class/pim_enrich\.converter\.enrich_to_standard\.value\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_reference_data\.factory\.product_value\.reference_data\.class/pim_reference_data\.factory\.value\.reference_data\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_reference_data\.factory\.product_value\.reference_data_collection\.class/pim_reference_data\.factory\.value\.reference_data_collection\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_reference_data\.product_value\.reference_data\.class/pim_reference_data\.value\.reference_data\.class/g'
find ./src/ -type f -print0 | xargs -0 sed -i 's/pim_reference_data\.product_value\.reference_data_collection\.class/pim_reference_data\.value\.reference_data_collection\.class/g'
```

## Building the front-end with webpack

1. Install the latest npm and nodejs https://nodejs.org/en/download/package-manager/
2. Run `php app/console pim:installer:dump-require-paths`
3. Run `php app/console assets:install --symlink`
1. Install nodejs (tested with >=6.11.0 until 8.2.1) and npm 5.0.3, you can follow the instructions here - https://nodejs.org/en/download/package-manager/ or install with homebrew - `brew install node@6` should install both these versions.
2. Run `php bin/console pim:installer:dump-require-paths`
3. Run `php bin/console assets:install --symlink`
4. Create a file in your project root called `package.json` with the following contents:

```js
```json
{
"name": "your-project-name",
"version": "1.0.0",
Expand All @@ -130,7 +210,7 @@ TODO

5. Run `npm install` inside your project root
6. Run `npm run webpack`
7. Run `php app/console cache:clear`
7. Run `php bin/console cache:clear`
8. Add to your .gitignore the following lines:

```
Expand All @@ -142,35 +222,35 @@ TODO

If you have any custom Javascript you will need to make the following changes:

When you require a html template, you no longer have to use the `text!` prefix.
When you require a html template inside a module, you no longer have to use the `text!` prefix. This is handled in [webpack.config.js](https://github.com/akeneo/pim-community-dev/blob/master/webpack.config.js#L78).

Before:

```javascript
define([
'text!oro/template/system/tab/system'
],
define([
'text!oro/template/system/tab/system'
],
```
After:
```javascript
define([
'oro/template/system/tab/system'
],
define([
'oro/template/system/tab/system'
],
```
Instead of using `module.config()` to access module configuration, you must instead use `__moduleConfig`.
Before:
```javascript
Routing.generate(module.config().url, {identifier: datagridView.id});
Routing.generate(module.config().url, {identifier: datagridView.id});
```
After:
```javascript
```javascript
Routing.generate(__moduleConfig.url, {identifier: datagridView.id});
```
```
You can now write custom Javascript using es2017 (es2015 and above) syntax. We use babel to transpile the JS during the webpack build step. Check out the full guide here - https://babeljs.io/learn-es2015/
While you are developing custom Javscript, you can run `npm run webpack-watch` to automatically compile and refresh your changes. Otherwise, you can run `npm run webpack` without refresh to see your changes.
While you are developing custom Javscript, you can run `npm run webpack-watch` to automatically compile and refresh your changes. Otherwise, you can run `npm run webpack` without refresh to see your changes. This command will also minify your code.
40 changes: 32 additions & 8 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ public function registerBundles()
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');

if (is_file($file = __DIR__.'/config/config_'.$this->getEnvironment().'_local.yml')) {
if (is_file($file = $this->getRootDir() . '/config/config_' . $this->getEnvironment() . '_local.yml')) {
$loader->load($file);
}

if (isset($this->bundleMap['DoctrineMongoDBBundle'])) {
$loader->load(__DIR__ .'/config/config_mongodb.yml');
}
}

/**
Expand Down Expand Up @@ -130,8 +126,6 @@ protected function getSymfonyBundles()
return [
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
// Uncomment the following line to use MongoDB implementation
// new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
Expand Down Expand Up @@ -177,4 +171,34 @@ protected function getOroBundles()
new Oro\Bundle\UserBundle\OroUserBundle(),
];
}

/**
* @return string
*/
public function getRootDir(): string
{
return __DIR__;
}

/**
* @return string
*/
public function getCacheDir(): string
{
return dirname(__DIR__)
. DIRECTORY_SEPARATOR
. 'var'
. DIRECTORY_SEPARATOR
. 'cache'
. DIRECTORY_SEPARATOR
. $this->getEnvironment();
}

/**
* @return string
*/
public function getLogDir(): string
{
return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'logs';
}
}
Loading

0 comments on commit 35db819

Please sign in to comment.