Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Druplan TicketMatic
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
planning
Druplan TicketMatic
Merge requests
!2
imp: add operation, action link
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
imp: add operation, action link
imp-add-ticketmatic-service
into
1.x
Overview
0
Commits
2
Pipelines
3
Changes
9
Merged
simon
requested to merge
imp-add-ticketmatic-service
into
1.x
2 years ago
Overview
0
Commits
2
Pipelines
3
Changes
9
Expand
0
0
Merge request reports
Compare
1.x
version 1
68f71713
2 years ago
1.x (base)
and
latest version
latest version
652a1411
2 commits,
2 years ago
version 1
68f71713
1 commit,
2 years ago
9 files
+
217
−
2
Expand all files
Preferences
File browser
List view
Tree view
Compare changes
Inline
Side-by-side
Show whitespace changes
Show one file at a time
Search (e.g. *.vue) (Ctrl+P)
src/Form/EventTicketMaticForm.php
0 → 100644
+
119
−
0
Options
<?php
namespace
Drupal\druplan_ticketmatic\Form
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\druplan_ticketmatic
\DruplanTicketmatic
;
use
Drupal\resource_planning
\Entity\Event
;
/**
* Provides a Druplan TicketMatic form.
*/
class
EventTicketMaticForm
extends
FormBase
{
/**
* The TicketMatic API.
*
* @var \Drupal\druplan_ticketmatic\DruplanTicketmatic
*/
protected
$ticketmatic
;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected
$entityTypeManager
;
/**
* The event.
*
* @var \Drupal\resource_planning\Entity\Event
*/
protected
$event
;
/**
* Constructs a Drupal\druplan_ticketmatic\Form\EventTicketMaticForm object.
*/
public
function
__construct
(
DruplanTicketmatic
$ticketmatic
,
EntityTypeManagerInterface
$entity_type_manager
)
{
$this
->
ticketmatic
=
$ticketmatic
;
$this
->
entityTypeManager
=
$entity_type_manager
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'druplan_ticketmatic.default'
),
$container
->
get
(
'entity_type.manager'
),
);
}
/**
* {@inheritdoc}
*/
public
function
getFormId
()
{
return
'druplan_ticketmatic_event_ticket_matic'
;
}
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
Event
$rp_event
=
NULL
)
{
if
(
$rp_event
)
{
$this
->
event
=
$rp_event
;
}
$form
[
'intro'
]
=
[
'#markup'
=>
$this
->
t
(
'Are you sure you wish to create a TicketMatic event?'
),
];
$view_builder
=
$this
->
entityTypeManager
->
getViewBuilder
(
'rp_event'
);
$form
[
'details'
]
=
[
'#type'
=>
'details'
,
'#title'
=>
$this
->
t
(
'Event Details'
),
'#open'
=>
TRUE
,
'details'
=>
$view_builder
->
build
(
$view_builder
->
view
(
$this
->
event
)
),
];
$form
[
'actions'
]
=
[
'#type'
=>
'actions'
,
];
$form
[
'actions'
][
'submit'
]
=
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Send'
),
];
return
$form
;
}
/**
* {@inheritdoc}
*/
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
if
(
$this
->
event
->
get
(
'ticketmatic_id'
)
->
value
)
{
$form_state
->
setErrorByName
(
'actions'
,
$this
->
t
(
'This event already has a ticketmatic ID'
)
);
}
}
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$this
->
ticketmatic
->
createEvent
(
$this
->
event
);
$this
->
messenger
()
->
addStatus
(
$this
->
t
(
'The Event has been created.'
));
}
}