Loading modules/freelinking_prepopulate/src/Plugin/freelinking/FreelinkingPrepopulate.php +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ class FreelinkingPrepopulate extends FreelinkingPluginBase implements ContainerF $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); $options = array_reduce($node_types, function (&$result, $node_type) { $options = array_reduce($node_types, function ($result, $node_type) { /** @var \Drupal\node\Entity\NodeType $node_type */ $result[$node_type->id()] = $node_type->label(); return $result; Loading modules/freelinking_prepopulate/tests/src/Functional/FreelinkingPrepopulateTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\Tests\freelinking\Functional\FreelinkingBrowserTestBase; use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait; use Drupal\user\Entity\Role; /** * Tests embedded prepopulate links. Loading Loading @@ -39,6 +40,15 @@ class FreelinkingPrepopulateTest extends FreelinkingBrowserTestBase { // Creates a content type to act as default prepopulate content type. $this->createContentType(['name' => 'Person', 'type' => 'person']); $this->createContentType(['name' => 'Restricted', 'type' => 'restricted']); $role_ids = $this->privilegedUser->getRoles(TRUE); $rid = reset($role_ids); $role = Role::load($rid); $this->grantPermissions($role, [ 'create person content', 'edit own person content', ]); $vocabulary = $this->createVocabulary(); Loading Loading @@ -119,6 +129,7 @@ class FreelinkingPrepopulateTest extends FreelinkingBrowserTestBase { <li>Default with body: [[create:Alex|Alex|Add Alex|body="A page about Alex."]]</li> <li>Basic page: [[create:History of Programming|History of Programming|Create New Page|type=page]]</li> <li>With fields: [[create:Sam|Sam|Add Sam|body="A page about Sam."|field_basic="test"|field_tags="tag1,tag2,tag3"]]</li> <li>Restricted: [[create:Secret|Secret|Create New Restricted|type=restricted]]</li> </ul> EOF; $this->drupalGet('node/add/page'); Loading Loading @@ -147,6 +158,8 @@ EOF; ->linkByHrefExists($pageLinkHref); $this->assertSession() ->linkByHrefExists($fieldsLinkHref); $this->assertSession() ->pageTextContainsOnce('Freelinking: Access denied to create missing content.'); // Logout and visit the page. $this->drupalLogout(); Loading src/Plugin/Filter/Freelinking.php +2 −2 Original line number Diff line number Diff line Loading @@ -318,7 +318,7 @@ EOF; * The plugin information. */ public static function extractPluginSettings($plugin_name, array $plugins) { return array_reduce($plugins, function (&$result, $info) use ($plugin_name) { return array_reduce($plugins, function ($result, $info) use ($plugin_name) { if ($info['plugin'] === $plugin_name) { $result = $info; } Loading @@ -336,7 +336,7 @@ EOF; * An indexed array of allowed plugin information. */ protected function extractAllowedPlugins(array $plugins) { return array_reduce($plugins, function (&$result, $info) { return array_reduce($plugins, function ($result, $info) { if ($info['enabled']) { $result[$info['plugin']] = $info; } Loading src/Plugin/freelinking/NodeTitle.php +1 −1 Original line number Diff line number Diff line Loading @@ -199,7 +199,7 @@ class NodeTitle extends FreelinkingPluginBase implements FreelinkingPluginInterf */ protected function getAllowedNodeTypes() { $node_types = $this->configuration['settings']['nodetypes']; return array_reduce($node_types, function (&$result, $item) { return array_reduce($node_types, function ($result, $item) { if ($item) { $result[] = $item; } Loading tests/src/Unit/Plugin/freelinking/DrupalOrgTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ class DrupalOrgTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { // Mock string translation service. $tProphet = $this->prophesize('\Drupal\Core\StringTranslation\TranslationInterface'); $tProphet->translateString(Argument::any())->willReturn('Click to view on drupal.org.'); Loading Loading
modules/freelinking_prepopulate/src/Plugin/freelinking/FreelinkingPrepopulate.php +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ class FreelinkingPrepopulate extends FreelinkingPluginBase implements ContainerF $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); $options = array_reduce($node_types, function (&$result, $node_type) { $options = array_reduce($node_types, function ($result, $node_type) { /** @var \Drupal\node\Entity\NodeType $node_type */ $result[$node_type->id()] = $node_type->label(); return $result; Loading
modules/freelinking_prepopulate/tests/src/Functional/FreelinkingPrepopulateTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\Tests\freelinking\Functional\FreelinkingBrowserTestBase; use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait; use Drupal\user\Entity\Role; /** * Tests embedded prepopulate links. Loading Loading @@ -39,6 +40,15 @@ class FreelinkingPrepopulateTest extends FreelinkingBrowserTestBase { // Creates a content type to act as default prepopulate content type. $this->createContentType(['name' => 'Person', 'type' => 'person']); $this->createContentType(['name' => 'Restricted', 'type' => 'restricted']); $role_ids = $this->privilegedUser->getRoles(TRUE); $rid = reset($role_ids); $role = Role::load($rid); $this->grantPermissions($role, [ 'create person content', 'edit own person content', ]); $vocabulary = $this->createVocabulary(); Loading Loading @@ -119,6 +129,7 @@ class FreelinkingPrepopulateTest extends FreelinkingBrowserTestBase { <li>Default with body: [[create:Alex|Alex|Add Alex|body="A page about Alex."]]</li> <li>Basic page: [[create:History of Programming|History of Programming|Create New Page|type=page]]</li> <li>With fields: [[create:Sam|Sam|Add Sam|body="A page about Sam."|field_basic="test"|field_tags="tag1,tag2,tag3"]]</li> <li>Restricted: [[create:Secret|Secret|Create New Restricted|type=restricted]]</li> </ul> EOF; $this->drupalGet('node/add/page'); Loading Loading @@ -147,6 +158,8 @@ EOF; ->linkByHrefExists($pageLinkHref); $this->assertSession() ->linkByHrefExists($fieldsLinkHref); $this->assertSession() ->pageTextContainsOnce('Freelinking: Access denied to create missing content.'); // Logout and visit the page. $this->drupalLogout(); Loading
src/Plugin/Filter/Freelinking.php +2 −2 Original line number Diff line number Diff line Loading @@ -318,7 +318,7 @@ EOF; * The plugin information. */ public static function extractPluginSettings($plugin_name, array $plugins) { return array_reduce($plugins, function (&$result, $info) use ($plugin_name) { return array_reduce($plugins, function ($result, $info) use ($plugin_name) { if ($info['plugin'] === $plugin_name) { $result = $info; } Loading @@ -336,7 +336,7 @@ EOF; * An indexed array of allowed plugin information. */ protected function extractAllowedPlugins(array $plugins) { return array_reduce($plugins, function (&$result, $info) { return array_reduce($plugins, function ($result, $info) { if ($info['enabled']) { $result[$info['plugin']] = $info; } Loading
src/Plugin/freelinking/NodeTitle.php +1 −1 Original line number Diff line number Diff line Loading @@ -199,7 +199,7 @@ class NodeTitle extends FreelinkingPluginBase implements FreelinkingPluginInterf */ protected function getAllowedNodeTypes() { $node_types = $this->configuration['settings']['nodetypes']; return array_reduce($node_types, function (&$result, $item) { return array_reduce($node_types, function ($result, $item) { if ($item) { $result[] = $item; } Loading
tests/src/Unit/Plugin/freelinking/DrupalOrgTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ class DrupalOrgTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { // Mock string translation service. $tProphet = $this->prophesize('\Drupal\Core\StringTranslation\TranslationInterface'); $tProphet->translateString(Argument::any())->willReturn('Click to view on drupal.org.'); Loading