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 deliverPaginationObject(ItemList $itemList, Pagerfanta $pagination) { if ($itemList->getItemsPerPage() > -1) { $pagination->setMaxPerPage($itemList->getItemsPerPage()); } $query = $this->request->query; if ($query->has($itemList->getQueryPaginationPageParameter())) { $page = intval($query->get($itemList->getQueryPaginationPageParameter())); try { $pagination->setCurrentPage($page); } catch (LessThan1CurrentPageException $e) { $pagination->setCurrentPage(1); } catch (OutOfRangeCurrentPageException $e) { $pagination->setCurrentPage(1); } } return $pagination; }
@param ItemList $itemList @param Pagerfanta $pagination @return Pagerfanta
deliverPaginationObject
php
concretecms/concretecms
concrete/src/Search/Pagination/PaginationFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Pagination/PaginationFactory.php
MIT
public function createQuery( ProviderInterface $searchProvider, $fields = [] ) { $query = new Query(); $set = $searchProvider->getDefaultColumnSet(); $query->setFields($fields); $query->setColumns($set); $query->setItemsPerPage($searchProvider->getItemsPerPage()); return $query; }
Creates the default query object for a particular search provider. Pre-loaded search fields can be added to filter the query. @param ProviderInterface $searchProvider @param Request $request @param FieldInterface[] @param string $method @return Query
createQuery
php
concretecms/concretecms
concrete/src/Search/Query/QueryFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Query/QueryFactory.php
MIT
public function createFromAdvancedSearchRequest(ProviderInterface $searchProvider, Request $request, $method = Request::METHOD_POST) { $defaultColumnSet = $searchProvider->getDefaultColumnSet(); $query = new Query(); $vars = $this->getRequestData($request, $method); $fields = $searchProvider->getFieldManager()->getFieldsFromRequest($vars); $set = $searchProvider->getBaseColumnSet(); $available = $searchProvider->getAvailableColumnSet(); if (is_array($vars['column'] ?? null)) { foreach ($vars['column'] as $key) { $column = $available->getColumnByKey($key); if ($column) { $set->addColumn($column); } } } if ($set->getColumns() === []) { foreach ($defaultColumnSet->getColumns() as $column) { $set->addColumn($column); } } $sort = empty($vars['fSearchDefaultSort']) ? null : $available->getColumnByKey($vars['fSearchDefaultSort']); if ($sort === null) { $set->setDefaultSortColumn($defaultColumnSet->getDefaultSortColumn(), $defaultColumnSet->getDefaultSortColumn()->getColumnSortDirection()); } else { $set->setDefaultSortColumn($sort, $vars['fSearchDefaultSortDirection'] ?? 'asc'); } $query->setFields($fields); $query->setColumns($set); $itemsPerPage = is_numeric($vars['fSearchItemsPerPage'] ?? null) ? (int) $vars['fSearchItemsPerPage'] : 0; if ($itemsPerPage > 0) { $query->setItemsPerPage($itemsPerPage); } return $query; }
Creates a Query object from the request of the standard Advanced Search dialog. This is the dialog that includes the stackable filters, customizable columns, items per page, etc... @param ProviderInterface $searchProvider @param Request $request @param string $method @return Query
createFromAdvancedSearchRequest
php
concretecms/concretecms
concrete/src/Search/Query/QueryFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Query/QueryFactory.php
MIT
public function createFromSavedSearch(SavedSearch $preset) { return $preset->getQuery(); }
Creates a query object from a saved search. You could easily just call `getQuery` on the preset directly; this is mainly here for code purity. @param SavedSearch $preset @return mixed
createFromSavedSearch
php
concretecms/concretecms
concrete/src/Search/Query/QueryFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Query/QueryFactory.php
MIT
public function getPagination(): \Concrete\Core\Search\Pagination\Pagination { return $this->pagination; }
@return \Concrete\Core\Search\Pagination\Pagination
getPagination
php
concretecms/concretecms
concrete/src/Search/Result/Result.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Search/Result/Result.php
MIT
protected function getConfiguredRule($configuration, RuleInterface $rule) { $configurationNormalized = str_replace(array("\r\n", "\r"), "\n", (string) $configuration); $rxSearch = '/'; // First of all we have either the start of the file or a line ending $rxSearch .= '(^|\n)'; $commentsBefore = $rule->getCommentsBefore(); if ($commentsBefore !== '') { // Then we may have the opening comment line $rxSearch .= '(\s*'.preg_quote($commentsBefore, '/').'\s*\n+)?'; } // Then we have the rule itself $rxSearch .= '\s*'.preg_replace("/\n\s*/", "\\s*\\n\\s*", preg_quote($rule->getCode(), '/')).'\s*'; $commentsAfter = $rule->getCommentsAfter(); if ($commentsAfter !== '') { // Then we may have the closing comment line $rxSearch .= '(\n\s*'.preg_quote($commentsAfter, '/').'\s*)?'; } // Finally we have the end of the file or a line ending $rxSearch .= '(\n|$)'; $rxSearch .= '/'; return preg_match($rxSearch, $configurationNormalized, $match) ? $match[0] : ''; }
Gets the rule, if present in a configuration. @param string $configuration The whole configuration. @param RuleInterface $rule The rule to be checked. @return string Returns the whole rule found (or '' if not found)
getConfiguredRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
MIT
public function hasRule($configuration, RuleInterface $rule) { return $this->getConfiguredRule($configuration, $rule) !== ''; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\ConfiguratorInterface::hasRule()
hasRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
MIT
public function addRule($configuration, RuleInterface $rule) { if ($this->getConfiguredRule($configuration, $rule) === '') { $configuration = rtrim($configuration); if ($configuration !== '') { $configuration .= "\n\n"; } $commentsBefore = $rule->getCommentsBefore(); if ($commentsBefore !== '') { $configuration .= $commentsBefore."\n"; } $configuration .= $rule->getCode()."\n"; $commentsAfter = $rule->getCommentsAfter(); if ($commentsAfter !== '') { $configuration .= $commentsAfter."\n"; } } return $configuration; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\ConfiguratorInterface::addRule()
addRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
MIT
public function removeRule($configuration, RuleInterface $rule) { $current = $this->getConfiguredRule($configuration, $rule); if ($current !== '') { $configuration = str_replace(array("\r\n", "\r"), "\n", (string) $configuration); $configuration = trim(str_replace($current, "\n\n", $configuration)); if ($configuration !== '') { $configuration .= "\n"; } } return $configuration; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\ConfiguratorInterface::removeRule()
removeRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php
MIT
public function setFilesystem(Filesystem $filesystem) { $this->filesystem = $filesystem; }
Set the Filesystem to use. @param Filesystem $filesystem
setFilesystem
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
public function getFilesystem() { if ($this->filesystem === null) { $this->filesystem = new Filesystem(); } return $this->filesystem; }
Get the Filesystem to use. @return Filesystem
getFilesystem
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
protected function getHTaccessFilename() { return DIR_BASE.'/.htaccess'; }
Return the full path name to the .htaccess file. @return string
getHTaccessFilename
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
public function canRead() { $ht = $this->getHTaccessFilename(); $fs = $this->getFilesystem(); if (@$fs->isFile($ht)) { $result = @is_readable($ht); } else { $result = @is_readable(@dirname($ht)); } return $result; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::canRead()
canRead
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
public function read() { $result = ''; $ht = $this->getHTaccessFilename(); $fs = $this->getFilesystem(); if (@$fs->isFile($ht)) { $result = @$fs->get($ht); if ($result === false) { throw new Exception("Failed to read from file $ht"); } } return $result; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::read()
read
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
public function canWrite() { $ht = $this->getHTaccessFilename(); $fs = $this->getFilesystem(); return (bool) (@$fs->isFile($ht) ? @$fs->isWritable($ht) : @$fs->isWritable(@dirname($ht))); }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::canWrite()
canWrite
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
public function write($configuration) { $ht = $this->getHTaccessFilename(); $fs = $this->getFilesystem(); if (@$fs->put($ht, $configuration) === false) { throw new Exception("Failed to write to file $ht"); } }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::write()
write
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/ApacheStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/ApacheStorage.php
MIT
public function hasRule($configuration, RuleInterface $rule) { throw new Exception(t('Managing nginx configuration is not implemented')); }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\ConfiguratorInterface::hasRule()
hasRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxConfigurator.php
MIT
public function addRule($configuration, RuleInterface $rule) { throw new Exception(t('Managing nginx configuration is not implemented')); }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\ConfiguratorInterface::addRule()
addRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxConfigurator.php
MIT
public function removeRule($configuration, RuleInterface $rule) { throw new Exception(t('Managing nginx configuration is not implemented')); }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\ConfiguratorInterface::removeRule()
removeRule
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxConfigurator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxConfigurator.php
MIT
public function canRead() { return false; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::canRead()
canRead
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxStorage.php
MIT
public function read() { throw new Exception(t('Reading nginx configuration is not implemented')); }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::read()
read
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxStorage.php
MIT
public function canWrite() { return false; }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::canWrite()
canWrite
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxStorage.php
MIT
public function write($configuration) { throw new Exception(t('Writing nginx configuration is not implemented')); }
{@inheritdoc} @see \Concrete\Core\Service\Configuration\StorageInterface::write()
write
php
concretecms/concretecms
concrete/src/Service/Configuration/HTTP/NginxStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Configuration/HTTP/NginxStorage.php
MIT
public function __construct(Request $request) { $this->request = $request; }
Class constructor. @param \Concrete\Core\Http\Request $request
__construct
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/ApacheDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/ApacheDetector.php
MIT
public function detect() { $result = null; if (($result === null || $result === '') && $this->request->server->has('SERVER_SOFTWARE')) { $version = $this->detectFromServer($this->request->server->get('SERVER_SOFTWARE')); if ($version !== null) { $result = $version; } } if (($result === null || $result === '') && function_exists('apache_get_version')) { $version = $this->detectFromSPL(@apache_get_version()); if ($version !== null) { $result = $version; } } if ($result === null || $result === '') { ob_start(); phpinfo(INFO_MODULES); $info = ob_get_contents(); ob_end_clean(); $result = $this->detectFromPHPInfo($info); } if (($result === null || $result === '')) { $version = $this->detectFromSapiName(PHP_SAPI); if ($version !== null) { $result = $version; } } return $result; }
{@inheritdoc} @see \Concrete\Core\Service\Detector\DetectorInterface::detect()
detect
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/ApacheDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/ApacheDetector.php
MIT
private function detectFromServer($value) { $result = null; if (is_string($value)) { if (preg_match('/\bApache\/(\d+(\.\d+)+)/i', $value, $m)) { $result = $m[1]; } elseif ($value === 'Apache') { $result = ''; } } return $result; }
Detect from the SERVER_SOFTWARE key of the superglobal server array. @param string $value @return null|string
detectFromServer
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/ApacheDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/ApacheDetector.php
MIT
private function detectFromPHPInfo($value) { $result = null; if (is_string($value) && preg_match('/\bApache\/(\d+(\.\d+)+)/i', $value, $m)) { $result = $m[1]; } return $result; }
Detect using PHPInfo. @param string $value @return null|string
detectFromPHPInfo
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/ApacheDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/ApacheDetector.php
MIT
private function detectFromSapiName($sapiName) { $result = null; if (is_string($sapiName) && preg_match('/^apache(\d)handler$/', $sapiName, $m)) { $result = $m[1]; } return $result; }
Detect using PHP_SAPI/php_sapi_name. @param string $value @return null|string
detectFromSapiName
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/ApacheDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/ApacheDetector.php
MIT
public function __construct(Request $request) { $this->request = $request; }
Class constructor. @param \Concrete\Core\Http\Request $request
__construct
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/NginxDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/NginxDetector.php
MIT
public function detect() { $result = null; if ($result === null && $this->request->server->has('SERVER_SOFTWARE')) { $result = $this->detectFromServer($this->request->server->get('SERVER_SOFTWARE')); } if ($result === null && function_exists('apache_get_version')) { $result = $this->detectFromSPL(@apache_get_version()); } if ($result === null) { ob_start(); phpinfo(INFO_MODULES); $info = ob_get_contents(); ob_end_clean(); $result = $this->detectFromPHPInfo($info); } return $result; }
{@inheritdoc} @see \Concrete\Core\Service\Detector\DetectorInterface::detect()
detect
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/NginxDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/NginxDetector.php
MIT
private function detectFromServer($value) { $result = null; if (is_string($value) && preg_match('/\bnginx\/(\d+(\.\d+)+)/i', $value, $m)) { $result = $m[1]; } return $result; }
Detect from the SERVER_SOFTWARE key of the superglobal server array. @param string $value @return null|string
detectFromServer
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/NginxDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/NginxDetector.php
MIT
private function detectFromPHPInfo($value) { $result = null; if (is_string($value) && preg_match('/\bnginx\/(\d+(\.\d+)+)/i', $value, $m)) { $result = $m[1]; } return $result; }
Detect using PHPInfo. @param string $value @return null|string
detectFromPHPInfo
php
concretecms/concretecms
concrete/src/Service/Detector/HTTP/NginxDetector.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Detector/HTTP/NginxDetector.php
MIT
public function getName() { return 'Apache'; }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getName()
getName
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getVersion() { return $this->version; }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getVersion()
getVersion
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getFullName() { $name = $this->getName(); $version = $this->getVersion(); return ($version === '') ? $name : "$name $version"; }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getFullName()
getFullName
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getDetector() { return $this->app->make($this->detector_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getDetector()
getDetector
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getGenerator() { return $this->app->make($this->generator_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getGenerator()
getGenerator
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getStorage() { return $this->app->make($this->storage_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getStorage()
getStorage
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getConfigurator() { return $this->app->make($this->configurator_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getConfigurator()
getConfigurator
php
concretecms/concretecms
concrete/src/Service/HTTP/Apache.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Apache.php
MIT
public function getName() { return 'nginx'; }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getName()
getName
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function getVersion() { return $this->version; }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getVersion()
getVersion
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function getFullName() { $name = $this->getName(); $version = $this->getVersion(); return ($version === '') ? $name : "$name $version"; }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getFullName()
getFullName
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function getDetector() { return $this->app->make($this->detector_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getDetector()
getDetector
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function getGenerator() { return $this->app->make($this->generator_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getGenerator()
getGenerator
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function getStorage() { return $this->app->make($this->storage_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getStorage()
getStorage
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function getConfigurator() { return $this->app->make($this->configurator_class); }
{@inheritdoc} @see \Concrete\Core\Service\ServiceInterface::getConfigurator()
getConfigurator
php
concretecms/concretecms
concrete/src/Service/HTTP/Nginx.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/HTTP/Nginx.php
MIT
public function __construct(Application $app) { $this->app = $app; }
Manager constructor. @param \Concrete\Core\Application\Application $app
__construct
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function extend($handle, $abstract) { $this->extensions[$handle] = $abstract; }
Add an extension to this manager. @param string $handle @param string|callable|ServiceInterface $abstract
extend
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function getExtensions() { return array_keys($this->extensions); }
An array of handles that have been added with `->extend`. @return string[]
getExtensions
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function has($handle) { return isset($this->extensions[$handle]); }
Does this handle exist? This method MUST return true for anything added with `->extend`. @param $handle @return bool
has
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function getService($handle, $version = '') { $result = null; if ($this->has($handle)) { $key = $handle; $version = (string) $version; if ($version !== '') { $key .= "@$version"; } if (!isset($this->services[$key])) { $abstract = $this->extensions[$handle]; $service = $this->buildService($abstract, $version); if ($service === null) { throw new \RuntimeException('Invalid service binding.'); } $this->services[$key] = $service; } $result = $this->services[$key]; } return $result; }
Get the driver for this handle. @param string $handle @param string $version @return ServiceInterface|null
getService
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
private function buildService($abstract, $version = '') { $resolved = null; if (is_string($abstract)) { // If it's a string, throw it at the IoC container $resolved = $this->app->make($abstract, array('version' => $version)); } elseif (is_callable($abstract)) { // If it's a callable, lets call it with the application and $this $resolved = $abstract($version, $this->app, $this); } return $resolved; }
Build a service from an abstract. @param string|callable $abstract @param string $version @return ServiceInterface|null
buildService
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function getAllServices() { $result = array(); foreach ($this->getExtensions() as $handle) { $result[$handle] = $this->getService($handle); } return $result; }
Returns all the available services. @return ServiceInterface[]
getAllServices
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function getActiveServices() { $active = array(); foreach ($this->getExtensions() as $handle) { $service = $this->getService($handle); $version = $service->getDetector()->detect(); if ($version !== null) { $active[] = $this->getService($handle, $version); } } return $active; }
Loops through the bound services and returns the ones that are active. @return ServiceInterface[]
getActiveServices
php
concretecms/concretecms
concrete/src/Service/Manager/ServiceManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Manager/ServiceManager.php
MIT
public function __construct($description = '', $required = false, $value = null) { $this->description = (string) $description; $this->required = $required; $this->value = $value; }
Initializes the instance. @param string $description Option description. @param bool|callable $required Is this option required? @param mixed $value Initial rule option.
__construct
php
concretecms/concretecms
concrete/src/Service/Rule/Option.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Option.php
MIT
public function getDescription() { return $this->description; }
Get the option description. @return string
getDescription
php
concretecms/concretecms
concrete/src/Service/Rule/Option.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Option.php
MIT
public function isRequired() { $result = $this->required; if (is_callable($result)) { $result = $result($this); } return (bool) $result; }
Is this option required? @return bool
isRequired
php
concretecms/concretecms
concrete/src/Service/Rule/Option.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Option.php
MIT
public function setValue($value) { $this->value = $value; }
Set the option value. @param mixed $value
setValue
php
concretecms/concretecms
concrete/src/Service/Rule/Option.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Option.php
MIT
public function getValue() { return $this->value; }
Get the option value. @return mixed
getValue
php
concretecms/concretecms
concrete/src/Service/Rule/Option.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Option.php
MIT
public function __construct($code, $enabled, $commentsBefore = '', $commentsAfter = '') { $this->code = $code; $this->enabled = $enabled; $this->commentsBefore = (string) $commentsBefore; $this->commentsAfter = (string) $commentsAfter; $this->options = array(); }
Intializes the instance. @param string|callable $code The code of the rule. @param bool|callable $enabled Is this rule enabled (should be present in the configuration) or disabled (should not be present in the configuration)? @param string $commentsBefore Optional comments to be placed before the rule itself. @param string $commentsAfter Optional comments to be placed after the rule itself.
__construct
php
concretecms/concretecms
concrete/src/Service/Rule/Rule.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Rule.php
MIT
public function addOption($handle, Option $option) { $this->options[$handle] = $option; }
{@inheritdoc} @see \Concrete\Core\Service\Rule\ConfigurableRuleInterface::addOption()
addOption
php
concretecms/concretecms
concrete/src/Service/Rule/Rule.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Rule.php
MIT
public function getOptions() { return $this->options; }
{@inheritdoc} @see \Concrete\Core\Service\Rule\RuleInterface::getOptions()
getOptions
php
concretecms/concretecms
concrete/src/Service/Rule/Rule.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Rule.php
MIT
public function getOption($handle) { return isset($this->options[$handle]) ? $this->options[$handle] : null; }
{@inheritdoc} @see \Concrete\Core\Service\Rule\ConfigurableRuleInterface::getOption()
getOption
php
concretecms/concretecms
concrete/src/Service/Rule/Rule.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Service/Rule/Rule.php
MIT
public static function setApplicationObject(Application $app) { static::$app = $app; }
DO NOT USE THIS METHOD Instead override the application bindings. This method only exists to enable legacy static methods on the real application instance @deprecated Create the session using $app->make('session');
setApplicationObject
php
concretecms/concretecms
concrete/src/Session/Session.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Session.php
MIT
public static function start() { /** @var FactoryInterface $factory */ return self::$app->make('session'); }
@deprecated Create the session using $app->make('session');
start
php
concretecms/concretecms
concrete/src/Session/Session.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Session.php
MIT
public static function testSessionFixation(SymfonySession $session) { $validator = self::$app->make('Concrete\Core\Session\SessionValidatorInterface'); $validator->handleSessionValidation($session); }
@param \Symfony\Component\HttpFoundation\Session\Session $session @deprecated Use \Concrete\Core\Session\SessionValidator
testSessionFixation
php
concretecms/concretecms
concrete/src/Session/Session.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Session.php
MIT
public function __construct(Application $app, Request $request) { $this->app = $app; $this->request = $request; }
SessionFactory constructor. @param \Concrete\Core\Application\Application $app @param \Concrete\Core\Http\Request $request @deprecated, will be removed
__construct
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
public function createSession() { $config = $this->app['config']['concrete.session']; $storage = $this->getSessionStorage($config); // We have to use "build" here because we have bound this classname to this factory method $session = new SymfonySession($storage); $session->setName(array_get($config, 'name')); /* @TODO Remove this call. We should be able to set this against the request somewhere much higher than this */ /* At the very least we should have an observer that can track the session status and set this */ $this->app->make(Request::class)->setSession($session); return $session; }
Create a new symfony session object This method MUST NOT start the session. @return \Symfony\Component\HttpFoundation\Session\Session @throws \Illuminate\Contracts\Container\BindingResolutionException
createSession
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
protected function getFileHandler(array $config) { return $this->app->make(NativeFileSessionHandler::class, [ 'savePath' => array_get($config, 'save_path'), ]); }
Create and return a newly built file session handler. @param array $config The `concrete.session` config item @return \Concrete\Core\Session\Storage\Handler\NativeFileSessionHandler
getFileHandler
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
protected function getDatabaseHandler(array $config) { return new PdoSessionHandler( $this->app->make(Connection::class)->getWrappedConnection(), [ 'db_table' => 'Sessions', 'db_id_col' => 'sessionID', 'db_data_col' => 'sessionValue', 'db_time_col' => 'sessionTime', 'db_lifetime_col' => 'sessionLifeTime', 'lock_mode' => PdoSessionHandler::LOCK_ADVISORY, ] ); }
Create a new database session handler to handle session. @param array $config The `concrete.session` config item @return \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
getDatabaseHandler
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
protected function getMemcachedHandler(array $config) { // Create new memcached instance $memcached = $this->app->make(Memcached::class, [ 'persistent_id' => 'CCM_SESSION', ]); $servers = array_get($config, 'servers', []); // Add missing servers foreach ($this->newMemcachedServers($memcached, $servers) as $server) { $memcached->addServer( array_get($server, 'host'), array_get($server, 'port'), array_get($server, 'weight') ); } // Return a newly built handler return $this->app->make(MemcachedSessionHandler::class, [ 'memcached' => $memcached, 'options' => ['prefix' => array_get($config, 'name') ?: 'CCM_SESSION'], ]); }
Return a built Memcached session handler. @param array $config The `concrete.session` config item @return \Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
getMemcachedHandler
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
protected function getDefaultHandler(array $config) { return $this->getFileHandler($config); }
Return the default session handler. @param array $config The `concrete.session` config item @return \Concrete\Core\Session\Storage\Handler\NativeFileSessionHandler
getDefaultHandler
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
private function getSessionStorage(array $config) { $app = $this->app; // If we're running through command line, just early return an in-memory storage if ($app->isRunThroughCommandLineInterface()) { return $app->make(MockArraySessionStorage::class); } // Resolve the handler based on config $handler = $this->getSessionHandler($config); $storage = $app->make(NativeSessionStorage::class, ['options' => [], 'handler' => $handler]); // Initialize the storage with some options $options = array_get($config, 'cookie', []) + [ 'gc_maxlifetime' => (int) array_get($config, 'max_lifetime') ?: (int) ini_get('session.gc_maxlifetime') ?: 7200, 'gc_probability' => (int) array_get($config, 'gc_probability') ?: (int) ini_get('session.gc_probability') ?: 1, 'gc_divisor' => (int) array_get($config, 'gc_divisor') ?: (int) ini_get('session.gc_divisor') ?: 100, ]; if (array_get($options, 'cookie_path', false) === false) { $options['cookie_path'] = $app['app_relative_path'] . '/'; } if (array_get($options, 'cookie_secure') === null) { $options['cookie_secure'] = $this->app->make(Request::class)->isSecure(); } $sameSite = array_get($options, 'samesite'); if ($sameSite) { $options['cookie_samesite'] = $sameSite; } $storage->setOptions($options); return $app->make(Storage\LoggedStorage::class, ['wrappedStorage' => $storage]); }
Get a session storage object based on configuration. @param array $config @return \Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface
getSessionStorage
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
private function getSessionHandler(array $config) { $handler = array_get($config, 'handler', 'default'); // Build handler using a matching method "get{Type}Handler" $method = Str::camel("get_{$handler}_handler"); if (method_exists($this, $method)) { return $this->{$method}($config); } /* * @todo Change this to return an exception if an unsupported handler is configured. This makes it easier to get * configuration dialed in properly */ //throw new \RuntimeException(t('Unsupported session handler "%s"', $handler)); // Return the default session handler by default return $this->getSessionHandler(['handler' => 'default'] + $config); }
Get a new session handler. @param array $config The config from our config repository @return \SessionHandlerInterface @throws \RuntimeException When a configured handler does not exist
getSessionHandler
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
private function newMemcachedServers(Memcached $memcached, array $servers) { $serverIndex = []; $existingServers = $memcached->getServerList(); foreach ($existingServers as $server) { $serverIndex[$server['host'] . ':' . $server['port']] = true; } foreach ($servers as $configServer) { $server = [ 'host' => array_get($configServer, 'host', ''), 'port' => array_get($configServer, 'port', 11211), 'weight' => array_get($configServer, 'weight', 0), ]; if (!isset($serverIndex[$server['host'] . ':' . $server['port']])) { yield $server; } } }
Generator for only returning hosts that aren't already added to the memcache instance. @param \Memcached $memcached @param array $servers The servers as described in config @return \Generator|string[] [ $host, $port, $weight ]
newMemcachedServers
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
protected function getRedisHandler(array $config) { $options = array_get($config, 'redis', []); // In case anyone puts the servers under redis configuration - similar to how we handle cache $servers = array_get($options, 'servers', []); if (empty($servers)) { $servers = array_get($config, 'servers', []); } // We pass the database because predis cant do select over clusters $redis = $this->getRedisInstance($servers, $options['database']); // In case of anyone setting prefix on the redis server directly // Similar to how we do it on cache $prefix = array_get($options, 'prefix') ?: array_get($config, 'name') ?: 'CCM_SESSION'; $prefix = rtrim($prefix, ':') . ':'; // We pass the prefix to the Redis Handler when we build it return $this->app->make(RedisSessionHandler::class, ['redis' => $redis, 'options' => ['prefix' => $prefix]]); }
Return a built Redis session handler. @param array $config The `concrete.session` config item @return \Concrete\Core\Session\Storage\Handler\RedisSessionHandler
getRedisHandler
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
private function getRedisInstance(array $servers, int $database = 1) { // This is a way to load our predis client or php redis without creating new instances if ($this->app->isShared('session/redis')) { $redis = $this->app->make('session/redis'); return $redis; } if (count($servers) == 1) { // If we only have one server in our array then we just reconnect to it $server = $servers[0]; $redis = null; $pass = array_get($server, 'password', null); $socket = array_get($server, 'socket', null); if ($socket === null) { $host = array_get($server, 'host', ''); $port = array_get($server, 'port', 6379); $ttl = array_get($server, 'ttl', 5); // Check for both server/host - fallback due to cache using server $host = !empty($host) ? $host : array_get($server, 'server', '127.0.0.1'); } if (class_exists('Redis')) { $redis = new Redis(); if ($socket !== null) { $redis->connect($server['socket']); } else { $redis->connect($host, $port, $ttl); if ($pass !== null) { $redis->auth($pass); } $redis->select($database); } } else { if ($socket !== null) { $redis = new Client(['scheme'=>'unix','path'=>$server['socket'],'database'=>$database,'password'=>$pass]); } else { $scheme = array_get($server, 'scheme', 'tcp'); $redis = new Client([ 'scheme' => $scheme, 'host' => $host, 'port' => $port, 'timeout' => $ttl, 'database' => $database, 'password' => $pass ]); } } } else { $serverArray = []; $ttl = 5; $password = null; foreach ($this->getRedisServers($servers, $database) as $server) { if (class_exists('RedisArray')) { if ($servers['scheme'] === 'unix') { $serverString = $server['path']; } else { $serverString = $server['host']; } if (isset($server['port'])) { $serverString .= ':' . $server['port']; } // We can only use one ttl for connection timeout so use the last set ttl // isset allows for 0 - unlimited if (isset($server['ttl'])) { $ttl = $server['ttl']; } if (isset($server['password'])) { $password = $server['password']; } $serverArray[] = $serverString; } else { //$server['alias'] = 'master'; $serverArray[] = $server; } } $options = ['connect_timeout' => $ttl]; if ($password !== null) { $options['auth'] = $password; } if (class_exists('RedisArray')) { $redis = new RedisArray($serverArray, $options); $redis->select($database); } else { $redis = new Client($serverArray); } } $this->app->instance('session/redis', $redis); return $redis; }
Decides whether to return a Redis Instance or RedisArray Instance depending on the number of servers passed to it. @param array $servers The `concrete.session.servers` or `concrete.session.redis.servers` config item @param int | null $database The concrete.session.redis.database config item @return \Redis | \RedisArray | \Predis\Client
getRedisInstance
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
private function getRedisServers(array $servers, int $database) { if (!empty($servers)) { foreach ($servers as $server) { if (isset($server['socket'])) { $server = [ 'scheme' => 'unix', 'path' => array_get($server, 'socket', ''), 'timeout' => array_get($server, 'ttl', null), 'password' => array_get($server, 'password', null), 'database' => array_get($server, 'database', $database) ]; } else { $host = array_get($server, 'host', ''); // Check for both server/host - fallback due to cache using server $host = !empty($host) ?: array_get($server, 'server', '127.0.0.1'); $server = [ 'scheme' => 'tcp', 'host' => $host, 'port' => array_get($server, 'port', 6379), 'timeout' => array_get($server, 'ttl', null), 'password' => array_get($server, 'password', null), 'database' => array_get($server, 'database', $database) ]; } yield $server; } } else { yield ['scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, 'timeout' => 5, 'database' => $database]; } }
Generator for Redis Array. @param array $servers The `concrete.session.servers` or `concrete.session.redis.servers` config item @param int $database Which database to use for each connection (only used for predis) @return \Generator| string[] [ $server, $port, $ttl ]
getRedisServers
php
concretecms/concretecms
concrete/src/Session/SessionFactory.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionFactory.php
MIT
public function getLoggerChannel() { return Channels::CHANNEL_AUTHENTICATION; }
{@inheritdoc} @see \Concrete\Core\Logging\LoggerAwareInterface::getLoggerChannel()
getLoggerChannel
php
concretecms/concretecms
concrete/src/Session/SessionValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionValidator.php
MIT
public function handleSessionValidation(SymfonySession $session) { $invalidate = false; $requestIP = $this->app->make(AddressInterface::class); $requestAgent = $this->request->server->get('HTTP_USER_AGENT'); $previousIP = Factory::parseAddressString($session->get('CLIENT_REMOTE_ADDR')); $previousAgent = $session->get('CLIENT_HTTP_USER_AGENT'); // Validate against the current uOnlineCheck. This will determine if the user has been inactive for too long. if ($this->shouldValidateUserActivity($session)) { $threshold = $this->getUserActivityThreshold(); if ((time() - $session->get('uOnlineCheck')) > $threshold) { $this->logger->notice(t('Session Invalidated. Session was inactive for more than %s seconds', $threshold)); $invalidate = true; } } // Validate against the `valid_since` config item $validSinceTimestamp = (int) $this->config->get(static::CONFIGKEY_SESSION_INVALIDATE); if ($validSinceTimestamp) { $validSince = Carbon::createFromTimestamp($validSinceTimestamp, 'utc'); $created = Carbon::createFromTimestamp($session->getMetadataBag()->getCreated()); if ($created->lessThan($validSince)) { $this->logger->notice('Session Invalidated. Session was created before "valid_since" setting.'); $invalidate = true; } } // Validate the request IP if ($this->shouldCompareIP() && $this->considerIPChanged($requestIP, $previousIP)) { if ($this->logger) { $this->logger->notice( 'Session Invalidated. Session IP "{session}" did not match provided IP "{client}".', [ 'session' => $previousIP, 'client' => (string) $requestIP, ] ); } $invalidate = true; } // Validate the request user agent if ($this->shouldCompareAgent() && $previousAgent && $previousAgent != $requestAgent) { if ($this->logger) { $this->logger->notice( 'Session Invalidated. Session user agent "{session}" did not match provided agent "{client}"', [ 'session' => $previousAgent, 'client' => $requestAgent, ] ); } $invalidate = true; } if ($invalidate) { $session->invalidate(); } else { $session->set('CLIENT_REMOTE_ADDR', (string) $requestIP); if (!$previousAgent && $requestAgent) { $session->set('CLIENT_HTTP_USER_AGENT', $requestAgent); } } return $invalidate; }
@param \Symfony\Component\HttpFoundation\Session\Session $session @return bool true if the session invalidated, false otherwise
handleSessionValidation
php
concretecms/concretecms
concrete/src/Session/SessionValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionValidator.php
MIT
public function shouldValidateUserActivity(SymfonySession $session) { return $this->config->get(static::CONFIGKEY_INVALIDATE_INACTIVE_USERS) && $session->has('uID') && $session->get('uID') > 0 && $session->has('uOnlineCheck') && $session->get('uOnlineCheck') > 0; }
@param \Symfony\Component\HttpFoundation\Session\Session $session @return bool
shouldValidateUserActivity
php
concretecms/concretecms
concrete/src/Session/SessionValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionValidator.php
MIT
public function hasActiveSession() { if ($this->app['cookie']->has($this->config->get('concrete.session.name'))) { return true; } if ($this->app->make(CookieService::class)->getCookie() !== null) { return true; } return false; }
Check if there is an active session. @return bool
hasActiveSession
php
concretecms/concretecms
concrete/src/Session/SessionValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionValidator.php
MIT
public function getActiveSession($start = false) { if ($start || $this->hasActiveSession()) { return $this->app->make('session'); } return null; }
Get the current session (if it exists). @param bool $start set to true to initialize the current session if it's not already started @return \Symfony\Component\HttpFoundation\Session\Session|null Returns NULL if $start is falsy and the session is not already started
getActiveSession
php
concretecms/concretecms
concrete/src/Session/SessionValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionValidator.php
MIT
public function setLogger(LoggerInterface $logger) { $this->logger = $logger; }
Sets a logger instance on the object. @param \Psr\Log\LoggerInterface $logger
setLogger
php
concretecms/concretecms
concrete/src/Session/SessionValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/SessionValidator.php
MIT
public function getLoggerChannel() { return Channels::CHANNEL_SECURITY; }
Declare our logging channel as "Security" @return string
getLoggerChannel
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
protected function log($level, $message, array $context = []) { if ($this->logger) { $metadata = $this->getMetadataBag(); $context['metadata'] = [ 'created' => $metadata->getCreated(), 'lifetime' => $metadata->getLifetime(), 'lastused' => $metadata->getLastUsed(), 'name' => $metadata->getName(), ]; if ($this->isStarted()) { $attributes = $this->getBag('attributes'); if ($attributes instanceof SessionBagProxy) { $attributes = $attributes->getBag(); } if ($attributes instanceof AttributeBagInterface) { $context['metadata']['uID'] = $attributes->get('uID', null); $context['metadata']['uGroups'] = array_values($attributes->get('uGroups', [])); } } $this->logger->log($level, $message, $context); } }
Log details if possible @param $message @param array $context
log
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
protected function logInfo($message, array $context = []) { return $this->log(LogLevel::INFO, $message, $context); }
Add info level logs @param $message @param array $context
logInfo
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
protected function logDebug($message, array $context = []) { return $this->log(LogLevel::DEBUG, $message, $context); }
Add debug level logs @param $message @param array $context
logDebug
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function start() { $this->logDebug('Session starting.'); return $this->wrappedStorage->start(); }
Starts the session. @return bool True if started @throws \RuntimeException if something goes wrong starting the session
start
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function isStarted() { return $this->wrappedStorage->isStarted(); }
Checks if the session is started. @return bool True if started, false otherwise
isStarted
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function getId() { return $this->wrappedStorage->getId(); }
Returns the session ID. @return string The session ID or empty
getId
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function setId($id) { $this->logDebug('Modifying session ID'); return $this->wrappedStorage->setId($id); }
Sets the session ID. @param string $id
setId
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function getName() { return $this->wrappedStorage->getName(); }
Returns the session name. @return mixed The session name
getName
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function setName($name) { return $this->wrappedStorage->setName($name); }
Sets the session name. @param string $name
setName
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function regenerate($destroy = false, $lifetime = null) { $this->logInfo('Regenerating session', ['destroy' => $destroy, 'lifetime' => $lifetime]); return $this->wrappedStorage->regenerate($destroy, $lifetime); }
Regenerates id that represents this storage. This method must invoke session_regenerate_id($destroy) unless this interface is used for a storage object designed for unit or functional testing where a real PHP session would interfere with testing. Note regenerate+destroy should not clear the session data in memory only delete the session data from persistent storage. Care: When regenerating the session ID no locking is involved in PHP's session design. See https://bugs.php.net/bug.php?id=61470 for a discussion. So you must make sure the regenerated session is saved BEFORE sending the headers with the new ID. Symfony's HttpKernel offers a listener for this. See Symfony\Component\HttpKernel\EventListener\SaveSessionListener. Otherwise session data could get lost again for concurrent requests with the new ID. One result could be that you get logged out after just logging in. @param bool $destroy Destroy session when regenerating? @param int $lifetime Sets the cookie lifetime for the session cookie. A null value will leave the system settings unchanged, 0 sets the cookie to expire with browser session. Time is in seconds, and is not a Unix timestamp. @return bool True if session regenerated, false if error @throws \RuntimeException If an error occurs while regenerating this storage
regenerate
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function save() { $this->logDebug('Session saving'); return $this->wrappedStorage->save(); }
Force the session to be saved and closed. This method must invoke session_write_close() unless this interface is used for a storage object design for unit or functional testing where a real PHP session would interfere with testing, in which case it should actually persist the session data if required. @throws \RuntimeException if the session is saved without being started, or if the session is already closed
save
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function clear() { $this->logInfo('Clearing Session.'); $metadata = $this->getMetadataBag(); $lifetime = $metadata->getLifetime(); $lastUsed = $metadata->getLastUsed(); // If the existing session has expired on its own if ($lifetime && time() > $lastUsed + $lifetime) { $this->logInfo('Session expired.'); } return $this->wrappedStorage->clear(); }
Clear all session data in memory.
clear
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function getBag($name) { return $this->wrappedStorage->getBag($name); }
Gets a SessionBagInterface by name. @param string $name @return SessionBagInterface @throws \InvalidArgumentException If the bag does not exist
getBag
php
concretecms/concretecms
concrete/src/Session/Storage/LoggedStorage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/LoggedStorage.php
MIT
public function __construct($savePath = null) { if (null === $savePath) { $savePath = ini_get('session.save_path'); } $baseDir = $savePath; if ($count = substr_count($savePath, ';')) { if ($count > 2) { throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath)); } // characters after last ';' are the path $baseDir = ltrim(strrchr($savePath, ';'), ';'); } ini_set('session.save_handler', 'files'); try { if ($baseDir && !is_dir($baseDir)) { mkdir($baseDir, app(Repository::class)->get('concrete.filesystem.permissions.directory'), true); } ini_set('session.save_path', $savePath); } catch (\Exception $e) { /* * Catch any exceptions caused by open_basedir restrictions and ignore them. * * Not the most elegant solution but far less tedious than trying to analyze the save path. * * - if the exception is not open_basedir related, pass it on. * - if a save path was manually specified, pass it on. */ if (strpos($e->getMessage(), 'open_basedir') === false || current(func_get_args())) { throw $e; } } }
Constructor. @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP. '/path', 'N;/path', or 'N;octal-mode;/path @see http://php.net/session.configuration.php#ini.session.save-path for further details. @throws \InvalidArgumentException On invalid $savePath
__construct
php
concretecms/concretecms
concrete/src/Session/Storage/Handler/NativeFileSessionHandler.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/Handler/NativeFileSessionHandler.php
MIT
public function __construct($redis, array $options = array()) { if ( !$redis instanceof \Redis && !$redis instanceof \RedisArray && !$redis instanceof \RedisCluster && !$redis instanceof \Predis\Client ) { throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis))); } if ($diff = array_diff(array_keys($options), array('prefix'))) { throw new \InvalidArgumentException(sprintf('The following options are not supported "%s"', implode(', ', $diff))); } $this->redis = $redis; $this->prefix = $options['prefix'] ? $options['prefix'] : 'sf_s'; }
List of available options: * prefix: The prefix to use for the keys in order to avoid collision on the Redis server. @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redis @param array $options An associative array of options @throws \InvalidArgumentException When unsupported client or options are passed
__construct
php
concretecms/concretecms
concrete/src/Session/Storage/Handler/RedisSessionHandler.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Session/Storage/Handler/RedisSessionHandler.php
MIT