code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function getPermissionObjectToCheck()
{
if (isset($this->permissionObjectToCheck) && is_object($this->permissionObjectToCheck)) {
return $this->permissionObjectToCheck;
} else {
return $this->permissionObject;
}
}
|
Set the actual object that should be checked for this permission (for example, a Page instance).
@param \Concrete\Core\Permission\ObjectInterface|null $object
|
getPermissionObjectToCheck
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function getPermissionObject()
{
return $this->permissionObject;
}
|
Get the object for which this permission is for (for example, a Page instance).
@return \Concrete\Core\Permission\ObjectInterface|null
|
getPermissionObject
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function loadAll()
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$permissionkeys = [];
$txt = $app->make('helper/text');
$e = $db->executeQuery(<<<'EOT'
select pkID, pkName, pkDescription, pkHandle, pkCategoryHandle, pkCanTriggerWorkflow, pkHasCustomClass, PermissionKeys.pkCategoryID, PermissionKeyCategories.pkgID
from PermissionKeys
inner join PermissionKeyCategories on PermissionKeyCategories.pkCategoryID = PermissionKeys.pkCategoryID
EOT
);
while (($r = $e->fetch(PDO::FETCH_ASSOC)) !== false) {
if ($r['pkHasCustomClass']) {
$class = '\\Core\\Permission\\Key\\' . $txt->camelcase($r['pkHandle'] . '_' . $r['pkCategoryHandle']) . 'Key';
} else {
$class = '\\Core\\Permission\\Key\\' . $txt->camelcase($r['pkCategoryHandle']) . 'Key';
}
$pkgHandle = $r['pkgID'] ? PackageList::getHandle($r['pkgID']) : null;
$class = core_class($class, $pkgHandle);
$pk = $app->make($class);
$pk->setPropertiesFromArray($r);
$permissionkeys[$r['pkHandle']] = $pk;
$permissionkeys[$r['pkID']] = $pk;
}
$cache = $app->make('cache/request');
if ($cache->isEnabled()) {
$cache->getItem('permission_keys')->set($permissionkeys)->save();
}
return $permissionkeys;
}
|
Get the list of all the defined permission keys.
@return \Concrete\Core\Permission\Key\Key[]
|
loadAll
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function hasCustomOptionsForm()
{
$app = Application::getFacadeApplication();
$locator = $app->make(FileLocator::class);
$pkgHandle = $this->getPackageHandle();
if ($pkgHandle) {
$locator->addLocation(new FileLocator\PackageLocation($pkgHandle));
}
$record = $locator->getRecord(DIRNAME_ELEMENTS . '/' . DIRNAME_PERMISSIONS . '/' . DIRNAME_KEYS . '/' . $this->getPermissionKeyHandle() . '.php');
return $record ? file_exists($record->getFile()) : false;
}
|
Does this permission key have a form (located at elements/permission/keys/<handle>.php)?
@return bool
|
hasCustomOptionsForm
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function getPackageID()
{
return isset($this->pkgID) ? (int) $this->pkgID : null;
}
|
Get the ID of the package that defines this permission key.
@return int|null
|
getPackageID
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function getPackageHandle()
{
$pkgID = $this->getPackageID();
return $pkgID ? PackageList::getHandle($this->pkgID) : null;
}
|
Get the handle of the package that defines this permission key.
@return string|null
|
getPackageHandle
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function getList($pkCategoryHandle, $filters = [])
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$q = 'select pkID from PermissionKeys inner join PermissionKeyCategories on PermissionKeys.pkCategoryID = PermissionKeyCategories.pkCategoryID where pkCategoryHandle = ?';
foreach ($filters as $key => $value) {
$q .= ' and ' . $key . ' = ' . $value . ' ';
}
$r = $db->executeQuery($q, [$pkCategoryHandle]);
$list = [];
while (($pkID = $r->fetchColumn()) !== false) {
$pk = self::load($pkID);
if ($pk) {
$list[] = $pk;
}
}
return $list;
}
|
Returns the list of all permissions of this category.
@param string $pkCategoryHandle
@param array $filters An array containing of field name => value (to be used directly in the SQL query)
@return \Concrete\Core\Permission\Key\Key[]
|
getList
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function export($axml)
{
$category = PermissionKeyCategory::getByID($this->pkCategoryID)->getPermissionKeyCategoryHandle();
$pkey = $axml->addChild('permissionkey');
$pkey->addAttribute('handle', $this->getPermissionKeyHandle());
$pkey->addAttribute('name', $this->getPermissionKeyName());
$pkey->addAttribute('description', $this->getPermissionKeyDescription());
$pkey->addAttribute('package', $this->getPackageHandle());
$pkey->addAttribute('category', $category);
$this->exportAccess($pkey);
return $pkey;
}
|
Export this permission key to a SimpleXMLElement instance.
@param \SimpleXMLElement $axml
@return \SimpleXMLElement
|
export
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function exportList($xml)
{
$categories = PermissionKeyCategory::getList();
$pxml = $xml->addChild('permissionkeys');
foreach ($categories as $cat) {
$permissions = static::getList($cat->getPermissionKeyCategoryHandle());
foreach ($permissions as $p) {
$p->export($pxml);
}
}
}
|
Export the list of all permissions of this category to a SimpleXMLElement instance.
@param \SimpleXMLElement $xml
|
exportList
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function getListByPackage($pkg)
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$kina = ['-1'];
$rs = $db->executeQuery('select pkCategoryID from PermissionKeyCategories where pkgID = ?', [$pkg->getPackageID()]);
while (($pkCategoryID = $rs->fetchColumn()) !== false) {
$kina[] = $pkCategoryID;
}
$kinstr = implode(',', $kina);
$categories = [];
/* @var \Concrete\Core\Permission\Category[] $categories */
$list = [];
$r = $db->executeQuery('select pkID, pkCategoryID from PermissionKeys where (pkgID = ? or pkCategoryID in (' . $kinstr . ')) order by pkID asc', [$pkg->getPackageID()]);
while (($row = $r->fetch(PDO::FETCH_ASSOC)) !== false) {
if (!isset($categories[$row['pkCategoryID']])) {
$categories[$row['pkCategoryID']] = PermissionKeyCategory::getByID($row['pkCategoryID']);
}
$pkc = $categories[$row['pkCategoryID']];
$pk = $pkc->getPermissionKeyByID($row['pkID']);
$list[] = $pk;
}
return $list;
}
|
Get the list of permission keys defined by a package.
Note, this queries both the pkgID found on the PermissionKeys table AND any permission keys of a special type
installed by that package, and any in categories by that package.
@param \Concrete\Core\Entity\Package|\Concrete\Core\Package\Package $pkg
@return \Concrete\Core\Permission\Key\Key[]
|
getListByPackage
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function import(SimpleXMLElement $pk)
{
if ($pk['package']) {
$app = Application::getFacadeApplication();
$pkg = $app->make(PackageService::class)->getByHandle($pk['package']);
} else {
$pkg = null;
}
$xml = app(Xml::class);
return self::add(
$pk['category'],
$pk['handle'],
$pk['name'],
$pk['description'],
$xml->getBool($pk['can-trigger-workflow']) ? 1 : 0,
$xml->getBool($pk['has-custom-class']) ? 1 : 0,
$pkg
);
}
|
Import a permission key from a SimpleXMLElement element.
@param \SimpleXMLElement $pk
@return \Concrete\Core\Permission\Key\Key
|
import
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function getByID($pkID)
{
$keys = null;
$app = Application::getFacadeApplication();
$cache = $app->make('cache/request');
if ($cache->isEnabled()) {
$item = $cache->getItem('permission_keys');
if (!$item->isMiss()) {
$keys = $item->get();
}
}
if ($keys === null) {
$keys = self::loadAll();
}
return isset($keys[$pkID]) ? $keys[$pkID] : null;
}
|
Get a permission key given its ID.
@param int $pkID
@return \Concrete\Core\Permission\Key\Key|null
|
getByID
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function getByHandle($pkHandle)
{
$keys = null;
$app = Application::getFacadeApplication();
$cache = $app->make('cache/request');
if ($cache->isEnabled()) {
$item = $cache->getItem('permission_keys');
if (!$item->isMiss()) {
$keys = $item->get();
}
}
if ($keys === null) {
$keys = self::loadAll();
}
return isset($keys[$pkHandle]) ? $keys[$pkHandle] : null;
}
|
Get a permission key given its handle.
@param string $pkHandle
@return \Concrete\Core\Permission\Key\Key|null
|
getByHandle
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function add($pkCategoryHandle, $pkHandle, $pkName, $pkDescription, $pkCanTriggerWorkflow, $pkHasCustomClass, $pkg = false)
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$pkCategoryID = $db->fetchColumn('select pkCategoryID from PermissionKeyCategories where pkCategoryHandle = ?', [$pkCategoryHandle]);
$db->insert('PermissionKeys', [
'pkHandle' => $pkHandle,
'pkName' => $pkName,
'pkDescription' => $pkDescription,
'pkCategoryID' => $pkCategoryID,
'pkCanTriggerWorkflow' => $pkCanTriggerWorkflow ? 1 : 0,
'pkHasCustomClass' => $pkHasCustomClass ? 1 : 0,
'pkgID' => is_object($pkg) ? $pkg->getPackageID() : 0,
]);
$pkID = $db->lastInsertId();
$keys = self::loadAll();
return $keys[$pkID];
}
|
Adds an permission key.
@param string $pkCategoryHandle
@param string $pkHandle
@param string $pkName
@param string $pkDescription
@param bool $pkCanTriggerWorkflow
@param bool $pkHasCustomClass
@param \Concrete\Core\Entity\Package|\Concrete\Core\Package\Package|null $pkg
|
add
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function setPermissionKeyHasCustomClass($pkHasCustomClass)
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$db->executeQuery('update PermissionKeys set pkHasCustomClass = ? where pkID = ?', [$pkHasCustomClass ? 1 : 0, $this->getPermissionKeyID()]);
self::loadAll();
}
|
Mark this permission key as having (or not) a custom class.
@param bool $pkHasCustomClass
|
setPermissionKeyHasCustomClass
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function validate()
{
$app = Application::getFacadeApplication();
$u = $app->make(User::class);
if ($u->isSuperUser()) {
return true;
}
$cache = $app->make('cache/request');
$object = $this->getPermissionObject();
if (is_object($object)) {
$identifier = sprintf('permission/key/%s/%s', $this->getPermissionKeyHandle(), $object->getPermissionObjectIdentifier());
} else {
$identifier = sprintf('permission/key/%s', $this->getPermissionKeyHandle());
}
$item = $cache->getItem($identifier);
if (!$item->isMiss()) {
return $item->get();
}
$pae = $this->getPermissionAccessObject();
if (is_object($pae)) {
$valid = $pae->validate();
} else {
$valid = false;
}
$cache->save($item->set($valid));
return $valid;
}
|
Check if the current user is of for this key and its current permission object (if any).
@return bool
|
validate
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function getAccessListItems()
{
$obj = $this->getPermissionAccessObject();
if (!$obj) {
return [];
}
$args = func_get_args();
switch (count($args)) {
case 0:
return $obj->getAccessListItems();
case 1:
return $obj->getAccessListItems($args[0]);
case 2:
return $obj->getAccessListItems($args[0], $args[1]);
case 3:
return $obj->getAccessListItems($args[0], $args[1], $args[2]);
default:
return call_user_func_array([$obj, 'getAccessListItems'], $args);
}
}
|
A shortcut for grabbing the current assignment and passing into that object.
@return \Concrete\Core\Permission\Access\ListItem\ListItem[]
|
getAccessListItems
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function getPermissionAssignmentObject()
{
$permissionObject = $this->getPermissionObject();
if (is_object($permissionObject)) {
$app = Application::getFacadeApplication();
$className = $permissionObject->getPermissionAssignmentClassName();
$targ = $app->make($className);
$targ->setPermissionObject($permissionObject);
} else {
$targ = new PermissionAssignment();
}
$targ->setPermissionKeyObject($this);
return $targ;
}
|
@return \Concrete\Core\Permission\Assignment\Assignment
|
getPermissionAssignmentObject
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function getPermissionAccessObject()
{
$targ = $this->getPermissionAssignmentObject();
return $targ->getPermissionAccessObject();
}
|
@return \Concrete\Core\Permission\Access\Access|null
|
getPermissionAccessObject
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public static function exportTranslations()
{
$translations = new Translations();
$categories = PermissionKeyCategory::getList();
foreach ($categories as $cat) {
$permissions = static::getList($cat->getPermissionKeyCategoryHandle());
foreach ($permissions as $p) {
$translations->insert('PermissionKeyName', $p->getPermissionKeyName());
if ($p->getPermissionKeyDescription()) {
$translations->insert('PermissionKeyDescription', $p->getPermissionKeyDescription());
}
}
}
return $translations;
}
|
Export the strings that should be translated.
@return \Gettext\Translations
|
exportTranslations
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
protected static function load($key, $loadBy = 'pkID')
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$txt = $app->make('helper/text');
$r = $db->fetchAssoc(
<<<EOT
select pkID, pkName, pkDescription, pkHandle, pkCategoryHandle, pkCanTriggerWorkflow, pkHasCustomClass, PermissionKeys.pkCategoryID, PermissionKeyCategories.pkgID
from PermissionKeys
inner join PermissionKeyCategories on PermissionKeyCategories.pkCategoryID = PermissionKeys.pkCategoryID where {$loadBy} = ?
EOT
,
[$key]
);
if ($r === false) {
return null;
}
if ($r['pkHasCustomClass']) {
$class = '\\Core\\Permission\\Key\\' . $txt->camelcase($r['pkHandle'] . '_' . $r['pkCategoryHandle']) . 'Key';
} else {
$class = '\\Core\\Permission\\Key\\' . $txt->camelcase($r['pkCategoryHandle']) . 'Key';
}
$pkgHandle = $r['pkgID'] ? PackageList::getHandle($r['pkgID']) : null;
$class = core_class($class, $pkgHandle);
$pk = $app->make($class);
$pk->setPropertiesFromArray($r);
return $pk;
}
|
Load a permission key by its ID (or whatever is passed to $loadBy).
@param int|mixed $key the ID (or the value of the $loadBy field) of the key to be loaded
@param string $loadBy the field to be used to locate the permission key
@return \Concrete\Core\Permission\Key\Key|null
|
load
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Key/Key.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Key/Key.php
|
MIT
|
public function __construct($calendar)
{
$this->calendar = $calendar;
}
|
Calendar constructor.
@param $calendar \Concrete\Core\Entity\Calendar\Calendar
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Registry/Entry/Object/Object/CalendarObject.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Registry/Entry/Object/Object/CalendarObject.php
|
MIT
|
public function canAddBlock($blockTypeOrBlock)
{
if ($blockTypeOrBlock instanceof Block) {
$blockType = $blockTypeOrBlock->getBlockTypeObject();
} else {
$blockType = $blockTypeOrBlock;
}
switch ($blockType->getBlockTypeHandle()) {
case BLOCK_HANDLE_LAYOUT_PROXY:
return $this->canAddLayout();
case BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY:
return $this->canAddBlocks();
}
$pk = $this->category->getPermissionKeyByHandle('add_block_to_area');
$pk->setPermissionObject($this->object);
return $pk->validate($blockTypeOrBlock);
}
|
Check if a new block can be added to the area, or if an existing block can be moved to it.
@param \Concrete\Core\Entity\Block\BlockType\BlockType|\Concrete\Core\Block\Block $blockTypeOrBlock specify a block type when adding a new block, a block instance when adding an existing block
@return bool
|
canAddBlock
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/AreaResponse.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/AreaResponse.php
|
MIT
|
public function canEditBoardInstanceSlot(int $slot): bool
{
$renderedSlotCollectionFactory = app(RenderedSlotCollectionFactory::class);
$rules = $renderedSlotCollectionFactory->getCurrentRules($this->getPermissionObject());
$permissionMethod = 'canEditBoardContents';
foreach ($rules as $rule) {
if ($rule->getSlot() == $slot && $rule->isLocked()) {
$permissionMethod = 'canEditBoardLockedRules'; // One locked rule is all it takes.
}
}
$boardPermissions = new Checker($this->getPermissionObject()->getBoard());
return $boardPermissions->$permissionMethod();
}
|
Checks the current slot as well as the current time. If the slot is locked, it uses the canEditLockedRules
command, otherwise it just uses canEditBoardContents(). However in both cases if the timestamp of the rule
in the slot is in the future or ends in the past, we disregard the rule.
@param int $slot
@return bool
|
canEditBoardInstanceSlot
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/BoardInstanceResponse.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/BoardInstanceResponse.php
|
MIT
|
public function canViewConversation()
{
$conversation = $this->getPermissionObject();
if (is_object($conversation)) {
$c = $conversation->getConversationPageObject();
if (is_object($c) && !$c->isError()) {
$cp = new \Permissions($c);
return $cp->canViewPage();
}
}
}
|
@todo Make this dependent on conversation-specific permissions.
|
canViewConversation
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/ConversationResponse.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/ConversationResponse.php
|
MIT
|
public function getAllowedFileExtensions()
{
$pk = $this->category->getPermissionKeyByHandle('add_file');
$pk->setPermissionObject($this->object);
$r = $pk->getAllowedFileExtensions();
return $r;
}
|
Returns all file extensions this user can add.
|
getAllowedFileExtensions
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/FileFolderResponse.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/FileFolderResponse.php
|
MIT
|
public function setPermissionObject($object)
{
$this->object = $object;
}
|
Sets the current permission object to the object provided, this object should implement the Permission ObjectInterface.
@param \Concrete\Core\Permission\ObjectInterface $object
|
setPermissionObject
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/Response.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/Response.php
|
MIT
|
public function setPermissionCategoryObject($category)
{
$this->category = $category;
}
|
Sets the current Permission Category object to an appropriate PermissionKeyCategory.
@param PermissionKeyCategory $category
|
setPermissionCategoryObject
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/Response.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/Response.php
|
MIT
|
public function testForErrors()
{
return false;
}
|
Returns an error constant if an error is present, false if there are no errors.
@return bool|int
|
testForErrors
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/Response.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/Response.php
|
MIT
|
public static function getResponse($object)
{
$cache = Core::make('cache/request');
$identifier = sprintf('permission/response/%s/%s', get_class($object), $object->getPermissionObjectIdentifier());
$item = $cache->getItem($identifier);
if (!$item->isMiss()) {
return $item->get();
}
$className = $object->getPermissionResponseClassName();
/** @var \Concrete\Core\Permission\Response\Response $pr */
$pr = Core::make($className);
if ($object->getPermissionObjectKeyCategoryHandle()) {
$category = PermissionKeyCategory::getByHandle($object->getPermissionObjectKeyCategoryHandle());
$pr->setPermissionCategoryObject($category);
}
$pr->setPermissionObject($object);
$cache->save($item->set($pr));
return $pr;
}
|
Passing in any object that implements the ObjectInterface, retrieve the Permission Response object.
@param \Concrete\Core\Permission\ObjectInterface $object
@return \Concrete\Core\Permission\Response\Response
|
getResponse
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/Response.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/Response.php
|
MIT
|
public function validate($permissionHandle, $args = array())
{
$app = Application::getFacadeApplication();
$u = $app->make(User::class);
if ($u->isSuperUser()) {
return true;
}
if (!is_object($this->category)) {
throw new Exception(t('Unable to get category for permission %s', $permissionHandle));
}
$pk = $this->category->getPermissionKeyByHandle($permissionHandle);
if (!$pk) {
throw new Exception(t('Unable to get permission key for %s', $permissionHandle));
}
$pk->setPermissionObject($this->object);
return call_user_func_array(array($pk, 'validate'), $args);
}
|
This function returns true if the user has permission to the object, or false if they do not have access.
@param string $permissionHandle A Permission Key Handle
@param array $args Arguments to pass to the PermissionKey object's validate function
@return bool
@throws Exception
|
validate
|
php
|
concretecms/concretecms
|
concrete/src/Permission/Response/Response.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Response/Response.php
|
MIT
|
public function __construct($controllerCallback)
{
$this->controllerCallback = $controllerCallback;
}
|
ControllerRouteCallback constructor. $action is something like
\My\Controller::myAction
@param string $action
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Routing/ControllerRouteAction.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/ControllerRouteAction.php
|
MIT
|
public function execute(Request $request, Route $route, $parameters)
{
$request->attributes->set('_controller', $this->getControllerCallback());
$app = Facade::getFacadeApplication();
$controllerResolver = $app->make(ApplicationAwareControllerResolver::class);
$callback = $controllerResolver->getController($request);
$argumentsResolver = $app->make(ArgumentResolver::class);
$arguments = $argumentsResolver->getArguments($request, $callback);
$controller = $callback[0];
$method = $callback[1];
if (method_exists($controller, 'on_start')) {
$response = $controller->on_start();
if ($response instanceof Response) {
return $response;
}
}
if (method_exists($controller, 'runAction')) {
$response = $controller->runAction($method, $arguments);
} else {
$response = call_user_func_array([$controller, $method], $arguments);
}
if ($response instanceof Response) {
// note, our RedirectResponse doesn't extend Response, it extends symfony2 response
return $response;
}
if ($response instanceof AbstractView) {
$content = $response->render();
} else if (method_exists($controller, 'getViewObject')) {
$content = null;
$view = $controller->getViewObject();
if (is_object($view)) {
$view->setController($controller);
if (isset($view) && $view instanceof AbstractView) {
$content = $view->render();
}
}
} else {
$content = $response;
}
if (is_object($content)) {
return $content;
}
$response = new Response();
$response->setContent($content);
return $response;
}
|
@param Request $request
@param Route $route
@param array $parameters
@return Response
|
execute
|
php
|
concretecms/concretecms
|
concrete/src/Routing/ControllerRouteAction.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/ControllerRouteAction.php
|
MIT
|
public function setCustomName($name)
{
$this->customName = $name;
}
|
Sets the custom name. Note: if the route has already been added to the route
collection you will want to use $route->updateName($name, $router)
instead
@param $name
|
setCustomName
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Route.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Route.php
|
MIT
|
public function addMiddleware(RouteMiddleware $middleware)
{
$this->middlewares[] = $middleware;
}
|
Adds middleware to the route.
@param RouteMiddleware $middleware
|
addMiddleware
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Route.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Route.php
|
MIT
|
public function setScopes($scope)
{
$this->setOption('oauth_scopes', $scope);
}
|
Explicitly sets an OAuth2 scope to a route. This will be used if the route is consumed in an
OAuth2 request.
@param string $scope
|
setScopes
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Route.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Route.php
|
MIT
|
public function __construct(Router $router, Route $route)
{
$this->route = $route;
$this->router = $router;
$this->router->addRoute($route);
}
|
RouteBuilder constructor.
@param Router $router
@param Route $route
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Routing/RouteBuilder.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/RouteBuilder.php
|
MIT
|
public function addMiddleware($middleware, $priority = 10)
{
if (!($middleware instanceof RouteMiddleware)) {
$routeMiddleware = new RouteMiddleware();
$routeMiddleware->setMiddleware($middleware);
$routeMiddleware->setPriority($priority);
} else {
$routeMiddleware = $middleware;
}
$this->middlewares[] = $routeMiddleware;
return $this;
}
|
@param string|object $middleware
@param int $priority
@return $this
|
addMiddleware
|
php
|
concretecms/concretecms
|
concrete/src/Routing/RouteGroupBuilder.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/RouteGroupBuilder.php
|
MIT
|
public function routes($routes, $pkgHandle = null)
{
// First, create a new, empty router for use with the routes passed in the callable.
$router = new Router(new RouteCollection(), $this->router->getActionFactory());
if (is_callable($routes)) {
// Run the callable with our empty router.
$routes($router);
// Grab the routes from the router, and pass them to our route group builder.
} else if (is_string($routes)) {
$app = Facade::getFacadeApplication();
/**
* @var $locator FileLocator
*/
$locator = $app->make(FileLocator::class);
if ($pkgHandle) {
$locator->addLocation(new FileLocator\PackageLocation($pkgHandle));
}
$file = $locator->getRecord(DIRNAME_ROUTES . DIRECTORY_SEPARATOR . $routes);
if ($file->exists()) {
require $file->getFile();
}
} else {
throw new \RuntimeException(t('Invalid input passed to RouteGroupBuilder::routes'));
}
$this->sendFromGroupToRouter($router->getRoutes(), $this->router);
return $this;
}
|
@param $routes
@param null $pkgHandle
@return $this
|
routes
|
php
|
concretecms/concretecms
|
concrete/src/Routing/RouteGroupBuilder.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/RouteGroupBuilder.php
|
MIT
|
public function get($path, $action)
{
return $this->createRouteBuilder($path, $action, ['GET']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
get
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function head($path, $action)
{
return $this->createRouteBuilder($path, $action, ['HEAD']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
head
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function post($path, $action)
{
return $this->createRouteBuilder($path, $action, ['POST']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
post
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function put($path, $action)
{
return $this->createRouteBuilder($path, $action, ['PUT']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
put
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function patch($path, $action)
{
return $this->createRouteBuilder($path, $action, ['PATCH']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
patch
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function delete($path, $action)
{
return $this->createRouteBuilder($path, $action, ['DELETE']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
delete
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function options($path, $action)
{
return $this->createRouteBuilder($path, $action, ['OPTIONS']);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
options
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function all($path, $action)
{
return $this->createRouteBuilder($path, $action, [
'GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS',
]);
}
|
@param string $path
@param string $action
@since 8.5.0a2
@return \Concrete\Core\Routing\RouteBuilder
|
all
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function getRouteByPath($path, RequestContext $context, array &$routeAttributes = [])
{
$path = $this->normalizePath($path);
$potentialRoutes = $this->filterRouteCollectionForPath($this->getRoutes(), $path);
$matcher = new UrlMatcher($potentialRoutes, $context);
$routeAttributes = $matcher->match($path);
return $potentialRoutes->get($routeAttributes['_route']);
}
|
{@inheritdoc}
@see \Concrete\Core\Routing\RouterInterface::getRouteByPath()
|
getRouteByPath
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function matchRoute(Request $request)
{
$attributes = [];
$route = $this->getRouteByPath($request->getPathInfo(), (new RequestContext())->fromRequest($request), $attributes);
$request->attributes->add($attributes);
$request->attributes->set('_route', $route);
return new MatchedRoute($route, $attributes);
}
|
{@inheritdoc}
@see \Concrete\Core\Routing\RouterInterface::matchRoute()
|
matchRoute
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function register(
$path,
$callback,
$handle = null,
array $requirements = [],
array $options = [],
$host = '',
$schemes = [],
$methods = [],
$condition = null
)
{
$route = new Route($this->normalizePath($path), [], $requirements, $options, $host, $schemes, $methods, $condition);
$route->setAction($callback);
if ($handle) {
$route->setCustomName($handle);
}
$this->addRoute($route);
return $route;
}
|
@deprecated. Use the verb methods instead.
@param $path
@param $callback
@param null $handle
@param array $requirements
@param array $options
@param string $host
@param array $schemes
@param array $methods
@param null $condition
@return Route
|
register
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function registerMultiple(array $routes)
{
foreach ($routes as $route => $route_settings) {
array_unshift($route_settings, $route);
call_user_func_array([$this, 'register'], $route_settings);
}
}
|
Registers routes from a config array. This is deprecated. Use the $router object
directly in an included file.
@deprecated.
@param array $routes
|
registerMultiple
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function route($data)
{
if (is_array($data)) {
$path = $data[0];
$pkg = $data[1];
} else {
$path = $data;
}
$path = trim($path, '/');
$pkgHandle = null;
if ($pkg) {
if (is_object($pkg)) {
$pkgHandle = $pkg->getPackageHandle();
} else {
$pkgHandle = $pkg;
}
}
$route = '/ccm';
if ($pkgHandle) {
$route .= "/{$pkgHandle}";
} else {
$route .= '/system';
}
$route .= "/{$path}";
return $route;
}
|
Returns a route string based on data. DO NOT USE THIS.
@deprecated
@param $data
@return string
|
route
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function setThemeByRoute($path, $theme = null, $wrapper = FILENAME_THEMES_VIEW)
{
$app = Application::getFacadeApplication();
$app->make(ThemeRouteCollection::class)->setThemeByRoute($path, $theme, $wrapper);
}
|
@deprecated Use $app->make(\Concrete\Core\Page\Theme\ThemeRouteCollection::class)->setThemeByRoute() with the same arguments
{@inheritdoc}
@see \Concrete\Core\Page\Theme\ThemeRouteCollection::setThemeByRoute()
|
setThemeByRoute
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
private function filterRouteCollectionForPath(RouteCollection $routes, $path)
{
$result = new RouteCollection();
foreach ($routes->getResources() as $resource) {
$result->addResource($resource);
}
foreach ($routes->all() as $name => $route) {
$routePath = $route->getPath();
$p = strpos($routePath, '{');
$skip = false;
if ($p === false) {
if ($routePath !== $path) {
$skip = true;
}
} elseif ($p > 0) {
$routeFixedPath = substr($routePath, 0, $p);
if ($route->getDefaults() !== []) {
$routeFixedPath = rtrim($routeFixedPath, '/');
}
if (strpos($path, $routeFixedPath) !== 0) {
$skip = true;
}
}
if ($skip === false) {
$result->add($name, $route);
}
}
return $result;
}
|
@param \Symfony\Component\Routing\RouteCollection $routes
@param string $path
@return \Symfony\Component\Routing\RouteCollection
|
filterRouteCollectionForPath
|
php
|
concretecms/concretecms
|
concrete/src/Routing/Router.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/Router.php
|
MIT
|
public function register()
{
$this->app->singleton(Router::class);
$this->app->singleton(RouterInterface::class, Router::class);
$this->app->bind(RouteActionFactoryInterface::class, function() {
return new RouteActionFactory();
});
$this->app->bind('router', Router::class);
$this->app->singleton(ThemeRouteCollection::class);
}
|
Registers the services provided by this provider.
|
register
|
php
|
concretecms/concretecms
|
concrete/src/Routing/RoutingServiceProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Routing/RoutingServiceProvider.php
|
MIT
|
public function getItemsPerPage()
{
$sessionQuery = $this->getSessionCurrentQuery();
if ($sessionQuery instanceof Query) {
return $sessionQuery->getItemsPerPage();
}
}
|
Gets items per page from the current preset or from the session.
@return int
|
getItemsPerPage
|
php
|
concretecms/concretecms
|
concrete/src/Search/AbstractSearchProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/AbstractSearchProvider.php
|
MIT
|
public function register()
{
$this->app->singleton(DefaultManager::class, function($app) {
$manager = new DefaultManager();
$manager->addIndex(Page::class, PageIndex::class);
$manager->addIndex(Entry::class, EntityIndex::class);
return $manager;
});
$this->app->bindIf(IndexManagerInterface::class, DefaultManager::class);
}
|
Registers the services provided by this provider.
|
register
|
php
|
concretecms/concretecms
|
concrete/src/Search/SearchServiceProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/SearchServiceProvider.php
|
MIT
|
private function sanitizeSortDirection($direction)
{
return strtolower(trim($direction)) === 'asc' ? 'asc' : 'desc';
}
|
Normalize a sort direction to "asc" or "desc".
@param $direction
@return string
|
sanitizeSortDirection
|
php
|
concretecms/concretecms
|
concrete/src/Search/Column/Column.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Column/Column.php
|
MIT
|
public function addColumnAfterKey($col, $key)
{
$columns = [];
foreach($this->columns as $column) {
$columns[] = $column;
if ($column->getColumnKey() == $key) {
$columns[] = $col;
}
}
$this->columns = $columns;
}
|
Add a column after a specific key.
@param \Concrete\Core\Search\Column\ColumnInterface $col
@param string $key
@return void
|
addColumnAfterKey
|
php
|
concretecms/concretecms
|
concrete/src/Search/Column/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Column/Set.php
|
MIT
|
public function addColumnBeforeKey($col, $key)
{
$columns = [];
foreach($this->columns as $column) {
if ($column->getColumnKey() == $key) {
$columns[] = $col;
}
$columns[] = $column;
}
$this->columns = $columns;
}
|
Add a column before a specific key.
@param \Concrete\Core\Search\Column\ColumnInterface $col
@param string $key
@return void
|
addColumnBeforeKey
|
php
|
concretecms/concretecms
|
concrete/src/Search/Column/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Column/Set.php
|
MIT
|
public function getAttributeKeyColumn($akHandle)
{
$result = null;
$ak = call_user_func(array($this->attributeClass, 'getByHandle'), $akHandle);
if ($ak !== null) {
$result = new AttributeKeyColumn($ak);
}
return $result;
}
|
@param string $akHandle
@return AttributeKeyColumn|null
|
getAttributeKeyColumn
|
php
|
concretecms/concretecms
|
concrete/src/Search/Column/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Column/Set.php
|
MIT
|
public function getData(string $key)
{
return $this->data[$key] ?? null;
}
|
@param string $key
@return mixed|null
|
getData
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/AbstractField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/AbstractField.php
|
MIT
|
public function __construct(?Key $attributeKey = null)
{
if ($attributeKey) {
$this->attributeKey = $attributeKey;
$this->akID = $attributeKey->getAttributeKeyID();
}
}
|
Initialize the instance.
@param Key $attributeKey the attribute key instance
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/AttributeKeyField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/AttributeKeyField.php
|
MIT
|
public function __sleep()
{
return ['data', 'akID'];
}
|
Return an array with the names of the properties to be serialized.
@return string[]
|
__sleep
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/AttributeKeyField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/AttributeKeyField.php
|
MIT
|
public function __wakeup()
{
$this->attributeKey = \Concrete\Core\Attribute\Key\Key::getByID($this->akID);
}
|
Initialize the instance once it has been deserialized.
|
__wakeup
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/AttributeKeyField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/AttributeKeyField.php
|
MIT
|
public function setName($name)
{
$this->name = $name;
}
|
Set the group name.
@param string $name
|
setName
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Group.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Group.php
|
MIT
|
public function setFields($fields)
{
$this->fields = $fields;
}
|
Set the fields belonging to this group.
@param FieldInterface[] $fields
|
setFields
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Group.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Group.php
|
MIT
|
public function addField(FieldInterface $field)
{
$this->fields[] = $field;
}
|
Add a field to this group.
@param FieldInterface $field
|
addField
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Group.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Group.php
|
MIT
|
public function addGroup($name, $fields = [])
{
$group = new Group();
$group->setName($name);
$group->setFields($fields);
$this->addGroupObject($group);
}
|
Add a group of fields.
@param string $name the group name
@param FieldInterface[] $fields
|
addGroup
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Manager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Manager.php
|
MIT
|
public function addGroupObject(GroupInterface $group)
{
$this->groups[] = $group;
}
|
Add a field group.
@param GroupInterface $group
|
addGroupObject
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Manager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Manager.php
|
MIT
|
public static function get($manager)
{
$app = Application::getFacadeApplication();
return $app->make(sprintf('manager/search_field/%s', $manager));
}
|
Get a search field manager given its handle.
@param string $manager the manager handle
@return \Concrete\Core\Search\Field\Manager
|
get
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/ManagerFactory.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/ManagerFactory.php
|
MIT
|
public function __construct($keywords = null)
{
if ($keywords) {
$this->data['keywords'] = $keywords;
$this->isLoaded = true;
}
}
|
Initialize the instance.
@param string|null $keywords the keywords to be searched
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Field/KeywordsField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Field/KeywordsField.php
|
MIT
|
public function getKey()
{
return 'keywords';
}
|
{@inheritdoc}
@see \Concrete\Core\Search\Field\FieldInterface::getKey()
|
getKey
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Field/KeywordsField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Field/KeywordsField.php
|
MIT
|
public function getDisplayName()
{
return t('Keywords');
}
|
{@inheritdoc}
@see \Concrete\Core\Search\Field\FieldInterface::getDisplayName()
|
getDisplayName
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Field/KeywordsField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Field/KeywordsField.php
|
MIT
|
public function filterList(ItemList $list)
{
if (isset($this->data['keywords'])) {
$list->filterByKeywords($this->data['keywords']);
}
}
|
{@inheritdoc}
@see \Concrete\Core\Search\Field\FieldInterface::filterList()
|
filterList
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Field/KeywordsField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Field/KeywordsField.php
|
MIT
|
public function renderSearchField()
{
$form = \Core::make('helper/form');
return $form->text('keywords', isset($this->data['keywords']) ? $this->data['keywords'] : '');
}
|
{@inheritdoc}
@see \Concrete\Core\Search\Field\AbstractField::renderSearchField()
|
renderSearchField
|
php
|
concretecms/concretecms
|
concrete/src/Search/Field/Field/KeywordsField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Field/Field/KeywordsField.php
|
MIT
|
public function __construct(IndexingDriverInterface $indexDriver)
{
$this->indexDriver = $indexDriver;
}
|
AbstractIndex constructor.
@param \Concrete\Core\Search\Index\Driver\IndexingDriverInterface $indexDriver
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/AbstractIndex.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/AbstractIndex.php
|
MIT
|
public function index($object)
{
return $this->getIndexer()->index($object);
}
|
Add an object to the index
@param mixed $object Object to index
@return bool Success or fail
|
index
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/AbstractIndex.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/AbstractIndex.php
|
MIT
|
public function forget($object)
{
return $this->getIndexer()->forget($object);
}
|
Remove an object from the index
@param mixed $object Object to forget
@return bool Success or fail
|
forget
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/AbstractIndex.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/AbstractIndex.php
|
MIT
|
protected function getIndexer()
{
return $this->indexDriver;
}
|
@return \Concrete\Core\Search\Index\Driver\IndexingDriverInterface
|
getIndexer
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/AbstractIndex.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/AbstractIndex.php
|
MIT
|
public function getIndexes($type, $includeGlobal=true)
{
// Yield all indexes registered against this type
if (isset($this->indexes[$type])) {
foreach ($this->indexes[$type] as $index) {
yield $type => $this->inflateIndex($index);
}
}
$all = self::TYPE_ALL;
if ($type !== $all && $includeGlobal) {
// Yield all indexes registered against ALL types
if (isset($this->indexes[$all])) {
foreach ($this->indexes[$all] as $key => $index) {
yield $all => $this->inflateIndex($index);
}
}
}
}
|
Get the indexes for a type
@param string $type
@param bool $includeGlobal
@return \Concrete\Core\Search\Index\IndexInterface[]|\Concrete\Core\Search\Index\Iterator
|
getIndexes
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
protected function inflateIndex($class)
{
if ($class instanceof IndexInterface) {
return $class;
}
if (!isset($this->inflated[$class])) {
$this->inflated[$class] = $this->app->make($class);
}
return $this->inflated[$class];
}
|
Get the proper index from the stored value
@param $class
@return IndexInterface
|
inflateIndex
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
public function getAllIndexes()
{
foreach ($this->indexes as $type => $indexList) {
// If we hit the "ALL" type, skip it for now
if ($type == self::TYPE_ALL) {
continue;
}
// Otherwise yield all indexes registered against this type
foreach ($this->getIndexes($type, false) as $index) {
yield $type => $index;
}
}
foreach ($this->getIndexes(self::TYPE_ALL) as $index) {
yield self::TYPE_ALL => $index;
}
}
|
Get all indexes registered against this manager
@return \Generator
|
getAllIndexes
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
public function addIndex($type, $index)
{
if (!isset($this->indexes[$type])) {
$this->indexes[$type] = [];
}
$this->indexes[$type][] = $index;
}
|
Add an index to this manager
@param string $type The type to index. Use DefaultManager::TYPE_ALL to apply to all types.
@param IndexInterface|string $index
|
addIndex
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
public function index($type, $object)
{
foreach ($this->getIndexes($type) as $index) {
$index->index($object);
}
}
|
Index an object
@param string $type
@param mixed $object
@return void
|
index
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
public function forget($type, $object)
{
foreach ($this->getIndexes($type) as $index) {
$index->forget($object);
}
}
|
Forget an object
@param string $type
@param mixed $object
@return void
|
forget
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
public function clear($type)
{
if ($type == self::TYPE_ALL) {
$indexes = $this->getAllIndexes();
} else {
$indexes = $this->getIndexes($type);
}
foreach ($indexes as $index) {
$index->clear();
}
}
|
Clear out a type.
Passing DefaultManager::TYPE_ALL will clear out ALL types, not just types registered against ALL
@param string $type The type to clear
|
clear
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/DefaultManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/DefaultManager.php
|
MIT
|
public function fetchPages()
{
$qb = $this->connection->createQueryBuilder();
// Find all pages that need indexing
$query = $qb
->select('p.cID')
->from('Pages', 'p')
->leftJoin('p', 'CollectionSearchIndexAttributes', 'a', 'p.cID = a.cID')
->where('cIsActive = 1')
->andWhere($qb->expr()->orX(
'a.ak_exclude_search_index is null',
'a.ak_exclude_search_index = 0'
))->execute();
while ($id = $query->fetchColumn()) {
yield $id;
}
}
|
Get Pages to add to the queue.
@return \Iterator
|
fetchPages
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/IndexObjectProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/IndexObjectProvider.php
|
MIT
|
public function fetchUsers()
{
/** @var Connection $db */
$db = $this->connection;
$query = $db->executeQuery('SELECT uID FROM Users WHERE uIsActive = 1');
while ($id = $query->fetchColumn()) {
yield $id;
}
}
|
Get Users to add to the queue.
@return \Iterator
|
fetchUsers
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/IndexObjectProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/IndexObjectProvider.php
|
MIT
|
public function fetchExpressObjects()
{
/** @var Connection $db */
$db = $this->connection;
$query = $db->executeQuery('SELECT id FROM ExpressEntities order by id asc');
while ($id = $query->fetchColumn()) {
yield $id;
}
}
|
Get Express objects to add to the queue.
@return \Iterator
|
fetchExpressObjects
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/IndexObjectProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/IndexObjectProvider.php
|
MIT
|
public function fetchExpressEntries()
{
/** @var Connection $db */
$db = $this->connection;
$query = $db->executeQuery('SELECT exEntryID FROM ExpressEntityEntries order by exEntryID asc');
while ($id = $query->fetchColumn()) {
yield $id;
}
}
|
Get Express entries to add to the queue.
@return \Iterator
|
fetchExpressEntries
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/IndexObjectProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/IndexObjectProvider.php
|
MIT
|
public function fetchFiles()
{
/** @var Connection $db */
$db = $this->connection;
$query = $db->executeQuery('SELECT fID FROM Files');
while ($id = $query->fetchColumn()) {
yield $id;
}
}
|
Get Files to add to the queue.
@return \Iterator
|
fetchFiles
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/IndexObjectProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/IndexObjectProvider.php
|
MIT
|
public function fetchSites()
{
/** @var Connection $db */
$db = $this->connection;
$query = $db->executeQuery('SELECT siteID FROM Sites');
while ($id = $query->fetchColumn()) {
yield $id;
}
}
|
Get Sites to add to the queue.
@return \Iterator
|
fetchSites
|
php
|
concretecms/concretecms
|
concrete/src/Search/Index/IndexObjectProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Index/IndexObjectProvider.php
|
MIT
|
protected function loadQueryStringPagingVariable()
{
$this->paginationPageParameter = \Config::get('concrete.seo.paging_string');
}
|
Get paging parameter from Concrete configuration
|
loadQueryStringPagingVariable
|
php
|
concretecms/concretecms
|
concrete/src/Search/ItemList/ItemList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/ItemList/ItemList.php
|
MIT
|
public function setNameSpace($nameSpace)
{
if (!isset($this->paginationPageParameter)) {
$this->loadQueryStringPagingVariable();
}
if(!is_null($nameSpace) && $nameSpace!=""){
$this->paginationPageParameter .= '_' . $nameSpace;
$this->sortColumnParameter .= '_' . $nameSpace;
$this->sortDirectionParameter .= '_' . $nameSpace;
}
}
|
Allow to modify the auto-pagination parameters and the auto-sorting parameters
@param mixed $nameSpace Content that will be added to the parameters
|
setNameSpace
|
php
|
concretecms/concretecms
|
concrete/src/Search/ItemList/ItemList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/ItemList/ItemList.php
|
MIT
|
public function __call($nm, $a)
{
if (substr($nm, 0, 8) == 'filterBy') {
$handle = uncamelcase(substr($nm, 8));
if (count($a) == 2) {
$this->filterByAttribute($handle, $a[0], $a[1]);
} else {
$this->filterByAttribute($handle, $a[0]);
}
} else {
if (substr($nm, 0, 6) == 'sortBy') {
$handle = uncamelcase(substr($nm, 6));
if (count($a) == 1) {
$this->sanitizedSortBy('ak_' . $handle, $a[0]);
} else {
$this->sanitizedSortBy('ak_' . $handle);
}
} else {
throw new \Exception(t('%s method does not exist for the %s class', $nm, get_called_class()));
}
}
}
|
Magic method for setting up additional filtering by attributes.
@param $nm
@param $a
@throws \Exception
|
__call
|
php
|
concretecms/concretecms
|
concrete/src/Search/ItemList/Database/AttributedItemList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/ItemList/Database/AttributedItemList.php
|
MIT
|
public function filterByAttribute($handle, $value, $comparison = '=')
{
$ak = call_user_func_array([$this->getAttributeKeyClassName(), 'getByHandle'], [$handle]);
if (!is_object($ak)) {
throw new InvalidAttributeException(t('Unable to find attribute %s', $handle));
}
$ak->getController()->filterByAttribute($this, $value, $comparison);
}
|
Filters by an attribute.
@param mixed $handle
@param mixed $value
@param mixed $comparison
@throws InvalidAttributeException
|
filterByAttribute
|
php
|
concretecms/concretecms
|
concrete/src/Search/ItemList/Database/AttributedItemList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/ItemList/Database/AttributedItemList.php
|
MIT
|
public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
{
return $query;
}
|
@param \Doctrine\DBAL\Query\QueryBuilder $query
@return \Doctrine\DBAL\Query\QueryBuilder
|
finalizeQuery
|
php
|
concretecms/concretecms
|
concrete/src/Search/ItemList/Database/ItemList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/ItemList/Database/ItemList.php
|
MIT
|
public function sortListByCursor(PagerProviderInterface $itemList, $direction)
{
$itemList->getQueryObject()->addOrderBy('g.gID', $direction);
}
|
@param GroupList $itemList
@param string $direction
|
sortListByCursor
|
php
|
concretecms/concretecms
|
concrete/src/Search/ItemList/Pager/Manager/UserGroupPagerManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/ItemList/Pager/Manager/UserGroupPagerManager.php
|
MIT
|
public function renderDefaultView($arguments = array())
{
return $this->renderView('application', $arguments);
}
|
This is a convenience method that does the following: 1. it grabs the pagination/view service (which by default
is bootstrap 3) 2. it sets up URLs to start with the pass of the current page, and 3. it uses the default
item list query string parameter for paging. If you need more custom functionality you should consider
using the Pagerfanta\View\ViewInterface objects directly.
@param array
@return string
|
renderDefaultView
|
php
|
concretecms/concretecms
|
concrete/src/Search/Pagination/Pagination.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Pagination/Pagination.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.