本文整理汇总了PHP中Nette\Security\User::getIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getIdentity方法的具体用法?PHP User::getIdentity怎么用?PHP User::getIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Security\User
的用法示例。
在下文中一共展示了User::getIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSuccessCommentRemoval
public function onSuccessCommentRemoval(Comment $comment, $id)
{
/** @var \Users\User $user */
$user = $this->user->getIdentity();
$pageLink = $this->linkGenerator->link('Pages:Front:Page:show', ['internal_id' => $comment->getPageId()]);
$this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has REMOVED</b> the Comment [%s#] of Author [%s] on the <a href="%s">Page [%s#%s]</a>', $user->getId(), $user->getUsername(), $id, $comment->getAuthor(), $pageLink, $comment->getPageId(), $comment->getPageTitle()), 'page_comment_release', $user->getId());
}
示例2: _panelPrihlaseny
/**
* Panel prihlaseneho uzivatela
* @param string $baseUrl
* @param string $log_out
* @return \App\FrontModule\Components\User\MenuItem */
private function _panelPrihlaseny($baseUrl, $log_out)
{
$menu_user = [];
$udata = $this->user->getIdentity();
if ($this->nastavenie['view_avatar']) {
$obb = Html::el('img class="avatar"');
if ($udata->avatar_25 && is_file('www/' . $udata->avatar_25)) {
$obb = $obb->src($baseUrl . '/www/' . $udata->avatar_25)->alt('avatar');
} else {
$obb = $obb->src($baseUrl . '/www/ikonky/64/figurky_64.png')->alt('bez avatara');
}
} else {
$obb = "";
}
$menu_user[] = new MenuItem(['odkaz' => 'UserLog:', 'nazov' => $obb . " " . $udata->meno . ' ' . $udata->priezvisko, 'title' => $udata->meno . ' ' . $udata->priezvisko]);
if ($this->user->isAllowed('admin', 'enter')) {
$menu_user[] = new MenuItem(['odkaz' => ':Admin:Homepage:', 'title' => 'Administrácia', 'ikonka' => $this->nastavenie['admin_link'] & 1 ? 'pencil' : '', 'nazov' => $this->nastavenie['admin_link'] & 2 ? $this->texty['base_AdminLink_name'] : '']);
}
if ($this->user->isInRole('admin')) {
$hl_m_db_info = $this->lang->getDBInfo();
$menu_user[] = new MenuItem(['abs_link' => $baseUrl . "/www/adminer/?server=" . $hl_m_db_info['host'] . "&db=" . $hl_m_db_info['dbname'], 'title' => 'Adminer', 'target' => '_blank', 'nazov' => Html::el('img')->src($baseUrl . '/www/ikonky/16/graf_16.png')->alt('Adminer')]);
}
$menu_user[] = new MenuItem(['odkaz' => 'signOut!', 'ikonka' => "sign-out", 'nazov' => $log_out]);
return $menu_user;
}
示例3: processCreateInvitation
public function processCreateInvitation(Form $form)
{
$value = $form->getValues();
$invitation = new Invitation($value['email'], $this->user->getIdentity());
try {
/** @var EntityResultObject $resultObject */
$resultObject = $this->invitationsFacade->createInvitation($invitation);
$this->flashMessage('Registrační pozvánka byla vytvořena.', 'success');
if (!$resultObject->hasNoErrors()) {
$error = $resultObject->getFirstError();
$this->flashMessage($error['message'], $error['type']);
}
} catch (InvitationCreationAttemptException $ca) {
$this->flashMessage('Pozvánku nebyla vytvořena. Zkuste akci opakovat později.', 'error');
} catch (UserAlreadyExistsException $uae) {
$form->addError('Pozvánku nelze odeslat. Uživatel s E-Mailem ' . $value['email'] . ' je již zaregistrován.');
return;
} catch (InvitationAlreadyExistsException $iae) {
$form->addError('Někdo jiný již odeslal pozvánku uživateli s E-mailem ' . $value['email']);
return;
} catch (DBALException $e) {
$this->flashMessage('Při vytváření pozvánky došlo k chybě. Zkuste akci opakovat později.', 'error');
}
$this->redirect('this');
}
示例4: createComponentShipmentForm
public function createComponentShipmentForm()
{
$form = $this->shipmentFormFactory->create($this->currentCartService->getCurrentCart()->getShipment(), $this->user->isLoggedIn() ? $this->user->getIdentity() : null);
$form->onSuccess[] = function (ShipmentForm $form) {
$this->updateShipment($form);
};
return $form;
}
示例5: getData
/**
* @return \Nette\Database\Table\Selection
*/
protected function getData()
{
$selection = $this->sectionFacade->all();
if (!$this->user->getIdentity()->super) {
$this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
}
return $selection;
}
示例6: getData
public function getData()
{
$selection = $this->sectionFacade->all();
if (!$this->user->getIdentity()->super) {
$this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
}
return $selection->fetchPairs('id', 'id');
}
示例7: getUserSection
/**
* @return \Nette\Database\Table\Selection
*/
public function getUserSection()
{
$selection = $this->sectionFacade->all();
if (!$this->user->getIdentity()->super) {
$this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
}
return $selection;
}
示例8: Submit
/**
* @param Form $form
*/
public function Submit(Form $form)
{
$json = new \stdClass();
$json->result = "success";
$values = $form->getValues();
$result = false;
if (!empty($values['userID'])) {
$userEntity = $this->userRepository->get($values['userID']);
if ($userEntity) {
if ($this->user->isAllowed("user_management", "edit")) {
$userEntity->setLogin($values['login']);
if (!empty($values['password1'])) {
$userEntity->setPassword($values['password1']);
}
if ($userEntity->getLogin() !== "root" && $userEntity->getUserID() !== $this->user->getId()) {
$userEntity->setActive($values['active']);
if ($userEntity->getRole()->getAclRoleID() != $this->user->getIdentity()->data['aclRoleID']) {
$userEntity->setAclRoleID($values['role']);
}
}
try {
$result = $this->userRepository->save();
} catch (\PDOException $e) {
$result = $e->getMessage();
}
} else {
$result = UserForm::PERMISSION;
}
}
} else {
if ($this->user->isAllowed("user_management", "add")) {
$userEntity = new UserEntity();
$userEntity->setLogin($values['login'])->setPassword($values['password1'])->setActive($values['active'])->setAclRoleID($values['role']);
try {
$result = $this->userRepository->push($userEntity)->save();
} catch (\PDOException $e) {
$result = $e->getMessage();
if (preg_match("/Duplicate entry/", $result)) {
$result = "Nick <strong>" . $values['login'] . "</strong> již existuje. Zvolte prosím jiný login.";
}
}
if ($result instanceof UserEntity || $result === TRUE) {
$result = TRUE;
}
} else {
$result = UserForm::PERMISSION;
}
}
if ($result === TRUE) {
$json->result = "success";
} else {
$json->result = "error";
$json->message = $result;
}
$response = new JsonResponse($json);
$this->getPresenter()->sendResponse($response);
}
示例9: loadFromSession
public static function loadFromSession(\Nette\Security\User $user)
{
$instance = new User();
$instance->setId($user->getIdentity()->id);
$instance->setRole($user->getRoles()[0]);
$instance->setEmail($user->getIdentity()->email);
$instance->setFirstName($user->getIdentity()->firstName);
$instance->setLastName($user->getIdentity()->lastName);
return $instance;
}
示例10: processForm
/**
* @param \Nette\Application\UI\Form $form
*/
public function processForm(Form $form)
{
$values = $form->values;
$event = $this->event ? $this->event : new Entity\Event($this->securityUser->getIdentity());
$event->name = $values->name;
$event->date = DateTime::from($values->date);
$event->place = $values->place;
$event->note = $values->note;
$this->eventFacade->save($event);
}
示例11: isGranted
/**
* {@inheritdoc}
*/
public function isGranted($attributes, $object = null)
{
if (!is_array($attributes)) {
$attributes = array($attributes);
}
if (!$this->user->isLoggedIn() || ($identity = $this->user->getIdentity()) === null) {
$identity = new GuestIdentity();
}
return $this->decisionManager->decide($identity, $attributes, $object);
}
示例12: log
/** Funkce pro zápis zprávy
*
* @param string $message
*/
public function log($message)
{
if (is_string($message) && !empty($message)) {
$record = array('timestamp' => new DateTime(), 'message' => $message, 'ip' => $_SERVER["REMOTE_ADDR"]);
if ($this->user && $this->user->isLoggedIn()) {
$record['userID'] = $this->user->getIdentity()->userID;
}
$this->database->table(SQLLogger::DB_TABLE)->insert($record);
}
}
示例13: formSucceeded
/**
* Callback method, that is called once form is successfully submitted, without validation errors.
*
* @param Form $form
* @param Nette\Utils\ArrayHash $values
*/
public function formSucceeded(Form $form, $values)
{
if ($this->pad === NULL) {
$this->em->persist($pad = new Pad($this->user->getIdentity()));
} else {
$pad = $this->pad;
}
$pad->setName($values->name);
$this->em->flush($pad);
$this->onSuccess($this, $pad);
}
示例14: formSucceeded
/**
* Callback method, that is called once form is successfully submitted, without validation errors.
*
* @param Form $form
* @param Nette\Utils\ArrayHash $values
*/
public function formSucceeded(Form $form, $values)
{
/** @var User $user */
$user = $this->user->getIdentity();
try {
$user->changePassword($values->current, $values->password);
$this->em->flush();
$this->onSuccess($this);
} catch (InvalidPasswordException $e) {
$form['current']->addError('Invalid current password');
}
}
示例15: consolidateCurrentCartWithCurrentUser
public function consolidateCurrentCartWithCurrentUser()
{
if ($this->user->isLoggedIn()) {
/** @var User $identity */
$identity = $this->user->getIdentity();
if ($this->getCurrentCart()->hasItems()) {
$this->getCurrentCart()->setUser($identity);
$this->saveCurrentCart();
} elseif ($identity->hasAnyCart()) {
$this->setCurrentCart($identity->getLastCart());
}
}
}