当前位置: 首页>>代码示例>>PHP>>正文


PHP entity_get_controller函数代码示例

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


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


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