本文整理汇总了PHP中Profile::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getUser方法的具体用法?PHP Profile::getUser怎么用?PHP Profile::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::getUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Constructor
*
* @param Profile $profile
*/
function __construct(Profile $profile)
{
$this->profile = $profile;
$this->user = $profile->getUser();
$this->fields = $this->loadFields();
$this->sections = $this->getSections();
//common_debug(var_export($this->sections, true));
//common_debug(var_export($this->fields, true));
}
示例2: onEndProfileGetAvatar
function onEndProfileGetAvatar(Profile $profile, $size, Avatar &$avatar = null)
{
if (empty($avatar)) {
try {
$user = $profile->getUser();
if (!empty($user) && !empty($user->email)) {
// Fake one!
$avatar = new Avatar();
$avatar->width = $avatar->height = $size;
$avatar->url = $this->libravatar_url($user->email, $size);
return false;
}
} catch (Exception $e) {
common_log(LOG_DEBUG, "Couldn't find User for Profile id: " . $profile->id . " (" . $profile->nickname . ")");
}
}
return true;
}
示例3: post
/**
* Sign and post the given Atom entry as a Salmon message.
*
* Side effects: may generate a keypair on-demand for the given user,
* which can be very slow on some systems (like those without php5-gmp).
*
* @param string $endpoint_uri
* @param string $xml string representation of payload
* @param Profile $user profile whose keys we sign with (must be a local user)
* @return boolean success
*/
public static function post($endpoint_uri, $xml, Profile $actor, Profile $target = null)
{
if (empty($endpoint_uri)) {
common_debug('No endpoint URI for Salmon post to ' . $actor->getUri());
return false;
}
try {
$magic_env = MagicEnvelope::signAsUser($xml, $actor->getUser());
} catch (Exception $e) {
common_log(LOG_ERR, "Salmon unable to sign: " . $e->getMessage());
return false;
}
// $target is so far only used in Diaspora, so it can be null
if (Event::handle('SalmonSlap', array($endpoint_uri, $magic_env, $target))) {
return false;
//throw new ServerException('Could not distribute salmon slap as no plugin completed the event.');
}
return true;
}
示例4: figureOutScope
public static function figureOutScope(Profile $actor, array $groups, $scope = null)
{
$scope = is_null($scope) ? self::defaultScope() : intval($scope);
// For private streams
try {
$user = $actor->getUser();
// FIXME: We can't do bit comparison with == (Legacy StatusNet thing. Let's keep it for now.)
if ($user->private_stream && ($scope === Notice::PUBLIC_SCOPE || $scope === Notice::SITE_SCOPE)) {
$scope |= Notice::FOLLOWER_SCOPE;
}
} catch (NoSuchUserException $e) {
// TODO: Not a local user, so we don't know about scope preferences... yet!
}
// Force the scope for private groups
foreach ($groups as $group_id) {
try {
$group = User_group::getByID($group_id);
if ($group->force_scope) {
$scope |= Notice::GROUP_SCOPE;
break;
}
} catch (Exception $e) {
common_log(LOG_ERR, 'Notice figureOutScope threw exception: ' . $e->getMessage());
}
}
return $scope;
}
示例5: getUser
function getUser()
{
if (is_null($this->UserID)) {
return parent::getUser();
}
if (is_null(parent::getUser()) && $this->UserID) {
parent::setUser(Outlet::getInstance()->load('User', $this->UserID));
}
return parent::getUser();
}
示例6: notifyActivity
/**
* Send a Salmon notification ping immediately, and confirm that we got
* an acceptable response from the remote site.
*
* @param mixed $entry XML string, Notice, or Activity
* @param Profile $actor
* @return boolean success
*/
public function notifyActivity($entry, Profile $actor)
{
if ($this->salmonuri) {
return Salmon::post($this->salmonuri, $this->notifyPrepXml($entry), $actor->getUser());
}
common_debug(__CLASS__ . ' error: No salmonuri for Ostatus_profile uri: ' . $this->uri);
return false;
}
示例7: addWebFingerPersonLinks
protected function addWebFingerPersonLinks(XML_XRD $xrd, Profile $target)
{
$xrd->links[] = new XML_XRD_Element_Link(Discovery::UPDATESFROM, common_local_url('ApiTimelineUser', array('id' => $target->id, 'format' => 'atom')), 'application/atom+xml');
// Get this profile's keypair
$magicsig = Magicsig::getKV('user_id', $target->id);
if (!$magicsig instanceof Magicsig && $target->isLocal()) {
$magicsig = Magicsig::generate($target->getUser());
}
if (!$magicsig instanceof Magicsig) {
return false;
// value doesn't mean anything, just figured I'd indicate this function didn't do anything
}
if (Event::handle('StartAttachPubkeyToUserXRD', array($magicsig, $xrd, $target))) {
$xrd->links[] = new XML_XRD_Element_Link(Magicsig::PUBLICKEYREL, 'data:application/magic-public-key,' . $magicsig->toString());
// The following event handles plugins like Diaspora which add their own version of the Magicsig pubkey
Event::handle('EndAttachPubkeyToUserXRD', array($magicsig, $xrd, $target));
}
}
示例8: get
# Prevent Null
// function baz(): bool {
// return null;
// }
// baz();
# Doesnt work
// function boo(): void {
// valid
// }
// boo();
class User
{
// Can't declare return type:
// public function __construct(): bool {
// return true;
// }
public function get() : self
{
return self;
}
}
class Profile extends User
{
public function getUser(int $id) : parent
{
return new User();
}
}
$p = new Profile();
$result = $p->getUser(1);
var_dump($result);
示例9: User
// Law of Demter (Tell, Don't Ask!)
//
//
// The method on an object is allowed to interact with the following:
//
// 1. Other methods on its object;
// 2. Methods on properties of the object;
// 3. Methods on arguments passed into the method;
// 4. Methods on instances of new objects, created inside of the method.
include "User.php";
include "Profile.php";
/**
* If we want to get the user's name, through the Profile object,
* it should TELL the name, not ASK for it a third party object,
* in our case the User object.
*
* So, without the law of Demeter in mind, the code would look like this:
*/
$user = new User("Josh", 29);
$userProfile = new Profile($user, "/img/josh.jpg");
echo $userProfile->getUser()->getName();
/**
* In the above example, we ASK the User object to give us it's name.
*
* Now, we'll make the Profile object TELL the user's name:
*/
echo $userProfile->getName();
/**
* The above row is the law of Demeter in action.
*/