ExpressionEngine Docs

# Addon Service

- Simple Example
- Addon Service Methods
- Addon Object Methods

## Simple Example

Read-only access to the data in an `addon.setup.php` file is made available via the object returned from a `ee('Addon')->get($addon_name)` call. The returned object has a `get($key)` method to retrieve data. For example:

    $info = ee('Addon')->get('hello_world');
    echo $info->get('description');

## Addon Service Methods

class `EllisLab\ExpressionEngine\Service\Addon\Factory`

- `get($name)`
- `all()`
- `installed($name)`

### `get($name)`

Get an add-on object.

Parameter | Type | Description
--- | --- | ---
$name | `String` | The short name of the add-on
Returns | `Addon` | An Addon

### `all()`

Get all add-ons.

Parameter | Type | Description
--- | --- | ---
Returns | `Array` | An array of Addon objects

### `installed($name)`

Get all the installed add-ons.

Parameter | Type | Description
--- | --- | ---
Returns | `Array` | An array of Addon objects

## Addon Object Methods

class `EllisLab\ExpressionEngine\Service\Addon\Addon`

- `isInstalled()`
- `hasUpdate()`
- `getInstalledVersion()`
- `getFrontendClass()`
- `getModuleClass()`
- `getPluginClass()`
- `getInstallerClass()`
- `getControlPanelClass()`
- `getExtensionClass()`
- `hasManual()`
- `hasFrontend()`
- `hasInstaller()`
- `hasControlPanel()`
- `hasModule()`
- `hasPlugin()`
- `hasExtension()`
- `hasFieldtype()`
- `getFieldtypeClasses()`
- `getFieldtypeNames()`
- `getProvider()`

### `isInstalled()`

Is this addon installed?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it is, FALSE if not

### `hasUpdate()`

Does this addon have an update available?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `getInstalledVersion()`

Get the installed version

Parameter | Type | Description
--- | --- | ---
Returns | `Mixed` | NULL if not installed or a version string

### `getFrontendClass()`

Get the plugin or module class

Parameter | Type | Description
--- | --- | ---
Returns | `String` | The fqcn or $class

### `getModuleClass()`

Get the module class

Parameter | Type | Description
--- | --- | ---
Returns | `String` | The fqcn or $class

### `getPluginClass()`

Get the plugin class

Parameter | Type | Description
--- | --- | ---
Returns | `String` | The fqcn or $class

### `getInstallerClass()`

Get the `*_upd` class

Parameter | Type | Description
--- | --- | ---
Returns | `String` | The fqcn or $class

### `getControlPanelClass()`

Get the `*_mcp` class

Parameter | Type | Description
--- | --- | ---
Returns | `String` | The fqcn or $class

### `getExtensionClass()`

Get the extension class

Parameter | Type | Description
--- | --- | ---
Returns | `String` | The fqcn or $class

### `hasManual()`

Does this addon have a `README.md` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasFrontend()`

Does this addon have module or plugin?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasInstaller()`

Does this addon have a `upd.` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasControlPanel()`

Does this addon have a `mcp.` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasModule()`

Does this addon have a `mod.` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasPlugin()`

Does this addon have a `pi.` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasExtension()`

Does this addon have a `ext.` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `hasFieldtype()`

Does this addon have a `ft.` file?

Parameter | Type | Description
--- | --- | ---
Returns | `Boolean` | TRUE if it does, FALSE if not

### `getFieldtypeClasses()`

Gets an array of the filedtype classes

Parameter | Type | Description
--- | --- | ---
Returns | `Array` | An array of classes

### `getFieldtypeNames()`

Get an associative array of names of each fieldtype. Maps the fieldtype’s shortname to it’s display name. The provider file is first checked for the display name in the fieldtypes key, falling back on the getName() method.

Parameter | Type | Description
--- | --- | ---
Returns | `Array` | An associative array of shortname to display name for each fieldtype.

### `getProvider()`

Get the add-on Provider

Parameter | Type | Description
--- | --- | ---
Returns | `EllisLab\ExpressionEngine\Core\Provider` | The add-on provider