Best practices for developers

Overview of standards and best practices for developers Ideally, all code that is included in Drupal Core and contributed modules, themes, and distributions will be secure, internationalized, maintainable, and efficient. In order to facilitate this, the Drupal community has developed a set of guidelines and standards for developers to follow. Most of these standards can be found under Best practices on Drupal.org Standards and best practices that developers should be aware of include: Security

BigPipe

The default BigPipe service. Hierarchy class \Drupal\big_pipe\Render\BigPipe implements BigPipeInterface File core/modules/big_pipe/src/Render/BigPipe.php, line 26 Namespace Drupal\big_pipe\Render Members Name Modifiers Type Description BigPipe::$configFactory protected property The config factory. BigPipe::$eventDispatcher protected property The event dispatcher. BigPipe::$httpKernel protected property The HTTP kernel. BigPipe::$renderer protected

BeforeCommand

An AJAX command for calling the jQuery before() method. The 'insert/before' command instructs the client to use jQuery's before() method to insert the given HTML content before each of elements matched by the given selector. This command is implemented by Drupal.AjaxCommands.prototype.insert() defined in misc/ajax.js. Hierarchy class \Drupal\Core\Ajax\InsertCommand implements CommandInterface, CommandWithAttachedAssetsInterface uses CommandWithAttachedAssetsTraitclass \Drupal\Core\Ajax\BeforeCo

BeforeCommand::render

public BeforeCommand::render() Implements Drupal\Core\Ajax\CommandInterface:render(). Overrides InsertCommand::render File core/lib/Drupal/Core/Ajax/BeforeCommand.php, line 24 Class BeforeCommand An AJAX command for calling the jQuery before() method. Namespace Drupal\Core\Ajax Code public function render() { return array( 'command' => 'insert', 'method' => 'before', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings

batch_get

&batch_get() Retrieves the current batch. Related topics Batch operations Creates and processes batch operations. File core/includes/form.inc, line 878 Functions for form and batch generation and processing. Code function &batch_get() { // Not drupal_static(), because Batch API operates at a lower level than most // use-cases for resetting static variables, and we specifically do not want a // global drupal_static_reset() resetting the batch information. Functions // that ar

batch_set

batch_set($batch_definition) Adds a new batch. Batch operations are added as new batch sets. Batch sets are used to spread processing (primarily, but not exclusively, forms processing) over several page requests. This helps to ensure that the processing is not interrupted due to PHP timeouts, while users are still able to receive feedback on the progress of the ongoing operations. Combining related operations into distinct batch sets provides clean code independence for each batch set, ensuring

BatchStorageInterface::update

public BatchStorageInterface::update(array $batch) Updates a batch. Parameters array $batch: The array representing the batch to update. File core/lib/Drupal/Core/Batch/BatchStorageInterface.php, line 35 Class BatchStorageInterface Defines a common interface for batch storage operations. Namespace Drupal\Core\Batch Code public function update(array $batch);

batch_process

batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = NULL) Processes the batch. This function is generally not needed in form submit handlers; Form API takes care of batches that were set during form submission. Parameters \Drupal\Core\Url|string $redirect: (optional) Either path or Url object to redirect to when the batch has finished processing. Note that to simply force a batch to (conditionally) redirect to a custom location after it is finished processing but to otherwise

BatchStorageInterface::delete

public BatchStorageInterface::delete($id) Deletes a batch. Parameters int $id: The ID of the batch to delete. File core/lib/Drupal/Core/Batch/BatchStorageInterface.php, line 43 Class BatchStorageInterface Defines a common interface for batch storage operations. Namespace Drupal\Core\Batch Code public function delete($id);

BatchStorageInterface::cleanup

public BatchStorageInterface::cleanup() Cleans up failed or old batches. File core/lib/Drupal/Core/Batch/BatchStorageInterface.php, line 48 Class BatchStorageInterface Defines a common interface for batch storage operations. Namespace Drupal\Core\Batch Code public function cleanup();