Skip to content

Commit

Permalink
Merge branch '1.7' into 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
glye committed Jul 28, 2017
2 parents 906c02e + 422fba2 commit a3a63c9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
Expand Up @@ -9,9 +9,9 @@
>{{ "role.policy.limitation.location.udw_button"|trans({}, "ezrepoforms_role") }}</button>
<div>
<ul id="{{form.limitationValues.vars.id}}-selected-location">
{% for limitationValue in form.limitationValues.vars.value %}
{% for limitationValue in form.limitationValues.vars.value|split(',') %}
<li>
{{ render( controller( "ez_content:view", {'contentId': limitationValue, 'viewType': '_platformui_content_name'} ) ) }}
{{ render( controller( "ez_content:viewAction", {'locationId': limitationValue, 'viewType': '_platformui_content_name'} ) ) }}
</li>
{% endfor %}
</ul>
Expand Down
21 changes: 20 additions & 1 deletion lib/Limitation/DataTransformer/UDWBasedValueTransformer.php
Expand Up @@ -24,7 +24,12 @@ public function transform($value)
return null;
}

return implode(',', $value);
$locations = [];
foreach ($value as $key => $path) {
$locations[] = $this->extractLocationIdFromPath($path);
}

return implode(',', $locations);
}

public function reverseTransform($value)
Expand All @@ -35,4 +40,18 @@ public function reverseTransform($value)

return explode(',', $value);
}

/**
* Extracts and returns an item id from a path, e.g. /1/2/58 => 58.
*
* @param string $path
*
* @return mixed
*/
private function extractLocationIdFromPath($path)
{
$pathParts = explode('/', trim($path, '/'));

return array_pop($pathParts);
}
}
Expand Up @@ -36,7 +36,7 @@ public function __construct(RoleService $roleService)
*/
public function validate($value, Constraint $constraint)
{
if (!$value instanceof RoleData) {
if (!$value instanceof RoleData || $value->identifier === null) {
return;
}

Expand Down
Expand Up @@ -61,6 +61,19 @@ public function testNotRoleData()
$this->validator->validate($value, new UniqueRoleIdentifier());
}

public function testNullRoleIdentifier()
{
$value = new RoleData(['identifier' => null]);
$this->roleService
->expects($this->never())
->method('loadRoleByIdentifier');
$this->executionContext
->expects($this->never())
->method('buildViolation');

$this->validator->validate($value, new UniqueRoleIdentifier());
}

public function testValid()
{
$identifier = 'foo_identifier';
Expand Down

0 comments on commit a3a63c9

Please sign in to comment.