...
 
Commits (2)
......@@ -8,7 +8,9 @@ namespace Minds\Controllers\api\v2\pro;
use Exception;
use Minds\Core\Di\Di;
use Minds\Core\Pro\Channel\Manager;
use Minds\Core\Pro\Channel\Manager as ChannelManager;
use Minds\Core\Pro\Manager;
use Minds\Core\Session;
use Minds\Entities\User;
use Minds\Interfaces;
use Minds\Api\Factory;
......@@ -23,14 +25,33 @@ class channel implements Interfaces\Api
*/
public function get($pages)
{
$currentUser = Session::getLoggedinUser();
$channel = new User($pages[0]);
$channel->fullExport = true; //get counts
$channel->exportCounts = true;
/** @var Manager $manager */
$manager = Di::_()->get('Pro\Channel\Manager');
$manager->setUser(new User($pages[0]));
$manager = Di::_()->get('Pro\Manager');
$manager->setUser($channel);
/** @var ChannelManager $manager */
$channelManager = Di::_()->get('Pro\Channel\Manager');
$channelManager->setUser($channel);
switch ($pages[1] ?? '') {
case 'content':
return Factory::response([
'content' => $manager->getAllCategoriesContent(),
'content' => $channelManager->getAllCategoriesContent(),
]);
default:
$exportedChannel = $channel->export();
$exportedChannel['pro_settings'] = $manager->get();
return Factory::response([
'channel' => $exportedChannel,
'me' => $currentUser ? $currentUser->export() : null,
]);
}
}
......
......@@ -50,8 +50,7 @@ class Manager
$initializeSettingsDelegate = null,
$hydrateSettingsDelegate = null,
$entitiesBuilder = null
)
{
) {
$this->repository = $repository ?: new Repository();
$this->saveAction = $saveAction ?: new Save();
$this->initializeSettingsDelegate = $initializeSettingsDelegate ?: new Delegates\InitializeSettingsDelegate();
......@@ -245,7 +244,7 @@ class Manager
}
if (isset($values['tile_ratio'])) {
if (!in_array($values['tile_ratio'], Settings::TILE_RATIOS)) {
if (!in_array($values['tile_ratio'], Settings::TILE_RATIOS, true)) {
throw new \Exception('Invalid tile ratio');
}
......@@ -257,7 +256,7 @@ class Manager
$image = $this->entitiesBuilder->single($values['logo_guid']);
// if the image doesn't exist or the guid doesn't correspond to an image
if(!$image || ($image->type !== 'object' || $image->subtype !== 'image')) {
if (!$image || ($image->type !== 'object' || $image->subtype !== 'image')) {
throw new \Exception('logo_guid must be a valid image guid');
}
......@@ -305,7 +304,7 @@ class Manager
}
if (isset($values['scheme'])) {
if (!in_array($values['scheme'], Settings::COLOR_SCHEMES)) {
if (!in_array($values['scheme'], Settings::COLOR_SCHEMES, true)) {
throw new \Exception('Invalid tile ratio');
}
$settings
......