Drupal Feeds

Valuebound: Extend existing field widgets in Drupal 8 application using annotation plugin

Feeds from Drupal.org - Fri, 2017-10-13 11:55

Have you ever wondered how the text or email or entity reference field is extended in Drupal 8? Or how to create a custom field/widget/formatter so that it can match with the rest of fields in your Drupal application? This blog will cover everything required to extend existing field widgets in Drupal 8 using annotation plugin. 

Many developers, who recently started working on Drupal 8, may not be aware of an entire process so let’s take a closer look to everything step-by-step. Key comparisons between Drupal 7 and Drupal 8, what is an annotation, why annotation and sample use case from an Inline Entity Form step-by-step. After completing this post, you will be able to extend the field with your own methods/functions without…

Categories: Straight From Drupal

Data Import

Latest Drupal Modules - Fri, 2017-10-13 10:55
Categories: Straight From Drupal

Nuvole: How to maintain Drush commands for Drush 8 and 9 and Drupal console with the same code base.

Planet Drupal - Fri, 2017-10-13 08:48
Config Split treats all the cli the same.

Drupal 8.4 and its upgrade to Symfony 3 has made the compatibility of the global Drush 8 a bit more challenging. Drush 9 works with Drupal 8.4 but it is not stable yet and the format of how third party Drush commands are made has changed significantly.

While Drush 9 comes with a command that helps porting Drush 8 commands you will still end up maintaining very similar code in two places one with calls to drush_confirm('...') and one with $this->io()->confirm('...'). If you decide to also provide your commands for Drupal console you now have three times the burden.

Because we tried to provide the commands for Config Split for both Drush and Drupal console early on we faced this problem already more than a year ago. And now it has paid off because porting the commands to Drush 9 was very quick.

The solution is actually really simple and brings the added benefit of being able to test the business logic of the commands in the absence of Drush or Drupal console. It is all about separating the command discovery from the command logic. Drush 8, 9 and Drupal console all have a bit different ways to discover and invoke commands, but the business logic you want to implement is the same so all we have to do is to extract a common "interface" our custom service can implement and then make the command definitions wrap that and keep things DRY.

The CliService

Config Split defines a config_split.cli service with the class ConfigSplitCliService with all its dependencies injected. It has the methods \Drupal\config_split\ConfigSplitCliService::ioExport and \Drupal\config_split\ConfigSplitCliService::ioImport that implement all the commands logic and delegate the actual importing and exporting to specific methods.

The method signature for both the export and import method are more or less the same: CliService::ioMethod($arguments, $io, callable $t).

  • $arguments: The arguments passed to the command.
  • $io: This is an object that interacts with the command line, in Drush 9 and Drupal console this comes from the Symfony console component, for Drush 8 we created a custom wrapper around drush_confirm and drush_log called ConfigSplitDrush8Io.
  • $t: This is essentially a t function akin to how Drupal translates strings. Because Drupal console translates things differently we had to be a bit creative with that by adding a t method to the command.
Commands wrap the service

The Drush 8 command is essentially:

<?php
function drush_config_split_export($split = NULL) {
  // Make the magic happen.
  \Drupal::service('config_split.cli')->ioExport($split, new ConfigSplitDrush8Io(), 'dt');
}
?>

For Drush 9 we can use dependency injection and the Drush 9 command becomes essentially:

<?php
class ConfigSplitCommands extends DrushCommands {
  public function splitExport($split = NULL) {
    $this->cliService->ioExport($split, $this->io(), 'dt');
  }
}
?>

And very similar the Drupal console command:

<?php
class ExportCommand extends SplitCommandBase {
  protected function execute(InputInterface $input, OutputInterface $output) {
    $this->setupIo($input, $output);
    // Make the magic happen.
    $this->cliService->ioExport($input->getOption('split'), $this->getIo(), [$this, 't']);
  }
}
?> Testing

The ConfigSplitCliServiceTest is a KernelTest which asserts that the export works as expected by exporting to a virtual file system. The test coverage is not 100% (patches welcome) but the most important aspects for the complete and conditional splitting (blacklist/graylist) is thoroughly tested. There are no limitations on what or how you can test your CliService since it is self contained in your module and does not depend on Drush or the Drupal console. For example one could write a unit test with a mocked $io object that asserts that the messages printed to the cli are correct.

Tags: Drupal 8Drupal PlanetDrush

Nuvole: How to maintain Drush commands for Drush 8 and 9 and Drupal console with the same code base.

Feeds from Drupal.org - Fri, 2017-10-13 08:48
Config Split treats all the cli the same.

Drupal 8.4 and its upgrade to Symfony 3 has made the compatibility of the global Drush 8 a bit more challenging. Drush 9 works with Drupal 8.4 but it is not stable yet and the format of how third party Drush commands are made has changed significantly.

While Drush 9 comes with a command that helps porting Drush 8 commands you will still end up maintaining very similar code in two places one with calls to drush_confirm('...') and one with $this->io()->confirm('...'). If you decide to also provide your commands for Drupal console you now have three times the burden.

