You are here

LayoutCanvasAwareTrait.php in TMGMT Translator Smartling 8.4

File

modules/tmgmt_smartling_acquia_cohesion/src/LayoutCanvasAwareTrait.php
View source
<?php

namespace Drupal\tmgmt_smartling_acquia_cohesion;

use Drupal\cohesion\LayoutCanvas\LayoutCanvas;
trait LayoutCanvasAwareTrait {

  /**
   * @param $json
   * @return bool|LayoutCanvas
   */
  public function isLayoutCanvas($json) {
    if (preg_match('/^\\{"canvas":\\[(.*)\\}$/', $json) !== 1 || empty(json_decode((string) $json))) {
      return false;
    }
    return new LayoutCanvas($json);
  }

}

Traits