You are here

MobileDeviceDetectionAttributes.php in Mobile Device Detection 8

File

src/Object/MobileDeviceDetectionAttributes.php
View source
<?php

namespace Drupal\mobile_device_detection\Object;

use Symfony\Component\Yaml\Yaml;
class MobileDeviceDetectionAttributes {

  /**
   * {@inheritdoc}
   */
  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;
  }

}