bug fix
This commit is contained in:
parent
a3aa69b5a5
commit
49bd0cad39
|
@ -140,7 +140,14 @@ class StackController extends AbstractController
|
||||||
}
|
}
|
||||||
$response[] = $temp;
|
$response[] = $temp;
|
||||||
}
|
}
|
||||||
return $this->json($response);
|
// calc has next page
|
||||||
|
$nextPage = true;
|
||||||
|
if((int)$provider->maxPages($params,$entityManager->getRepository(StackContent::class)->getAllContentCount()) == $params['page'])
|
||||||
|
$nextPage = false;
|
||||||
|
return $this->json([
|
||||||
|
'data'=>$response,
|
||||||
|
'nextPage'=>$nextPage
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/stack/replays/search/{url}', name: 'app_stack_replays_get')]
|
#[Route('/api/stack/replays/search/{url}', name: 'app_stack_replays_get')]
|
||||||
|
@ -306,4 +313,30 @@ class StackController extends AbstractController
|
||||||
'message'=> 'تمام موارد لازم را وارد کنید.'
|
'message'=> 'تمام موارد لازم را وارد کنید.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/api/stack/replayedit/{id}', name: 'app_stack_replay_edit')]
|
||||||
|
public function app_stack_replay_edit($id,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
|
||||||
|
{
|
||||||
|
$params = [];
|
||||||
|
if ($content = $request->getContent()) {
|
||||||
|
$params = json_decode($content, true);
|
||||||
|
}
|
||||||
|
if( array_key_exists('body',$params )){
|
||||||
|
$stack = $entityManager->getRepository(StackContent::class)->find($id);
|
||||||
|
if(! $stack)
|
||||||
|
throw $this->createNotFoundException();
|
||||||
|
$stack->setBody($params['body']);
|
||||||
|
$entityManager->persist($stack);
|
||||||
|
$entityManager->flush();
|
||||||
|
return $this->json([
|
||||||
|
'error'=> 0,
|
||||||
|
'message'=> 'ok',
|
||||||
|
'url'=>$stack->getUrl()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $this->json([
|
||||||
|
'error'=> 999,
|
||||||
|
'message'=> 'تمام موارد لازم را وارد کنید.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,19 @@ class StackContentRepository extends ServiceEntityRepository
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||||
|
* @throws \Doctrine\ORM\NoResultException
|
||||||
|
*/
|
||||||
|
public function getAllContentCount(): int{
|
||||||
|
return $this->createQueryBuilder('s')
|
||||||
|
->select('count(s.id)')
|
||||||
|
->andWhere('s.upper IS NULL')
|
||||||
|
->getQuery()
|
||||||
|
->getSingleScalarResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws \Doctrine\ORM\NoResultException
|
||||||
|
|
|
@ -19,8 +19,13 @@ class Provider
|
||||||
$page = $params['page'];
|
$page = $params['page'];
|
||||||
$response['page'] = $page;
|
$response['page'] = $page;
|
||||||
|
|
||||||
|
$cat = '';
|
||||||
|
if(array_key_exists('cat',$params))
|
||||||
|
$cat = $params['cat'];
|
||||||
|
$response['cat'] = $cat;
|
||||||
|
|
||||||
//set max Count of content want to search
|
//set max Count of content want to search
|
||||||
$count = 30;
|
$count = 15;
|
||||||
if(array_key_exists('count',$params))
|
if(array_key_exists('count',$params))
|
||||||
$count = $params['count'];
|
$count = $params['count'];
|
||||||
$response['count'] = $count;
|
$response['count'] = $count;
|
||||||
|
@ -33,6 +38,11 @@ class Provider
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function maxPages($params,$rowsAllCount){
|
||||||
|
$res = $rowsAllCount / $params['count'];
|
||||||
|
return is_float($res) ? (int)$res+1:$res;
|
||||||
|
}
|
||||||
public function gravatarHash($email){
|
public function gravatarHash($email){
|
||||||
return md5( strtolower( trim( $email) ) );
|
return md5( strtolower( trim( $email) ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue