Commit a38e3925 authored by dj3c1t's avatar dj3c1t

test canOpenUrl dans controleurs et views

parent 39c87bc3
......@@ -13,6 +13,12 @@ use Dj3c1t\HttpBundle\REST\RestResponse;
class DerivationController extends Controller {
public function addAction(Request $request) {
$sm = $this->get('sourceml.source_manager');
if(!$sm->canOpenUrl()) {
return new RestResponse(json_encode(array(
"error" => 'cannot read external url from the server'
)));
}
$data = $request->request->all();
if(
!isset($data["id"])
......@@ -28,7 +34,6 @@ class DerivationController extends Controller {
"error" => "can't load source informations"
)));
}
$sm = $this->get('sourceml.source_manager');
if(!$sm->userCan("edit", $source)) {
return new RestResponse(json_encode(array(
"error" => "your are not allowed to edit this source"
......
......@@ -181,6 +181,20 @@ class SourceController extends Controller {
public function addReferenceAction(Request $request, $sourceType) {
$sm = $this->get('sourceml.source_manager');
if(!$sm->canOpenUrl()) {
$this->get('session')->getFlashBag()->add(
'error',
'cannot read external url from the server'
);
return $this->redirect(
$this->generateUrl(
'account_source_index',
array(
"sourceType" => $sourceType
)
)
);
}
$em = $this->get('doctrine')->getManager();
$source = new Source();
if(!($SourceType = $sm->getSourceType($sourceType))) {
......
......@@ -154,6 +154,8 @@
</div>
</div>
{% if sourceml.canOpenUrl() %}
<div class="row">
<div class="col-xs-12">
<h3>Sources de dérivation</h3>
......@@ -176,6 +178,7 @@
</div>
</div>
</div>
{% endif %}
{% endblock %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment