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


PHP entity_uri函数代码示例

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


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

示例1: fieldFindCandidate

 /**
  * {@inheritdoc}
  */
 function fieldFindCandidate(array $items)
 {
     $terms = array();
     foreach ($items as $item) {
         $terms[$item['tid']] = TRUE;
     }
     if (count($terms) > 1) {
         $walk = $terms;
         $visited = array();
         while (!empty($walk)) {
             $visited += $walk;
             foreach ($walk as $tid => $true) {
                 $parents = taxonomy_get_parents($tid);
                 unset($walk[$tid]);
                 foreach ($parents as $parent_tid => $parent) {
                     unset($terms[$parent_tid]);
                     if (!isset($visited[$parent_tid])) {
                         $walk[$parent_tid] = $parent;
                     }
                 }
             }
         }
     }
     // Return the path of the first found term, if any.
     foreach ($terms as $tid => $term_info) {
         $term = taxonomy_term_load($tid);
         if (!empty($term)) {
             $uri = entity_uri('taxonomy_term', $term);
             if (!empty($uri)) {
                 return $uri['path'];
             }
         }
     }
     return NULL;
 }
开发者ID:geodesfour,项目名称:dp741,代码行数:38,代码来源:TermReference.php

示例2: hook_commerce_product_uri

/**
 * Lets modules specify the path information expected by a uri callback.
 *
 * The Product module defines a uri callback for the product entity even though
 * it doesn't actually define any product menu items. The callback invokes this
 * hook and will return the first set of path information it finds. If the
 * Product UI module is enabled, it will alter the product entity definition to
 * use its own uri callback that checks commerce_product_uri() for a return
 * value and defaults to an administrative link defined by that module.
 *
 * This hook is used as demonstrated below by the Product Reference module to
 * direct modules to link the product to the page where it is actually displayed
 * to the user. Currently this is specific to nodes, but the system should be
 * beefed up to accommodate even non-entity paths.
 *
 * @param $product
 *   The product object whose uri information should be returned.
 *
 * @return
 *   Implementations of this hook should return an array of information as
 *   expected to be returned to entity_uri() by a uri callback function.
 *
 * @see commerce_product_uri()
 * @see entity_uri()
 */
function hook_commerce_product_uri($product)
{
    // If the product has a display context, use it entity_uri().
    if (!empty($product->display_context)) {
        return entity_uri($product->display_context['entity_type'], $product->display_context['entity']);
    }
}
开发者ID:boiler256,项目名称:drupalcommerce,代码行数:32,代码来源:commerce_product.api.php

示例3: getDrupalEntityPath

 /**
  * Uses drupal 7 API to generate the entity URL
  *
  * @param string $type
  * @param mixed $entity
  *
  * @return string
  */
 private function getDrupalEntityPath($type, $entity)
 {
     $uri = entity_uri($type, $entity);
     if (!$uri) {
         throw new \InvalidArgumentException(sprintf("%s: entity type is not supported yet"));
     }
     return $uri['path'];
 }
开发者ID:makinacorpus,项目名称:drupal-ulink,代码行数:16,代码来源:EntityLinkGenerator.php

示例4: unikue_preprocess_comment

/**
 * Process variables for comment.tpl.php.
 *
 * @see comment.tpl.php
 */
function unikue_preprocess_comment(&$variables)
{
    $comment = $variables['elements']['#comment'];
    $node = $variables['elements']['#node'];
    $variables['comment'] = $comment;
    $variables['node'] = $node;
    $variables['author'] = theme('username', array('account' => $comment));
    $variables['created'] = date('d F Y', $comment->created);
    // Avoid calling format_date() twice on the same timestamp.
    if ($comment->changed == $comment->created) {
        $variables['changed'] = $variables['created'];
    } else {
        $variables['changed'] = format_date($comment->changed);
    }
    $variables['new'] = !empty($comment->new) ? t('new') : '';
    $variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
    $variables['signature'] = $comment->signature;
    $uri = entity_uri('comment', $comment);
    $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
    $variables['title'] = l($comment->subject, $uri['path'], $uri['options']);
    $variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
    $variables['submitted'] = t('!username  on !datetime', array('!username' => $variables['author'], '!datetime' => date('d/m/Y', $comment->created)));
    // Preprocess fields.
    field_attach_preprocess('comment', $comment, $variables['elements'], $variables);
    // Helpful $content variable for templates.
    foreach (element_children($variables['elements']) as $key) {
        $variables['content'][$key] = $variables['elements'][$key];
    }
    // Set status to a string representation of comment->status.
    if (isset($comment->in_preview)) {
        $variables['status'] = 'comment-preview';
    } else {
        $variables['status'] = $comment->status == COMMENT_NOT_PUBLISHED ? 'comment-unpublished' : 'comment-published';
    }
    // Gather comment classes.
    // 'comment-published' class is not needed, it is either 'comment-preview' or
    // 'comment-unpublished'.
    if ($variables['status'] != 'comment-published') {
        $variables['classes_array'][] = $variables['status'];
    }
    if ($variables['new']) {
        $variables['classes_array'][] = 'comment-new';
    }
    if (!$comment->uid) {
        $variables['classes_array'][] = 'comment-by-anonymous';
    } else {
        if ($comment->uid == $variables['node']->uid) {
            $variables['classes_array'][] = 'comment-by-node-author';
        }
        if ($comment->uid == $variables['user']->uid) {
            $variables['classes_array'][] = 'comment-by-viewer';
        }
    }
    foreach ($variables['content']['links']['comment']['#links'] as $key => $value) {
        $variables['content']['links']['comment']['#links'][$key]['attributes']['class'] = array('button button-small');
    }
}
开发者ID:toptomatotwo,项目名称:tomwebdev,代码行数:62,代码来源:comment.vars.php

示例5: viewAction

 /**
  * @Route("/{entity_type}/{entity}", name="entity_view", defaults={"view_mode" = "full", "langcode" = null, "page" = null})
  * @Method("GET")
  * @ParamConverter("entity", converter="drupal.entity")
  * @Template
  */
 public function viewAction(Request $request, $entity_type, $entity)
 {
     $view_mode = $request->get('view_mode');
     $langcode = $request->get('langcode');
     $page = $request->get('page');
     list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
     $entities = entity_view($entity_type, array($id => $entity), $view_mode, $langcode, $page);
     return array('label' => entity_label($entity_type, $entity), 'uri' => entity_uri($entity_type, $entity), 'entity_type' => $entity_type, 'id' => $id, 'vid' => $vid, 'bundle' => $bundle, 'entity' => $entity, 'content' => reset($entities[$entity_type]));
 }
开发者ID:bangpound,项目名称:drupal-bundle,代码行数:15,代码来源:EntityController.php

示例6: formatGenres

 public function formatGenres($genres)
 {
     $element = array();
     foreach ($genres as $delta => $resource) {
         $wrapper = $resource->getInterpreter()->getWrapper();
         $uri = entity_uri('taxonomy_term', $wrapper->value());
         $element[$delta] = array('#type' => 'link', '#title' => $wrapper->name->value(), '#href' => $uri['path'], '#options' => $uri['options']);
     }
     return drupal_render($element);
 }
开发者ID:adam-s,项目名称:954live,代码行数:10,代码来源:Artists__1_1.php

示例7: fieldFindCandidate

 /**
  * {@inheritdoc}
  */
 function fieldFindCandidate(array $items)
 {
     $field = $this->getFieldInfo();
     if ($target_type = $field['settings']['target_type']) {
         foreach ($items as $item) {
             if (1 && !empty($item['target_id']) && count($target_entities = entity_load($target_type, array($item['target_id']))) && ($uri = entity_uri($target_type, reset($target_entities)))) {
                 return $uri['path'];
             }
         }
     }
 }
开发者ID:radicalsuz,项目名称:fe,代码行数:14,代码来源:EntityReference.php

示例8: handleEntity

 public function handleEntity(array &$metadata = array())
 {
     $uri = entity_uri($this->original_entity->type(), $this->original_entity->definition);
     if (empty($uri['path'])) {
         return;
     }
     $redirects = redirect_load_multiple(false, array('redirect' => $uri['path']));
     foreach ($redirects as $index => $redirect) {
         $entity = new Entity($redirect, 'redirect');
         $this->addDependency($entity, false);
         $this->addDependency($this->original_entity, array($entity->uuid()));
     }
 }
开发者ID:sammarks,项目名称:publisher,代码行数:13,代码来源:URLRedirectHandler.php

示例9: genresProcess

 public function genresProcess($tids)
 {
     $genres = taxonomy_term_load_multiple($tids);
     if (empty($genres)) {
         return NULL;
     }
     $element = [];
     foreach ($genres as $genre) {
         $path = entity_uri('taxonomy_term', $genre);
         $element[] = array('name' => entity_label('taxonomy_term', $genre), 'path' => url($path['path'], $path['options']));
     }
     return $element;
 }
开发者ID:adam-s,项目名称:954live,代码行数:13,代码来源:LivesearchArtists__1_0.php

示例10: gavias_laikafood_preprocess_comment

/**
 * Override or insert variables into the comment template.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 */
