本文整理汇总了PHP中xPDO::invokeEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::invokeEvent方法的具体用法?PHP xPDO::invokeEvent怎么用?PHP xPDO::invokeEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::invokeEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changePassword
/**
* Change the user password.
*
* @access public
* @param string $newPassword Password to set.
* @param string $oldPassword Current password for validation.
* @return boolean Indicates if password was successfully changed.
* @todo Add support for configurable password encoding.
*/
public function changePassword($newPassword, $oldPassword)
{
$changed = false;
if ($this->passwordMatches($oldPassword)) {
if (!empty($newPassword)) {
$this->set('password', $newPassword);
$changed = $this->save();
if ($changed) {
$this->xpdo->invokeEvent('OnUserChangePassword', array('user' => &$this, 'newpassword' => $newPassword, 'oldpassword' => $oldPassword, 'userid' => $this->get('id'), 'username' => $this->get('username'), 'userpassword' => $newPassword));
}
}
}
return $changed;
}
示例2: getProperties
/**
* Get the properties on this source
* @param boolean $parsed
* @return array
*/
public function getProperties($parsed = false)
{
$properties = $this->get('properties');
$defaultProperties = $this->getDefaultProperties();
if (!empty($properties) && is_array($properties)) {
foreach ($properties as &$property) {
$property['overridden'] = 0;
if (array_key_exists($property['name'], $defaultProperties)) {
if ($defaultProperties[$property['name']]['value'] != $property['value']) {
$property['overridden'] = 1;
}
} else {
$property['overridden'] = 2;
}
}
$properties = array_merge($defaultProperties, $properties);
} else {
$properties = $defaultProperties;
}
/** @var array $results Allow manipulation of media source properties via event */
$results = $this->xpdo->invokeEvent('OnMediaSourceGetProperties', array('properties' => $this->xpdo->toJSON($properties)));
if (!empty($results)) {
foreach ($results as $result) {
$result = is_array($result) ? $result : $this->xpdo->fromJSON($result);
$properties = array_merge($properties, $result);
}
}
if ($parsed) {
$properties = $this->parseProperties($properties);
}
return $this->prepareProperties($properties);
}