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


PHP KService::has方法代码示例

本文整理汇总了PHP中KService::has方法的典型用法代码示例。如果您正苦于以下问题:PHP KService::has方法的具体用法?PHP KService::has怎么用?PHP KService::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KService的用法示例。


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

示例1: toSerializableArray

 /**
  * @{inheritdoc}
  */
 public function toSerializableArray($entity)
 {
     $data = parent::toSerializableArray($entity);
     $data['username'] = $entity->username;
     if (KService::has('com:people.viewer') && KService::get('com:people.viewer')->eql($entity)) {
         $data['email'] = $entity->email;
     }
     return $data;
 }
开发者ID:walteraries,项目名称:anahita,代码行数:12,代码来源:person.php

示例2: _beforeRepositoryFetch

 protected function _beforeRepositoryFetch($context)
 {
     if (KService::has('com:people.viewer') && is_person(get_viewer()) && get_viewer()->admin()) {
         return;
     }
     $query = $context->query;
     $config = pick($query->privacy, new KConfig());
     $config->append(array('viewer' => get_viewer()));
     $where = $this->buildCondition(get_viewer(), $config);
     $query->where($where);
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:11,代码来源:privatable.php

示例3: _beforeRepositoryFetch

 /**
  * {@inheritdoc}
  */
 protected function _beforeRepositoryFetch(KCommandContext $context)
 {
     if (KService::has('com:people.viewer') && is_person(get_viewer()) && get_viewer()->admin()) {
         return;
     }
     $query = $context->query;
     $repository = $query->getRepository();
     $config = pick($query->privacy, new KConfig());
     $config->append(array('visible_to_leaders' => true, 'viewer' => get_viewer(), 'graph_check' => true));
     $where = $this->buildCondition('@col(id)', $config, '@col(access)');
     $query->where($where);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:15,代码来源:privatable.php

示例4: getAPI

 /**
  * Get a service api
  *
  * @param  string $service The service name.
  * 
  * @return ComConnectOauthApiAbstract
  */
 public static function getAPI($service)
 {
     $service = strtolower($service);
     $identifier = 'com://site/connect.oauth.service.' . $service;
     if (!KService::has($identifier)) {
         $config = array();
         $config['consumer'] = self::getConsumer($service);
         $config['enabled'] = self::enabled($service);
         KService::set($identifier, KService::get($identifier, $config));
     }
     return KService::get($identifier);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:19,代码来源:api.php

示例5: _beforeQuerySelect

 /**
  * {@inheritdoc}
  */
 protected function _beforeQuerySelect(KCommandContext $context)
 {
     if (KService::has('com:people.viewer') && is_person(get_viewer()) && get_viewer()->admin()) {
         return;
     }
     $query = $context->query;
     $repository = $query->getRepository();
     $config = pick($query->privacy, new KConfig());
     $config->append(array('visible_to_leaders' => true, 'viewer' => KService::get('com:people.viewer'), 'graph_check' => true));
     $query->getRepository()->addBehavior('ownable');
     //do a left join operation just in case an owner is missing
     $query->link('owner', array('type' => 'weak', 'bind_type' => false));
     $config->append(array('use_access_column' => '@col(access)'));
     $c1 = $this->buildCondition('@col(owner.id)', $config, '@col(owner.access)');
     $c2 = $this->buildCondition('@col(owner.id)', $config, $config->use_access_column);
     $where = "IF({$c1}, {$c2}, 0)";
     $query->where($where);
 }
开发者ID:LuccaCaldas,项目名称:anahita,代码行数:21,代码来源:privatable.php

示例6: _beforeRepositoryFetch

 /**
  * Adds a filter to the query based on the access mode
  *
  * @param  KCommandContext $context
  * 
  * @return void
  */
 protected function _beforeRepositoryFetch(KCommandContext $context)
 {
     if (KService::has('viewer')) {
         $query = $context->query;
         $repository = $query->getRepository();
         $viewer = get_viewer();
         if ($viewer->id) {
             $query->where("IF( FIND_IN_SET({$viewer->id}, @col(blockedIds)), 0, 1)");
         }
     }
 }
开发者ID:josefXXX,项目名称:anahita,代码行数:18,代码来源:followable.php

示例7: toSerializableArray

 /**
  * {@inheritdoc}
  */
 public function toSerializableArray($entity)
 {
     $data = new KConfig();
     $viewer = KService::has('com:people.viewer') ? KService::get('com:people.viewer') : null;
     $data[$entity->getIdentityProperty()] = $entity->getIdentityId();
     $data['objectType'] = 'com.' . $entity->getIdentifier()->package . '.' . $entity->getIdentifier()->name;
     if ($entity->isDescribable()) {
         $data['name'] = $entity->name;
         $data['body'] = $entity->body;
         $data['alias'] = $entity->alias;
     }
     if ($entity->inherits('ComBaseDomainEntityComment')) {
         $data['body'] = $entity->body;
     }
     if ($entity->isPortraitable()) {
         $imageURL = array();
         if ($entity->portraitSet()) {
             $sizes = $entity->getPortraitSizes();
             foreach ($sizes as $name => $size) {
                 $url = null;
                 if ($entity->portraitSet()) {
                     $url = $entity->getPortraitURL($name);
                 }
                 $parts = explode('x', $size);
                 $width = 0;
                 $height = 0;
                 if (count($parts) == 0) {
                     continue;
                 } elseif (count($parts) == 1) {
                     $height = $width = $parts[0];
                 } else {
                     $width = $parts[0];
                     $height = $parts[1];
                     //hack to set the ratio based on the original
                     if ($height == 'auto' && isset($sizes['original'])) {
                         $original_size = explode('x', $sizes['original']);
                         $height = $width * $original_size[1] / $original_size[0];
                     }
                 }
                 $imageURL[$name] = array('size' => array('width' => (int) $width, 'height' => (int) $height), 'url' => $url);
             }
         }
         $data['imageURL'] = $imageURL;
     }
     // @todo check for $entity->isAuthorizer() and $entity->authorize('administration') scenarios later on
     if ($entity->isAdministrable()) {
         $data['administratorIds'] = array_values($entity->administratorIds->toArray());
         if ($viewer) {
             $data['isAdministrated'] = $viewer->administrator($entity);
         }
     }
     if ($viewer && !$viewer->eql($entity)) {
         if ($entity->isFollowable()) {
             $data['isLeader'] = $viewer->following($entity);
         }
         if ($entity->isLeadable()) {
             $data['isFollower'] = $viewer->leading($entity);
         }
     }
     if ($entity->isModifiable() && !is_person($entity)) {
         $data->append(array('author' => null, 'creationTime' => null, 'editor' => null, 'updateTime' => null));
         if (isset($entity->author)) {
             $data['author'] = $entity->author->toSerializableArray();
             $data['creationTime'] = $entity->creationTime->getDate();
         }
         if (isset($entity->editor)) {
             $data['editor'] = $entity->editor->toSerializableArray();
             $data['updateTime'] = $entity->updateTime->getDate();
         }
     }
     if ($entity->isCommentable()) {
         $data['openToComment'] = (bool) $entity->openToComment;
         $data['numOfComments'] = $entity->numOfComments;
         $data['lastCommentTime'] = $entity->lastCommentTime ? $entity->lastCommentTime->getDate() : null;
         $data['lastComment'] = null;
         $data['lastCommenter'] = null;
         if (isset($entity->lastComment)) {
             $data['lastComment'] = $entity->lastComment->toSerializableArray();
         }
         if (isset($entity->lastCommenter)) {
             $data['lastCommenter'] = $entity->lastCommenter->toSerializableArray();
         }
     }
     if ($entity->isFollowable()) {
         $data['followerCount'] = $entity->followerCount;
     }
     if ($entity->isLeadable()) {
         $data['leaderCount'] = $entity->leaderCount;
         $data['mutualCount'] = $entity->mutualCount;
     }
     if ($entity->isSubscribable()) {
         $data['subscriberCount'] = $entity->subscriberCount;
     }
     if ($entity->isVotable()) {
         $data['voteUpCount'] = $entity->voteUpCount;
     }
     if ($entity->isOwnable()) {
//.........这里部分代码省略.........
开发者ID:stonyyi,项目名称:anahita,代码行数:101,代码来源:default.php

示例8: _beforeEntityUpdate

 /**
  * Before Update timestamp modified on and modifier
  *
  * @param KCommandContext $context Context parameter
  * 
  * @return void
  */
 protected function _beforeEntityUpdate(KCommandContext $context)
 {
     $entity = $context->entity;
     $modified = array_keys(KConfig::unbox($entity->getModifiedData()));
     $modified = count(array_intersect($this->_modifiable_properties, $modified)) > 0;
     if ($modified && KService::has('com:people.viewer')) {
         $entity->editor = get_viewer();
     }
 }
开发者ID:walteraries,项目名称:anahita,代码行数:16,代码来源:modifiable.php

示例9: _initToolbar

 function _initToolbar()
 {
     jimport('joomla.html.toolbar');
     require_once 'rttoolbar.class.php';
     if (KService::has('com:controller.toolbar')) {
         $toolbar = KService::get('com:controller.toolbar');
         JFactory::getDocument()->setBuffer($toolbar->getTitle(), 'modules', 'title');
         $bar = JToolBar::getInstance('toolbar');
         foreach ($toolbar->getCommands() as $command) {
             if (!$command->attribs->href) {
                 $command->attribs->href = '#';
             }
             $command->attribs->class = implode(" ", (array) KConfig::unbox($command->attribs->class));
             $command->attribs->class .= ' toolbar';
             $html = '<li>';
             $html .= '	<a ' . KHelperArray::toString($command->attribs) . '>';
             $html .= '		<span class="' . $command->icon . '" title="' . JText::_($command->title) . '"></span>';
             $html .= JText::_($command->label);
             $html .= '   </a>';
             $html .= '</li>';
             $bar->appendButton('custom', $html, $command->id);
         }
     } else {
         $bar = JToolBar::getInstance('toolbar');
     }
     $toolbar = $bar;
     $newbar = array();
     $newhelp = array();
     $actions = array();
     $first = array();
     foreach ($toolbar->_bar as $button) {
         if (strtolower($button[0]) == 'help') {
             // $newhelp[] = $button;
         } elseif (strtolower($button[1]) == 'unarchive' or strtolower($button[1]) == 'archive' or strtolower($button[1]) == 'publish' or strtolower($button[1]) == 'unpublish' or strtolower($button[1]) == 'move' or strtolower($button[1]) == 'copy' or strtolower($button[1]) == 'trash') {
             $actions[] = $button;
         } else {
             if (strtolower($button[1]) == 'new' or strtolower($button[1]) == 'apply' or strtolower($button[1]) == 'save') {
                 $first[] = $button;
             } else {
                 $newbar[] = $button;
             }
         }
     }
     //create new toolbar object
     $toolbar = new RTToolbar('toolbar');
     //$toolbar->_buttonPath[0] = $this->basePath.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'toolbar'.DS.'button';
     $toolbar->_bar = $newbar;
     $toolbar->_buttonPath = $bar->_buttonPath;
     $toolbar->_actions = $actions;
     $toolbar->_first = $first;
     $this->toolbar = $toolbar;
     $this->actions = $actions;
     $this->first = $first;
     //new help button
     $helpbar = new RTToolbar('help');
     //$helpbar->_buttonPath[0] = $this->basePath.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'toolbar'.DS.'button';
     $helpbar->_bar = $newhelp;
     $this->help = $helpbar;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:59,代码来源:rtcore.class.php

示例10: getRepository

 /**
  * Helper mehtod to return a repository for an entity.
  *
  * @param string $identifier Entity Identifier
  * @param array  $config     Configuration
  *
  * @return AnDomainRepositoryAbstract
  */
 public static function getRepository($identifier, $config = array())
 {
     if (strpos($identifier, 'repos:') === 0) {
         $repository = KService::get($identifier);
     } else {
         $strIdentifier = (string) $identifier;
         if (!KService::has($identifier)) {
             $identifier = self::getEntityIdentifier($identifier);
         }
         if (!KService::has($identifier)) {
             KService::set($strIdentifier, KService::get($identifier, $config));
         }
         $repository = KService::get($identifier)->getRepository();
     }
     return $repository;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:24,代码来源:domain.php


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