• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP entity_get_controller函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中entity_get_controller函数的典型用法代码示例。如果您正苦于以下问题:PHP entity_get_controller函数的具体用法?PHP entity_get_controller怎么用?PHP entity_get_controller使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了entity_get_controller函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: refreshToken

 /**
  * Create a token for a user, and return its value.
  *
  * @param string $token
  *   The refresh token.
  *
  * @throws BadRequestException
  *
  * @return RestfulTokenAuth
  *   The new access token.
  */
 public function refreshToken($token)
 {
     // Check if there is a token that did not expire yet.
     /* @var \Drupal\restful\Plugin\resource\DataProvider\DataProviderEntityInterface $data_provider */
     $data_provider = $this->getDataProvider();
     $query = $data_provider->EFQObject();
     $results = $query->entityCondition('entity_type', $this->entityType)->entityCondition('bundle', 'refresh_token')->propertyCondition('token', $token)->range(0, 1)->execute();
     if (empty($results['restful_token_auth'])) {
         throw new BadRequestException('Invalid refresh token.');
     }
     // Remove the refresh token once used.
     $refresh_token = entity_load_single('restful_token_auth', key($results['restful_token_auth']));
     $uid = $refresh_token->uid;
     // Get the access token linked to this refresh token then do some cleanup.
     $access_token_query = new EntityFieldQuery();
     $access_token_reference = $access_token_query->entityCondition('entity_type', 'restful_token_auth')->entityCondition('bundle', 'access_token')->fieldCondition('refresh_token_reference', 'target_id', $refresh_token->id)->range(0, 1)->execute();
     if (!empty($access_token_reference['restful_token_auth'])) {
         $access_token = key($access_token_reference['restful_token_auth']);
         entity_delete('restful_token_auth', $access_token);
     }
     $refresh_token->delete();
     // Create the new access token and return it.
     /* @var \Drupal\restful_token_auth\Entity\RestfulTokenAuthController $controller */
     $controller = entity_get_controller($this->getEntityType());
     $token = $controller->generateAccessToken($uid);
     return $this->view($token->id);
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:38,代码来源:RefreshToken__1_0.php


示例2: testCreateNode

 /**
  * Test node creation by editor.
  *
  * 1. Editor creates Draft node
  * 2. Editor set status from Draft to Final Draft
  * 3. The node appears in the users's overview screen.
  */
 public function testCreateNode()
 {
     $this->drupalGet('node/add/news');
     $this->assertRaw('Current: Draft');
     $this->assertRaw('Final Draft');
     $this->assertNoRaw('Rejected');
     $this->assertNoRaw('Approved');
     $this->assertNoRaw('To Be Reviewed');
     $this->assertNoRaw('To Be Approved');
     $this->assertNoRaw('Ready To Publish');
     $this->assertNoRaw('Published');
     // Create a node in Draft state.
     $options = array('title_field[und][0][value]' => $this->nodeTitle1);
     $this->drupalPost('node/add/news', $options, t('Save'));
     $node = $this->drupalGetNodeByTitle($this->nodeTitle1);
     $nid = $node->nid;
     $this->assertEquals('draft', $node->workbench_moderation['current']->state);
     // Moderate to Final Draft.
     $options = array('title_field[en][0][value]' => $this->nodeTitle1, 'workbench_moderation_state_new' => 'final_draft');
     $this->drupalPost("node/{$nid}/edit", $options, t('Save'));
     // Reset the cache sice we are using node_load().
     entity_get_controller('node')->resetCache(array($node->nid));
     $node = node_load($nid);
     $this->assertEquals('final_draft', $node->workbench_moderation['current']->state);
     // Test the node appears in user's overview screen.
     $this->drupalGet('admin/workbench');
     $this->assertText($this->nodeTitle1);
 }
开发者ID:enriquesanchezhernandez,项目名称:campaigns,代码行数:35,代码来源:WorkflowPublicationEditorTest.php


示例3: getOrCreateToken

 /**
  * Create a token for a user, and return its value.
  */
 public function getOrCreateToken()
 {
     $entity_type = $this->getEntityType();
     $account = $this->getAccount();
     // Check if there is a token that did not expire yet.
     /* @var DataProviderEntityInterface $data_provider */
     $data_provider = $this->getDataProvider();
     $query = $data_provider->EFQObject();
     $result = $query->entityCondition('entity_type', $entity_type)->entityCondition('bundle', 'access_token')->propertyCondition('uid', $account->uid)->range(0, 1)->execute();
     $token_exists = FALSE;
     if (!empty($result[$entity_type])) {
         $id = key($result[$entity_type]);
         $access_token = entity_load_single($entity_type, $id);
         $token_exists = TRUE;
         if (!empty($access_token->expire) && $access_token->expire < REQUEST_TIME) {
             if (variable_get('restful_token_auth_delete_expired_tokens', TRUE)) {
                 // Token has expired, so we can delete this token.
                 $access_token->delete();
             }
             $token_exists = FALSE;
         }
     }
     if (!$token_exists) {
         /* @var \Drupal\restful_token_auth\Entity\RestfulTokenAuthController $controller */
         $controller = entity_get_controller($this->getEntityType());
         $access_token = $controller->generateAccessToken($account->uid);
         $id = $access_token->id;
     }
     $output = $this->view($id);
     return $output;
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:34,代码来源:AccessToken__1_0.php


示例4: testModerateToBeApproved

 /**
  * Test node creation by editor.
  *
  * 1. Editor creates Draft node
  * 2. Editor set status from Draft to Final Draft
  * 3. The node appears in the users's overview screen.
  */
 public function testModerateToBeApproved()
 {
     $this->loginAs('editor1');
     $node = $this->drupalCreateNode(array('language' => 'en', 'title' => $this->nodeTitle1, 'type' => 'news', 'workbench_access' => 1007));
     workbench_moderation_moderate($node, 'final_draft');
     $this->loginAs('review_manager1');
     // Set node status To Be Reviewed.
     $options = array('title_field[en][0][value]' => $this->nodeTitle1, 'workbench_moderation_state_new' => 'needs_review');
     $this->drupalPost("node/{$node->nid}/edit", $options, t('Save'));
     entity_get_controller('node')->resetCache(array($node->nid));
     $node = node_load($node->nid);
     $this->assertEquals('needs_review', $node->workbench_moderation['current']->state);
     // Set the reviewer to project_manager1
     $pm1 = user_load_by_name('project_manager1');
     $options = array('project_manager' => $pm1->uid);
     $this->drupalPost("node/{$node->nid}/review", $options, t('Change'));
     $this->drupalGet("node/{$node->nid}/review");
     $this->assertText('project_manager1');
     // Define the list of approvers.
     // Cannot use drupalPost here.
     $ap1 = user_load_by_name('approver1');
     $ap2 = user_load_by_name('approver2 ');
     $form_state = array('node' => $node, 'values' => array('rows' => array($ap1->uid => array('weight' => -10), $ap2->uid => array('weight' => -11))));
     module_load_include('inc', 'osha_workflow', 'osha_workflow.admin');
     drupal_form_submit('osha_workflow_node_approval_form', $form_state, $node);
     $this->drupalGet("node/{$node->nid}/approve");
     $this->assertText($ap1->name);
     $this->assertText($ap2->name);
     $this->loginAs('project_manager1');
     $options = array('workbench_moderation_state_new' => 'to_be_approved');
     $this->drupalPost("node/{$node->nid}/edit", $options, t('Save'));
     entity_get_controller('node')->resetCache(array($node->nid));
     $node = node_load($node->nid);
     $this->assertEquals('to_be_approved', $node->workbench_moderation['current']->state);
 }
开发者ID:enriquesanchezhernandez,项目名称:campaigns,代码行数:42,代码来源:WorkflowPublicationProjectManagerTest.php


示例5: setUp

 function setUp()
 {
     $this->entityTypeId = 'user';
     $this->testLanguageSelector = FALSE;
     $this->name = $this->randomName();
     parent::setUp();
     entity_get_controller('user')->resetCache();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:8,代码来源:UserTranslationUITest.php


示例6: getController

 /**
  * Get Drupal 7 entity controller
  *
  * @return \DrupalEntityControllerInterface
  */
 protected final function getController()
 {
     if (!$this->controller) {
         $this->controller = entity_get_controller($this->entityType);
         if (!$this->controller) {
             throw new \InvalidArgumentException(sprintf("%s: entity type does not exist", $this->entityType));
         }
     }
     return $this->controller;
 }
开发者ID:makinacorpus,项目名称:drupal-sf-dic,代码行数:15,代码来源:DefaultEntityStorageProxy.php


示例7: assertFieldValues

 /**
  * Assert that a field has the expected values in an entity.
  *
  * This function only checks a single column in the field values.
  *
  * @param EntityInterface $entity
  *   The entity to test.
  * @param $field_name
  *   The name of the field to test
  * @param $expected_values
  *   The array of expected values.
  * @param $langcode
  *   (Optional) The language code for the values. Defaults to
  *   \Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED.
  * @param $column
  *   (Optional) The name of the column to check. Defaults to 'value'.
  */
 function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $column = 'value')
 {
     // Re-load the entity to make sure we have the latest changes.
     entity_get_controller($entity->getEntityTypeId())->resetCache(array($entity->id()));
     $e = entity_load($entity->getEntityTypeId(), $entity->id());
     $field = $values = $e->getTranslation($langcode)->{$field_name};
     // Filter out empty values so that they don't mess with the assertions.
     $field->filterEmptyItems();
     $values = $field->getValue();
     $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
     foreach ($expected_values as $key => $value) {
         $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:31,代码来源:FieldTestBase.php


示例8: testModerateToNeedsReview

 /**
  * Test node creation by editor.
  *
  * 1. Editor creates Draft node
  * 2. Editor set status from Draft to Final Draft
  * 3. The node appears in the users's overview screen.
  */
 public function testModerateToNeedsReview()
 {
     $this->loginAs('editor1');
     $this->drupalGet('node/add/news');
     $this->assertRaw('Current: Draft');
     $this->assertRaw('Final Draft');
     $this->assertNoRaw('Rejected');
     $this->assertNoRaw('Approved');
     $this->assertNoRaw('To Be Reviewed');
     $this->assertNoRaw('To Be Approved');
     $this->assertNoRaw('Ready To Publish');
     $this->assertNoRaw('Published');
     // Create a node1, node2 in Final draft state.
     $options = array('title_field[und][0][value]' => $this->nodeTitle1, 'workbench_moderation_state_new' => 'final_draft');
     $this->drupalPost('node/add/news', $options, t('Save'));
     $node1 = $this->drupalGetNodeByTitle($this->nodeTitle1);
     $this->assertEquals('final_draft', $node1->workbench_moderation['current']->state);
     $options = array('title_field[und][0][value]' => $this->nodeTitle2, 'workbench_moderation_state_new' => 'final_draft');
     $this->drupalPost('node/add/news', $options, t('Save'));
     $node2 = $this->drupalGetNodeByTitle($this->nodeTitle2);
     $this->assertEquals('final_draft', $node1->workbench_moderation['current']->state);
     $this->loginAs('review_manager1');
     // Moderate node1 to Needs Review.
     $nid1 = $node1->nid;
     $options = array('title_field[en][0][value]' => $this->nodeTitle1, 'workbench_moderation_state_new' => 'needs_review');
     $this->drupalPost("node/{$nid1}/edit", $options, t('Save'));
     // Moderate node2 to Draft.
     $nid2 = $node2->nid;
     $options = array('title_field[en][0][value]' => $this->nodeTitle2, 'workbench_moderation_state_new' => 'draft');
     $this->drupalPost("node/{$nid2}/edit", $options, t('Save'));
     // Reset the cache sice we are using node_load().
     entity_get_controller('node')->resetCache(array($node1->nid, $node2->nid));
     $node1 = node_load($nid1);
     $node2 = node_load($nid2);
     $this->assertEquals('needs_review', $node1->workbench_moderation['current']->state);
     $this->assertEquals('draft', $node2->workbench_moderation['current']->state);
     // Test the node appears in user's needs review.
     $this->drupalGet('admin/workbench');
     $this->assertText($this->nodeTitle1);
     $this->assertText($this->nodeTitle2);
 }
开发者ID:enriquesanchezhernandez,项目名称:campaigns,代码行数:48,代码来源:WorkflowPublicationReviewManagerTest.php


示例9: refreshToken

  /**
   * Create a token for a user, and return its value.
   *
   * @param string $token
   *   The refresh token.
   *
   * @throws RestfulBadRequestException
   *
   * @return \RestfulTokenAuth
   *   The new access token.
   */
  public function refreshToken($token) {
    // Check if there is a token that did not expire yet.
    $query = new EntityFieldQuery();
    $results = $query
      ->entityCondition('entity_type', $this->entityType)
      ->entityCondition('bundle', 'refresh_token')
      ->propertyCondition('token', $token)
      ->range(0, 1)
      ->execute();

    if (empty($results['restful_token_auth'])) {
      throw new \RestfulBadRequestException('Invalid refresh token.');
    }

    // Remove the refresh token once used.
    $refresh_token = entity_load_single('restful_token_auth', key($results['restful_token_auth']));
    $uid = $refresh_token->uid;

    // Get the access token linked to this refresh token then do some cleanup.
    $access_token_query = new EntityFieldQuery();
    $access_token_reference = $access_token_query
      ->entityCondition('entity_type', $this->getEntityType())
      ->entityCondition('bundle', $this->getBundle())
      ->fieldCondition('refresh_token_reference', 'target_id', $refresh_token->id)
      ->range(0, 1)
      ->execute();

    if (!empty($access_token_reference['restful_token_auth'])) {
      $access_token_id = key($access_token_reference['restful_token_auth']);
      entity_delete('restful_token_auth', $access_token_id);
    }

    $refresh_token->delete();

    // Create the new access token and return it.
    $controller = entity_get_controller($this->getEntityType());
    $token = $controller->generateAccessToken($uid);
    return $this->viewEntity($token->id);
  }
开发者ID:humanitarianresponse,项目名称:site,代码行数:50,代码来源:RestfulRefreshTokenAuthentication.class.php


示例10: ensureSubqueue

 /**
  * Makes sure that every simple queue has a subqueue.
  */
 protected function ensureSubqueue()
 {
     global $user;
     static $queues = array();
     if (!isset($queues[$this->queue->name])) {
         $queues[$this->queue->name] = TRUE;
         $transaction = db_transaction();
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'entityqueue_subqueue')->entityCondition('bundle', $this->queue->name);
         $result = $query->execute();
         // If we don't have a subqueue already, create one now.
         if (empty($result['entityqueue_subqueue'])) {
             $subqueue = entityqueue_subqueue_create();
             $subqueue->queue = $this->queue->name;
             $subqueue->name = $this->queue->name;
             $subqueue->label = $this->getSubqueueLabel($subqueue);
             $subqueue->module = 'entityqueue';
             $subqueue->uid = $user->uid;
             entity_get_controller('entityqueue_subqueue')->save($subqueue, $transaction);
         }
     }
 }
开发者ID:dalia-m-elsayed,项目名称:spica,代码行数:25,代码来源:SimpleEntityQueueHandler.class.php


示例11: refreshToken

  /**
   * Create a token for a user, and return its value.
   *
   * @param string $token
   *   The refresh token.
   *
   * @throws RestfulBadRequestException
   *
   * @return \RestfulTokenAuth
   *   The new access token.
   */
  public function refreshToken($token) {
    $account = $this->getAccount();
    // Check if there is a token that did not expire yet.
    $query = new EntityFieldQuery();
    $results = $query
      ->entityCondition('entity_type', $this->entityType)
      ->entityCondition('bundle', 'refresh_token')
      ->propertyCondition('token', $token)
      ->range(0, 1)
      ->execute();

    if (empty($results['restful_token_auth'])) {
      throw new \RestfulBadRequestException('Invalid refresh token.');
    }

    // Remove the refresh token once used.
    $refresh_token = entity_load_single('restful_token_auth', key($results['restful_token_auth']));
    $refresh_token->delete();

    // Create the new access token and return it.
    $controller = entity_get_controller($this->getEntityType());
    $token = $controller->generateAccessToken($account->uid);
    return $this->viewEntity($token->id);
  }
开发者ID:pcambra,项目名称:site,代码行数:35,代码来源:RestfulRefreshTokenAuthentication.class.php


示例12: delete

 public function delete($fpids)
 {
     $transaction = db_transaction();
     if (!empty($fpids)) {
         $entities = fieldable_panels_panes_load_multiple($fpids, array());
         try {
             foreach ($entities as $fpid => $entity) {
                 // Call the entity-specific callback (if any):
                 module_invoke_all('entity_delete', $entity, 'fieldable_panels_pane');
                 field_attach_delete('fieldable_panels_pane', $entity);
             }
             // Delete after calling hooks so that they can query entity tables as needed.
             db_delete('fieldable_panels_panes')->condition('fpid', $fpids, 'IN')->execute();
             db_delete('fieldable_panels_panes_revision')->condition('fpid', $fpids, 'IN')->execute();
         } catch (Exception $e) {
             $transaction->rollback();
             watchdog_exception('fieldable_panels_pane', $e);
             throw $e;
         }
         // Clear the page and block and entity_load_multiple caches.
         entity_get_controller('fieldable_panels_pane')->resetCache();
     }
 }
开发者ID:bellcom,项目名称:syddjurs.dk,代码行数:23,代码来源:PanelsPaneController.class.php


示例13: deleteOne

 /**
  * Deletes one address.
  *
  * @param int $type
  *   Type of the argument given, can be the address id (BY_AID) or the address nickname (BY_NAME).
  * @param mixed $arg
  *   Either the address id or the address nickname.
  *
  * @access private
  * @return boolean
  *   TRUE if the address was deleted.
  *   FALSE otherwise.
  * @throws UcAddressesDbException
  */
 private function deleteOne($type, $arg)
 {
     // Reasons to skip out early
     if (!$this->isOwned()) {
         return FALSE;
     }
     // We can't delete an address that is a default address, so
     // we'll need to make sure this address is loaded.
     $this->loadOne($type, $arg);
     if ($type == self::BY_AID) {
         $address = $this->getAddressById($arg);
     }
     if ($type == self::BY_NAME) {
         $address = $this->getAddressByName($arg);
     }
     if (!$address) {
         return FALSE;
     }
     if ($address->isDefault('shipping') || $address->isDefault('billing')) {
         return FALSE;
     }
     // Delete the address from the database only if it is not new (else it won't exist in the db).
     if (!$address->isNew()) {
         db_delete('uc_addresses')->condition('aid', $address->getId())->execute();
     }
     // Remove from address book object.
     $this->removeAddressFromAddressBook($address);
     // Give other modules a chance to react on this.
     module_invoke_all('uc_addresses_address_delete', $address);
     entity_get_controller('uc_addresses')->invoke('delete', $address);
     return TRUE;
 }
开发者ID:shaheerali49,项目名称:herozfitcart,代码行数:46,代码来源:UcAddressesAddressBook.class.php


示例14: deleteProgrammatically

 /**
  * Deletes the entity from database. This is copied from the entity_delete()
  * function since entity module may not be installed.
  */
 public function deleteProgrammatically()
 {
     $entity_class = "RedTest\\core\\entities\\" . Utils::makeTitleCase($this->entity_type);
     $info = entity_get_info($this->entity_type);
     if (isset($info['deletion callback'])) {
         $info['deletion callback']($this->getId());
         return TRUE;
     } elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
         entity_get_controller($this->entity_type)->delete(array($this->getId()));
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:18,代码来源:Entity.php


示例15: purgeInstanceData

 /**
  * Purge all data from a field instance.
  *
  * @param array $instance
  *   The field instance definition. This may be deleted or inactive.
  */
 public static function purgeInstanceData(array $instance)
 {
     $field = static::readFieldByID($instance['field_id']);
     $data_table = _field_sql_storage_tablename($field);
     // Ensure the entity caches are cleared for the changed entities.
     if ($ids = db_query("SELECT entity_id FROM {$data_table} WHERE entity_type = :type AND bundle = :bundle", array(':type' => $instance['entity_type'], ':bundle' => $instance['bundle']))->fetchCol()) {
         entity_get_controller($instance['entity_type'])->resetCache($ids);
         db_delete($data_table)->condition('entity_type', $instance['entity_type'])->condition('bundle', $instance['bundle'])->execute();
     }
     $revision_table = _field_sql_storage_revision_tablename($field);
     if (db_table_exists($revision_table)) {
         db_delete($revision_table)->condition('entity_type', $instance['entity_type'])->condition('bundle', $instance['bundle'])->execute();
     }
     watchdog('helper', "Purged data for field instance ID {$instance['id']}.");
 }
开发者ID:juampynr,项目名称:DrupalCampEs,代码行数:21,代码来源:FieldHelper.php


示例16: renderTestEntity

 /**
  * Renders a entity_test and sets the output in the internal browser.
  *
  * @param int $id
  *   The entity_test ID to render.
  * @param string $view_mode
  *   (optional) The view mode to use for rendering. Defaults to 'full'.
  * @param bool $reset
  *   (optional) Whether to reset the entity_test controller cache. Defaults to
  *   TRUE to simplify testing.
  */
 protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE)
 {
     if ($reset) {
         entity_get_controller('entity_test')->resetCache(array($id));
     }
     $entity = entity_load('entity_test', $id);
     $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode);
     $build = $display->build($entity);
     $output = drupal_render($build);
     $this->drupalSetContent($output);
     $this->verbose($output);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:23,代码来源:DateTimeFieldTest.php


示例17: testHiddenField

 /**
  * Tests hiding a field in a form.
  */
 function testHiddenField()
 {
     $entity_type = 'entity_test_rev';
     $field_storage = $this->fieldStorageSingle;
     $field_storage['entity_type'] = $entity_type;
     $field_name = $field_storage['name'];
     $this->instance['field_name'] = $field_name;
     $this->instance['default_value'] = array(0 => array('value' => 99));
     $this->instance['entity_type'] = $entity_type;
     $this->instance['bundle'] = $entity_type;
     entity_create('field_storage_config', $field_storage)->save();
     $this->instance = entity_create('field_instance_config', $this->instance);
     $this->instance->save();
     // We explicitly do not assign a widget in a form display, so the field
     // stays hidden in forms.
     // Display the entity creation form.
     $this->drupalGet($entity_type . '/add');
     // Create an entity and test that the default value is assigned correctly to
     // the field that uses the hidden widget.
     $this->assertNoField("{$field_name}[0][value]", 'The field does not appear in the form');
     $this->drupalPostForm(NULL, array('user_id' => 1, 'name' => $this->randomMachineName()), t('Save'));
     preg_match('|' . $entity_type . '/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test_rev @id has been created.', array('@id' => $id)), 'Entity was created');
     $entity = entity_load($entity_type, $id);
     $this->assertEqual($entity->{$field_name}->value, 99, 'Default value was saved');
     // Update the instance to remove the default value and switch to the
     // default widget.
     $this->instance->default_value = NULL;
     $this->instance->save();
     entity_get_form_display($entity_type, $this->instance->bundle, 'default')->setComponent($this->instance->getName(), array('type' => 'test_field_widget'))->save();
     // Display edit form.
     $this->drupalGet($entity_type . '/manage/' . $id);
     $this->assertFieldByName("{$field_name}[0][value]", 99, 'Widget is displayed with the correct default value');
     // Update the entity.
     $value = mt_rand(1, 127);
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $this->assertText(t('entity_test_rev @id has been updated.', array('@id' => $id)), 'Entity was updated');
     entity_get_controller($entity_type)->resetCache(array($id));
     $entity = entity_load($entity_type, $id);
     $this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated');
     // Set the field back to hidden.
     entity_get_form_display($entity_type, $this->instance->bundle, 'default')->removeComponent($this->instance->getName())->save();
     // Create a new revision.
     $edit = array('revision' => TRUE);
     $this->drupalPostForm($entity_type . '/manage/' . $id, $edit, t('Save'));
     // Check that the expected value has been carried over to the new revision.
     entity_get_controller($entity_type)->resetCache(array($id));
     $entity = entity_load($entity_type, $id);
     $this->assertEqual($entity->{$field_name}->value, $value, 'New revision has the expected value for the field with the Hidden widget');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:55,代码来源:FormTest.php


示例18: tincan_lrs_statement_view

/**
 * Loads UI controller and generates view pages for Tincan Statements
 *
 * @param integer id
 *
 * @return string content
 */
function tincan_lrs_statement_view($id)
{
    $content = "";
    $entity = entity_load('tincan_statement', array($id));
    if (!empty($entity)) {
        $controller = entity_get_controller('tincan_statement');
        $content = $controller->view($entity);
    } else {
        $content = '<p>No statement found for drupal id: ' . $id . '</p>';
    }
    drupal_set_title($entity[$id]->label());
    return $content;
}
开发者ID:jackrabbithanna,项目名称:tincan_lrs,代码行数:20,代码来源:Statement.php


示例19: set

 /**
  * {@inheritdoc}
  */
 public function set($value)
 {
     /* @var CacheFragmentController $controller */
     $controller = entity_get_controller('cache_fragment');
     if (!$controller->createCacheFragments($this->cacheFragments)) {
         return;
     }
     $this->cacheObject->set($this->generateCacheId(), $value);
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:12,代码来源:RenderCache.php


示例20: execute


//.........这里部分代码省略.........
     }
     // The transition is allowed. Let other modules modify the comment.
     // @todo D8: remove all but last items from $context.
     $context = array('node' => $entity, 'sid' => $new_sid, 'old_sid' => $old_sid, 'uid' => $user->uid, 'transition' => $this);
     drupal_alter('workflow_comment', $this->comment, $context);
     // Now, change the database.
     // Log the new state in {workflow_node}.
     if (!$field_name) {
         if ($state_changed || $this->comment) {
             // If the node does not have an existing 'workflow' property,
             // save the $old_sid there, so it can be logged.
             if (!isset($entity->workflow)) {
                 // This is a workflow_node sid.
                 $entity->workflow = $old_sid;
                 // This is a workflow_node sid.
             }
             // Change the state for {workflow_node}.
             // The equivalent for Field API is in WorkflowDefaultWidget::submit.
             $data = array('nid' => $entity_id, 'sid' => $new_sid, 'uid' => isset($entity->workflow_uid) ? $entity->workflow_uid : $user->uid, 'stamp' => REQUEST_TIME);
             workflow_update_workflow_node($data);
             $entity->workflow = $new_sid;
             // This is a workflow_node sid.
         }
     } else {
         // This is a Workflow Field.
         // Until now, adding code here (instead of in workflow_execute_transition() )
         // doesn't work, creating an endless loop.
         /*
              if ($state_changed || $this->comment) {
                // Do a separate update to update the field (Workflow Field API)
                // This will call hook_field_update() and WorkflowFieldDefaultWidget::submit().
                // $entity->{$field_name}[$this->language] = array();
                // $entity->{$field_name}[$this->language][0]['workflow']['workflow_sid'] = $new_sid;
                // $entity->{$field_name}[$this->language][0]['workflow']['workflow_comment'] = $this->comment;
                $entity->{$field_name}[$this->language][0]['transition'] = $this;
         
                // Save the entity, but not through entity_save(),
                // since this will check permissions again and trigger rules.
                // @TODO: replace below by a workflow_field setter callback.
                // The transition was successfully executed, or else a message was raised.
         //        entity_save($entity_type, $entity);
                // or
         //        field_attach_update($entity_type, $entity);
         
                // Reset the entity cache after update.
                entity_get_controller($entity_type)->resetCache(array($entity_id));
         
                $new_sid = workflow_node_current_state($entity, $entity_type, $field_name);
              }
         */
     }
     $this->is_executed = TRUE;
     if ($state_changed || $this->comment) {
         // Log the transition in {workflow_node_history}.
         $this->save();
         // Register state change with watchdog.
         if ($state_changed) {
             $workflow = $this->getWorkflow();
             // Get the workflow_settings, unified for workflow_node and workflow_field.
             // @todo D8: move settings back to Workflow (like workflownode currently is).
             // @todo D8: to move settings back, grep for "workflow->options" and "field['settings']".
             $field = _workflow_info_field($field_name, $workflow);
             if (($new_state = $this->getNewState()) && !empty($field['settings']['watchdog_log'])) {
                 $entity_type_info = entity_get_info($entity_type);
                 $message = $this->isScheduled() ? 'Scheduled state change of @type %label to %state_name executed' : 'State of @type %label set to %state_name';
                 $args = array('@type' => $entity_type_info['label'], '%label' => entity_label($entity_type, $entity), '%state_name' => check_plain(t($new_state->label())));
                 $uri = entity_uri($entity_type, $entity);
                 watchdog('workflow', $message, $args, WATCHDOG_NOTICE, l('view', $uri['path']));
             }
         }
         // Remove any scheduled state transitions.
         foreach (WorkflowScheduledTransition::load($entity_type, $entity_id, $field_name) as $scheduled_transition) {
             /* @var $scheduled_transition WorkflowScheduledTransition */
             $scheduled_transition->delete();
         }
         // Notify modules that transition has occurred.
         // Action triggers should take place in response to this callback, not the 'transaction pre'.
         if (!$field_name) {
             // Now that workflow data is saved, reset stuff to avoid problems
             // when Rules etc want to resave the data.
             // Remember, this is only for nodes, and node_save() is not necessarily performed.
             unset($entity->workflow_comment);
             module_invoke_all('workflow', 'transition post', $old_sid, $new_sid, $entity, $force, $entity_type, $field_name, $this);
             entity_get_controller('node')->resetCache(array($entity->nid));
             // from entity_load(), node_save();
         } else {
             // module_invoke_all('workflow', 'transition post', $old_sid, $new_sid, $entity, $force, $entity_type, $field_name, $this);
             // We have a problem here with Rules, Trigger, etc. when invoking
             // 'transition post': the entity has not been saved, yet. we are still
             // IN the transition, not AFTER. Alternatives:
             // 1. Save the field here explicitly, using field_attach_save;
             // 2. Move the invoke to another place: hook_entity_insert(), hook_entity_update();
             // 3. Rely on the entity hooks. This works for Rules, not for Trigger.
             // --> We choose option 2:
             // - First, $entity->workflow_transitions[] is set for easy re-fetching.
             // - Then, post_execute() is invoked via workflowfield_entity_insert(), _update().
         }
     }
     return $new_sid;
 }
开发者ID:jeddobson,项目名称:LacunaStories,代码行数:101,代码来源:WorkflowTransition.php



注:本文中的entity_get_controller函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP entity_get_display函数代码示例发布时间:2022-05-15
下一篇:
PHP entity_get_bundles函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap