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 Oct 8, 2016
2 parents 8117e09 + 9fa17e2 commit f2fded9
Show file tree
Hide file tree
Showing 150 changed files with 3,311 additions and 747 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oro\Bundle\ActivityBundle\Form\DataTransformer;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManager;

Expand Down Expand Up @@ -34,28 +36,34 @@ class ContextsToViewTransformer implements DataTransformerInterface
/** @var EntityTitleResolverInterface */
protected $entityTitleResolver;

/** @var bool */
protected $collectionModel;

/**
* @param EntityManager $entityManager
* @param ConfigManager $configManager
* @param TranslatorInterface $translator
* @param TokenStorageInterface $securityTokenStorage
* @param EventDispatcherInterface $dispatcher
* @param EntityTitleResolverInterface $entityTitleResolver
* @param bool $collectionModel True if result should be Collection instead of array
*/
public function __construct(
EntityManager $entityManager,
ConfigManager $configManager,
TranslatorInterface $translator,
TokenStorageInterface $securityTokenStorage,
EventDispatcherInterface $dispatcher,
EntityTitleResolverInterface $entityTitleResolver
EntityTitleResolverInterface $entityTitleResolver,
$collectionModel = false
) {
$this->entityManager = $entityManager;
$this->configManager = $configManager;
$this->translator = $translator;
$this->securityTokenStorage = $securityTokenStorage;
$this->dispatcher = $dispatcher;
$this->entityTitleResolver = $entityTitleResolver;
$this->collectionModel = $collectionModel;
}

/**
Expand All @@ -67,7 +75,7 @@ public function transform($value)
return '';
}

if (is_array($value)) {
if (is_array($value) || $value instanceof Collection) {
$result = [];
$user = $this->securityTokenStorage->getToken()->getUser();
foreach ($value as $target) {
Expand Down Expand Up @@ -130,6 +138,10 @@ public function reverseTransform($value)
$result = array_merge($result, $entities);
}

if ($this->collectionModel) {
$result = new ArrayCollection($result);
}

return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$this->translator,
$this->securityTokenStorage,
$this->dispatcher,
$this->entityTitleResolver
$this->entityTitleResolver,
$options['collectionModel']
)
);
}
Expand Down Expand Up @@ -108,7 +109,8 @@ public function configureOptions(OptionsResolver $resolver)

$resolver->setDefaults([
'tooltip' => false,
'configs' => $defaultConfigs
'configs' => $defaultConfigs,
'collectionModel' => false,
]);

$resolver->setNormalizer(
Expand Down
12 changes: 6 additions & 6 deletions src/Oro/Bundle/ActivityBundle/Resources/views/macros.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
#}
{% macro activity_contexts(entity, target, checkTarget) %}
<script type="text/template" id="activity-context-activity-list">
<div class="context-item" style="border: none" data-cid="<%= entity.cid %>">
<span data-id="<%= entity.get('targetId') %>">
<span class="<%= entity.get('icon') %>"></span>
<div class="context-item" style="border: none" data-cid="<%- entity.cid %>">
<span data-id="<%- entity.get('targetId') %>">
<span class="<%- entity.get('icon') %>"></span>
<% if (entity.get('link')) { %>
<a href="<%= entity.get('link') %>">
<span class="context-label"><%= entity.get('title') %></span>
<a href="<%- entity.get('link') %>">
<span class="context-label"><%- entity.get('title') %></span>
</a>
<% } else { %>
<span class="context-label"><%= entity.get('title') %></span>
<span class="context-label"><%- entity.get('title') %></span>
<% } %>
{% if resource_granted('EDIT', entity) %}
<i class="icon-remove"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testBuildForm()
$this->dispatcher,
$this->entityTitleResolver
);
$type->buildForm($builder, []);
$type->buildForm($builder, ['collectionModel' => false]);
}

public function testSetDefaultOptions()
Expand All @@ -92,7 +92,8 @@ public function testSetDefaultOptions()
->method('setDefaults')
->with(
[
'tooltip' => false,
'tooltip' => false,
'collectionModel' => false,
'configs' => [
'placeholder' => 'oro.activity.contexts.placeholder',
'allowClear' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/Bundle/ActivityListBundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class CalendarEventActivityListProvider implements ActivityListProviderInterface
*/
public function getTemplate()
{
return 'OroCalendarBundle:CalendarEvent:js/activityItemTemplate.js.twig';
return 'OroCalendarBundle:CalendarEvent:js/activityItemTemplate.html.twig';
}
...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'OroActivityListBundle:ActivityList/js:view.js.twig' %}
{% extends 'OroActivityListBundle:ActivityList/js:view.html.twig' %}

