interface DeviceInterface (View source)

Class Device A representation of a device.

\@package Concrete\Core\Device

Constants

UNKNOWN

Device type constants, combine them like so:.

$device = new Device('Microsoft Surface', 1366, 768, Device::TABLET | Device::DESKTOP, 1.5);

and you can test against them like this:

$type = $device->getType();
// Is the type known, and if so is it mobile?
if ($type != Device::UNKNOWN && $type & Device::MOBILE) {
    // Mobile
}

MOBILE

TABLET

DESKTOP

Methods

string
getHandle()

Get the device handle.

string
getName()

Get the device name.

string
getBrand()

Get the device brand.

string
getUserAgent()

Get the device user agent.

int
getWidth()

Get the screen width of the device in pixels Be sure to adjust this by the device pixel ratio.

int
getHeight()

Get the screen height of the device in pixels Be sure to adjust this by the device pixel ratio.

int
getType()

Get the devices type this is an int that maps to a constant on this class, UNKNOWN MOBILE TABLET or DESKTOP If testing against a device and not against "UNKNOWN", do not test this directly against a device type, instead use bitwise AND to test for the enum you'd like to test:.

int
getPixelRatio()

Get the device pixel ratio.

string
getViewportHTML()

Get the HTML for this device's viewport.

string
getIconClass()

Get the class to be used for this device's icon.

bool
isMobile()

No description

bool
isTablet()

No description

bool
isDesktop()

No description

string
getDefaultOrientation()

Get the device's default orientation.

static DeviceInterface
configConstructor($handle, array $config)

Construct from given configuration.

Details

string getHandle()

Get the device handle.

Return Value

string

string getName()

Get the device name.

Return Value

string

string getBrand()

Get the device brand.

Return Value

string

string getUserAgent()

Get the device user agent.

Return Value

string

int getWidth()

Get the screen width of the device in pixels Be sure to adjust this by the device pixel ratio.

Return Value

int

int getHeight()

Get the screen height of the device in pixels Be sure to adjust this by the device pixel ratio.

Return Value

int

int getType()

Get the devices type this is an int that maps to a constant on this class, UNKNOWN MOBILE TABLET or DESKTOP If testing against a device and not against "UNKNOWN", do not test this directly against a device type, instead use bitwise AND to test for the enum you'd like to test:.

// Check if the type is known, if so is it mobile? if ($device->getType() == Device::UNKNOWN) { $is_mobile = !!($device->getPixelRatio() & Device::MOBILE); }

http://php.net/manual/en/language.operators.bitwise.php

Return Value

int

int getPixelRatio()

Get the device pixel ratio.

Return Value

int

string getViewportHTML()

Get the HTML for this device's viewport.

Return Value

string

string getIconClass()

Get the class to be used for this device's icon.

Return Value

string

bool isMobile()

No description

Return Value

bool

bool isTablet()

No description

Return Value

bool

bool isDesktop()

No description

Return Value

bool

string getDefaultOrientation()

Get the device's default orientation.

Return Value

string ["landscape"|"portrait"]

static DeviceInterface configConstructor($handle, array $config)

Construct from given configuration.

Parameters

$handle
array $config

Return Value

DeviceInterface