Posts

Showing posts from 2020

Redirect examples - Drupal 8

  Ex : use Symfony \ Component \ HttpFoundation \ RedirectResponse ; // Redirect to specific route or URL. return new RedirectResponse ( \ Drupal :: url ( 'user.page' ) ) ; return new RedirectResponse ( \ Drupal :: url ( 'locale.translate_status' , [ ] , [ 'absolute' = > TRUE ] ) ) ; return new RedirectResponse ( \ Drupal :: url ( '<front>' , [ ] , [ 'absolute' = > TRUE ] ) ) ; return new RedirectResponse ( Url :: fromRoute ( 'system.modules_uninstall' ) - > setAbsolute ( ) - > toString ( ) ) ; return new RedirectResponse ( Url :: fromRoute ( '<current>' ) - > toString ( ) ) ; // Redirect to external URL. use Drupal \ Core \ Routing \ TrustedRedirectResponse ; return new TrustedRedirectResponse ( 'http://www.google.com/' ) ; // If you have extended ControllerBase class or use Drupal\Core\Routing\UrlGeneratorTrait; return $this - > redirect ( '...

Drupal logger

    \Drupal::logger('content_entity_example')->notice('Source data:: %source_data',     array(         '%source_data' => print_r($source_data, TRUE),     )); 

Configure varnish in mac ios localhost

 Make apache to listen port 8080 ======================== Listen port 8080 in httpd.conf Change virtual host to 8080 Point varnish to web server ===================== vim /usr/local/etc/varnish/default.vcl # Default backend definition. Set this to point to your content server. backend default {     .host = "127.0.0.1";     .port = "8080"; } Start varnish ========= varnishd -T 127.0.0.1:2000 -a 127.0.0.1:80 -b 127.0.0.1:8080 -s file,/tmp,500M -a => end point for varnish. When accessing http://localhost you are accessing varnish and then varnish talking to http://localhost:8080 -b => server address http://localhost:8080 In the above case your website non-cached version is available at http://localhost:8080 and cached version of available at http://localhost:80

PHP compatability checker

  https://github.com/PHPCompatibility/PHPCompatibility vendor/bin/phpcs -p /mypath/to/sourcecode --standard=PHPCompatibility --extensions=module/php,inc/php,install/php,php/php --runtime-set testVersion 7.3

Ubuntu memory issue while using composer install

https://stackoverflow.com/questions/18116261/php-composer-update-cannot-allocate-memory-error-using-laravel-4

Clicks

Image

Miscellaneous

https://www.conversioncenter.net/area-conversion/from-hectare-to-cent-(Indian)

Free Drupal themes to look for

Themes https://www.drupal.org/project/bfd https://www.drupal.org/project/catalog_lite https://www.drupal.org/project/global_zymphonies_theme https://www.drupal.org/project/holy https://www.drupal.org/project/mili https://www.drupal.org/project/tara boostrap specific modules https://www.drupal.org/project/bootstrap_layouts

Programatically create layout builder section in Drupal

A sample script which can create a one column layout and store body field in it. namespace Drupal\custommodule\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\layout_builder\Section; use Drupal\layout_builder\SectionComponent; use Drupal\node\Entity\Node; use Drupal\block\Entity\Block; use Drupal\block_content\Entity\BlockContent; use Drupal\layout_builder\Entity; $entity = Node::load(10);     $section = new Section('layout_onecol');     $uuid = $entity->uuid();     $region = 'content';     $pluginConfiguration = [         'id' => 'field_block:node:article:body',         'provider' => 'layout_builder',         'label_display' => FALSE,         'view_mode' => 'default',         'entity' => $entity->id(),         'context_mapping' => [         ...