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 Aug 23, 2016
2 parents 878ec9f + 3caee19 commit cc1f221
Show file tree
Hide file tree
Showing 93 changed files with 2,531 additions and 557 deletions.
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
}
],
"repositories": [
{
"type": "git",
"url": "https://github.com/orocrm/TranslationFormBundle.git"
},
{
"type": "composer",
"url": "https://packagist.orocrm.com"
Expand Down Expand Up @@ -56,7 +52,7 @@
"leafo/lessphp": "0.4.0",
"genemu/form-bundle": "2.2.1",
"zendframework/zend-mail": "2.1.5",
"a2lix/translation-form-bundle": "dev-1.x-symfony2.8",
"a2lix/translation-form-bundle": "1.x-dev",
"mtdowling/cron-expression": "1.0.*",
"jdare/clank-bundle": "0.1.*",
"guzzle/guzzle": "3.7.*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Oro\Bundle\ActivityListBundle\Model\ActivityListDateProviderInterface;
use Oro\Bundle\ActivityListBundle\Model\ActivityListGroupProviderInterface;
use Oro\Bundle\CommentBundle\Model\CommentProviderInterface;
use Oro\Bundle\UIBundle\Tools\HtmlTagHelper;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -49,28 +48,22 @@ class ActivityListChainProvider
/** @var string[] */
protected $ownerActivities;

/** @var HtmlTagHelper */
protected $htmlTagHelper;

/**
* @param DoctrineHelper $doctrineHelper
* @param ConfigManager $configManager
* @param TranslatorInterface $translator
* @param EntityRoutingHelper $routingHelper
* @param HtmlTagHelper $htmlTagHelper
*/
public function __construct(
DoctrineHelper $doctrineHelper,
ConfigManager $configManager,
TranslatorInterface $translator,
EntityRoutingHelper $routingHelper,
HtmlTagHelper $htmlTagHelper
EntityRoutingHelper $routingHelper
) {
$this->doctrineHelper = $doctrineHelper;
$this->configManager = $configManager;
$this->translator = $translator;
$this->routingHelper = $routingHelper;
$this->htmlTagHelper = $htmlTagHelper;
}

/**
Expand Down Expand Up @@ -410,7 +403,7 @@ public function getProviderByOwnerClass($className)
* @param string $verb
* @param ActivityList|null $list
*
* @return ActivityList
* @return ActivityList|null
*/
protected function getActivityListEntityForEntity(
$entity,
Expand All @@ -424,9 +417,8 @@ protected function getActivityListEntityForEntity(
}

$list->setSubject($provider->getSubject($entity));
$list->setDescription($this->htmlTagHelper->stripTags(
$this->htmlTagHelper->purify($provider->getDescription($entity))
));
//do not use htmlTagHelper->purify - it leads to a huge performance degradation
$list->setDescription(trim(strip_tags($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 @@ -89,7 +89,6 @@ services:
- "@oro_entity_config.config_manager"
- "@translator"
- "@oro_entity.routing_helper"
- "@oro_ui.html_tag_helper"

oro_activity_list.provider.email_recipients:
class: %oro_activity_list.provider.email_recipients.class%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Oro\Component\ChainProcessor\ProcessorInterface;
use Oro\Bundle\ApiBundle\Config\ConfigExtraInterface;
use Oro\Bundle\ApiBundle\Config\EntityDefinitionConfigExtra;
use Oro\Bundle\ApiBundle\Exception\RuntimeException;
use Oro\Bundle\ApiBundle\Metadata\MetadataExtraInterface;
use Oro\Bundle\ApiBundle\Provider\ConfigProvider;
use Oro\Bundle\ApiBundle\Provider\MetadataProvider;
Expand Down Expand Up @@ -113,6 +114,9 @@ protected function createEntitySubresources(
$config->getDefinition(),
$metadataExtras
);
if (null === $metadata) {
throw new RuntimeException(sprintf('A metadata for "%s" entity does not exist.', $entityClass));
}

$resourceExcludedActions = $resource->getExcludedActions();
$subresourceExcludedActions = !empty($resourceExcludedActions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* If "identifier_fields_only" config extra exists:
* * Adds identifier fields which were not configured yet based on an entity metadata.
* * Removes all other fields and association.
* Updates configuration of fields if other fields a linked to them using "property_path".
* Sets "exclusion_policy = all" for the entity. It means that the configuration
* of all fields and associations was completed.
* By performance reasons all these actions are done in one processor.
Expand Down Expand Up @@ -92,20 +93,12 @@ public function process(ContextInterface $context)
if ($context->hasExtra(FilterIdentifierFieldsConfigExtra::NAME)) {
$this->completeIdentifierFields($definition, $metadata, $existingFields);
} else {
$this->completeExtendedAssociations(
$definition,
$metadata->name,
$context->getVersion(),
$context->getRequestType()
);
$version = $context->getVersion();
$requestType = $context->getRequestType();
$this->completeExtendedAssociations($definition, $metadata->name, $version, $requestType);
$this->completeFields($definition, $metadata, $existingFields);
$this->completeAssociations(
$definition,
$metadata,
$existingFields,
$context->getVersion(),
$context->getRequestType()
);
$this->completeAssociations($definition, $metadata, $existingFields, $version, $requestType);
$this->completeDependentAssociations($definition, $metadata, $version, $requestType);
}
// make sure that identifier field names are set
$idFieldNames = $definition->getIdentifierFieldNames();
Expand Down Expand Up @@ -366,6 +359,57 @@ protected function completeAssociation(
}
}

/**
* @param EntityDefinitionConfig $definition
* @param ClassMetadata $metadata
* @param string $version
* @param RequestType $requestType
*/
protected function completeDependentAssociations(
EntityDefinitionConfig $definition,
ClassMetadata $metadata,
$version,
RequestType $requestType
) {
$fields = $definition->getFields();
foreach ($fields as $field) {
$propertyPath = $field->getPropertyPath();
if (!$propertyPath) {
continue;
}
$path = ConfigUtil::explodePropertyPath($propertyPath);
if (1 === count($path)) {
continue;
}

$targetDefinition = $definition;
$targetMetadata = $metadata;
foreach ($path as $targetFieldName) {
$isAssociation = $targetMetadata->hasAssociation($targetFieldName);
$targetField = $targetDefinition->getField($targetFieldName);
if (null === $targetField) {
$targetField = $targetDefinition->addField($targetFieldName);
$targetField->setExcluded();
if ($isAssociation) {
$this->completeAssociation(
$targetField,
$targetMetadata->getAssociationTargetClass($targetFieldName),
$version,
$requestType
);
}
}
if (!$isAssociation) {
break;
}
$targetDefinition = $targetField->getOrCreateTargetEntity();
$targetMetadata = $this->doctrineHelper->getEntityMetadataForClass(
$targetMetadata->getAssociationTargetClass($targetFieldName)
);
}
}
}

/**
* @param EntityDefinitionConfig $definition
*/
Expand Down
Loading

0 comments on commit cc1f221

Please sign in to comment.