# depicter/1.6.2/app/src/Controllers/Ajax/DataSourceAjaxController.php

Depicter — Popup &amp; Slider Builder, version 1.6.2. 36 lines.

- Page: https://pluginprobe.com/plugins/depicter/1.6.2/code/app/src/Controllers/Ajax/DataSourceAjaxController.php
- Raw: https://pluginprobe.com/plugins/depicter/1.6.2/raw/app/src/Controllers/Ajax/DataSourceAjaxController.php
- Modified: 2023-02-09T06:22:12+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/depicter/1.6.2/code/app/src/Controllers/Ajax/DataSourceAjaxController.php#L10-L20`.

```php
<?php

namespace Depicter\Controllers\Ajax;

use Averta\Core\Utility\Data;
use Averta\WordPress\Utility\Sanitize;
use Psr\Http\Message\ResponseInterface;
use WPEmerge\Requests\RequestInterface;

class DataSourceAjaxController {

	/**
	 * List available asset groups for a dataSource
	 *
	 * @param RequestInterface $request
	 * @param                  $view
	 *
	 * @return ResponseInterface
	 */
    public function getAssets( RequestInterface $request, $view ){
	    $args = [];

		$args['type'] = Sanitize::textfield( $request->query( 'type' ) ) ?: 'wpPost';

	    if( ! Data::isNullOrEmptyStr( $request->query( 'postType' ) ) ){
		    $args['postType'] = Sanitize::textfield( $request->query( 'postType' ) );
	    } else {
			$args['postType'] = \Depicter::dataSource()->getPostTypeByType( $args['type'] );
	    }

		return \Depicter::json(
			[ 'hits' => \Depicter::dataSource()->getByType( $args['type'] )->getAssets( $args ) ]
		)->withStatus(200);
    }
}

```
