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


PHP Assert::notEmpty方法代码示例

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


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

示例1: generate

 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 static function generate($key = array(), $autoRefresh = true)
 {
     if (Common::isUuid($key)) {
         $key = array('user_id' => $key);
     } elseif (!isset($key['user_id'])) {
         $key['user_id'] = User::get('id');
     }
     // to support emails, too
     // Assert::true(Common::isUuid($key['user_id']));
     $_this = Common::getModel('AuthKey');
     if (!Common::isUuid($key['auth_key_type_id']) && !empty($key['auth_key_type_id'])) {
         $key['auth_key_type_id'] = $_this->AuthKeyType->lookup($key['auth_key_type_id']);
     }
     Assert::true(Common::isUuid($key['auth_key_type_id']));
     $recursive = -1;
     $sameTypeKey = $_this->find('first', array('conditions' => array('user_id' => $key['user_id'], 'auth_key_type_id' => $key['auth_key_type_id']), 'recursive' => -1));
     if ($sameTypeKey) {
         if (!$autoRefresh) {
             return false;
         }
         $key['id'] = $sameTypeKey['AuthKey']['id'];
     }
     do {
         $key['key'] = Security::generateAuthKey();
     } while (!$_this->isUnique(array('key' => $key['key'])));
     Assert::notEmpty($key['key']);
     $_this->create();
     Assert::notEmpty($_this->save($key));
     return $key['key'];
 }
开发者ID:stripthis,项目名称:donate,代码行数:36,代码来源:auth_key.php

示例2: edit

 /**
  * undocumented function
  *
  * @param string $id
  * @return void
  * @access public
  */
 function edit($id = null, $parentId = null)
 {
     $action = 'add';
     if ($this->action == 'edit') {
         $Comment = $this->Comment->find('first', array('conditions' => array('Comment.id' => $id)));
         Assert::notEmpty($Comment, '404');
         Assert::true($this->Comment->isOwn($Comment, 'Comment'), '403');
         $action = 'edit';
     } else {
         $Comment = $this->Comment->create();
     }
     $referer = $this->referer();
     $parentId = isset($this->params['named']['parent_id']) ? $this->params['named']['parent_id'] : false;
     $foreignId = isset($this->params['named']['foreign_id']) ? $this->params['named']['foreign_id'] : false;
     $this->set(compact('action', 'referer', 'parentId', 'foreignId'));
     $this->action = 'edit';
     if ($this->isGet()) {
         return $this->data = $Comment;
     }
     $this->data['Comment']['user_id'] = User::get('id');
     $this->Comment->set($this->data);
     $result = $this->Comment->save();
     if ($this->Comment->validationErrors) {
         $msg = __('There are problems with the form.', true);
         $this->Message->add($msg, 'error', true, $referer);
     }
     Assert::notEmpty($result);
     $msg = __('Successfully saved!', true);
     $this->Message->add($msg, 'ok', true, $this->data['Comment']['referer']);
 }
开发者ID:stripthis,项目名称:donate,代码行数:37,代码来源:comments_controller.php

示例3: admin_delete

 /**
  * undocumented function
  *
  * @param string $id 
  * @return void
  * @access public
  */
 function admin_delete($id)
 {
     $smiley = $this->Smiley->find('first', array('conditions' => array('Smiley.id' => $id), 'contain' => false, 'fields' => array('id')));
     Assert::notEmpty($smiley, '404');
     $this->Smiley->del($id);
     $msg = __('Smiley deleted.', true);
     $this->Message->add($msg, 'ok', true, $this->referer());
 }
开发者ID:stripthis,项目名称:donate,代码行数:15,代码来源:smileys_controller.php

示例4: admin_delete

 /**
  * undocumented function
  *
  * @param string $id 
  * @return void
  * @access public
  */
 function admin_delete($id)
 {
     $filter = $this->Filter->find('first', array('conditions' => array('Filter.id' => $id), 'contain' => false, 'fields' => array('id', 'user_id')));
     Assert::notEmpty($filter, '404');
     Assert::true(AppModel::isOwn($filter, 'Filter'), '403');
     $this->Filter->del($id);
     $msg = __('Filter deleted.', true);
     $this->Message->add($msg, 'ok', true, $this->referer());
 }
开发者ID:stripthis,项目名称:donate,代码行数:16,代码来源:filters_controller.php

示例5: admin_delete

 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function admin_delete($id)
 {
     $role = $this->Role->findById($id);
     Assert::notEmpty($role, '404');
     Assert::false(in_array($role['Role']['name'], $this->Role->unEditable), '403');
     $this->Role->del($id);
     $msg = __('Role was successfully removed.', true);
     $this->Message->add($msg, 'ok', true, array('action' => 'admin_index'));
 }
