diff --git a/content_entity_example/content_entity_example.menu_links.yml b/content_entity_example/content_entity_example.menu_links.yml new file mode 100755 index 0000000..3e9098e --- /dev/null +++ b/content_entity_example/content_entity_example.menu_links.yml @@ -0,0 +1,10 @@ +content_entity_example.list: + title: Content Entity Example Listing + route_name: content_entity_example.list + description: 'List ContentEntityExample content' + weight: 10 +content_entity_example.admin.structure.settings: + title: Content Entity Example Settings + description: 'Configure content_entity_example entity' + route_name: content_entity_example.settings + parent: system.admin_structure diff --git a/content_entity_example/content_entity_example.module b/content_entity_example/content_entity_example.module index 45584f3..f3e4812 100755 --- a/content_entity_example/content_entity_example.module +++ b/content_entity_example/content_entity_example.module @@ -14,28 +14,6 @@ */ /** - * Implements hook_menu_link_defaults(). - */ -function content_entity_example_menu_link_defaults() { - $links = array(); - - $links['content_entity_example.admin.structure.settings'] = array( - 'link_title' => t('Content Entity Example Settings'), - 'description' => 'Configure content_entity_example entity', - 'route_name' => 'content_entity_example.settings', - 'parent' => 'system.admin.structure', - ); - - $links['content_entity_example.list'] = array( - 'link_title' => t('Content Entity Example Listing'), - 'description' => 'List ContentEntityExample content', - 'route_name' => 'content_entity_example.list', - ); - - return $links; -} - -/** * Implements hook_permission(). */ function content_entity_example_permission() { diff --git a/content_entity_example/lib/Drupal/content_entity_example/Entity/ContentEntityExample.php b/content_entity_example/lib/Drupal/content_entity_example/Entity/ContentEntityExample.php index 187769c..1ff8431 100755 --- a/content_entity_example/lib/Drupal/content_entity_example/Entity/ContentEntityExample.php +++ b/content_entity_example/lib/Drupal/content_entity_example/Entity/ContentEntityExample.php @@ -5,7 +5,7 @@ */ namespace Drupal\content_entity_example\Entity; -use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldDefinition; use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\EntityTypeInterface; @@ -49,7 +49,7 @@ class ContentEntityExample extends ContentEntityBase implements ContentEntityExa /** * {@inheritdoc} */ - public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { + public static function preCreate(EntityStorageInterface $storage_controller, array &$values) { parent::preCreate($storage_controller, $values); $values += array( 'user_id' => \Drupal::currentUser()->id(), diff --git a/content_entity_example/lib/Drupal/content_entity_example/Entity/Form/ContentEntityExampleFormController.php b/content_entity_example/lib/Drupal/content_entity_example/Entity/Form/ContentEntityExampleFormController.php index 54a55a5..3a448ba 100755 --- a/content_entity_example/lib/Drupal/content_entity_example/Entity/Form/ContentEntityExampleFormController.php +++ b/content_entity_example/lib/Drupal/content_entity_example/Entity/Form/ContentEntityExampleFormController.php @@ -21,7 +21,7 @@ class ContentEntityExampleFormController extends ContentEntityFormController { */ public function buildForm(array $form, array &$form_state) { /* @var $entity \Drupal\content_entity_example\Entity\ContentEntityExample */ - $form = parent::form($form, $form_state); + $form = parent::buildForm($form, $form_state); $entity = $this->entity; $form['user_id'] = array( diff --git a/content_entity_example/lib/Drupal/content_entity_example/Tests/ContentEntityExampleTest.php b/content_entity_example/lib/Drupal/content_entity_example/Tests/ContentEntityExampleTest.php index 41535af..1e45866 100755 --- a/content_entity_example/lib/Drupal/content_entity_example/Tests/ContentEntityExampleTest.php +++ b/content_entity_example/lib/Drupal/content_entity_example/Tests/ContentEntityExampleTest.php @@ -17,7 +17,9 @@ use Drupal\simpletest\WebTestBase; */ class ContentEntityExampleTest extends WebTestBase { - public static $modules = array('content_entity_example'); + public static $modules = array('content_entity_example', 'block'); + + protected $web_user; /** * {@inheritdoc} @@ -30,23 +32,23 @@ class ContentEntityExampleTest extends WebTestBase { ); } + public function setUp() { + parent::setUp(); + + $this->web_user = $this->drupalCreateUser(array('view content_entity_example entity')); + $this->drupalPlaceBlock('system_menu_block:tools', array()); + } /** * Basic tests for Content Entity Example. */ public function testContentEntityExample() { - // Listing menu not visible without permission. - $this->drupalGet('/'); - $this->assertNoText('Content Entity Example Listing', - 'The listing menu appears on the page'); + $this->assertNoText('Content Entity Example Listing'); + + $this->drupalLogin($this->web_user); - // Add permission. - $web_user = $this->drupalCreateUser(array('view content_entity_example entity')); - $this->drupalLogin($web_user); - $this->drupalGet('/'); + $this->assertLink('Content Entity Example Listing'); - $this->assertText('Content Entity Example Listing', - 'The listing menu appears on the page'); } }