本文整理汇总了PHP中APP::uses方法的典型用法代码示例。如果您正苦于以下问题:PHP APP::uses方法的具体用法?PHP APP::uses怎么用?PHP APP::uses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APP
的用法示例。
在下文中一共展示了APP::uses方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFilter
<?php
APP::uses('AppController', 'Controller');
App::uses('ExcelProcessor', 'Lib');
App::import('Vendor', 'Classes/PHPExcel.php');
App::import('Vendor', 'PHPExcel_IOFactory', array('file' => 'Classes/PHPExcel/IOFactory.php'));
App::import('Vendor', 'PHPExcelReader', array('file' => 'Classes/PHPExcel/Reader/Excel2007.php'));
App::import('Vendor', 'PHPExcelWriter', array('file' => 'Classes/PHPExcel/Writer/Excel2007.php'));
class TeamleadersController extends AppController
{
public $uses = array("Role", "User", "Superadmin", "Manager", "Teamleader", "Telecaller", "Allocationmaster");
public $paginate = array('limit' => 25, 'conditions' => array('status' => '1'), 'order' => array('User.username' => 'asc'));
public function beforeFilter()
{
parent::beforeFilter();
}
public function isAuthorized($user)
{
if ($user['role'] === 'TeamLeader') {
if ($this->action === 'index' || $this->action === 'add' || $this->action === 'edit' || $this->action === 'delete' || $this->action === 'upload_excel') {
return true;
}
} else {
return false;
}
}
public function index()
{
$this->paginate = array('limit' => 20, 'conditions' => array('User.role' => 'TeamLeader'), 'order' => array('User.username' => 'asc'));
$users = $this->paginate('User');
$this->set(compact('users'));
示例2: beforeSave
<?php
/**
* Model class for users database
* Uses Containable behaviour.
*/
APP::uses('AuthComponent', 'Controller/Component');
class User extends AppModel
{
public $name = 'User';
public $cacheQueries = TRUE;
//Cache for single request.
public $actsAs = array('Containable');
//Associations with other models
public $hasMany = array('Car' => array('className' => 'Car', 'foreignKey' => 'user_id', 'conditions' => array('Car.deleted' => 0), 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => FALSE, 'exclusive' => FALSE, 'finderQuery' => ''));
//Validation rules
public $validate = array('given_name' => array('rule' => 'notEmpty', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a given name!'), 'surname_name' => array('rule' => 'notEmpty', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a surname!'), 'password' => array('provided' => array('rule' => 'notEmpty', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a password!'), 'matches' => array('rule' => array('fieldsMatch', 'password_confirmation'), 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Passwords do not match!')), 'email' => array('validEmail' => array('rule' => 'email', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a valid email address!'), 'uniqueEmail' => array('rule' => 'isUnique', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'This email exists already!')));
/**
* Hash passwords
* @see Model::beforeSave()
*/
public function beforeSave($options = array())
{
if (!empty($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return TRUE;
}
/**
* Custom validation rule for matching fields.
* @param array $check the value of the field to be checked. array('field' => 'value')
示例3:
<?php
App::uses('File', 'Utility');
APP::uses('Folder', 'Utility');
/**
* Extensions Locales Controller
*
* PHP version 5
*
* @category Controller
* @package Croogo
* @version 1.0
* @author Fahad Ibnay Heylaal <contact@fahad19.com>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @link http://www.croogo.org
*/
class ExtensionsLocalesController extends ExtensionsAppController
{
/**
* Controller name
*
* @var string
* @access public
*/
public $name = 'ExtensionsLocales';
/**
* Models used by the Controller
*
* @var array
* @access public
*/
示例4: finalizeRules
<?php
APP::uses("Market", "Model");
App::uses("TraitCountry", "Model");
App::uses('AuditableModel', 'Model');
class Phone extends AuditableModel
{
const ORDER = 0;
const MAIN = 1;
const SMS = 2;
public $name = 'Phone';
public $validate = array('phone' => array('rule' => array('phone', '/^([0-9\\s\\-\\+\\(\\)]*)$/'), 'message' => 'Please supply a valid phone number.'));
public function finalizeRules()
{
foreach (array("phone") as $field) {
foreach ($this->validator()->getField($field)->getRules() as $rule) {
$rule->required = TRUE;
break;
//I only need required on one of the rules
}
}
}
public function beforeValidate($options = array())
{
// market touch point
$trait = new TraitCountry();
$validator = $this->validator();
$format = $trait->getTrait($this->getMarketId(), 'phone_format');
//use Market Traits to validate city.
if (!empty($format)) {
$num = $trait->getTrait($this->getMarketId(), 'zip_qualifier');
示例5: array
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
APP::uses('AppModel', 'Model');
class Teamleader extends AppModel
{
public $actsAs = array('Containable');
// public $primaryKey = "user_id";
public $belongsTo = array('User' => array('className' => 'User', 'foreignKey' => 'id', 'conditions' => '', 'fields' => '', 'order' => ''), 'Manager' => array('className' => 'Manager', 'foreignKey' => 'manager_id', 'conditions' => '', 'fields' => '', 'order' => ''));
public $hasMany = array('Telecaller' => array('className' => 'Telecaller', 'foreign_key' => 'teamleader_id', 'conditions' => '', 'fields' => '', 'order' => ''));
}
示例6: __construct
/**
* コンストラクタ
*/
public function __construct()
{
parent::__construct();
APP::uses("TmhkConverter", "TokushuMojiHenkanKun.Lib");
}
示例7: UserService
function UserService()
{
APP::uses("User", "UserManager.Model");
$this->User = new User();
}