To send mails to Mailhog on dev-enviroment:
- Add in settings.local.php:
$config['symfony_mailer.settings']['transport'] = 'smtp://mail:1025';
// Retrieve or initialize the captured data in local storage | |
let capturedLinks = JSON.parse(localStorage.getItem('capturedLinks') || '[]'); | |
// Function to capture all links and titles on the current page | |
function captureAllLinks() { | |
const links = document.querySelectorAll('.gs-title a.gs-title'); | |
links.forEach(link => { | |
const title = link.textContent.trim(); | |
let url = link.getAttribute('href') || ''; // Fallback to empty string if URL is null |
<?php | |
/** | |
* Scenario: We just added a new content entity via drush generate entity:content. We want to install it. | |
* The module was already enabled, so we can easily install it with 2 lines. | |
*/ | |
function superentity_demo_update_8001() | |
{ | |
$entity_type_manager = \Drupal::entityTypeManager(); | |
\Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type_manager->getDefinition('id_of_my_entity')); |
<?php | |
# If you have a SMTP setup, such as for example 'Postmark', where we have a config file `symfony_mailer.mailer_transport.postmark.yml`, | |
# this override would locally in Docksal make the Mailhog handler for what in prod is Postmark: | |
$config['symfony_mailer.mailer_transport.postmark']['configuration']['user'] = ''; | |
$config['symfony_mailer.mailer_transport.postmark']['configuration']['pass'] = ''; | |
$config['symfony_mailer.mailer_transport.postmark']['configuration']['host'] = 'mail'; | |
$config['symfony_mailer.mailer_transport.postmark']['configuration']['port'] = '1025'; |
To send mails to Mailhog on dev-enviroment:
$config['symfony_mailer.settings']['transport'] = 'smtp://mail:1025';
Let's say you just generated a content entity with drush:
drush generate entity:content
(... you go through the prompts, and the entity is created in an existing, enabled module)
In the module's .install
file, add a hook_update_N()
, for example if you previously called your entity a_super_cool_entity
/**
<?php | |
// Get the default target_id for this field from the field settings. | |
$default_target_uuid = $loaded_node->field_some_entity_ref_field->getFieldDefinition()->get('default_value')[0]['target_uuid']; | |
$default_media_entity = $this->entityRepository->loadEntityByUuid('media', $default_target_uuid); | |
$default_media_entity_id = $default_media_entity->id(); | |
// Check if is the default one. | |
$photo = $loaded_node->field_some_entity_ref_field->getValue(); | |
if ($photo[0]['target_id'] == $default_media_entity_id) { |
This is scaffolding for a React component that can properly use GSAP. We setup a random class selector to pass to GSAP when the component is ready. This assumes also some TailwindCSS classes to provide the styling.
The idea is that any Docker image can be used inside the Github Action to perform a unit of work. In this example, we use an Docker image that is intended to compile our Sphinx build files. It mounts the work directory, in this case we want it on the image docs
folder, launches the container and runs the make html
command inside the container, which compiles the code into HTML, and places it into a folder output
. The work directory is mounted to the docker container, so even ater it shuts down, we are left with the resulting files. Subsequent steps can access this directory as expected, and do whatever with it, e.g. deploy it to our server.
<?php | |
use Drupal\Component\Utility\Html; | |
// For example, we have a node with a "tracking ID" that we want to weave in as an image element to the first paragraph. | |
// This snippet will alter that markup so when we pass it through to whatever renderer, | |
// we've leveraged PHP built in XML editing to "weave" this snippet into the first <p> tag | |
$description = $some_node->body->value; | |
$tracking_markup = "<img src='whatever' />"; | |
if (!empty($description)) { | |
// We might get wonky HTML, so we don't want the xml lib warnings to flood watchdog. |