本文整理匯總了PHP中Streams::getExtendClasses方法的典型用法代碼示例。如果您正苦於以下問題:PHP Streams::getExtendClasses方法的具體用法?PHP Streams::getExtendClasses怎麽用?PHP Streams::getExtendClasses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Streams
的用法示例。
在下文中一共展示了Streams::getExtendClasses方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: exportArray
/**
* Returns array of fields allowed for user
* @method exportArray
* @param {array} $options=array()
* Options can include:
* "asUserId" => Defaults to the logged in user, or "" if not logged in
* If access is not set for the stream it will be calculated for <code>$asUserId</code>
* @return {array}
*/
function exportArray($options = null)
{
$asUserId = isset($options['asUserId']) ? $options['asUserId'] : null;
if (!isset($asUserId)) {
$user = Users::loggedInUser();
$asUserId = $user ? $user->id : '';
}
$this->calculateAccess($asUserId);
if ($this->testReadLevel('content')) {
$result = $this->toArray();
$result['icon'] = $this->iconUrl();
} else {
if (!$this->testReadLevel('see')) {
return array();
}
$result = array();
$default = array('publisherId', 'name', 'type', 'title', 'icon', 'insertedTime', 'updatedTime');
if (isset($this->type)) {
$fields = array_merge($default, Q_Config::get('Streams', 'types', $this->type, 'see', array()));
}
foreach ($fields as $field) {
$result[$field] = $field === 'icon' ? $this->iconUrl() : $this->{$field};
}
}
$classes = Streams::getExtendClasses($this->type);
$fieldNames = array();
foreach ($classes as $k => $v) {
foreach ($v as $f) {
foreach ($fieldNames as $key) {
$result[$f] = isset($this->{$f}) ? $this->{$f} : null;
}
}
}
$result['access'] = array('readLevel' => $this->get('readLevel', $this->readLevel), 'writeLevel' => $this->get('writeLevel', $this->writeLevel), 'adminLevel' => $this->get('adminLevel', $this->adminLevel));
$result['isRequired'] = $this->isRequired();
return $result;
}
示例2: afterFetchExtended
protected static function afterFetchExtended($publisherId, $streams)
{
if (!$streams) {
return;
}
$classes = array();
$rows = array();
$streamNamesByType = array();
foreach ($streams as $stream) {
if (!$stream) {
continue;
}
$streamNamesByType[$stream->type][] = $stream->name;
}
$classes = array();
foreach ($streams as $stream) {
if (!$stream) {
continue;
}
$type = $stream->type;
if (!isset($classes[$type])) {
$classes[$type] = Streams::getExtendClasses($type);
foreach ($classes[$type] as $className => $fieldNames) {
$rows[$className] = call_user_func(array($className, 'select'), '*')->where(array('publisherId' => $publisherId, 'streamName' => $streamNamesByType[$type]))->fetchDbRows(null, '', 'streamName');
}
}
}
foreach ($streams as $stream) {
if (!$stream) {
continue;
}
$streamName = $stream->name;
foreach ($classes[$stream->type] as $className => $fieldNames) {
if (empty($rows[$className][$streamName])) {
continue;
}
$row = $stream->rows[$className] = $rows[$className][$streamName];
$row->set('Streams_Stream', $stream);
foreach ($fieldNames as $f) {
if (!isset($rows[$className][$streamName])) {
continue;
}
$stream->{$f} = $rows[$className][$streamName]->{$f};
}
}
}
}