开发者ID:stripthis,项目名称:donate,代码行数:15,代码来源:roles_controller.php

示例6: beforeFilter

 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function beforeFilter()
 {
     if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
         Assert::false($this->name == 'App', '404');
         Assert::true(!!$this->action, '404');
     }
     $this->Session = $this->AppSession;
     ClassRegistry::addObject('Component.Session', $this->Session);
     ClassRegistry::addObject('Component.RequestHandler', $this->RequestHandler);
     ClassRegistry::addObject('Component.Cookie', $this->Cookie);
     ClassRegistry::addObject('Component.Email', $this->Email);
     ClassRegistry::addObject('Component.Pgp', $this->Pgp);
     $this->_loadPermissions();
     $this->_setLanguage();
     $this->_loadPluginConfigs();
     if ($this->isAdmin()) {
         $this->layout = 'admin';
     }
     if (defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
         return;
     }
     $this->RequestHandler->setContent('list', 'text/html');
     if (empty($this->ignoreUserSession)) {
         $rules = Configure::read('App.userPermissions.' . User::get('Role.name'));
         Assert::notEmpty($rules, '500');
         $canAccess = Common::requestAllowed($this->name, $this->action, $rules, true);
         if (!$canAccess) {
             Assert::true(User::is('guest'), '403');
             if ($this->isOkForSessionRedirect()) {
                 $this->Session->write($this->loginRedirectSesskey, $this->here);
             }
             $this->Session->write('cant_access', true);
             return $this->redirect('/admin/auth/login', '403', true);
         }
         if (!User::is('guest') && $this->name == 'auth' && $this->action == 'login') {
             $url = '/admin/home';
             if ($this->Session->check($this->loginRedirectSesskey)) {
                 $url = $this->Session->read($this->loginRedirectSesskey);
             }
             $this->redirect($url);
         }
     }
     $here = $this->params['url']['url'];
     if (!empty($here) && $here[0] != '/') {
         $here = '/' . $here;
     }
     $this->setJson('here', $here);
     $ajax = $isAjax = false;
     if ($this->isAjax()) {
         $this->layout = 'ajax';
         $ajax = $isAjax = true;
     }
     $this->set(compact('ajax', 'isAjax', 'here'));
 }
开发者ID:stripthis,项目名称:donate,代码行数:60,代码来源:app_controller.php

示例7: date

 /**
  * undocumented function
  *
  * @param unknown $format
  * @param unknown $timeZone
  * @param unknown $when
  * @return void
  * @access public
  */
 static function date($format, $timeZone, $when = 'now')
 {
     try {
         $DateTimeZone = new DateTimeZone($timeZone);
         $DateTime = new DateTime($when, $DateTimeZone);
         $date = $DateTime->format($format);
     } catch (Exception $Exception) {
         throw new AppException($Exception->getMessage());
     }
     Assert::notEmpty($date);
     return $date;
 }
开发者ID:stripthis,项目名称:donate,代码行数:21,代码来源:time_zone.php

示例8: admin_edit

 /**
  * undocumented function
  *
  * @param string $id 
  * @return void
  * @access public
  */
 function admin_edit($id = null)
 {
     $settings = $this->Setting->find('first');
     Assert::notEmpty($settings, '404');
     if ($this->isGet()) {
         return $this->data = $settings;
     }
     $this->Setting->set($this->data);
     if (!$this->Setting->save()) {
         $msg = __('The settings could not be updated.', true);
         return $this->Message->add($msg, 'error');
     }
     $msg = __('The settings were saved', true);
     $this->Message->add($msg, 'ok');
 }
开发者ID:stripthis,项目名称:donate,代码行数:22,代码来源:settings_controller.php

示例9: updatePassword

function updatePassword($uid, $password)
{
    Assert::isId($uid);
    Assert::notEmpty($password);
    return query("update user set password = '" . md5($password) . "', changepw = 1 where uid = {$uid}");
}
开发者ID:Bobsel,项目名称:gn-tic,代码行数:6,代码来源:db.user.php

示例10: admin_delete

 /**
  * delete action
  *
  * @param string $id the transaction id
  * @return void
  * @access public
  */
 function admin_delete($id = null)
 {
     $transaction = $this->Transaction->find('first', array('conditions' => array('Transaction.id' => $id), 'contain' => array('Gift')));
     Assert::notEmpty($transaction, '404');
     Assert::true(User::allowed($this->name, $this->action, $transaction), '403');
     $this->Transaction->set(array('id' => $id, 'archived' => '1'));
     $this->Transaction->save();
     $msg = __('The Transaction has been deleted.', true);
     $this->Message->add($msg, 'ok', true, array('action' => 'admin_index'));
 }