Because we tried to provide the commands for Config Split for both Drush and Drupal console early on we faced this problem already more than a year ago. And now it has paid off because porting the commands to Drush 9 was very quick.

The solution is actually really simple and brings the added benefit of being able to test the business logic of the commands in the absence of Drush or Drupal console. It is all about separating the command discovery from the command logic. Drush 8, 9 and Drupal console all have a bit different ways to discover and invoke commands, but the business logic you want to implement is the same so all we have to do is to extract a common "interface" our custom service can implement and then make the command definitions wrap that and keep things DRY.

The CliService

Config Split defines a config_split.cli service with the class ConfigSplitCliService with all its dependencies injected. It has the methods \Drupal\config_split\ConfigSplitCliService::ioExport and \Drupal\config_split\ConfigSplitCliService::ioImport that implement all the commands logic and delegate the actual importing and exporting to specific methods.

The method signature for both the export and import method are more or less the same: CliService::ioMethod($arguments, $io, callable $t).

  • $arguments: The arguments passed to the command.
  • $io: This is an object that interacts with the command line, in Drush 9 and Drupal console this comes from the Symfony console component, for Drush 8 we created a custom wrapper around drush_confirm and drush_log called ConfigSplitDrush8Io.
  • $t: This is essentially a t function akin to how Drupal translates strings. Because Drupal console translates things differently we had to be a bit creative with that by adding a t method to the command.
Commands wrap the service

The Drush 8 command is essentially:

<?php
function drush_config_split_export($split = NULL) {
  // Make the magic happen.
  \Drupal::service('config_split.cli')->ioExport($split, new ConfigSplitDrush8Io(), 'dt');
}
?>

For Drush 9 we can use dependency injection and the Drush 9 command becomes essentially:

<?php
class ConfigSplitCommands extends DrushCommands {
  public function splitExport($split = NULL) {
    $this->cliService->ioExport($split, $this->io(), 'dt');
  }
}
?>

And very similar the Drupal console command:

<?php
class ExportCommand extends SplitCommandBase {
  protected function execute(InputInterface $input, OutputInterface $output) {
    $this->setupIo($input, $output);
    // Make the magic happen.
    $this->cliService->ioExport($input->getOption('split'), $this->getIo(), [$this, 't']);
  }
}
?> Testing

The ConfigSplitCliServiceTest is a KernelTest which asserts that the export works as expected by exporting to a virtual file system. The test coverage is not 100% (patches welcome) but the most important aspects for the complete and conditional splitting (blacklist/graylist) is thoroughly tested. There are no limitations on what or how you can test your CliService since it is self contained in your module and does not depend on Drush or the Drupal console. For example one could write a unit test with a mocked $io object that asserts that the messages printed to the cli are correct.

Tags: Drupal 8Drupal PlanetDrush
Categories: Straight From Drupal

InternetDevels: More profits & less effort with Drupal multisite functionality

Planet Drupal - Fri, 2017-10-13 08:27
More profits & less effort with Drupal multisite functionality

Here is another recipe for success. You can have a whole team of websites playing for you, and they don’t have to be created from scratch or managed separately. The secret lies in Drupal’s well-developed multisite functionality. Thanks to this, Drupal will not only let you leave your competitors behind, but also multiply this effect by many times.

Read more

InternetDevels: More profits & less effort with Drupal multisite functionality

Feeds from Drupal.org - Fri, 2017-10-13 08:27
More profits & less effort with Drupal multisite functionality

Here is another recipe for success. You can have a whole team of websites playing for you, and they don’t have to be created from scratch or managed separately. The secret lies in Drupal’s well-developed multisite functionality. Thanks to this, Drupal will not only let you leave your competitors behind, but also multiply this effect by many times.

Read more
Categories: Straight From Drupal

Appnovation Technologies: A Homeowner's Guide to Drupal Security

Planet Drupal - Fri, 2017-10-13 07:00
A Homeowner's Guide to Drupal Security Working in our Managed Services department, we handle many Drupal 7 and 8 sites - all of which have one thing in common. Despite their different requirements, designs and content - they all need security updates applying and are all in need of some care and attention when it comes to securing them. If a Drupal site was a house: Securi...

Appnovation Technologies: A Homeowner's Guide to Drupal Security

Feeds from Drupal.org - Fri, 2017-10-13 07:00
A Homeowner's Guide to Drupal Security Working in our Managed Services department, we handle many Drupal 7 and 8 sites - all of which have one thing in common. Despite their different requirements, designs and content - they all need security updates applying and are all in need of some care and attention when it comes to securing them. If a Drupal site was a house: Securi...
Categories: Straight From Drupal

Views Reset

Latest Drupal Modules - Fri, 2017-10-13 06:55

Helps to add simple Reset button in views exposed forms.

Default views comes with reset button that will be standard HTML submit buttons. It will take bit more time to load the view when clicked as it will go through Drupal form submission process. However we just want to get the view loaded without any filtering applied or with just default filter. So, this module helps us to load that view without gong through complex form submission.

Categories: Straight From Drupal

Email scheduler

Latest Drupal Modules - Fri, 2017-10-13 04:10

