This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements template_preprocess_paragraph(). | |
* | |
* @param array $variables | |
* An associative array containing: | |
* - elements: An array of elements to display in view mode. | |
* - paragraph: The paragraph object. | |
* - view_mode: View mode; e.g., 'full', 'teaser'... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\book; | |
use Drupal\Core\Entity\EntityManagerInterface; | |
use Drupal\Core\Render\RendererInterface; | |
use Drupal\Core\StringTranslation\TranslationInterface; | |
use Drupal\Core\Config\ConfigFactoryInterface; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\commerce_order_number\Form; | |
use Drupal\commerce_order_number\OrderNumber; | |
use Drupal\commerce_order_number\OrderNumberFormatterInterface; | |
use Drupal\commerce_order_number\OrderNumberGeneratorManager; | |
use Drupal\Core\Config\ConfigFactoryInterface; | |
use Drupal\Core\Form\ConfigFormBase; | |
use Drupal\Core\Form\FormStateInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\drupalbook\Form; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormStateInterface; | |
use Egulias\EmailValidator\EmailValidator; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// /modules/custom/drupalbook/src/Plugin/Block/CartBlock.php | |
namespace Drupal\drupalbook\Plugin\Block; | |
use Drupal\commerce_cart\CartProviderInterface; | |
use Drupal\Core\Block\BlockBase; | |
use Drupal\Core\Entity\EntityTypeManagerInterface; | |
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | |
use Symfony\Component\DependencyInjection\ContainerInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// /modules/custom/drupalbook/src/Controller/ModalFormContactController.php | |
namespace Drupal\drupalbook\Controller; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use Drupal\Core\Ajax\AjaxResponse; | |
use Drupal\Core\Ajax\OpenModalDialogCommand; | |
use Drupal\Core\Controller\ControllerBase; | |
use Drupal\Core\Form\FormBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\did_this_help\Plugin\views\filter; | |
use Drupal\views\Plugin\views\filter\InOperator; | |
/** | |
* Filters by given list of yes/no options. | |
* | |
* @ingroup views_filter_handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// from https://www.drupal.org/project/did_this_help | |
// https://drupalbook.org/drupal/914-writing-integration-views | |
/** | |
* @file | |
* Provide views data for did_this_help.module. | |
*/ | |
/** | |
* Implements hook_views_data(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Select | |
// Get single value: | |
$query = \Drupal::database()->select('node_field_data', 'n'); | |
$query->addField('n', 'nid'); | |
$query->condition('n.title', 'About Us'); | |
$query->range(0, 1); | |
$nid = $query->execute()->fetchField(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// modules/custom/drupalbook_examples/src/EventSubscriber/DrupalbookExamplesSubscriber.php | |
namespace Drupal\drupalbook_examples\EventSubscriber; | |
use Symfony\Component\HttpFoundation\RedirectResponse; | |
use Symfony\Component\HttpKernel\KernelEvents; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
class DrupalbookExamplesSubscriber implements EventSubscriberInterface { |
NewerOlder