This file contains hidden or 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
| {% set has_bg_colour = paragraph.field_background_colour.value %} | |
| {# | |
| We are going to check here if the paragraph bundle has a background colour | |
| set. If so, we apply that background colour as a class on that paragraph bundle. | |
| Then, if it has a background colour, we decide that we want to give it some | |
| padding, so we also add a .has-bg class to it. If individual paragraph bundles | |
| need to override that, we can use removceClass on their paragraph.html.twig files. | |
| #} |
This file contains hidden or 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 | |
| /** | |
| * snippets for dealing with custom entities | |
| * Use dependency injection in actual code | |
| */ | |
| function d8_custom_entity_new_entity_form() { | |
| $entity = \Drupal::entityTypeManager() | |
| ->getStorage('the_entity_type') | |
| ->create() | |
| ->setOwnerId(\Drupal::currentUser()->id()); |
This file contains hidden or 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\require_login\EventSubscriber; | |
| use Drupal\Component\Serialization\Json; | |
| use Drupal\Core\Config\ConfigFactory; | |
| use Drupal\Core\Path\PathValidator; | |
| use Drupal\Core\Routing\CurrentRouteMatch; | |
| use Drupal\Core\Session\AccountInterface; | |
| use Drupal\Core\Url; |
This file contains hidden or 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\free_trial; | |
| use Drupal\Core\Entity\EntityTypeManager; | |
| use Drupal\user\RoleInterface; | |
| /** | |
| * Class CreateLicense. | |
| */ | |
| class CreateLicense implements CreateLicenseInterface { |
This file contains hidden or 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 | |
| // Load all licenses for current user that grant a specific license | |
| $existing = $this->entityTypeManager->getStorage('commerce_license') | |
| ->loadByProperties([ | |
| 'license_role' => 'machine_name_of_role', | |
| 'uid' => \Drupal::current_user()->id() | |
| ]); |
This file contains hidden or 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 hook_element_info_alter(). | |
| */ | |
| function scholarrx_user_registration_element_info_alter(array &$info) { | |
| $info['password_confirm']['#process'][] = 'scholarrx_process_password_confirm'; | |
| } | |
| function scholarrx_process_password_confirm(&$element, FormStateInterface $form_state, &$complete_form) { |
This file contains hidden or 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_promotion_prorated\Plugin\Commerce\PromotionOffer; | |
| use Drupal\commerce_license\Entity\License; | |
| use Drupal\commerce_order\Adjustment; | |
| use Drupal\commerce_order\Entity\Order; | |
| use Drupal\commerce_order\Entity\OrderItem; | |
| use Drupal\commerce_order\Entity\OrderItemInterface; | |
| use Drupal\commerce_price\Price; |
This file contains hidden or 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\module\Plugin\rest\resource; | |
| use Drupal\commerce_order\Entity\Order; | |
| use Drupal\commerce_payment\Entity\Payment; | |
| use Drupal\commerce_payment\Exception\PaymentGatewayException; | |
| use Drupal\commerce_payment\PaymentGatewayManager; | |
| use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase; | |
| use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\SupportsRefundsInterface; |
This file contains hidden or 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 | |
| // using PayPal EC as example | |
| /** @var PaymentGatewayManager $plugin */ | |
| $plugin = \Drupal::service('plugin.manager.commerce_payment_gateway'); | |
| // Get the id of config from `drupal debug:config | grep paypal` | |
| /** @var Config $config */ | |
| $config = \Drupal::service('config.factory') |
This file contains hidden or 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_form_customizations\Plugin\Commerce\ReportType; | |
| use Drupal\commerce_order\Adjustment; | |
| use Drupal\commerce_order\Entity\Order; | |
| use Drupal\commerce_order\Entity\OrderInterface; | |
| use Drupal\commerce_order\Entity\OrderItemInterface; | |
| use Drupal\commerce_price\Price; | |
| use Drupal\commerce_promotion\Entity\CouponInterface; |