# Email scheduler version 1.0 #

This modules allows the configure of email notifications based on user roles.

### How do I get this set up? ###

* Install and enable the module as normal
* Select the type that you need to config to send emails (/admin/config/email_scheduler)
* Go to user(/admin/people) or role (/admin/people/permissions/roles) to configure the settings

### Completed ###

Categories: Straight From Drupal

Flickr: My Laptop

Feeds from Drupal.org - Fri, 2017-10-13 02:22

m.gifford posted a photo:

My Laptop

Categories: Straight From Drupal

Platform.sh: Going Local with Lando

Planet Drupal - Thu, 2017-10-12 20:43
Going Local with Lando Crell Thu, 10/12/2017 - 20:43 Blog lando-cover

Platform.sh aims to be a complete solution for web development and hosting, while at the same time offering the flexibility to slot into your own development tools and methodologies. That's a tricky balance to strike at times: Providing a complete solution while offering maximum flexibility at the same time.

One area where we generally favor flexibility is in your local development environment. You can use whatever local development tools you're most comfortable with: MAMP, WAMP, VirtualBox, Docker, or just a native local install of your needed tools.

For those who fear analysis-paralysis from so many choices, though, we've decided to start reviewing and green-lighting recommended tools that we've found work well. And the first local development tool we can recommend is Lando.

Lando is a Docker-based local development environment that grew out of Kalabox, a VirtualBox-based local dev tool for Drupal. Lando is much more flexible and lighter-weight than a virtual machine-based solution, and has direct support for a variety of systems including Drupal, Laravel, Backdrop, and WordPress. It even goes beyond PHP with support for Node.js, Python, and Ruby as well, just as we do.

Like Platform.sh, Lando is controlled by a YAML configuration file. Although being Docker-based it cannot directly mimic how a Platform.sh project works, it can approximate it reasonably well.

We've included a recommended Lando configuration file in our documentation. It's fairly straightforward and easy to adapt for your particular application. It's also possible to synchronize data from a Platform.sh environment to your local Lando instance in just a few short commands. Lando's own documentation provides more details on how to trick out your local system with whatever you may need.

We still believe in allowing you to pick your own development workflow, so you don't have to change anything if you already have a workflow that works for you; if you want our advice, though, Lando is a solid option that should get you up and running locally in minutes, while Platform.sh handles all of your staging and production needs.

Larry Garfield Larry Garfield 18 Oct, 2017

How NFPA Is Bringing Paper Processes Online With Drupal 8

Upcoming Webinars - Thu, 2017-10-12 20:33

Firewise USA™'s paper application process existed for 15 years but, in 2016, the Firewise team decided to bring the process online. They chose to build this process on top of Drupal 8.

Since moving to Drupal, the Wildfire Division of the National Fire Protection Association has streamlined their processes - enabling them to more efficiently deliver on their program’s goal: teaching individuals how to adapt to living with wildfires and take community action to prevent loss of property.

Language Undefined

Content Access Booster

Latest Drupal Modules - Thu, 2017-10-12 19:31
Abstract

Boost large websites using content_access (eventually combined with other access modules like node access node reference or node access user reference

Categories: Straight From Drupal

Database

Latest Drupal Modules - Thu, 2017-10-12 19:06
Categories: Straight From Drupal

Menu Formatter

Latest Drupal Modules - Thu, 2017-10-12 18:13

-- SUMMARY --

If you would like to render a menu in an entity reference field, this is the module for you!

-- REQUIREMENTS --

You must have the menu_ui and entity_reference core modules installed.

-- INSTALLATION --

* Install as usual as per http://drupal.org/node/895232.

-- USAGE --

Categories: Straight From Drupal

Texas Creative: Drupal and Wordpress and Joomla, Oh My!

Planet Drupal - Thu, 2017-10-12 16:32

Not all CMS are created equal. Before building your next website, here are a few tips on why your CMS choice matters. (Plot twist: as told by an Account Manager.)

Read More

Texas Creative: Drupal and Wordpress and Joomla, Oh My!

Feeds from Drupal.org - Thu, 2017-10-12 16:32

Not all CMS are created equal. Before building your next website, here are a few tips on why your CMS choice matters. (Plot twist: as told by an Account Manager.)

Read More
Categories: Straight From Drupal

Amazon Elastic Transcoder

Latest Drupal Modules - Thu, 2017-10-12 15:09

A video transcoder for the video module. This project allows drupal 7 website operators to transcode video using Amazon Elastic Transcoding services on the AWS cloud. Services utilized include S3, SNS, and Elastic Transcoder.

Dependencies:

  • Video (2.x)
  • Amazon S3 (2.x-dev)
  • Amazon S3 CORS (optional w/ patches provided below)

Several patches are required to achieve full feature coverage. Issues will be listed below.

Categories: Straight From Drupal

Yet Another Blog Archive

Latest Drupal Modules - Thu, 2017-10-12 14:46

Module provides "Archive Block" as blogger.com for core blog module.

Categories: Straight From Drupal

Pages

Subscribe to My Drupal aggregator