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 | |
define('DRUPAL_ROOT', getcwd()); | |
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); | |
$admin = user_load(1); | |
$pass = isset($_GET['pass'])? trim($_GET['pass']): 'pass'; | |
$uid = isset($_GET['uid'])? trim($_GET['uid']): 1; | |
user_save($admin, array('pass' => $pass)); |
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
/** | |
* Implements hook_views_pre_view(). | |
*/ | |
function icareix_global_views_pre_view(ViewExecutable $view, $display_id, array &$args) { | |
if ($view->id() == 'job_list' && $display_id == 'page_1') { | |
if (\Drupal::currentUser()->hasPermission('add job entities')) { | |
$url = \Drupal\Core\Url::fromUserInput('/admin/structure/job/add'); | |
$empty = \Drupal::l(t('Add new job'), $url); | |
$options = array( |
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
drush updatedb --entity-updates - update DB data after entity update. |
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
use Drupal\image\Entity\ImageStyle; | |
$file = \Drupal\file\Entity\File::load(17); | |
$uri = $file->getFileUri(); | |
$url = ImageStyle::load('small_user_pic')->buildUrl($uri); |
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
entity_delete_multiple('tracking_log', \Drupal::entityQuery('tracking_log')->execute()); | |
entity_delete_multiple('tracking_service', \Drupal::entityQuery('tracking_service')->execute()); |
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
$file_data = \Drupal::request()->files->get('ava'); | |
$file = file_get_contents($file_data); | |
$file = file_save_data($file); | |
return $file->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
$url = 'url'; | |
$url_object = \Drupal::service('path.validator')->getUrlIfValid($url); | |
$route = $url_object->getRouteName(); |
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
// Clean local task cache by tag. | |
\Drupal\Core\Cache\Cache::invalidateTags(['config:block.block.icareix_local_tasks']); |
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
// from entity | |
$tags = \Drupal::entityTypeManager()->getStorage('job')->load(1)->getCacheTags(); | |
// from views | |
$tags = \Drupal\views\Entity\View::load('front')->getCacheTags(); |
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
$route_name = \Drupal::service('current_route_match')->getRouteName(); |
OlderNewer