...
 
Commits (3)
<?php
/**
* pro
*
* @author edgebal
*/
namespace Minds\Controllers\api\v2\admin;
use Minds\Api\Factory;
use Minds\Core\Pro\Manager;
use Minds\Entities\User as UserEntity;
use Minds\Interfaces;
use Minds\Core\Di\Di;
class pro implements Interfaces\Api, Interfaces\ApiAdminPam
{
/**
* Equivalent to HTTP GET method
* @param array $pages
* @return mixed|null
*/
public function get($pages)
{
return Factory::response([]);
}
/**
* Equivalent to HTTP POST method
* @param array $pages
* @return mixed|null
*/
public function post($pages)
{
return Factory::response([]);
}
/**
* Equivalent to HTTP PUT method
* @param array $pages
* @return mixed|null
*/
public function put($pages)
{
if (!($pages[0] ?? null)) {
return Factory::response([
'status' => 'error',
'message' => 'Emtpy target',
]);
}
$target = new UserEntity($pages[0]);
if (!$target || !$target->guid) {
return Factory::response([
'status' => 'error',
'message' => 'Invalid target',
]);
}
/** @var Manager $manager */
$manager = Di::_()->get('Pro\Manager');
$manager
->setUser($target);
$success = $manager->enable(time() + (365 * 86400));
if (!$success) {
return Factory::response([
'status' => 'error',
'message' => 'Error disabling Pro',
]);
}
return Factory::response([]);
}
/**
* Equivalent to HTTP DELETE method
* @param array $pages
* @return mixed|null
*/
public function delete($pages)
{
if (!($pages[0] ?? null)) {
return Factory::response([
'status' => 'error',
'message' => 'Emtpy target',
]);
}
$target = new UserEntity($pages[0]);
if (!$target || !$target->guid) {
return Factory::response([
'status' => 'error',
'message' => 'Invalid target',
]);
}
/** @var Manager $manager */
$manager = Di::_()->get('Pro\Manager');
$manager
->setUser($target);
$success = $manager->disable();
if (!$success) {
return Factory::response([
'status' => 'error',
'message' => 'Error disabling Pro',
]);
}
return Factory::response([]);
}
}
......@@ -40,25 +40,30 @@ class pro implements Interfaces\Api
*/
public function post($pages)
{
/** @var Manager $manager */
$manager = Di::_()->get('Pro\Manager');
$manager
->setUser(Session::getLoggedinUser());
// TODO: Send and process payment data
$success = $manager->enable(time() + (365 * 86400));
if (!$success) {
return Factory::response([
'status' => 'error',
'message' => 'Error activating Pro',
]);
}
return Factory::response([
'isActive' => $manager->isActive(),
'settings' => $manager->get(),
'status' => 'error',
'message' => 'Minds Pro is not yet publicly available.',
]);
// /** @var Manager $manager */
// $manager = Di::_()->get('Pro\Manager');
// $manager
// ->setUser(Session::getLoggedinUser());
//
// // TODO: Send and process payment data
// $success = $manager->enable(time() + (365 * 86400));
//
// if (!$success) {
// return Factory::response([
// 'status' => 'error',
// 'message' => 'Error activating Pro',
// ]);
// }
//
// return Factory::response([
// 'isActive' => $manager->isActive(),
// 'settings' => $manager->get(),
// ]);
}
/**
......
......@@ -40,8 +40,7 @@ class Security
$cookie = null,
$jwt = null,
$config = null
)
{
) {
$this->cookie = $cookie ?: new Cookie();
$this->jwt = $jwt ?: new Jwt();
$this->config = $config ?: Di::_()->get('Config');
......@@ -114,7 +113,8 @@ class Security
->setPath('/')
->setHttpOnly(false)
->create();
} catch (Exception $e) { }
} catch (Exception $e) {
}
}
/**
......
......@@ -19,27 +19,25 @@ class DomainSpec extends ObjectBehavior
/** @var Repository */
protected $repository;
function let(
public function let(
Config $config,
Repository $repository
)
{
) {
$this->config = $config;
$this->repository = $repository;
$this->beConstructedWith($config, $repository);
}
function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(Domain::class);
}
function it_should_lookup_for_a_domain(
public function it_should_lookup_for_a_domain(
Response $repositoryResponse,
Settings $settings
)
{
) {
$this->config->get('root_domains')
->shouldBeCalled()
->willReturn(['minds.com']);
......@@ -59,11 +57,10 @@ class DomainSpec extends ObjectBehavior
->shouldReturn($settings);
}
function it_should_get_an_icon(
public function it_should_get_an_icon(
Settings $settings,
User $user
)
{
) {
$user->getIconURL('large')
->shouldBeCalled()
->willReturn('/1000/large');
......
......@@ -8,12 +8,12 @@ use Prophecy\Argument;
class SettingsSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(Settings::class);
}
function it_should_get_one_line_headline_from_single_line_value()
public function it_should_get_one_line_headline_from_single_line_value()
{
$this->setHeadline('This is a headline');
......@@ -22,7 +22,7 @@ class SettingsSpec extends ObjectBehavior
->shouldReturn('This is a headline');
}
function it_should_get_one_line_headline_from_multi_line_value()
public function it_should_get_one_line_headline_from_multi_line_value()
{
$this->setHeadline("This is a headline.\nOther line");
......@@ -31,21 +31,21 @@ class SettingsSpec extends ObjectBehavior
->shouldReturn('This is a headline. Other line');
}
function it_should_export()
public function it_should_export()
{
$this
->export()
->shouldBeArray();
}
function it_should_build_styles()
public function it_should_build_styles()
{
$this
->buildStyles()
->shouldBeArray();
}
function it_should_calc_tile_ratio_percentage()
public function it_should_calc_tile_ratio_percentage()
{
$this
->setTileRatio('1:1');
......