All

Drupal 8: How to Return a Markup incl. a URL link

Drupal 8 provides a useful helper funciton $entity->toLink(..). You must return it by converting to a string by using ->toString() at the end.

public function foo(Request $request = NULL) {

  $id = $request->get('id');  // from query string
  $entity = YourEntity::load($id);

  $message = $this->t('Check at @url.', [
    '@url' => $entity->toLink('<TEXT_TO_LINK_HERE>', 'edit-form')->toString(),
  ]);

  return [
    '#type' => 'markup',
    '#markup' => $message, 
  ];
}
続きを読む

PHP: How to Install Zend Framework v1 (zf1)

You can install Zend Framework v2 as follows:

composer require zendframework/zendframework

However Zend Framework v1 has already been obsolete, therefore when you want to install it manually, you need to download the library from GitHub, and copy (move) to your application directory.

続きを読む

Drupal 8: How to Translate Your Custom Block Fields

If you want to create a module that provides your custom block(s) in Drupal 8, for instance, you can only write two source codes such as my_custom_block.info.yml and MyCustomBlock.php. However how can you make custom configuration fields on your custom block translatable? The answer is to add one additional file my_custom_block.yml as a schema file.

続きを読む
Subscribe to All