You are here

public function MobileDeviceDetectionAttributes::get in Mobile Device Detection 8

Same name and namespace in other branches
  1. 8.3 src/Object/MobileDeviceDetectionAttributes.php \Drupal\mobile_device_detection\Object\MobileDeviceDetectionAttributes::get()
  2. 8.2 src/Object/MobileDeviceDetectionAttributes.php \Drupal\mobile_device_detection\Object\MobileDeviceDetectionAttributes::get()

File

src/Object/MobileDeviceDetectionAttributes.php, line 12

Class

MobileDeviceDetectionAttributes

Namespace

Drupal\mobile_device_detection\Object

Code

public function get($attribute = null) {
  $file = __DIR__ . '/../../config/attributes/attributes.yml';
  if (!file_exists($file)) {
    return false;
  }
  $attributes = Yaml::parse(file_get_contents($file))['attributes'];
  if (!is_null($attribute)) {
    return $attributes[$attribute];
  }
  return $attributes;
}