Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity content generator fixes #193

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ class {{ entity_class }}DeleteForm extends ContentEntityConfirmFormBase
$this->entity->delete();

watchdog('content', '@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label()));
$form_state['redirect_route'] = $this->getCancelUrl();
$form_state->setRedirect('{{ entity_name }}.list');
}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class {{ entity_class }}Form extends ContentEntityForm
public function submit(array $form, FormStateInterface $form_state) {
// Build the entity object from the submitted values.
$entity = parent::submit($form, $form_state);
$form_state['redirect_route']['route_name'] = '{{ entity_name }}.list';
$form_state->setRedirect('{{ entity_name }}.list');

return $entity;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/skeleton/module/src/Entity/entity-content.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Drupal\{{ module }}\Entity;

{% block use_class %}
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinition;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\{{ module }}\{{ entity_class }}Interface;
Expand Down Expand Up @@ -114,18 +114,18 @@ class {{ entity_class }} extends ContentEntityBase implements {{ entity_class }}
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = FieldDefinition::create('integer')
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the {{ entity_class }} entity.'))
->setReadOnly(TRUE);

$fields['uuid'] = FieldDefinition::create('uuid')
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The UUID of the {{ entity_class }} entity.'))
->setReadOnly(TRUE);


$fields['name'] = FieldDefinition::create('string')
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the {{ entity_class }} entity.'))
->setSettings(array(
Expand All @@ -145,15 +145,15 @@ class {{ entity_class }} extends ContentEntityBase implements {{ entity_class }}
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);

$fields['langcode'] = FieldDefinition::create('language')
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The language code of {{ entity_class }} entity.'));

$fields['created'] = FieldDefinition::create('created')
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));

$fields['changed'] = FieldDefinition::create('changed')
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Drupal\{{module}};
{% endblock %}

{% block use_class %}
use Drupal\Core\Entity\EntityAccessController;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
{% endblock %}
Expand All @@ -20,7 +20,7 @@ use Drupal\Core\Session\AccountInterface;
*
* @see \Drupal\{{module}}\Entity\{{ entity_class }}.
*/
class {{ entity_class }}AccessController extends EntityAccessController
class {{ entity_class }}AccessController extends EntityAccessControlHandler
{% endblock %}

{% block class_methods %}
Expand Down