This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//The submit handler function: | |
public function reImportAllFiles(array &$form, FormStateInterface $form_state){ | |
$form_state->setRedirect('vrt_dram.batch', array()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//If anonymous | |
if (\Drupal::currentUser()->isAnonymous()) { | |
// Do something.. | |
} | |
//if user has role | |
$roles = \Drupal::currentUser()->getRoles(); | |
if(!in_array("administrator", $roles)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
///////////////////JSON | |
//How to render Json from Drupal 8 | |
$response = new Response(); | |
$response->setContent(json_encode($mydata)); | |
$response->headers->set('Content-Type', 'application/json'); | |
return $response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//If is frontpage | |
$on_frontpage = \Drupal::service('path.matcher')->isFrontPage(); | |
//Match canonical route | |
$route_match = \Drupal::routeMatch(); | |
if ($route_match->getRouteName() == 'entity.node.canonical') { | |
// Do something.. | |
} |
NewerOlder