本文整理汇总了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'];
}
示例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']);
}
示例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());
}
示例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());
}
示例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'));
}
示例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'));
}
示例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;
}
示例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');
}
示例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}");
}
示例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'));
}
示例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'));
}
示例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;
}
示例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);
}
示例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'));
}
示例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());
}