# erp/1.3.13/includes/api/class-utility-controller.php

ERP: Complete HR, Accounting &amp; CRM Suite Built for WooCommerce, version 1.3.13. 55 lines.

- Page: https://pluginprobe.com/plugins/erp/1.3.13/code/includes/api/class-utility-controller.php
- Raw: https://pluginprobe.com/plugins/erp/1.3.13/raw/includes/api/class-utility-controller.php
- Modified: 2018-09-03T08:36:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/erp/1.3.13/code/includes/api/class-utility-controller.php#L10-L20`.

```php
<?php
namespace WeDevs\ERP\API;

use WP_Error;
use WP_REST_Response;
use WP_REST_Server;
class Utility_Controller extends REST_Controller {
    /**
     * Endpoint namespace.
     *
     * @var string
     */
    protected $namespace = 'erp/v1';

    /**
     * Route base.
     *
     * @var string
     */
    protected $rest_base = 'utility';

    /**
     * Register the routes for the objects of the controller.
     */
    public function register_routes() {
        register_rest_route( $this->namespace, '/' . $this->rest_base .'/get-active-plugins', [
            [
                'methods'             => WP_REST_Server::READABLE,
                'callback'            => [ $this, 'get_active_plugins' ],
                'args'                => $this->get_collection_params(),
                'permission_callback' => function ( $request ) {
                    return current_user_can('erp_view_list' );
                },
            ],
            'schema' => [ $this, 'get_public_item_schema' ],
        ] );
    }

    /**
     * Get the list of active plugins
     *
     * @since 1.3.0
     *
     * @param $request
     *
     * @return mixed|WP_REST_Response
     */
    public function get_active_plugins( $request ){
        $active_plugins = get_option('active_plugins');
        $response = rest_ensure_response( $active_plugins );

        return $response;
    }
}

```
