HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/public_html/modules/contrib/coffee/coffee.api.php
<?php

/**
 * @file
 * Hooks provided by Coffee module.
 */

use Drupal\Core\Url;
use Drupal\views\Views;

/**
 * @addtogroup hooks
 * @{
 */

/**
 * Extend the Coffee functionality with your own commands and items.
 *
 * Here's an example of how to add content to Coffee.
 */
function hook_coffee_commands() {
  $commands = [];

  // Basic example, for 1 result.
  $commands[] = [
    'value' => Url::fromRoute('my.simple.route')->toString(),
    'label' => 'Simple',
    // Every result should include a command.
    'command' => ':simple',
  ];

  // More advanced example to include view results.
  if ($view = Views::getView('frontpage')) {
    $view->setDisplay();
    $view->preExecute();
    $view->execute();

    foreach ($view->result as $row) {
      $entity = $row->_entity;
      $commands[] = [
        'value' => $entity->toUrl()->toString(),
        'label' => 'Pub: ' . $entity->label(),
        // You can also specify commands that if the user enters, this command
        // should show.
        'command' => ':x ' . $entity->label(),
      ];
    }
  }

  return $commands;
}

/**
 * @} End of "addtogroup hooks"
 */