Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
novicell/dds_global_content / src / GlobalContentTrait.php
Size: Mime:
<?php
/**
 * Created by PhpStorm.
 * User: pve
 * Date: 29/03/2018
 * Time: 21.45
 */

namespace Drupal\dds_global_content;

trait GlobalContentTrait {

  public function getGlobalContents(): GlobalContentViewBuilder {
    /** @var GlobalContentViewBuilder $service */
    static $service = null;
    if (is_null($service)) {
      $service = \Drupal::service('global_contents');
    }
    return $service;
  }

  /**
   * @param string $machine_name
   * @deprecated Use gc() instead.
   *
   * @return array
   *   A render array to render the global content.
   */
  public function c($machine_name) {
    /** @var GlobalContentViewBuilder $service */
    $service = $this->getGlobalContents();
    return $service->get($machine_name)->toRenderable();
  }

  /**
   * Returns a render array representation of the object.
   *
   * @param string $machine_name
   * @param string|null $langcode
   *
   * @return array
   *   A render array to render the global content.
   */
  public function gc($machine_name, $langcode = NULL) {
    /** @var GlobalContentViewBuilder $service */
    $service = $this->getGlobalContents();
    return $service->get($machine_name, $langcode)->toRenderable();
  }

}