function gavias_laikafood_preprocess_comment(&$vars)
{
    $vars['title_attributes_array']['class'][] = 'comment-title';
    $vars['content_attributes_array']['class'][] = 'comment-content';
    $uri = entity_uri('comment', $vars['comment']);
    $uri['options'] += array('attributes' => array('rel' => 'bookmark'));
    $vars['title'] = l($vars['comment']->subject, $uri['path'], $uri['options']);
    $vars['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
    $vars['created'] = '<span class="date-time permalink">' . l($vars['created'], $uri['path'], $uri['options']) . '</span>';
    $vars['datetime'] = format_date($vars['comment']->created, 'custom', 'c');
    $vars['unpublished'] = '';
    if ($vars['status'] == 'comment-unpublished') {
        $vars['unpublished'] = '<div class="unpublished">' . t('Unpublished') . '</div>';
    }
}
开发者ID:ucaka,项目名称:forestway,代码行数:21,代码来源:template.functions.php

示例11: _defaultDatasEntities

 protected function _defaultDatasEntities($route = 'entities.json')
 {
     $options = $this->getOptions();
     $datas = array();
     foreach ($this->elements() as $entity) {
         $wrapper = entity_metadata_wrapper($options['entity-type'], $entity);
         $data = $this->dataModel($route);
         $data['id'] = $wrapper->getIdentifier();
         $data['url'] = call_user_func_array('url', entity_uri($options['entity-type'], $entity));
         $data['title'] = $wrapper->title->value();
         $data['body'] = $wrapper->body->value->value();
         $datas[] = $data;
     }
     return $datas;
 }
开发者ID:TommyTran1,项目名称:excelpoint,代码行数:15,代码来源:ReactComponentLiveBox.class.php

示例12: __construct

 /**
  * Constructor for the Add to cart form. Provide $nid as the id of the
  * product display node. Other optional arguments are product reference field
  * name, view mode of the product display node and language of the product
  * display node. If optional arguments are not provided, their default values
  * are assumed, which are "field_product", "default" and "en" respectively.
  *
  * @param int $nid
  *   Product display node id.
  */
 public function __construct($nid)
 {
     $args = func_get_args();
     array_shift($args);
     $field_name = array_shift($args);
     $view_mode = array_shift($args);
     $language = array_shift($args);
     if (is_null($field_name)) {
         $field_name = 'field_product';
     }
     if (is_null($view_mode)) {
         $view_mode = 'default';
     }
     if (is_null($language)) {
         $language = 'en';
     }
     $node = node_load($nid);
     $instance = field_info_instance('node', $field_name, $node->type);
     $display = field_get_display($instance, $view_mode, $node);
     $settings = array_merge(field_info_formatter_settings($display['type']), $display['settings']);
     $field_product = field_get_items('node', $node, $field_name);
     $product_id = $field_product[0]['product_id'];
     $products = commerce_product_load_multiple(array($product_id));
     $type = !empty($settings['line_item_type']) ? $settings['line_item_type'] : 'product';
     $line_item = commerce_product_line_item_new(commerce_product_reference_default_product($products), $settings['default_quantity'], 0, array(), $type);
     $line_item->data['context']['product_ids'] = array_keys($products);
     $line_item->data['context']['add_to_cart_combine'] = !empty($settings['combine']);
     $line_item->data['context']['show_single_product_attributes'] = !empty($settings['show_single_product_attributes']);
     $cart_context = array('entity_type' => 'node', 'entity_id' => $nid, 'display' => 'default', 'language' => $language);
     $cart_context['class_prefix'] = $cart_context['entity_type'] . '-' . $nid;
     $cart_context['view_mode'] = $cart_context['entity_type'] . '_' . $view_mode;
     $entity_uri = entity_uri($cart_context['entity_type'], $node);
     $arguments = array('form_id' => commerce_cart_add_to_cart_form_id(array($product_id)), 'line_item' => $line_item, 'show_quantity' => $settings['show_quantity']);
     // Add the display path and referencing entity data to the line item.
     if (!empty($entity_uri['path'])) {
         $arguments['line_item']->data['context']['display_path'] = $entity_uri['path'];
     }
     $arguments['line_item']->data['context']['entity'] = array('entity_type' => $cart_context['entity_type'], 'entity_id' => $cart_context['entity_id'], 'product_reference_field_name' => $field_name);
     // Update the product_ids variable to point to the entity data if we're
     // referencing multiple products.
     if (count($arguments['line_item']->data['context']['product_ids']) > 1) {
         $arguments['line_item']->data['context']['product_ids'] = 'entity';
     }
     parent::__construct($arguments['form_id'], $arguments['line_item'], $arguments['show_quantity'], $cart_context);
     $this->cart_context = $cart_context;
     $this->arguments = $arguments;
 }
开发者ID:redcrackle,项目名称:redtest-core,代码行数:57,代码来源:CommerceAddToCartForm.php

示例13: render

 public function render($results)
 {
     $social = NULL;
     if ($this->wrapper->field_social->value()[0]['url']) {
         $social = $this->wrapper->field_social->value()[0]['url'];
     }
     $uri = entity_uri('node', $this->wrapper->value());
     $path = drupal_get_path_alias($uri['path']);
     // ld+json microdata URLs are absolute
     $address = $this->wrapper->field_address->value();
     $geo = $this->wrapper->field_geo->value();
     $output = array('@type' => 'MusicVenue', "@context" => "http://schema.org", 'name' => $this->wrapper->title->value(), 'description' => $this->wrapper->field_about->value(), 'image' => file_create_url($this->wrapper->field_image->value()['uri']), 'sameAs' => $social, 'telephone' => $this->wrapper->field_phone->value(), 'url' => url($path, array('absolute' => TRUE)), 'address' => array('@type' => 'PostalAddress', "@context" => "http://schema.org", 'streetAddress' => $address['thoroughfare'], 'addressLocality' => $address['locality'], 'addressRegion' => $address['administrative_area'], 'postalCode' => $address['postal_code']), 'geo' => array('@type' => 'GeoCoordinates', "@context" => "http://schema.org", 'latitude' => $geo['lat'], 'longitude' => $geo['lon']));
     $output['event'] = $this->eventJSON($results);
     $element = array('#type' => 'markup', '#markup' => '<script type="application/ld+json">' . json_encode($output) . "</script>");
     // json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
     drupal_add_html_head($element, 'livesource_jsonld');
 }
开发者ID:adam-s,项目名称:954live,代码行数:17,代码来源:MicrodataVenueStyle.php

示例14: hookTokens

 /**
  * {@inheritdoc}
  */
 public function hookTokens($type, $tokens, array $data = array(), array $options = array())
 {
     $replacements = array();
     if ($this->isValidTokenType($type)) {
         foreach ($tokens as $name => $original) {
             if ($this->isValidToken($original)) {
                 $render = array();
                 $entity_id = $this->getEntityIdFromToken($original);
                 $entity_type = $type == 'term' ? 'taxonomy_term' : $type;
                 $entity_info = entity_get_info($entity_type);
                 $entity = $entity_info['load hook']($entity_id);
                 $uri = entity_uri($entity_type, $entity);
                 $replacements[$original] = url($uri['path'], array('absolute' => TRUE));
             }
         }
     }
     return $replacements;
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:21,代码来源:UrlTokenHandler.php

示例15: action_feedback

function action_feedback()
{
    $transaction = TransactionSession::getFromSession();
    if (!$transaction) {
        return t('There was an error processing the entities.');
    }
    // Before marking the transaction session as complete, set the title.
    action_feedback_title();
    // Set the forced flag based on if any of the root entites were forced.
    $forced = false;
    $root_entity_ids = array();
    foreach ($transaction->getRootEntities() as $uuid => $root_entity) {
        $root_entity_ids[] = $uuid;
        if (array_key_exists('force', $root_entity['options']) && $root_entity['options']['force']) {
            $forced = true;
            break;
        }
    }
    // Add each of the entities to the list for the form.
    $form_entities = array();
    foreach ($transaction->getAllEntities() as $dependency) {
        if (!array_key_exists('original_dependency', $dependency)) {
            continue;
        }
        $original_dependency = $dependency['original_dependency'];
        $form_entity = array();
        $entity = \Drupal\publisher\Entity::loadByUUID($dependency['entity_uuid'], $dependency['entity_type']);
        $entity_uri = entity_uri($entity->type(), $entity->definition);
        $entity_path = ltrim($entity_uri['path'], '/');
        $form_entity['label'] = l(entity_label($entity->type(), $entity->definition), $entity_path) . ' [<strong>' . $entity->type() . '</strong> <code>' . $entity->id() . '</code>]';
        $form_entity['required'] = $original_dependency['required'];
        $form_entity['required_if'] = $original_dependency['required_if'];
        $form_entity['entity_type'] = $dependency['entity_type'];
        $form_entity['root_entity'] = in_array($dependency['entity_uuid'], $root_entity_ids);
        $form_entities[$dependency['entity_uuid']] = $form_entity;
    }
    // If there are no entities to move, complete the session.
    if (count($form_entities) <= 0) {
        $transaction->complete();
    }
    // Output each of the entities to the page with their status.
    $form = drupal_get_form('publisher_select_entities_form', $form_entities, 'publisher_action_feedback_entities_selected', $forced, $transaction->getRemote());
    return $form;
}
开发者ID:sammarks,项目名称:publisher,代码行数:44,代码来源:send.php


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