Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
labelabeille
server
Commits
a9ee2eb0
Commit
a9ee2eb0
authored
May 07, 2016
by
wilhelmhb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handlers for the entities
parent
ea9a89c2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1302 additions
and
0 deletions
+1302
-0
src/ApiBundle/Entity/Handler/PsBoxHandler.php
src/ApiBundle/Entity/Handler/PsBoxHandler.php
+144
-0
src/ApiBundle/Entity/Handler/PsClientHandler.php
src/ApiBundle/Entity/Handler/PsClientHandler.php
+144
-0
src/ApiBundle/Entity/Handler/PsCustomNoteCustomerHandler.php
src/ApiBundle/Entity/Handler/PsCustomNoteCustomerHandler.php
+144
-0
src/ApiBundle/Entity/Handler/PsCustomNoteHandler.php
src/ApiBundle/Entity/Handler/PsCustomNoteHandler.php
+144
-0
src/ApiBundle/Entity/Handler/PsCustomerHandler.php
src/ApiBundle/Entity/Handler/PsCustomerHandler.php
+148
-0
src/ApiBundle/Entity/Handler/PsDefaultNoteCustomerHandler.php
...ApiBundle/Entity/Handler/PsDefaultNoteCustomerHandler.php
+144
-0
src/ApiBundle/Entity/Handler/PsDefaultNoteHandler.php
src/ApiBundle/Entity/Handler/PsDefaultNoteHandler.php
+144
-0
src/ApiBundle/Entity/Handler/PsHiveGroupHandler.php
src/ApiBundle/Entity/Handler/PsHiveGroupHandler.php
+145
-0
src/ApiBundle/Entity/Handler/PsHiveHandler.php
src/ApiBundle/Entity/Handler/PsHiveHandler.php
+145
-0
No files found.
src/ApiBundle/Entity/Handler/PsBoxHandler.php
0 → 100644
View file @
a9ee2eb0
<?php
namespace
ApiBundle\Entity\Handler
;
use
Doctrine\Common\Persistence\ObjectManager
;
use
Symfony\Component\Form\FormFactoryInterface
;
use
ApiBundle\Entity\Interfaces\CommonHandlerInterface
;
use
ApiBundle\Entity\Interfaces\CommonInterface
;
use
ApiBundle\Form\PsBoxType
;
use
ApiBundle\Entity\PsBox
;
use
ApiBundle\Exception\InvalidFormException
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\Debug\Exception\ClassNotFoundException
;
class
PsBoxHandler
implements
CommonHandlerInterface
{
private
$formFactory
;
private
$om
;
private
$entityClass
;
private
$repository
;
public
function
__construct
(
ObjectManager
$om
,
$entityClass
,
FormFactoryInterface
$formFactory
)
{
$this
->
om
=
$om
;
$this
->
entityClass
=
$entityClass
;
$this
->
repository
=
$this
->
om
->
getRepository
(
$this
->
entityClass
);
$this
->
formFactory
=
$formFactory
;
}
public
function
get
(
$id
)
{
return
$this
->
repository
->
find
(
$id
);
}
/**
* Get a list of PsBoxs.
*
* @param int $limit the limit of the result
* @param int $offset starting from the offset
*
* @return array
*/
public
function
all
(
$limit
=
5
,
$offset
=
0
)
{
return
$this
->
repository
->
findBy
(
array
(),
null
,
$limit
,
$offset
);
}
/**
* Create a new PsBox.
*
* @param array $parameters
*
* @return PsBoxInterface
*/
public
function
post
(
array
$parameters
)
{
$psbox
=
$this
->
createPsBox
();
// factory method create an empty PsBox
// Process form does all the magic, validate and hydrate the PsBox Object.
return
$this
->
processForm
(
$psbox
,
$parameters
,
'POST'
);
}
/**
* Processes the form.
*
* @param PsBoxInterface $psbox
* @param array $parameters
* @param String $method
*
* @return PsBoxInterface
*
* @throws \Acme\BlogBundle\Exception\InvalidFormException
*/
private
function
processForm
(
PsBox
$psbox
,
array
$parameters
,
$method
=
"PUT"
)
{
$parameters
=
$parameters
[
'apibundle_psbox'
];
$form
=
$this
->
formFactory
->
create
(
new
PsBoxType
(),
$psbox
,
array
(
'method'
=>
$method
));
$form
->
submit
(
$parameters
,
'PATCH'
!==
$method
);
if
(
$form
->
isValid
())
{
$psbox
=
$form
->
getData
();
$this
->
om
->
persist
(
$psbox
);
$this
->
om
->
flush
(
$psbox
);
return
$psbox
;
}
throw
new
InvalidFormException
(
'Invalid submitted data'
,
$form
);
}
/**
* Presents the form to use to create a new psbox.
*
* @ApiDoc(
* resource = true,
* statusCodes = {
* 200 = "Returned when successful"
* }
* )
*
* @View()
*
* @return FormTypeInterface
*/
public
function
newAction
()
{
return
$this
->
createForm
(
new
PsBoxType
());
}
private
function
createPsBox
()
{
return
new
$this
->
entityClass
();
}
public
function
delete
(
PsBox
$psbox
)
{
$this
->
om
->
remove
(
$psbox
);
$this
->
om
->
flush
();
$response
=
new
JsonResponse
([
'success'
=>
true
],
301
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
/**
* Edit a Page, or create if not exist.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
put
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PUT'
);
}
/**
* Partially update a Page.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
patch
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PATCH'
);
}
}
src/ApiBundle/Entity/Handler/PsClientHandler.php
0 → 100755
View file @
a9ee2eb0
<?php
namespace
ApiBundle\Entity\Handler
;
use
Doctrine\Common\Persistence\ObjectManager
;
use
Symfony\Component\Form\FormFactoryInterface
;
use
ApiBundle\Entity\Interfaces\CommonHandlerInterface
;
use
ApiBundle\Entity\Interfaces\CommonInterface
;
use
ApiBundle\Form\PsClientType
;
use
ApiBundle\Entity\PsClient
;
use
ApiBundle\Exception\InvalidFormException
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\Debug\Exception\ClassNotFoundException
;
class
PsClientHandler
implements
CommonHandlerInterface
{
private
$formFactory
;
private
$om
;
private
$entityClass
;
private
$repository
;
public
function
__construct
(
ObjectManager
$om
,
$entityClass
,
FormFactoryInterface
$formFactory
)
{
$this
->
om
=
$om
;
$this
->
entityClass
=
$entityClass
;
$this
->
repository
=
$this
->
om
->
getRepository
(
$this
->
entityClass
);
$this
->
formFactory
=
$formFactory
;
}
public
function
get
(
$id
)
{
return
$this
->
repository
->
find
(
$id
);
}
/**
* Get a list of PsClients.
*
* @param int $limit the limit of the result
* @param int $offset starting from the offset
*
* @return array
*/
public
function
all
(
$limit
=
null
,
$offset
=
null
)
{
return
$this
->
repository
->
findBy
(
array
(),
null
,
$limit
,
$offset
);
}
/**
* Create a new PsClient.
*
* @param array $parameters
*
* @return PsClientInterface
*/
public
function
post
(
array
$parameters
)
{
$psclient
=
$this
->
createPsClient
();
// factory method create an empty PsClient
// Process form does all the magic, validate and hydrate the PsClient Object.
return
$this
->
processForm
(
$psclient
,
$parameters
,
'POST'
);
}
/**
* Processes the form.
*
* @param PsClientInterface $psclient
* @param array $parameters
* @param String $method
*
* @return PsClientInterface
*
* @throws \Acme\BlogBundle\Exception\InvalidFormException
*/
private
function
processForm
(
PsClient
$psclient
,
array
$parameters
,
$method
=
"PUT"
)
{
$parameters
=
$parameters
[
'apibundle_psclient'
];
$form
=
$this
->
formFactory
->
create
(
new
PsClientType
(),
$psclient
,
array
(
'method'
=>
$method
));
$form
->
submit
(
$parameters
,
'PATCH'
!==
$method
);
if
(
$form
->
isValid
())
{
$psclient
=
$form
->
getData
();
$this
->
om
->
persist
(
$psclient
);
$this
->
om
->
flush
(
$psclient
);
return
$psclient
;
}
throw
new
InvalidFormException
(
'Invalid submitted data'
,
$form
);
}
/**
* Presents the form to use to create a new psclient.
*
* @ApiDoc(
* resource = true,
* statusCodes = {
* 200 = "Returned when successful"
* }
* )
*
* @View()
*
* @return FormTypeInterface
*/
public
function
newAction
()
{
return
$this
->
createForm
(
new
PsClientType
());
}
private
function
createPsClient
()
{
return
new
$this
->
entityClass
();
}
public
function
delete
(
PsClient
$pshive
)
{
$this
->
om
->
remove
(
$pshive
);
$this
->
om
->
flush
();
$response
=
new
JsonResponse
([
'success'
=>
true
],
301
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
/**
* Edit a Page, or create if not exist.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
put
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PUT'
);
}
/**
* Partially update a Page.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
patch
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PATCH'
);
}
}
src/ApiBundle/Entity/Handler/PsCustomNoteCustomerHandler.php
0 → 100644
View file @
a9ee2eb0
<?php
namespace
ApiBundle\Entity\Handler
;
use
Doctrine\Common\Persistence\ObjectManager
;
use
Symfony\Component\Form\FormFactoryInterface
;
use
ApiBundle\Entity\Interfaces\CommonHandlerInterface
;
use
ApiBundle\Entity\Interfaces\CommonInterface
;
use
ApiBundle\Form\PsCustomNoteCustomerType
;
use
ApiBundle\Entity\PsCustomNoteCustomer
;
use
ApiBundle\Exception\InvalidFormException
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\Debug\Exception\ClassNotFoundException
;
class
PsCustomNoteCustomerHandler
implements
CommonHandlerInterface
{
private
$formFactory
;
private
$om
;
private
$entityClass
;
private
$repository
;
public
function
__construct
(
ObjectManager
$om
,
$entityClass
,
FormFactoryInterface
$formFactory
)
{
$this
->
om
=
$om
;
$this
->
entityClass
=
$entityClass
;
$this
->
repository
=
$this
->
om
->
getRepository
(
$this
->
entityClass
);
$this
->
formFactory
=
$formFactory
;
}
public
function
get
(
$id
)
{
return
$this
->
repository
->
find
(
$id
);
}
/**
* Get a list of PsCustomNoteCustomers.
*
* @param int $limit the limit of the result
* @param int $offset starting from the offset
*
* @return array
*/
public
function
all
(
$limit
=
null
,
$offset
=
null
)
{
return
$this
->
repository
->
findBy
(
array
(),
null
,
$limit
,
$offset
);
}
/**
* Create a new PsCustomNoteCustomer.
*
* @param array $parameters
*
* @return PsCustomNoteCustomerInterface
*/
public
function
post
(
array
$parameters
)
{
$pscustomnotecustomer
=
$this
->
createPsCustomNoteCustomer
();
// factory method create an empty PsCustomNoteCustomer
// Process form does all the magic, validate and hydrate the PsCustomNoteCustomer Object.
return
$this
->
processForm
(
$pscustomnotecustomer
,
$parameters
,
'POST'
);
}
/**
* Processes the form.
*
* @param PsCustomNoteCustomerInterface $pscustomnotecustomer
* @param array $parameters
* @param String $method
*
* @return PsCustomNoteCustomerInterface
*
* @throws \Acme\BlogBundle\Exception\InvalidFormException
*/
private
function
processForm
(
PsCustomNoteCustomer
$pscustomnotecustomer
,
array
$parameters
,
$method
=
"PUT"
)
{
$parameters
=
$parameters
[
'apibundle_pscustomnotecustomer'
];
$form
=
$this
->
formFactory
->
create
(
new
PsCustomNoteCustomerType
(),
$pscustomnotecustomer
,
array
(
'method'
=>
$method
));
$form
->
submit
(
$parameters
,
'PATCH'
!==
$method
);
if
(
$form
->
isValid
())
{
$pscustomnotecustomer
=
$form
->
getData
();
$this
->
om
->
persist
(
$pscustomnotecustomer
);
$this
->
om
->
flush
(
$pscustomnotecustomer
);
return
$pscustomnotecustomer
;
}
throw
new
InvalidFormException
(
'Invalid submitted data'
,
$form
);
}
/**
* Presents the form to use to create a new pscustomnotecustomer.
*
* @ApiDoc(
* resource = true,
* statusCodes = {
* 200 = "Returned when successful"
* }
* )
*
* @View()
*
* @return FormTypeInterface
*/
public
function
newAction
()
{
return
$this
->
createForm
(
new
PsCustomNoteCustomerType
());
}
private
function
createPsCustomNoteCustomer
()
{
return
new
$this
->
entityClass
();
}
public
function
delete
(
PsCustomNoteCustomer
$pscustomnotecustomer
)
{
$this
->
om
->
remove
(
$pscustomnotecustomer
);
$this
->
om
->
flush
();
$response
=
new
JsonResponse
([
'success'
=>
true
],
301
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
/**
* Edit a Page, or create if not exist.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
put
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PUT'
);
}
/**
* Partially update a Page.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
patch
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PATCH'
);
}
}
src/ApiBundle/Entity/Handler/PsCustomNoteHandler.php
0 → 100644
View file @
a9ee2eb0
<?php
namespace
ApiBundle\Entity\Handler
;
use
Doctrine\Common\Persistence\ObjectManager
;
use
Symfony\Component\Form\FormFactoryInterface
;
use
ApiBundle\Entity\Interfaces\CommonHandlerInterface
;
use
ApiBundle\Entity\Interfaces\CommonInterface
;
use
ApiBundle\Form\PsCustomNoteType
;
use
ApiBundle\Entity\PsCustomNote
;
use
ApiBundle\Exception\InvalidFormException
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\Debug\Exception\ClassNotFoundException
;
class
PsCustomNoteHandler
implements
CommonHandlerInterface
{
private
$formFactory
;
private
$om
;
private
$entityClass
;
private
$repository
;
public
function
__construct
(
ObjectManager
$om
,
$entityClass
,
FormFactoryInterface
$formFactory
)
{
$this
->
om
=
$om
;
$this
->
entityClass
=
$entityClass
;
$this
->
repository
=
$this
->
om
->
getRepository
(
$this
->
entityClass
);
$this
->
formFactory
=
$formFactory
;
}
public
function
get
(
$id
)
{
return
$this
->
repository
->
find
(
$id
);
}
/**
* Get a list of PsCustomNotes.
*
* @param int $limit the limit of the result
* @param int $offset starting from the offset
*
* @return array
*/
public
function
all
(
$limit
=
null
,
$offset
=
null
)
{
return
$this
->
repository
->
findBy
(
array
(),
null
,
$limit
,
$offset
);
}
/**
* Create a new PsCustomNote.
*
* @param array $parameters
*
* @return PsCustomNoteInterface
*/
public
function
post
(
array
$parameters
)
{
$pscustomnote
=
$this
->
createPsCustomNote
();
// factory method create an empty PsCustomNote
// Process form does all the magic, validate and hydrate the PsCustomNote Object.
return
$this
->
processForm
(
$pscustomnote
,
$parameters
,
'POST'
);
}
/**
* Processes the form.
*
* @param PsCustomNoteInterface $pscustomnote
* @param array $parameters
* @param String $method
*
* @return PsCustomNoteInterface
*
* @throws \Acme\BlogBundle\Exception\InvalidFormException
*/
private
function
processForm
(
PsCustomNote
$pscustomnote
,
array
$parameters
,
$method
=
"PUT"
)
{
$parameters
=
$parameters
[
'apibundle_pscustomnote'
];
$form
=
$this
->
formFactory
->
create
(
new
PsCustomNoteType
(),
$pscustomnote
,
array
(
'method'
=>
$method
));
$form
->
submit
(
$parameters
,
'PATCH'
!==
$method
);
if
(
$form
->
isValid
())
{
$pscustomnote
=
$form
->
getData
();
$this
->
om
->
persist
(
$pscustomnote
);
$this
->
om
->
flush
(
$pscustomnote
);
return
$pscustomnote
;
}
throw
new
InvalidFormException
(
'Invalid submitted data'
,
$form
);
}
/**
* Presents the form to use to create a new pscustomnote.
*
* @ApiDoc(
* resource = true,
* statusCodes = {
* 200 = "Returned when successful"
* }
* )
*
* @View()
*
* @return FormTypeInterface
*/
public
function
newAction
()
{
return
$this
->
createForm
(
new
PsCustomNoteType
());
}
private
function
createPsCustomNote
()
{
return
new
$this
->
entityClass
();
}
public
function
delete
(
PsCustomNote
$pscustomnote
)
{
$this
->
om
->
remove
(
$pscustomnote
);
$this
->
om
->
flush
();
$response
=
new
JsonResponse
([
'success'
=>
true
],
301
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/json'
);
return
$response
;
}
/**
* Edit a Page, or create if not exist.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
put
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PUT'
);
}
/**
* Partially update a Page.
*
* @param PageInterface $page
* @param array $parameters
*
* @return PageInterface
*/
public
function
patch
(
$page
,
array
$parameters
)
{
return
$this
->
processForm
(
$page
,
$parameters
,
'PATCH'
);
}
}
src/ApiBundle/Entity/Handler/PsCustomerHandler.php
0 → 100755
View file @
a9ee2eb0
<?php
namespace
ApiBundle\Entity\Handler
;
use
Doctrine\Common\Persistence\ObjectManager
;
use
Symfony\Component\Form\FormFactoryInterface
;
use
ApiBundle\Entity\Interfaces\CommonHandlerInterface
;
use
ApiBundle\Entity\Interfaces\CommonInterface
;
use
ApiBundle\Entity\PsCustomer
;
use
ApiBundle\Form\PsCustomerType
;
use
ApiBundle\Exception\InvalidFormException
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\Debug\Exception\ClassNotFoundException
;
class
PsCustomerHandler
implements
CommonHandlerInterface
{
private
$formFactory
;
private
$om
;
private
$entityClass
;
private
$repository
;
public
function
__construct
(
ObjectManager
$om
,
$entityClass
,
FormFactoryInterface
$formFactory
)
{
$this
->
om
=
$om
;
$this
->
entityClass
=
$entityClass
;
$this
->
repository
=
$this
->
om
->
getRepository
(
$this
->
entityClass
);
$this
->
formFactory
=
$formFactory
;
}
public
function
get
(
$id
)
{
return
$this
->
repository
->
find
(
$id
);
}
/**
* Get a list of PsCustomers.
*
* @param int $limit the limit of the result
* @param int $offset starting from the offset
*
* @return array
*/
public
function
all
(
$limit
=
5
,
$offset
=
0
)
{
return
$this
->
repository
->
findBy
(
array
(),
null
,
$limit
,
$offset
);
}
/**
* Create a new PsCustomer.
*
* @param array $parameters
*