Install fluent

Last updated on
18 August 2022

To install fluent you need to use composer in your root project directory

$ composer req drupal/fluent

Enable module 

$ drush en fluent

How to use it

Fluent via global function

<?php

function hook_pre_process_something() {
  $linkTitle = using($paragraph)->value('field_link.title');
}

Inject via dependency injection

<?php

use Drupal\fluent\Fluent;


class MyClass {
  public function __construct(Fluent $fluent) {
    $this->fluent = $fluent;
  }

  public function methodUsingFluent() {
    $node = Node::load(1);
    $title = $this->fluent->using($node)->value('title');
    // ...
  }
}
services:
  class: MyClass
  arguments:
    - '@fluent.service'

Help improve this page

Page status: No known problems

You can: