This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: jeromechevalier | |
* Date: 29/10/2018 | |
* Time: 14:15 | |
*/ | |
namespace Drupal\portal_users\Plugin\views\filter; |
This file contains 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
public function displayListDownloads() | |
{ | |
$header = array( | |
array('data' => t('Name'), 'field' => 'name'), | |
array('data' => t('File ID'), 'field' => 'download_file__target_id'), | |
); | |
// Retrieve accessible location id by the user |
This file contains 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
// Load user information | |
$user = User::load(\Drupal::currentUser()->id()); | |
$tempList = $user->get('field_user_sites')->referencedEntities(); | |
$sitesId = array(); | |
if (count($tempList) > 0) { | |
foreach ($tempList as $site) { | |
$sitesId[] = $site->id(); | |
} | |
} |
This file contains 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
$fields['physical_location'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Physical Location')) | |
->setDescription(t('Reference the idenfication number of a physical location')) | |
->setRevisionable(FALSE) | |
->setSetting('target_type', 'site_entity') | |
->setSetting('handler', 'default') | |
->setTranslatable(FALSE) | |
->setDisplayOptions('form', [ | |
'type' => 'entity_reference_autocomplete', | |
'settings' => [ | |
'match_operator' => 'CONTAINS', |
This file contains 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
$fields['download_file'] = BaseFieldDefinition::create('file') | |
->setLabel(t('Forecast data')) | |
->setSetting('file_directory', 'forecast') | |
->setSetting('max_filesize', '10MB') | |
->setSetting('file_extensions', 'csv') | |
->setSetting('description_field', FALSE) | |
->setDisplayOptions('form', [ | |
'label' => 'hidden', | |
'type' => 'file_generic', | |
'weight' => 4, |
This file contains 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
$myevent = new AINotificationEvent(['recipient' => 1,'priority' => $AINotificationEvent::LOW_PRIORITY,'message' => 'My message to notify','module' => AINotificationEvent::ORIGIN_AI_ENGINE]); | |
$event_dispatcher = \Drupal::service('event_dispatcher'); | |
$event_dispatcher->dispatch(AINotificationEvent::EVENT_ID, $myevent); |
This file contains 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
// Test Field | |
$render['myTextField'] = [ | |
'#type' => 'textfield', | |
'#title' => t('My title'), | |
]; | |
// Number Field | |
$render['myNumberField'] = [ |
This file contains 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
$form['submit'] = [ | |
'#type' => 'submit', | |
'#value' => $this->t('Update user'), | |
]; | |
// Add the css classes name | |
$form['submit']['#attributes']['class'][] = 'btn btn-success'; |