# assistant/0.3.1/backend/src/System/Contracts/ControllerAbstract.php

Assistant – Every Day Productivity Apps, version 0.3.1. 40 lines.

- Page: https://pluginprobe.com/plugins/assistant/0.3.1/code/backend/src/System/Contracts/ControllerAbstract.php
- Raw: https://pluginprobe.com/plugins/assistant/0.3.1/raw/backend/src/System/Contracts/ControllerAbstract.php
- Modified: 2020-03-25T19:33:50+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/assistant/0.3.1/code/backend/src/System/Contracts/ControllerAbstract.php#L10-L20`.

```php
<?php

namespace FL\Assistant\System\Contracts;

use FL\Assistant\Data\Pager;

abstract class ControllerAbstract {


	/**
	 * @var string
	 */
	protected $namespace = 'fl-assistant/v1';

	public function route( $route, array $config = [] ) {
		register_rest_route( $this->namespace, $route, $config );
	}

	abstract public function register_routes();

	/**
	 * Paginates the contents of an array
	 *
	 * @param array $data - complete list of items to paginate
	 * @param $limit
	 * @param $offset
	 *
	 * @return Pager
	 */
	public function paginate_array( array $data, $limit, $offset ) {

		$items = array_slice( $data, $offset, $limit, false );
		$total = count( $items );
		$limit = intval( $limit );
		$offset = intval( $offset );

		return new Pager( $items, $total, $limit, $offset );
	}
}

```
