Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Sep 7, 2016
2 parents cc1f221 + 360dd0b commit f6f5b33
Show file tree
Hide file tree
Showing 222 changed files with 3,438 additions and 948 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CHANGELOG for 1.10.0
===================
This changelog references the relevant changes (new features, changes and bugs) done in 1.10.0 versions.
* The application has been upgraded to Symfony 2.8
* The application has been upgraded to Symfony 2.8 (Symfony 2.8.10 doesn't supported because of [Symfony issue](https://github.com/symfony/symfony/issues/19840))
* Added support php 7
* Changed minimum required php version to 5.5.9

Expand Down
19 changes: 19 additions & 0 deletions UPGRADE-1.10.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
UPGRADE FROM 1.10.0 to 1.10.1
=============================

####EntityExtendBundle
- `Oro\Bundle\EntityExtendBundle\Migration\EntityMetadataHelper`
- `getEntityClassByTableName` deprecated, use `getEntityClassesByTableName` instead
- removed property `tableToClassMap` in favour of `tableToClassesMap`
- `Oro\Bundle\EntityExtendBundle\Migration\ExtendOptionsBuilder
- construction signature was changed now it takes next arguments:
`EntityMetadataHelper` $entityMetadataHelper,
`FieldTypeHelper` $fieldTypeHelper,
`ConfigManager` $configManager
- removed property `tableToEntityMap` in favour of `tableToEntitiesMap`
- renamed method `getEntityClassName` in favour of `getEntityClassNames`
- `Oro\Bundle\EntityExtendBundle\Migration\ExtendOptionsParser`
- construction signature was changed now it takes next arguments:
`EntityMetadataHelper` $entityMetadataHelper,
`FieldTypeHelper` $fieldTypeHelper,
`ConfigManager` $configManager
19 changes: 19 additions & 0 deletions UPGRADE-1.9.9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
UPGRADE FROM 1.9.8 to 1.9.9
===========================

####EntityExtendBundle
- `Oro\Bundle\EntityExtendBundle\Migration\EntityMetadataHelper`
- `getEntityClassByTableName` deprecated, use `getEntityClassesByTableName` instead
- removed property `tableToClassMap` in favour of `tableToClassesMap`
- `Oro\Bundle\EntityExtendBundle\Migration\ExtendOptionsBuilder
- construction signature was changed now it takes next arguments:
`EntityMetadataHelper` $entityMetadataHelper,
`FieldTypeHelper` $fieldTypeHelper,
`ConfigManager` $configManager
- removed property `tableToEntityMap` in favour of `tableToEntitiesMap`
- renamed method `getEntityClassName` in favour of `getEntityClassNames`
- `Oro\Bundle\EntityExtendBundle\Migration\ExtendOptionsParser`
- construction signature was changed now it takes next arguments:
`EntityMetadataHelper` $entityMetadataHelper,
`FieldTypeHelper` $fieldTypeHelper,
`ConfigManager` $configManager
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ext-mbstring": "*",
"ext-gd": "*",
"ext-xml": "*",
"symfony/symfony": "2.8.*",
"symfony/symfony": "2.8.*, !=2.8.10",
"twig/twig": "1.24.*",
"doctrine/orm": "2.5.1",
"doctrine/doctrine-bundle": "1.6.3",
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@
</exclude>
</whitelist>
</filter>

</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function getDatagridContext(DatagridConfiguration $config)
{
return [
ContextHelper::ENTITY_CLASS_PARAM => $this->gridConfigurationHelper->getEntity($config),
ContextHelper::DATAGRID_PARAM => $config->offsetGetByPath('[name]'),
ContextHelper::DATAGRID_PARAM => $config->getName(),
ContextHelper::GROUP_PARAM => $this->groups,
];
}
Expand Down
1 change: 0 additions & 1 deletion src/Oro/Bundle/ActionBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ services:
- [setGroups, [['', 'datagridRowAction']]]
tags:
- { name: oro_datagrid.extension }
lazy: true

oro_action.datagrid.action.action_widget_action:
class: %oro_action.datagrid.action.action_widget_action.class%
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/Bundle/ActivityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": ">=5.5.9",
"symfony/symfony": "2.8.*",
"symfony/symfony": "2.8.*, !=2.8.10",
"oro/ui-bundle": "dev-master",
"oro/entity-config-bundle": "dev-master",
"oro/entity-extend-bundle": "dev-master",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ protected function getListDataIdsForInheritances(QueryBuilder $qb, $entityClass,
$inheritanceQb,
$inheritanceTarget,
$key,
':entityId'
':entityId',
$this->config->get('oro_activity_list.grouping')
);

$this->activityListFilterHelper->addFiltersToQuery($inheritanceQb, $filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function hasInheritances($entityClass)
* @param array $inheritanceTarget
* @param string $aliasSuffix
* @param string $entityIdExpr
* @param bool $head Head activity only
*/
public function applyInheritanceActivity(QueryBuilder $qb, $inheritanceTarget, $aliasSuffix, $entityIdExpr)
public function applyInheritanceActivity(QueryBuilder $qb, $inheritanceTarget, $aliasSuffix, $entityIdExpr, $head)
{
$alias = 'ta_' . $aliasSuffix;
$qb->leftJoin('activity.' . $inheritanceTarget['targetClassAlias'], $alias);
Expand All @@ -68,6 +69,9 @@ public function applyInheritanceActivity(QueryBuilder $qb, $inheritanceTarget, $
$aliasSuffix
)->getDQL()
));
if ($head) {
$qb->andWhere($qb->expr()->andX('activity.head = true'));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function isApplicableTarget($entityClass, $accessible = true);
public function getSubject($entity);

/**
* Return text representation. Should be a plain text.
*
* @param object $entity
*
* @return string|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ protected function getActivityListEntityForEntity(
}

$list->setSubject($provider->getSubject($entity));
//do not use htmlTagHelper->purify - it leads to a huge performance degradation
$list->setDescription(trim(strip_tags($provider->getDescription($entity))));
$list->setDescription($provider->getDescription($entity));
$this->setDate($entity, $provider, $list);
$list->setOwner($provider->getOwner($entity));
if ($provider instanceof ActivityListUpdatedByProviderInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,35 @@ public function testHasInheritancesConfigured()

public function testApplyInheritanceActivity()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
->getMock();
$expr = new Expr();
$em->expects($this->any())->method('getExpressionBuilder')->willReturn($expr);
$mainQb = $this->prepareMock();

$this->activityInheritanceTargetsHelper->applyInheritanceActivity(
$mainQb,
[
'targetClass' => 'Acme\Bundle\AcmeBundle\Entity\Contact',
'targetClassAlias' => 'contact_e8d5b2ba',
'path' => [
'accounts'
]
],
0,
':entityId',
false
);

$mainQb = new QueryBuilder($em);
$inheritedQb = clone $mainQb;
$expectedDQL = 'SELECT activity.id, activity.updatedAt '
. 'FROM ActivityList activity '
. 'LEFT JOIN activity.contact_e8d5b2ba ta_0 '
. 'WHERE ta_0.id IN(SELECT inherit_0.id'
. ' FROM Acme\Bundle\AcmeBundle\Entity\Contact inherit_0'
. ' INNER JOIN inherit_0.accounts t_0_0 WHERE t_0_0.id = :entityId)';

$mainQb->select('activity.id, activity.updatedAt');
$mainQb->from('ActivityList', 'activity');
$this->assertSame($expectedDQL, $mainQb->getDQL());
}

$em->expects($this->any())
->method('createQueryBuilder')
->willReturn($inheritedQb);
$this->registry->expects($this->any())
->method('getManagerForClass')
->willReturn($em);
public function testApplyInheritanceActivityHeadOnly()
{
$mainQb = $this->prepareMock();

$this->activityInheritanceTargetsHelper->applyInheritanceActivity(
$mainQb,
Expand All @@ -143,16 +153,44 @@ public function testApplyInheritanceActivity()
]
],
0,
':entityId'
':entityId',
true
);

$expectedDQL = 'SELECT activity.id, activity.updatedAt '
. 'FROM ActivityList activity '
. 'LEFT JOIN activity.contact_e8d5b2ba ta_0 '
. 'WHERE ta_0.id IN(SELECT inherit_0.id'
. ' FROM Acme\Bundle\AcmeBundle\Entity\Contact inherit_0'
. ' INNER JOIN inherit_0.accounts t_0_0 WHERE t_0_0.id = :entityId)';
. ' INNER JOIN inherit_0.accounts t_0_0 WHERE t_0_0.id = :entityId) AND activity.head = true';

$this->assertSame($expectedDQL, $mainQb->getDQL());
}

/**
* @return QueryBuilder
*/
protected function prepareMock()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
->getMock();
$expr = new Expr();
$em->expects($this->any())->method('getExpressionBuilder')->willReturn($expr);

$mainQb = new QueryBuilder($em);
$inheritedQb = clone $mainQb;

$mainQb->select('activity.id, activity.updatedAt');
$mainQb->from('ActivityList', 'activity');

$em->expects($this->any())
->method('createQueryBuilder')
->willReturn($inheritedQb);
$this->registry->expects($this->any())
->method('getManagerForClass')
->willReturn($em);

return $mainQb;
}
}
2 changes: 1 addition & 1 deletion src/Oro/Bundle/ActivityListBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": ">=5.5.9",
"symfony/symfony": "2.8.*",
"symfony/symfony": "2.8.*, !=2.8.10",
"oro/ui-bundle": "dev-master",
"oro/organization-bundle": "dev-master",
"oro/entity-config-bundle": "dev-master",
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/Bundle/AddressBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"require": {
"php": ">=5.5.9",
"symfony/symfony": "2.8.*",
"symfony/symfony": "2.8.*, !=2.8.10",
"doctrine/orm": ">=2.2.3,<2.5-dev",
"doctrine/doctrine-bundle": "1.1.*",
"friendsofsymfony/rest-bundle": "1.5.0-RC2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ protected function getApiFormTypeGuessers(ContainerBuilder $container)
public function getTagKeyForExtension()
{
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'extended-type'
? 'extended_type'
: 'alias';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Oro\Bundle\ApiBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

use Oro\Bundle\ApiBundle\Util\DependencyInjectionUtil;

class ConstraintTextExtractorConfigurationCompilerPass implements CompilerPassInterface
{
const EXCEPTION_TEXT_EXTRACTOR_SERVICE_ID = 'oro_api.constraint_text_extractor';
const EXCEPTION_TEXT_EXTRACTOR_TAG = 'oro.api.constraint_text_extractor';

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
DependencyInjectionUtil::registerTaggedServices(
$container,
self::EXCEPTION_TEXT_EXTRACTOR_SERVICE_ID,
self::EXCEPTION_TEXT_EXTRACTOR_TAG,
'addExtractor'
);
}
}
11 changes: 6 additions & 5 deletions src/Oro/Bundle/ApiBundle/Model/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ public static function create($title, $detail = null)
/**
* Creates an instance of Error class represents a violation of validation constraint.
*
* @param string|Label $title A short, human-readable summary of the problem that should not change
* from occurrence to occurrence of the problem.
* @param string|Label|null $detail A human-readable explanation specific to this occurrence of the problem
* @param string|Label $title A short, human-readable summary of the problem that should not change
* from occurrence to occurrence of the problem.
* @param string|Label|null $detail A human-readable explanation specific to this occurrence of the problem
* @param integer|null $statusCode A status code should be returned for the error. Default value - 400
*
* @return Error
*/
public static function createValidationError($title, $detail = null)
public static function createValidationError($title, $detail = null, $statusCode = Response::HTTP_BAD_REQUEST)
{
return self::create($title, $detail)->setStatusCode(Response::HTTP_BAD_REQUEST);
return self::create($title, $detail)->setStatusCode($statusCode);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Oro/Bundle/ApiBundle/OroApiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Oro\Component\ChainProcessor\DependencyInjection\LoadProcessorsCompilerPass;
use Oro\Bundle\ApiBundle\DependencyInjection\Compiler\ApiDocConfigurationCompilerPass;
use Oro\Bundle\ApiBundle\DependencyInjection\Compiler\ConfigurationCompilerPass;
use Oro\Bundle\ApiBundle\DependencyInjection\Compiler\ConstraintTextExtractorConfigurationCompilerPass;
use Oro\Bundle\ApiBundle\DependencyInjection\Compiler\DataTransformerConfigurationCompilerPass;
use Oro\Bundle\ApiBundle\DependencyInjection\Compiler\EntityAliasesConfigurationCompilerPass;
use Oro\Bundle\ApiBundle\DependencyInjection\Compiler\ExceptionTextExtractorConfigurationCompilerPass;
Expand All @@ -29,6 +30,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new EntityAliasesConfigurationCompilerPass());
$container->addCompilerPass(new ExclusionProviderConfigurationCompilerPass());
$container->addCompilerPass(new ExceptionTextExtractorConfigurationCompilerPass());
$container->addCompilerPass(new ConstraintTextExtractorConfigurationCompilerPass());
$container->addCompilerPass(
new LoadProcessorsCompilerPass(
'oro_api.processor_bag',
Expand Down
20 changes: 14 additions & 6 deletions src/Oro/Bundle/ApiBundle/Processor/Shared/CollectFormErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,27 @@
use Oro\Component\ChainProcessor\ContextInterface;
use Oro\Component\ChainProcessor\ProcessorInterface;
use Oro\Bundle\ApiBundle\Processor\FormContext;
use Oro\Bundle\ApiBundle\Request\ConstraintTextExtractorInterface;
use Oro\Bundle\ApiBundle\Model\Error;
use Oro\Bundle\ApiBundle\Model\ErrorSource;
use Oro\Bundle\ApiBundle\Request\Constraint;
use Oro\Bundle\ApiBundle\Validator\Constraints\ConstraintWithStatusCodeInterface;
use Oro\Bundle\ApiBundle\Util\ValueNormalizerUtil;

/**
* Collects errors occurred during the the form submit and adds them into the Context.
*/
class CollectFormErrors implements ProcessorInterface
{
/** @var ConstraintTextExtractorInterface */
protected $constraintTextExtractor;

/**
* @param ConstraintTextExtractorInterface $constraintTextExtractor
*/
public function __construct(ConstraintTextExtractorInterface $constraintTextExtractor)
{
$this->constraintTextExtractor = $constraintTextExtractor;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -176,7 +186,7 @@ protected function getFormErrorTitle(FormError $formError)
return Constraint::EXTRA_FIELDS;
}

return ValueNormalizerUtil::humanizeClassName(get_class($cause->getConstraint()), 'Constraint');
return $this->constraintTextExtractor->getConstraintType($cause->getConstraint());
}

// undefined constraint type
Expand All @@ -193,9 +203,7 @@ protected function getFormErrorStatusCode(FormError $formError)
$cause = $formError->getCause();
if ($cause instanceof ConstraintViolation) {
$constraint = $cause->getConstraint();
if ($constraint instanceof ConstraintWithStatusCodeInterface) {
return $constraint->getStatusCode();
}
return $this->constraintTextExtractor->getConstraintStatusCode($constraint);
}

return null;
Expand Down
Loading

0 comments on commit f6f5b33

Please sign in to comment.