-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1475 from tripal/tv4g1-1393-ContentTypesYML-ymlOnly
Redo of "Content Types and Fields defined by YAML" focused on minimal changes
- Loading branch information
Showing
30 changed files
with
5,133 additions
and
1,156 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
namespace Drupal\tripal\Entity; | ||
|
||
use Drupal\Core\Config\Entity\ConfigEntityBase; | ||
|
||
/** | ||
* Provides a UI for YML-based TripalEntityType creation. | ||
* Each instance of this entity is a single configuration for tripal content | ||
* types in your site. | ||
* | ||
* @ConfigEntityType( | ||
* id = "tripalentitytype_collection", | ||
* label = @Translation("Tripal Content Type Collection"), | ||
* label_collection = @Translation("Tripal Content Type Collections"), | ||
* label_singular = @Translation("Tripal Content Type Collection"), | ||
* label_plural = @Translation("Tripal Content Type Collections"), | ||
* label_count = @PluralTranslation( | ||
* singular = "@count Tripal Content Type collection", | ||
* plural = "@count Tripal Content Type collections", | ||
* ), | ||
* handlers = { | ||
* "list_builder" = "Drupal\tripal\ListBuilders\TripalEntityTypeCollectionListBuilder", | ||
* "form" = { | ||
* "delete" = "Drupal\tripal\Form\TripalEntityTypeCollectionDeleteForm", | ||
* } | ||
* }, | ||
* config_prefix = "tripalentitytype_collection", | ||
* admin_permission = "administer tripal", | ||
* entity_keys = { | ||
* "id" = "id", | ||
* "label" = "label", | ||
* }, | ||
* config_export = { | ||
* "id", | ||
* "label", | ||
* "description", | ||
* "content_types" | ||
* }, | ||
* links = { | ||
* "delete-form" = "/admin/tripal/config/tripalentitytype-collection/{config}/delete", | ||
* "collection" = "/admin/tripal/config/tripalentitytype-collection" | ||
* } | ||
* ) | ||
*/ | ||
class TripalEntityTypeCollection extends ConfigEntityBase implements TripalEntityTypeCollectionInterface { | ||
|
||
/** | ||
* The TripalEntityTypeCollectionConfig ID. | ||
* | ||
* @var string | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* The TripalEntityTypeCollectionConfig label. | ||
* | ||
* @var string | ||
*/ | ||
protected $label; | ||
|
||
/** | ||
* The TripalEntityTypeCollectionConfig description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description; | ||
|
||
/** | ||
* | ||
* @var array | ||
*/ | ||
protected $content_types; | ||
|
||
/** | ||
* Retrieves the current description for the content type configuration. | ||
* | ||
* @return string | ||
*/ | ||
public function description() { | ||
return $this->description; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
namespace Drupal\tripal\Entity; | ||
|
||
use Drupal\Core\Config\Entity\ConfigEntityInterface; | ||
|
||
/** | ||
* Provides a UI for YML-based TripalEntityType creation. | ||
* Each instance of this entity is a single configuration for tripal content | ||
* types in your site. | ||
*/ | ||
interface TripalEntityTypeCollectionInterface extends ConfigEntityInterface { | ||
// Add get/set methods for your configuration properties here. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Drupal\tripal\Entity; | ||
|
||
use Drupal\Core\Config\Entity\ConfigEntityBase; | ||
|
||
/** | ||
* Provides a UI for YML-based TripalField creation. | ||
* Each instance of this entity is a single configuration for Tripal Field Collection | ||
* in your site. | ||
* | ||
* @ConfigEntityType( | ||
* id = "tripalfield_collection", | ||
* label = @Translation("Tripal Field Collection"), | ||
* label_collection = @Translation("Tripal Field Collection"), | ||
* handlers = { | ||
* "list_builder" = "Drupal\tripal\ListBuilders\TripalFieldCollectionListBuilder", | ||
* "form" = { | ||
* "add" = "Drupal\tripal\Form\TripalFieldCollectionForm", | ||
* "edit" = "Drupal\tripal\Form\TripalFieldCollectionForm", | ||
* "delete" = "Drupal\tripal\Form\TripalFieldCollectionDeleteForm", | ||
* } | ||
* }, | ||
* config_prefix = "tripalfield_collection", | ||
* admin_permission = "administer tripal", | ||
* entity_keys = { | ||
* "id" = "id", | ||
* "label" = "label", | ||
* }, | ||
* config_export = { | ||
* "id", | ||
* "label", | ||
* "description", | ||
* "fields" | ||
* }, | ||
* links = { | ||
* "collection" = "/admin/tripal/config/tripalfield-collection", | ||
* "delete-form" = "/admin/tripal/config/tripalfield-collection/{config}/delete" | ||
* } | ||
* ) | ||
*/ | ||
class TripalFieldCollection extends ConfigEntityBase implements TripalFieldCollectionInterface { | ||
|
||
/** | ||
* The Config ID. | ||
* | ||
* @var string | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* The Config label. | ||
* | ||
* @var string | ||
*/ | ||
protected $label; | ||
|
||
/** | ||
* The Config description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description; | ||
|
||
/** | ||
* | ||
* @var array | ||
*/ | ||
protected $fields; | ||
|
||
/** | ||
* Retrieves the current description. | ||
* | ||
* @return string | ||
*/ | ||
public function description() { | ||
return $this->description; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
namespace Drupal\tripal\Entity; | ||
|
||
use Drupal\Core\Config\Entity\ConfigEntityInterface; | ||
|
||
/** | ||
* Provides a UI for YML-based TripalField creation. | ||
* Each instance of this entity is a single configuration for tripal fields | ||
* in your site. | ||
*/ | ||
interface TripalFieldCollectionInterface extends ConfigEntityInterface { | ||
// Add get/set methods for your configuration properties here. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
namespace Drupal\tripal\Form; | ||
|
||
use Drupal\Core\Entity\EntityConfirmFormBase; | ||
use Drupal\Core\Url; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Builds the form to delete an Chado Term Mapping Config Entity. | ||
*/ | ||
|
||
class TripalEntityTypeCollectionDeleteForm extends EntityConfirmFormBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getQuestion() { | ||
return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDescription() { | ||
return $this->t('You are deleting an entire configuration that specifies how ' . | ||
'content types should be created by Tripal. Rebuild the cache to re-import ' . | ||
'the default settings of this configuration.'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCancelUrl() { | ||
return new Url('entity.tripalentitytype_collection.collection'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfirmText() { | ||
return $this->t('Delete'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
$this->entity->delete(); | ||
$this->messenger()->addMessage($this->t('The %label Tripal Content Type Collection has been deleted.', ['%label' => $this->entity->label()])); | ||
|
||
$form_state->setRedirectUrl($this->getCancelUrl()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
namespace Drupal\tripal\Form; | ||
|
||
use Drupal\Core\Entity\EntityConfirmFormBase; | ||
use Drupal\Core\Url; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Builds the form to delete an Chado Term Mapping Config Entity. | ||
*/ | ||
|
||
class TripalFieldCollectionDeleteForm extends EntityConfirmFormBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getQuestion() { | ||
return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDescription() { | ||
return $this->t('You are deleting an entire configuration that specifies how ' . | ||
'fields are attached to content types in Tripal. Rebuild the cache to re-import ' . | ||
'the default settings of this configuration.'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCancelUrl() { | ||
return new Url('entity.tripalfield_collection.collection'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfirmText() { | ||
return $this->t('Delete'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
$this->entity->delete(); | ||
$this->messenger()->addMessage($this->t('Entity %label has been deleted.', ['%label' => $this->entity->label()])); | ||
|
||
$form_state->setRedirectUrl($this->getCancelUrl()); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
tripal/src/ListBuilders/TripalEntityTypeCollectionListBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Drupal\tripal\ListBuilders; | ||
|
||
use Drupal\Core\Config\Entity\ConfigEntityListBuilder; | ||
use Drupal\Core\Entity\EntityInterface; | ||
|
||
|
||
/** | ||
* Provides a listing of Content Types configurations. | ||
*/ | ||
class TripalEntityTypeCollectionListBuilder extends ConfigEntityListBuilder { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildHeader() { | ||
$header['label'] = $this->t('Configuration Name'); | ||
$header['id'] = $this->t('ID'); | ||
$header['description'] = $this->t('Description'); | ||
return $header + parent::buildHeader(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildRow(EntityInterface $entity) { | ||
$row['label'] = $entity->label(); | ||
$row['id'] = $entity->id(); | ||
$row['description'] = $entity->description(); | ||
|
||
// You probably want a few more properties here... | ||
|
||
return $row + parent::buildRow($entity); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
tripal/src/ListBuilders/TripalFieldCollectionListBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Drupal\tripal\ListBuilders; | ||
|
||
use Drupal\Core\Config\Entity\ConfigEntityListBuilder; | ||
use Drupal\Core\Entity\EntityInterface; | ||
|
||
|
||
/** | ||
* Provides a listing of Tripal Field configurations. | ||
*/ | ||
class TripalFieldCollectionListBuilder extends ConfigEntityListBuilder { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildHeader() { | ||
$header['label'] = $this->t('Configuration Name'); | ||
$header['id'] = $this->t('ID'); | ||
$header['description'] = $this->t('Description'); | ||
return $header + parent::buildHeader(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildRow(EntityInterface $entity) { | ||
$row['label'] = $entity->label(); | ||
$row['id'] = $entity->id(); | ||
$row['description'] = $entity->description(); | ||
|
||
// You probably want a few more properties here... | ||
|
||
return $row + parent::buildRow($entity); | ||
} | ||
|
||
} |
Oops, something went wrong.