mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'features/create-social-action' into 'master'
Create social work See merge request Chill-Projet/chill-bundles!90
This commit is contained in:
@@ -359,9 +359,10 @@ class ApiController extends AbstractCRUDController
|
||||
* 6. validate the base entity (not the deserialized one). Groups are fetched from getValidationGroups, validation is perform by `validate`
|
||||
* 7. run onAfterValidation
|
||||
* 8. if errors, return a 422 response with errors
|
||||
* 9. flush the data
|
||||
* 10. run onAfterFlush
|
||||
* 11. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
||||
* 9. if $forcePersist === true, persist the entity
|
||||
* 10. flush the data
|
||||
* 11. run onAfterFlush
|
||||
* 12. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
||||
*
|
||||
* @param string action
|
||||
* @param mixed id
|
||||
@@ -370,11 +371,12 @@ class ApiController extends AbstractCRUDController
|
||||
* @param string $property the name of the property. This will be used to make a `add+$property` and `remove+$property` method
|
||||
* @param string $postedDataType the type of the posted data (the content)
|
||||
* @param string $postedDataContext a context to deserialize posted data (the content)
|
||||
* @param bool $forcePersist force to persist the created element (only for POST request)
|
||||
* @throw BadRequestException if unable to deserialize the posted data
|
||||
* @throw BadRequestException if the method is not POST or DELETE
|
||||
*
|
||||
*/
|
||||
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, $postedDataContext = []): Response
|
||||
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
|
||||
{
|
||||
$entity = $this->getEntity($action, $id, $request);
|
||||
|
||||
@@ -429,6 +431,10 @@ class ApiController extends AbstractCRUDController
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
if ($forcePersist && $request->getMethod() === Request::METHOD_POST) {
|
||||
$this->getDoctrine()->getManager()->persist($postedData);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
|
||||
|
@@ -146,7 +146,7 @@ class CRUDRoutesLoader extends Loader
|
||||
|
||||
foreach ($crudConfig['actions'] as $name => $action) {
|
||||
// filter only on single actions
|
||||
$singleCollection = $action['single-collection'] ?? $name === '_entity' ? 'single' : NULL;
|
||||
$singleCollection = $action['single_collection'] ?? $name === '_entity' ? 'single' : NULL;
|
||||
if ('collection' === $singleCollection) {
|
||||
// continue;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class CRUDRoutesLoader extends Loader
|
||||
// path are rewritten
|
||||
// if name === 'default', we rewrite it to nothing :-)
|
||||
$localName = \in_array($name, [ '_entity', '_index' ]) ? '' : '/'.$name;
|
||||
if ('collection' === $action['single-collection'] || '_index' === $name) {
|
||||
if ('collection' === $action['single_collection'] || '_index' === $name) {
|
||||
$localPath = $action['path'] ?? $localName.'.{_format}';
|
||||
} else {
|
||||
$localPath = $action['path'] ?? '/{id}'.$localName.'.{_format}';
|
||||
|
@@ -205,7 +205,7 @@ class Configuration implements ConfigurationInterface
|
||||
->ignoreExtraKeys(false)
|
||||
->info('the requirements for the route. Will be set to `[ \'id\' => \'\d+\' ]` if left empty.')
|
||||
->end()
|
||||
->enumNode('single-collection')
|
||||
->enumNode('single_collection')
|
||||
->values(['single', 'collection'])
|
||||
->defaultValue('single')
|
||||
->info('indicates if the returned object is a single element or a collection. '.
|
||||
|
@@ -11,13 +11,16 @@
|
||||
*
|
||||
* Do not take time into account
|
||||
*
|
||||
* **Experimental**
|
||||
*/
|
||||
const dateToISO = (date) => {
|
||||
if (null === date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
this.$store.state.startDate.getFullYear(),
|
||||
(this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'),
|
||||
this.$store.state.startDate.getDate().toString().padStart(2, '0')
|
||||
date.getFullYear(),
|
||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||
date.getDate().toString().padStart(2, '0')
|
||||
].join('-');
|
||||
};
|
||||
|
||||
@@ -36,10 +39,12 @@ const ISOToDate = (str) => {
|
||||
/**
|
||||
* Return a date object from iso string formatted as YYYY-mm-dd:HH:MM:ss+01:00
|
||||
*
|
||||
* **Experimental**
|
||||
*/
|
||||
const ISOToDatetime = (str) => {
|
||||
console.log(str);
|
||||
if (null === str) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let
|
||||
[cal, times] = str.split('T'),
|
||||
[year, month, date] = cal.split('-'),
|
||||
|
@@ -19,7 +19,6 @@ class CollectionNormalizer implements NormalizerInterface, NormalizerAwareInterf
|
||||
public function normalize($collection, string $format = null, array $context = [])
|
||||
{
|
||||
/** @var $collection Collection */
|
||||
/** @var $collection Chill\MainBundle\Pagination\PaginatorInterface */
|
||||
$paginator = $collection->getPaginator();
|
||||
|
||||
$data['count'] = $paginator->getTotalItems();
|
||||
|
Reference in New Issue
Block a user