removed "report" config entity
so as to try out making it a content entity instead.
This commit is contained in:
parent
c48f58d49b
commit
e14a68ef62
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_reporting\Entity;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||
|
||||
/**
|
||||
* Defines the OpenCase Report entity.
|
||||
*
|
||||
* @ConfigEntityType(
|
||||
* id = "opencase_report",
|
||||
* label = @Translation("OpenCase Report"),
|
||||
* handlers = {
|
||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||
* "list_builder" = "Drupal\opencase_reporting\OpenCaseReportListBuilder",
|
||||
* "form" = {
|
||||
* "add" = "Drupal\opencase_reporting\Form\OpenCaseReportForm",
|
||||
* "edit" = "Drupal\opencase_reporting\Form\OpenCaseReportForm",
|
||||
* "delete" = "Drupal\opencase_reporting\Form\OpenCaseReportDeleteForm"
|
||||
* },
|
||||
* "route_provider" = {
|
||||
* "html" = "Drupal\opencase_reporting\OpenCaseReportHtmlRouteProvider",
|
||||
* },
|
||||
* },
|
||||
* config_prefix = "opencase_report",
|
||||
* admin_permission = "use opencase",
|
||||
* entity_keys = {
|
||||
* "id" = "id",
|
||||
* "label" = "label",
|
||||
* "uuid" = "uuid"
|
||||
* },
|
||||
* links = {
|
||||
* "canonical" = "/opencase/reporting/opencase_report/{opencase_report}",
|
||||
* "add-form" = "/opencase/reporting/opencase_report/add",
|
||||
* "edit-form" = "/opencase/reporting/opencase_report/{opencase_report}/edit",
|
||||
* "delete-form" = "/opencase/reporting/opencase_report/{opencase_report}/delete",
|
||||
* "collection" = "/opencase/reporting/opencase_reports"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class OpenCaseReport extends ConfigEntityBase implements OpenCaseReportInterface {
|
||||
|
||||
/**
|
||||
* The OpenCase Report ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The OpenCase Report label.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label;
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_reporting\Entity;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
||||
|
||||
/**
|
||||
* Provides an interface for defining OpenCase Report entities.
|
||||
*/
|
||||
interface OpenCaseReportInterface extends ConfigEntityInterface {
|
||||
|
||||
// Add get/set methods for your configuration properties here.
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_reporting\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityConfirmFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Builds the form to delete OpenCase Report entities.
|
||||
*/
|
||||
class OpenCaseReportDeleteForm extends EntityConfirmFormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCancelUrl() {
|
||||
return new Url('entity.opencase_report.collection');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfirmText() {
|
||||
return $this->t('Delete');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->entity->delete();
|
||||
|
||||
drupal_set_message(
|
||||
$this->t('content @type: deleted @label.',
|
||||
[
|
||||
'@type' => $this->entity->bundle(),
|
||||
'@label' => $this->entity->label(),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_reporting\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityForm;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Class OpenCaseReportForm.
|
||||
*/
|
||||
class OpenCaseReportForm extends EntityForm {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$form = parent::form($form, $form_state);
|
||||
|
||||
$opencase_report = $this->entity;
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Report Title'),
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => $opencase_report->label(),
|
||||
'#required' => TRUE,
|
||||
];
|
||||
|
||||
$form['id'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#default_value' => $opencase_report->id(),
|
||||
'#machine_name' => [
|
||||
'exists' => '\Drupal\opencase_reporting\Entity\OpenCaseReport::load',
|
||||
],
|
||||
'#disabled' => !$opencase_report->isNew(),
|
||||
];
|
||||
|
||||
/* You will need additional form elements for your custom properties. */
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$opencase_report = $this->entity;
|
||||
$status = $opencase_report->save();
|
||||
|
||||
switch ($status) {
|
||||
case SAVED_NEW:
|
||||
drupal_set_message($this->t('Created report: %label.', [
|
||||
'%label' => $opencase_report->label(),
|
||||
]));
|
||||
break;
|
||||
|
||||
default:
|
||||
drupal_set_message($this->t('Saved report: %label.', [
|
||||
'%label' => $opencase_report->label(),
|
||||
]));
|
||||
}
|
||||
$form_state->setRedirectUrl($opencase_report->toUrl('collection'));
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_reporting;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Provides routes for OpenCase Report entities.
|
||||
*
|
||||
* @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
|
||||
* @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
|
||||
*/
|
||||
class OpenCaseReportHtmlRouteProvider extends AdminHtmlRouteProvider {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutes(EntityTypeInterface $entity_type) {
|
||||
$collection = parent::getRoutes($entity_type);
|
||||
|
||||
// Provide your custom entity routes here.
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_reporting;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* Provides a listing of OpenCase Report entities.
|
||||
*/
|
||||
class OpenCaseReportListBuilder extends ConfigEntityListBuilder {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildHeader() {
|
||||
$header['label'] = $this->t('Report');
|
||||
return $header + parent::buildHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
$row['label'] = $entity->label();
|
||||
return $row + parent::buildRow($entity);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user