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


PHP Sites::currentSite方法代码示例

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


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

示例1: initialize

 public function initialize(Controller $controller)
 {
     $this->controller = $controller;
     if (1 == $controller->Auth->user('role_id') && isset($controller->params['admin'])) {
         $Model =& $controller->{$controller->modelClass};
         if ($Model->Behaviors->attached('SiteFilter')) {
             $Model->Behaviors->SiteFilter->disableFilter($Model);
         }
     }
     $site = Sites::currentSite();
 }
开发者ID:daniel-neumann,项目名称:sites,代码行数:11,代码来源:SiteFilterComponent.php

示例2: initialize

 public function initialize(Controller $controller, $settings = array())
 {
     if (1 == $controller->Auth->user('role_id') && isset($controller->params['admin'])) {
         if ($controller->{$controller->modelClass}) {
             $Model =& $controller->{$controller->modelClass};
             if ($Model instanceof Model && $Model->useTable && $Model->Behaviors->attached('SiteFilter')) {
                 $Model->Behaviors->SiteFilter->disableFilter($Model);
             }
         }
     }
     $site = Sites::currentSite();
 }
开发者ID:daniel-neumann,项目名称:sites,代码行数:12,代码来源:MultisiteComponent.php

示例3: beforeFind

 public function beforeFind(Model $model, $query)
 {
     if ($this->settings[$model->alias]['enabled'] === false) {
         return $query;
     }
     $this->_setupRelationships($model, $this->settings[$model->alias]);
     $site = Sites::currentSite();
     $sites = array(Sites::ALL_SITES);
     if ($site) {
         $sites = array_unique(array(Sites::ALL_SITES, $site['Site']['id']));
     }
     $setting = Set::merge(array('relationship' => array(), 'joins' => array()), $this->settings[$model->alias]);
     extract($setting);
     if (!empty($joins)) {
         foreach ($joins as $join => &$joinConfig) {
             if (empty($joinConfig)) {
                 continue;
             }
             // link to Site model
             $foreignKey = $joinConfig['alias'] . '.site_id';
             if (empty($joinConfig['conditions'][$foreignKey])) {
                 $joinConfig['conditions'][$foreignKey] = $sites;
             }
             $foreignKey = $joinConfig['alias'] . '.' . Inflector::underscore($model->alias) . '_id';
             $condition = "{$model->alias}.{$model->primaryKey} = {$foreignKey}";
             if (!in_array($condition, $joinConfig['conditions'])) {
                 $joinConfig['conditions'][] = $condition;
             }
         }
     }
     if (!empty($query['joins'])) {
         $joins = Set::merge($query['joins'], $joins);
     }
     if (!empty($relationship) && $this->settings[$model->alias]['filter']) {
         $relation = key($relationship);
         $foreignKey = $model->{$relation}['Site']['foreignKey'];
         switch ($relation) {
             case 'belongsTo':
                 $query['conditions'][$model->alias . '.' . $foreignKey] = $sites;
                 break;
             case 'hasAndBelongsToMany':
             default:
                 $with = $model->{$relation}['Site']['with'];
                 if (strpos($with, '.') !== false) {
                     list($pluginName, $with) = pluginSplit($with);
                 }
                 $joinModel = $model->{$with};
                 $ds = $joinModel->getDataSource();
                 $associationForeignKey = $model->{$relation}['Site']['associationForeignKey'];
                 $currentJoins = Set::extract('{n}.alias', $joins);
                 if (!empty($currentJoins) && in_array($joinModel->alias, $currentJoins)) {
                     break;
                 }
                 $joins[] = array('type' => 'LEFT', 'table' => $ds->fullTableName($joinModel, true, true), 'alias' => $joinModel->alias, 'conditions' => array("{$model->alias}.{$model->primaryKey} = {$joinModel->alias}.{$foreignKey}"));
                 if (is_string($query['conditions'])) {
                     $query['conditions'] = array($query['conditions'], $joinModel->alias . '.' . $associationForeignKey => $sites);
                 } else {
                     $query['conditions'][$joinModel->alias . '.' . $associationForeignKey] = $sites;
                 }
                 break;
         }
     }
     $query['joins'] = $joins;
     unset($query['recursive']);
     return $query;
 }
开发者ID:daniel-neumann,项目名称:sites,代码行数:66,代码来源:SiteFilterBehavior.php


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