You are here

protected function ProtectedNodeParagraphs::createProtectedNodeWithParagraphs in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.paragraphs.test \ProtectedNodeParagraphs::createProtectedNodeWithParagraphs()

Helper for creating a new protected node with a nested paragraphs item.

Please make sure the user has the permission to create the node before calling the method.

Parameters

string $password: A password.

Return value

array An array containing the node and the paragraphs_item object.

3 calls to ProtectedNodeParagraphs::createProtectedNodeWithParagraphs()
ProtectedNodeParagraphs::testAllowedView in tests/protected_node.paragraphs.test
Test function.
ProtectedNodeParagraphs::testAllowedViewWrongPassword in tests/protected_node.paragraphs.test
Test function.
ProtectedNodeParagraphs::testAuthenticatedNonAllowedView in tests/protected_node.paragraphs.test
Test function.

File

tests/protected_node.paragraphs.test, line 235
Test protected node behavior with paragraphs private files.

Class

ProtectedNodeParagraphs
Configure protected_node to use per node password and use private file field.

Code

protected function createProtectedNodeWithParagraphs($password) {
  $node = $this
    ->createProtectedNode($password);

  // Retrieve the child paragraphs item.
  $parent_paragraphs_item_id = $node->{$this->paragraphs_field_name}[LANGUAGE_NONE][0]['value'];
  $paragraphs_items = entity_load('paragraphs_item', array(
    $parent_paragraphs_item_id,
  ));
  $paragraphs_item = array_shift($paragraphs_items);
  $child_paragraphs_item_id = $paragraphs_item->{$this->paragraphs_field_name}[LANGUAGE_NONE][0]['value'];
  $paragraphs_items = entity_load('paragraphs_item', array(
    $child_paragraphs_item_id,
  ));
  $paragraphs_item = array_shift($paragraphs_items);
  return array(
    'node' => $node,
    'paragraphs_item' => $paragraphs_item,
  );
}