Skip to content

Instantly share code, notes, and snippets.

@nidaismailshah
nidaismailshah / ParagraphLabel.php
Created May 5, 2020 09:30
Alter Label or other attributes in rendered entities in Acquia ContentHub 2.x. Label appears when entities are listed in Acquia Lift Campaign Builder. Register this as an event subscriber within a custom drupal 8 module.
<?php
namespace Drupal\<custom_module>\EventSubscriber\Cdf;
use Drupal\acquia_contenthub\AcquiaContentHubEvents;
use Drupal\acquia_contenthub\Event\CreateCdfEntityEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
*
@nidaismailshah
nidaismailshah / content_hub_custom.php
Last active August 29, 2018 14:07
Enables Acquia Content Hub to work with content translations and custom languages on drupal 7
<?php
/**
* To make Content hub work with Drupal 7 content translation module and custom languages (with hyphen in the langcode)
* these hook implementations will need to be added to a custom module on the both the publisher and the subscriber site.
* Two text fields field_tnid and field_custom_language will also need to be created on the required content types to
* carry the tnid and custom language information across.
* The fields should be hidden from the node view and node edit form as these should only be used by this code.
*/
@nidaismailshah
nidaismailshah / addLiftTitleToParagraphs.php
Last active March 26, 2018 16:22
Add (and alter) attributes to Acquia Content Hub Entities before pushing to content hub.
<?php
use Acquia\ContentHubClient\Entity as ContentHubEntity;
use Acquia\ContentHubClient\Attribute;
/**
* @param \Acquia\ContentHubClient\Entity $contenthub_entity
*
* Implements hook_acquia_contenthub_cdf_from_drupal_alter()
*/
@nidaismailshah
nidaismailshah / FeatureContext.php
Created December 20, 2015 15:42 — forked from jhedstrom/FeatureContext.php
Step-definition for complex node structure (field collection + entity reference).
<?php
/**
* @Given /^I am viewing a product with the following related products:$/
*/
public function assertRelatedProducts(TableNode $relatedProducts) {
// First, create a product.
$product = (object) array(
'title' => 'Parent Product',
'type' => 'product',
'uid' => 1,