Ejemplo n.º 1
0
 /**
  * Checks if a field lookup key is translated. This will be TRUE unless one
  * of the following conditions applies:
  *
  * - The key is the Drupal\Core\Language\Language::LANGCODE_NOT_SPECIFIED
  *   constant.
  * - The key is the LANGUAGE_NONE constant from Drupal 7.
  * - The key is the string 'und'.
  *
  * @param Node $key
  *  The key to check.
  *
  * @return boolean
  */
 public static function isTranslation(Node $key)
 {
     if ($key instanceof ClassConstantLookupNode) {
         $constant = $key->getClassName() . '::' . $key->getConstantName();
         return $constant != '\\Drupal\\Core\\Language\\Language::LANGCODE_NOT_SPECIFIED';
     } elseif ($key instanceof ConstantNode) {
         return $key->getConstantName() != 'LANGUAGE_NONE';
     } elseif ($key instanceof StringNode) {
         return $key->toValue() != 'und';
     } else {
         return TRUE;
     }
 }
 private function toScalar(Node $node)
 {
     return $node->toValue();
 }