{% block activityIcon %}
<i class="{{ oro_entity_config_value(entityClass, 'icon')|raw }}"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@
<div class="container-fluid accordion"
data-page-component-module="oroactivitylist/js/app/components/activity-list-component"
data-page-component-options="{{ options|json_encode }}"></div>
{% include 'OroActivityListBundle:ActivityList:js/list.js.twig' with {'id': 'template-activity-list'} %}
{% include 'OroActivityListBundle:ActivityList:js/view.js.twig' with {'id': 'template-activity-item'} %}
{% include 'OroActivityListBundle:ActivityList:js/list.html.twig' with {'id': 'template-activity-list'} %}
{% include 'OroActivityListBundle:ActivityList:js/view.html.twig' with {'id': 'template-activity-item'} %}
{% for activityClass, activityOptions in configuration %}
{% include activityOptions.template with {'id': ('template-activity-item-' ~ activityClass) } %}
{% endfor %}
{% include 'OroCommentBundle:Comment/js:list.js.twig' with {'id': 'template-activity-item-comment'} %}
{% include 'OroCommentBundle:Comment/js:list.html.twig' with {'id': 'template-activity-item-comment'} %}
{% endblock %}

{% placeholder oro_activity_list_after with {entityClass: oro_class_name(entity, true), entityId: entity.id} %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function getOrganization($activityEntity)
*/
public function getTemplate()
{
return 'OroCalendarBundle:CalendarEvent:js/activityItemTemplate.js.twig';
return 'OroCalendarBundle:CalendarEvent:js/activityItemTemplate.html.twig';
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends 'OroActivityListBundle:ActivityList/js:activityItemTemplate.js.twig' %}
{% extends 'OroActivityListBundle:ActivityList/js:activityItemTemplate.html.twig' %}
{% import 'OroActivityBundle::macros.html.twig' as AC %}

{% set entityClass = 'Oro\\Bundle\\CalendarBundle\\Entity\\CalendarEvent' %}
{% set entityName = oro_entity_config_value(entityClass, 'label')|trans %}

{% block activityDetails %}
{{ entityName|raw }}
{{ entityName }}
<% var template = (verb == 'create')
? {{ 'oro.calendar.calendarevent.added_by'|trans|json_encode|raw }}
: {{ 'oro.calendar.calendarevent.updated_by'|trans|json_encode|raw }};
Expand Down Expand Up @@ -37,8 +37,8 @@
{% set action %}
<% if (editable) { %>
<a href="#" class="action item-edit-button"
title="{{ 'oro.calendar.calendarevent.update_event'|trans({'{{ entity }}': entityName})|raw }}">
<i class="icon-edit hide-text">{{ 'oro.calendar.calendarevent.update_event'|trans({'{{ entity }}': entityName})|raw }}</i>
title="{{ 'oro.calendar.calendarevent.update_event'|trans({'{{ entity }}': entityName}) }}">
<i class="icon-edit hide-text">{{ 'oro.calendar.calendarevent.update_event'|trans({'{{ entity }}': entityName}) }}</i>
</a>
<% } %>
{% endset %}
Expand All @@ -47,8 +47,8 @@
{% set action %}
<% if (removable) { %>
<a href="#" class="action item-remove-button"
title="{{ 'oro.calendar.calendarevent.delete_event'|trans({'{{ entity }}': entityName})|raw }}">
<i class="icon-trash hide-text">{{ 'oro.calendar.calendarevent.delete_event'|trans({'{{ entity }}': entityName})|raw }}</i>
title="{{ 'oro.calendar.calendarevent.delete_event'|trans({'{{ entity }}': entityName}) }}">
<i class="icon-trash hide-text">{{ 'oro.calendar.calendarevent.delete_event'|trans({'{{ entity }}': entityName}) }}</i>
</a>
<% } %>
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

<script type="text/template" id="activity-context-activity-list">
<div class="context-item" style="border: none" data-cid="<%= entity.cid %>">
<span data-id="<%= entity.get('targetId') %>">
<span class="<%= entity.get('icon') %>"></span>
<span data-id="<%- entity.get('targetId') %>">
<span class="<%- entity.get('icon') %>"></span>
<% if (entity.get('link')) { %>
<a href="<%= entity.get('link') %>">
<span class="context-label"><%= entity.get('title') %></span>
<a href="<%- entity.get('link') %>">
<span class="context-label"><%- entity.get('title') %></span>
</a>
<% } else { %>
<span class="context-label"><%= entity.get('title') %></span>
<span class="context-label"><%- entity.get('title') %></span>
<% } %>
<% if (editable) { %>
<i class="icon-remove"></i>
Expand Down
2 changes: 1 addition & 1 deletion src/Oro/Bundle/CommentBundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function isCommentsEnabled($entityClass)
}
...
```
The comment widget will be rendered into ```div.message .comment``` node of js/activityItemTemplate.js.twig template.
The comment widget will be rendered into ```div.message .comment``` node of js/activityItemTemplate.html.twig template.

Attachment configuration
------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="comment-title">
<% if (avatarUrl) { %>
<img class="comment-title-avatar" src="<%= avatarUrl %>" />
<img class="comment-title-avatar" src="<%- avatarUrl %>" />
<% } else { %>
<div class="comment-title-avatar no-avatar" />
<% } %>
Expand All @@ -25,23 +25,23 @@
<div class="attachment-item">
<div class="thumbnail">
<% if (attachmentThumbnail) { %>
<a href="<%= attachmentURL %>" data-gallery="comment-view-<%= relationId %>" class="no-hash" title="<%= attachmentFileName %>">
<span class="thumbnail" style="background: url('<%= attachmentThumbnail %>') 50% 50% no-repeat;"></span>
<a href="<%- attachmentURL %>" data-gallery="comment-view-<%- relationId %>" class="no-hash" title="<%- attachmentFileName %>">
<span class="thumbnail" style="background: url('<%- attachmentThumbnail %>') 50% 50% no-repeat;"></span>
</a>
<% } else { %>
<i class="fa <%= attachmentIcon %> fa-3x"></i>
<i class="fa <%- attachmentIcon %> fa-3x"></i>
<% } %>
</div>
<div class="dropdown link-to-record">
<a class="no-hash dropdown-toggle file-menu" href="javascript: void(0);" data-toggle="dropdown">
<i class="fa <%= attachmentIcon %>"></i> <%= attachmentFileName %>
<i class="fa <%- attachmentIcon %>"></i> <%- attachmentFileName %>
</a>
<ul class="dropdown-menu file-menu" role="menu" aria-labelledby="dropdownMenu">
<a class="no-hash" tabindex="-1" href="<%= attachmentURL %>">
<%= _.__('oro.comment.attachment.download') %><span>(<%= attachmentSize %>)</span>
<a class="no-hash" tabindex="-1" href="<%- attachmentURL %>">
<%= _.__('oro.comment.attachment.download') %><span>(<%- attachmentSize %>)</span>
</a>
<% if (attachmentThumbnail) { %>
<a class="view-image no-hash" tabindex="-1" data-gallery="comment-view-<%= relationId %>" href="<%= attachmentURL %>"><%= _.__('oro.comment.attachment.view') %></a>
<a class="view-image no-hash" tabindex="-1" data-gallery="comment-view-<%- relationId %>" href="<%- attachmentURL %>"><%= _.__('oro.comment.attachment.view') %></a>
<% } %>
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
data-page-component-options="{{ options|json_encode }}">
</div>
</div>
{% include 'OroCommentBundle:Comment/js:list.js.twig' with {'id': 'template-activity-item-comment'} %}
{% include 'OroCommentBundle:Comment/js:list.html.twig' with {'id': 'template-activity-item-comment'} %}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<% if (attachmentURL) { %>
<div class="attachment-item">
<i class="icon-paper-clip"></i>
<a href="<%= attachmentURL %>" class="no-hash" title="<%= attachmentFileName %>"><%= attachmentFileName %></a> (<%= attachmentSize %>)
<a href="<%- attachmentURL %>" class="no-hash" title="<%- attachmentFileName %>"><%- attachmentFileName %></a> (<%- attachmentSize %>)
<button class="btn btn-link icon-remove remove-attachment" type="button"></button>
</div>
<% } %>
Expand Down
74 changes: 74 additions & 0 deletions src/Oro/Bundle/ConfigBundle/Config/ConfigChangeSet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Oro\Bundle\ConfigBundle\Config;

class ConfigChangeSet
{
/** @var array */
protected $changeSet = [];

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

/**
* Returns config change set
*
* @return array [name => ['new' => value, 'old' => value], ...]
*/
public function getChanges()
{
return $this->changeSet;
}

/**
* Checks whenever configuration value is changed
*
* @param string $name
*
* @return bool
*/
public function isChanged($name)
{
return !empty($this->changeSet[$name]);
}

/**
* Retrieve new value from change set
*
* @param string $name
*
* @return mixed
* @throws \LogicException
*
*/
public function getNewValue($name)
{
if (!$this->isChanged($name)) {
throw new \LogicException('Could not retrieve value for given key');
}

return $this->changeSet[$name]['new'];
}

/**
* Retrieve old value from change set
*
* @param string $name
*
* @return mixed
* @throws \LogicException
*/
public function getOldValue($name)
{
if (!$this->isChanged($name)) {
throw new \LogicException('Could not retrieve value for given key');
}

return $this->changeSet[$name]['old'];
}
}
9 changes: 7 additions & 2 deletions src/Oro/Bundle/ConfigBundle/Config/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ public function flush()
* Save settings
*
* @param array $settings
*
* @return ConfigChangeSet
*/
public function save($settings)
{
$settings = $this->normalizeSettings($settings);
if (empty($settings)) {
return;
return new ConfigChangeSet([]);
}

$oldValues = [];
Expand All @@ -222,11 +224,14 @@ public function save($settings)

list($updated, $removed) = $this->getScopeManager()->save($event->getSettings());

$event = new ConfigUpdateEvent($this->buildChangeSet($updated, $removed, $oldValues));
$changeSet = new ConfigChangeSet($this->buildChangeSet($updated, $removed, $oldValues));
$event = new ConfigUpdateEvent($changeSet);
$this->eventDispatcher->dispatch(ConfigUpdateEvent::EVENT_NAME, $event);

// clear a local cache
$this->localCache->clear();

return $changeSet;
}

/**
Expand Down
Loading

0 comments on commit f2fded9

Please sign in to comment.