Skip to content

Commit

Permalink
Merge branch '1.13' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Feb 15, 2018
2 parents f6f8af3 + 9fd6ca9 commit d0fd60c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
13 changes: 11 additions & 2 deletions Controller/PlatformUIController.php
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Translation\TranslatorInterface;

class PlatformUIController extends Controller
{
Expand All @@ -25,23 +26,31 @@ class PlatformUIController extends Controller
/** @var \EzSystems\PlatformUIBundle\Loader\Loader */
private $loader;

/** @var \Symfony\Component\Translation\TranslatorInterface */
private $translator;

/** @var int */
private $comboCacheTtl;

public function __construct(Provider $configAggregator, Loader $loader, $comboCacheTtl = 0)
public function __construct(Provider $configAggregator, Loader $loader, TranslatorInterface $translator, $comboCacheTtl = 0)
{
$this->configAggregator = $configAggregator;
$this->loader = $loader;
$this->translator = $translator;
$this->comboCacheTtl = $comboCacheTtl;
}

/**
* Renders the "shell" page to run the JavaScript application.
*
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function shellAction()
public function shellAction(Request $request)
{
$this->translator->setLocale($request->getPreferredLanguage() ?: $request->getDefaultLocale());

return $this->render(
'eZPlatformUIBundle:PlatformUI:shell.html.twig',
['parameters' => $this->configAggregator->getConfig()]
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.yml
Expand Up @@ -59,6 +59,7 @@ services:
arguments:
- "@ezsystems.platformui.application_config.aggregator"
- "@ezsystems.platformui.loader.combo_loader"
- "@translator"
- "@=container.getParameter('kernel.debug') ? 0 : parameter('ezsystems.platformui.application_config.combo_loader.cache_ttl')"
parent: ezsystems.platformui.controller.base

Expand Down
5 changes: 3 additions & 2 deletions Resources/public/js/extensions/ez-draftconflict.js
Expand Up @@ -28,16 +28,17 @@ YUI.add('ez-draftconflict', function (Y) {
* @method _fireEditContentRequest
* @param {Y.eZ.ContentInfo} contentItem
* @param {Y.eZ.ContentType} contentType
* @param {String} languageCode
* @protected
*/
_fireEditContentRequest: function(contentInfo, contentType) {
_fireEditContentRequest: function(contentInfo, contentType, languageCode) {
/**
* Fired when a content needs to be edited
* @event editContentRequest
*/
this.fire('editContentRequest',{
contentInfo: contentInfo,
languageCode: contentInfo.get('mainLanguageCode'),
languageCode: languageCode ? languageCode : contentInfo.get('mainLanguageCode'),
contentType: contentType
});
},
Expand Down
Expand Up @@ -68,7 +68,8 @@ YUI.add('ez-locationviewviewservice', function (Y) {
_editContent: function (e) {
this._fireEditContentRequest(
this.get('location').get('contentInfo'),
this.get('contentType')
this.get('contentType'),
this.get('languageCode')
);
},

Expand Down
17 changes: 5 additions & 12 deletions Tests/js/views/services/assets/ez-locationviewviewservice-tests.js
Expand Up @@ -313,16 +313,9 @@ YUI.add('ez-locationviewviewservice-tests', function (Y) {
},

"Should fire `editContentRequest` when receiving an editAction event": function () {
var languageCode = "fre-FR",
contentInfo = new Mock(),
var contentInfo = new Mock(),
contentType = {};

Mock.expect(contentInfo, {
method: 'get',
args: ['mainLanguageCode'],
returns: languageCode
});

Mock.expect(this.locationMock, {
method: 'get',
args: ['contentInfo'],
Expand All @@ -331,7 +324,7 @@ YUI.add('ez-locationviewviewservice-tests', function (Y) {

this.service.set('contentType', contentType);

this.service.on('*:editContentRequest', function (e) {
this.service.on('*:editContentRequest', Y.bind(function (e) {
Assert.areSame(
contentInfo,
e.contentInfo,
Expand All @@ -343,11 +336,11 @@ YUI.add('ez-locationviewviewservice-tests', function (Y) {
"ContentType provided in the EventFacade is not the same"
);
Assert.areSame(
languageCode,
this.languageCode,
e.languageCode,
"LanguageCode provided in the EventFacade is not the same"
"LanguageCode provided in the EventFacade is the one of the displayed content"
);
});
}, this));

this.service.fire('whatever:editAction');
},
Expand Down

0 comments on commit d0fd60c

Please sign in to comment.