本文整理汇总了PHP中Component::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::initialize方法的具体用法?PHP Component::initialize怎么用?PHP Component::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize(Controller $Controller)
{
parent::initialize($Controller);
if (!self::_isSiftable($Controller)) {
return;
}
if (empty($Controller->request->data['Sifter'])) {
if (empty($Controller->request->params['named'])) {
return true;
}
$Controller->request->params['named'] = Hash::expand($Controller->request->params['named']);
return self::_sift($Controller);
}
$Model = $Controller->{$Controller->modelClass};
$field = array_filter((array) $Model->sifterConfig('fields'));
if (self::_isAjax($Controller)) {
if (!array_key_exists($Controller->request->data['Sifter']['search_field'], $field) || empty($Controller->request->data['Sifter']['search_value'])) {
return true;
}
return self::_setAutoComplete($Controller, array($Controller->request->data['Sifter']['search_field'] => $field[$Controller->request->data['Sifter']['search_field']]));
} elseif ($Controller->request->is('post')) {
unset($Controller->request->data['Sifter']);
$url = array();
foreach (Hash::filter($Controller->request->data) as $model => $fields) {
foreach ($fields as $field => $data) {
$url[$model . '.' . $field] = $data;
}
}
return $Controller->redirect(Hash::merge($url, array_diff_key($Controller->request->params, array('plugin' => null, 'controller' => null, 'action' => null, 'named' => null, 'pass' => null))));
}
}
示例2: initialize
public function initialize(Controller $controller)
{
parent::initialize($controller);
$this->WorkflowActions = ClassRegistry::init('SimpleWorkflow.WorkflowActions');
$this->UserWorkflowActions = ClassRegistry::init('SimpleWorkflow.UserWorkflowActions');
$this->MapUserActionWorkflow = ClassRegistry::init('SimpleWorkflow.MapUserActionWorkflow');
}
示例3: initialize
/**
* Initialize
*
* @since 0.1
* @author Anthony Putignano <anthony@wizehive.com>
* @param Controller $controller A reference to the instantiating controller object
* @return void
*/
public function initialize(Controller $controller)
{
parent::initialize($controller);
if (!isset($this->Storage)) {
$this->Storage = new OAuth2Storage($this->settings);
}
if (!isset($this->Server)) {
$this->Server = new OAuth2_Server($this->Storage, $this->settings, array(new OAuth2_GrantType_AuthorizationCode($this->Storage), new OAuth2_GrantType_RefreshToken($this->Storage, array('always_issue_new_refresh_token' => false))));
}
if (!isset($this->Request)) {
$this->Request = new OAuth2_Request($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
}
if (!isset($this->ServerReflection)) {
$this->ServerReflection = new ReflectionClass('OAuth2_Server');
}
$methods = $this->ServerReflection->getMethods();
foreach ($methods as $method) {
$this->availableMethods[$method->name] = null;
$MethodReflection = new ReflectionMethod('OAuth2_Server', $method->name);
$params = $MethodReflection->getParameters();
if (!empty($params) && !empty($params[0]->name) && $params[0]->name === 'request') {
$this->availableMethods[$method->name] = 'request';
}
}
}
示例4: initialize
public function initialize(Controller $controller)
{
parent::initialize($controller);
if (count($controller->request->query) && !empty($this->settings)) {
$conditions = array();
foreach ($controller->request->query as $key => $value) {
if (empty($this->settings[$key]) || empty($value) || empty($this->settings[$key]['field'])) {
continue;
}
if (empty($this->settings[$key]['type'])) {
$this->settings[$key]['type'] = 'default';
}
$controller->request->data($key, $value);
switch ($this->settings[$key]['type']) {
case 'range':
list($key, $value) = $this->_range($this->settings[$key]['field'], $value);
$conditions[$key] = $value;
break;
case 'text':
list($key, $value) = $this->_text($this->settings[$key]['field'], $value);
$conditions[$key] = $value;
break;
default:
list($key, $value) = $this->_default($this->settings[$key]['field'], $value);
$conditions[$key] = $value;
break;
}
$conditions[$key] = $value;
}
$controller->request->filter = $conditions;
$this->conditions = $conditions;
}
}
示例5: initialize
/**
* Called before the Controller::beforeFilter().
*
* @param $controller
* @return void
*/
public function initialize($controller)
{
parent::initialize($controller);
$this->LightOpenID = new LightOpenID(env('SERVER_NAME'));
$this->Controller =& $controller;
$this->Controller->loadModel('AuthService.OpenidUser');
$this->Controller->loadModel('User');
}
示例6: initialize
public function initialize(Controller $controller)
{
parent::initialize($controller);
$this->controller = $controller;
foreach ($controller->uses as $model) {
$this->{$model} = $controller->{$model};
}
}
示例7: initialize
/**
* MobileComponent::initialize()
*
* @param Controller $Controller
* @return void
*/
public function initialize(Controller $Controller)
{
parent::initialize($Controller);
$this->Controller = $Controller;
if ($this->settings['on'] !== 'initialize') {
return;
}
$this->_init();
}
示例8: initialize
public function initialize(Controller $controller)
{
parent::initialize($controller);
App::import('Vendor', 'PHPExcel', array('file' => 'PHPExcel/PHPExcel.php'));
if (!class_exists('PHPExcel')) {
throw new CakeException('Vendor class PHPExcel not found!');
}
$dataArray = array();
}
示例9: initialize
/**
* Initialize the component
*
* Setup properties and injects API methods to the controller
* @return void
*/
public function initialize(Controller $controller)
{
$this->_controller = $controller;
parent::initialize($controller);
$this->_apiVersionPrefix = str_replace('.', '_', $this->_apiVersion);
$methods = $this->_apiMethods;
foreach ($methods as &$method) {
$method = $this->_apiVersionPrefix . '_' . $method;
}
$controller->methods = array_keys(array_flip($controller->methods) + array_flip($methods));
}
示例10: initialize
/**
* Initialize component
*
* @return array
* @author Daniel Quappe
*/
public function initialize(Controller $Controller)
{
$this->Controller = $Controller;
//$res = App::import('Vendor', 'Payment.sofortlib/sofortLib');
$res = App::import('Vendor', 'Payment.sofortlib/sofortLib_sofortueberweisung_classic');
//$res2 = App::import('Vendor', 'Payment.sofortlib/sofortLib_classic_notification.inc');
if (!$res) {
trigger_error('sofortlib cannot be found');
}
parent::initialize($Controller);
}
示例11: initialize
/**
* Controllers initialize function.
*/
public function initialize($Controller)
{
parent::initialize($Controller);
$this->Controller = $Controller;
Configure::write('CORE.current_route', Router::currentRoute());
$this->__registerPlugins();
$this->__paginationRecall();
if (Configure::read('Website.force_www')) {
$this->forceWwwUrl();
}
}
示例12: initialize
public function initialize(Controller $controller)
{
$this->Controller = $controller;
$this->Status = ClassRegistry::init('Status');
$this->Regulation = ClassRegistry::init('Regulation');
$this->Code = ClassRegistry::init('Code');
$this->Department = ClassRegistry::init('Department');
$this->Chapter = ClassRegistry::init('Chapter');
$this->CustomsDuty = ClassRegistry::init('CustomsDuty');
$this->Country = ClassRegistry::init('Country');
parent::initialize($controller);
}
示例13: initialize
/**
* Overrides initialize
*
* Overrides applied before the controller’s beforeFilter method.
*
* @param Controller $controller
* @return boolean|void
*/
public function initialize(Controller $controller)
{
parent::initialize($controller);
$settings = $this->settings;
if (isset($settings['api_key'])) {
$this->WakaTime->setApiKey($settings['api_key']);
} elseif (Configure::check('wakatime.api_key')) {
$this->WakaTime->setApiKey(Configure::read('wakatime.api_key'));
} else {
throw new InvalidArgumentException('WakaTime API key is required.');
}
return true;
}
示例14: initialize
/**
* Controller名とAction名に大文字が含まれる場合に例外を投げる
* [a-z][0-9][_]のみを有効とする
* @throws BadRequestException
* @param controller
* @return void
*/
public function initialize(Controller $controller)
{
parent::initialize($controller);
//requestのcontroller名とaction名を取得
$reqController = $controller->request->controller;
$reqAction = $controller->request->action;
if ($reqController !== strtolower($reqController)) {
// 大文字が含まれている
throw new BadRequestException(__('This address is not valid'));
}
if ($reqAction !== strtolower($reqAction)) {
// 大文字が含まれている
throw new BadRequestException(__('This address is not valid'));
}
}
示例15: initialize
public function initialize($controller, $settings = array())
{
if (Configure::read('debug') != 0) {
ini_set('soap.wsdl_cache_enabled', false);
}
$this->controller = $controller;
if (isset($settings['wsdl']) && !empty($settings['wsdl'])) {
$this->__settings['wsdl'] = $settings['wsdl'];
}
if (isset($settings['prefix'])) {
$this->__settings['prefix'] = $settings['prefix'];
}
if (isset($settings['action'])) {
$this->__settings['action'] = is_array($settings['action']) ? $settings['action'] : array($settings['action']);
}
parent::initialize($controller);
}