开发者ID:stripthis,项目名称:donate,代码行数:17,代码来源:transactions_controller.php

示例11: admin_view

 /**
  * undocumented function
  *
  * @param string $id 
  * @return void
  * @access public
  */
 function admin_view($id = null)
 {
     $gift = $this->Gift->find('first', array('conditions' => array('Gift.id' => $id), 'contain' => array('Contact.Address.Phone', 'Contact.Address.Country(id, name)', 'Contact.Address.State(id, name)', 'Contact.Address.City(id, name)', 'GiftType(humanized)', 'Office(id, name)', 'Appeal', 'Frequency', 'Currency(iso_code)')));
     Assert::notEmpty($gift, '404');
     Assert::true(User::allowed($this->name, $this->action, $gift), '403');
     $this->paginate['Transaction'] = array('conditions' => array('Transaction.gift_id' => $id), 'contain' => array('Gateway(name)', 'Currency(iso_code)'), 'order' => array('Transaction.created' => 'asc'));
     $transactions = $this->paginate('Transaction');
     $this->Gift = ClassRegistry::init('Gift');
     $commentMethod = $this->Gift->hasMany['Comment']['threaded'] ? 'threaded' : 'all';
     $comments = $this->Gift->Comment->find($commentMethod, array('conditions' => array('Comment.foreign_id' => $id), 'contain' => array('User(login, id)')));
     $this->set(compact('gift', 'comments', 'commentMethod', 'transactions'));
 }
开发者ID:stripthis,项目名称:donate,代码行数:19,代码来源:gifts_controller.php

示例12: guestLogin

 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 static function guestLogin()
 {
     $_this = ClassRegistry::init(__CLASS__);
     $backup = $_this->data;
     $_this->id = $_this->lookup(array('login' => Configure::read('App.emails.guestAccount')), 'id', false);
     if (empty($_this->id)) {
         $_this->create(array('login' => Configure::read('App.emails.guestAccount'), 'level' => 'guest'));
         Assert::notEmpty($_this->save(), 'no_guest_account');
     }
     User::setActive($_this->id, true);
     $_this->set($backup);
     return true;
 }
开发者ID:stripthis,项目名称:donate,代码行数:19,代码来源:user.php

示例13: admin_delete

 /**
  * delete action
  *
  * @param string $id the office id
  * @return void
  * @access public
  */
 function admin_delete($id = null, $undelete = false)
 {
     $office = $this->Office->find('first', array('conditions' => compact('id'), 'contain' => array('User', 'Gift')));
     Assert::notEmpty($office, '404');
     $noUsers = empty($office['User']);
     $noGifts = empty($office['Gift']);
     $url = array('action' => 'index');
     if (!$noGifts || !$noUsers) {
         $msg = __('Sorry, but there are still users, transactions or gifts related to this office.', true);
         $this->Message->add($msg, 'error', true, $url);
     }
     $this->Office->del($id);
     $msg = __('The Office has been deleted.', true);
     $this->Message->add($msg, 'ok', true, $url);
 }
开发者ID:stripthis,项目名称:donate,代码行数:22,代码来源:offices_controller.php

示例14: admin_delete

 /**
  * Admin delete an template action
  *
  * @param string $id the template id
  * @return void
  * @access public
  */
 function admin_delete($id = null, $undelete = false)
 {
     $template = $this->Template->find('first', array('conditions' => compact('id')));
     Assert::notEmpty($template, '404');
     Assert::true(User::allowed($this->name, $this->action, $template), '403');
     $this->Template->del($id);
     $msg = __('The Template has been deleted.', true);
     $this->Message->add($msg, 'ok', true, array('action' => 'admin_index'));
 }
开发者ID:stripthis,项目名称:donate,代码行数:16,代码来源:templates_controller.php

示例15: admin_delete_item

 /**
  * undocumented function
  *
  * @param string $segmentId 
  * @param string $foreignId 
  * @return void
  * @access public
  */
 function admin_delete_item($segmentId, $foreignId)
 {
     $segment = $this->Segment->find('first', array('conditions' => array('id' => $segmentId), 'fields' => array('user_id')));
     Assert::notEmpty($segment);
     Assert::true(AppModel::isOwn($segment, 'Segment'), '403');
     $this->SegmentItem->deleteAll(array('segment_id' => $segmentId, 'foreign_id' => $foreignId));
     $msg = 'The item was successfully removed from segment.';
     $this->Message->add($msg, 'ok', true, $this->referer());
 }
开发者ID:stripthis,项目名称:donate,代码行数:17,代码来源:segments_controller.php


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