repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
lochmueller/staticfilecache
Classes/Cache/Rule/NoIntScripts.php
NoIntScripts.checkRule
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { if ($frontendController->isINTincScript()) { foreach ((array)$frontendController->config['INTincScript'] as $key => $configuration) { $explanation[__CLASS__ . ':' . $key] = 'The page has a INTincScript: ' . \implode(', ', $this->getInformation($configuration)); } } }
php
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { if ($frontendController->isINTincScript()) { foreach ((array)$frontendController->config['INTincScript'] as $key => $configuration) { $explanation[__CLASS__ . ':' . $key] = 'The page has a INTincScript: ' . \implode(', ', $this->getInformation($configuration)); } } }
[ "public", "function", "checkRule", "(", "TypoScriptFrontendController", "$", "frontendController", ",", "string", "$", "uri", ",", "array", "&", "$", "explanation", ",", "bool", "&", "$", "skipProcessing", ")", "{", "if", "(", "$", "frontendController", "->", ...
Check if there are no _INT scripts. @param TypoScriptFrontendController $frontendController @param string $uri @param array $explanation @param bool $skipProcessing
[ "Check", "if", "there", "are", "no", "_INT", "scripts", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/NoIntScripts.php#L26-L33
train
lochmueller/staticfilecache
Classes/Cache/Rule/NoIntScripts.php
NoIntScripts.getInformation
protected function getInformation($configuration): array { $info = []; if (isset($configuration['type'])) { $info[] = 'type: ' . $configuration['type']; } $check = [ 'userFunc', 'includeLibs', 'extensionName', 'pluginName', ]; foreach ($check as $value) { if (isset($configuration['conf'][$value])) { $info[] = $value . ': ' . $configuration['conf'][$value]; } } return $info; }
php
protected function getInformation($configuration): array { $info = []; if (isset($configuration['type'])) { $info[] = 'type: ' . $configuration['type']; } $check = [ 'userFunc', 'includeLibs', 'extensionName', 'pluginName', ]; foreach ($check as $value) { if (isset($configuration['conf'][$value])) { $info[] = $value . ': ' . $configuration['conf'][$value]; } } return $info; }
[ "protected", "function", "getInformation", "(", "$", "configuration", ")", ":", "array", "{", "$", "info", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "configuration", "[", "'type'", "]", ")", ")", "{", "$", "info", "[", "]", "=", "'type: '", ...
Get the debug information. @param array $configuration @return array
[ "Get", "the", "debug", "information", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/NoIntScripts.php#L42-L61
train
lochmueller/staticfilecache
Classes/Traits/CacheTrait.php
CacheTrait.cacheLongTime
protected function cacheLongTime(string $entryIdentifier, callable $callback, int $lifetime = 3600, array $tags = []) { return $this->cacheViaTrait('sfc_' . $entryIdentifier, $callback, 'cache_pagesection', $lifetime, $tags); }
php
protected function cacheLongTime(string $entryIdentifier, callable $callback, int $lifetime = 3600, array $tags = []) { return $this->cacheViaTrait('sfc_' . $entryIdentifier, $callback, 'cache_pagesection', $lifetime, $tags); }
[ "protected", "function", "cacheLongTime", "(", "string", "$", "entryIdentifier", ",", "callable", "$", "callback", ",", "int", "$", "lifetime", "=", "3600", ",", "array", "$", "tags", "=", "[", "]", ")", "{", "return", "$", "this", "->", "cacheViaTrait", ...
Cache long time. @param string $entryIdentifier @param callable $callback @param int $lifetime Default 60 Minutes (3.600 seconds) @param array $tags @return mixed
[ "Cache", "long", "time", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Traits/CacheTrait.php#L57-L60
train
lochmueller/staticfilecache
Classes/Traits/CacheTrait.php
CacheTrait.cacheRemoteUri
protected function cacheRemoteUri(string $entryIdentifier, int $lifetime = 3600, array $tags = []) { $result = $this->cacheViaTrait($entryIdentifier, function () { }, 'remote_file', $lifetime, $tags); if (null === $result) { // call two times, because the anonym function is not the real result. // The result is output by the get method of the remote_file backend. $result = $this->cacheViaTrait($entryIdentifier, function () { }, 'remote_file', $lifetime, $tags); } return $result; }
php
protected function cacheRemoteUri(string $entryIdentifier, int $lifetime = 3600, array $tags = []) { $result = $this->cacheViaTrait($entryIdentifier, function () { }, 'remote_file', $lifetime, $tags); if (null === $result) { // call two times, because the anonym function is not the real result. // The result is output by the get method of the remote_file backend. $result = $this->cacheViaTrait($entryIdentifier, function () { }, 'remote_file', $lifetime, $tags); } return $result; }
[ "protected", "function", "cacheRemoteUri", "(", "string", "$", "entryIdentifier", ",", "int", "$", "lifetime", "=", "3600", ",", "array", "$", "tags", "=", "[", "]", ")", "{", "$", "result", "=", "$", "this", "->", "cacheViaTrait", "(", "$", "entryIdenti...
Cache remote file time. @param string $entryIdentifier @param int $lifetime Default 60 Minutes (3.600 seconds) @param array $tags @return mixed
[ "Cache", "remote", "file", "time", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Traits/CacheTrait.php#L71-L83
train
lochmueller/staticfilecache
Classes/Traits/CacheTrait.php
CacheTrait.cacheViaTrait
protected function cacheViaTrait(string $entryIdentifier, callable $callback, string $cacheIdentifier, int $lifetime = 0, array $tags = []) { try { /** @var AbstractFrontend $cache */ $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheIdentifier); } catch (\Exception $ex) { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); $logger->error($ex->getMessage(), ['entryIdentifier' => $entryIdentifier, 'cacheIdentifier' => $cacheIdentifier]); return \call_user_func_array($callback, []); } // Do not use "has" because the cache is a shared resource $result = $cache->get($entryIdentifier); if (false !== $result) { return $result; } $result = \call_user_func_array($callback, []); $cache->set($entryIdentifier, $result, $tags, 0 === $lifetime ? null : $lifetime); return $result; }
php
protected function cacheViaTrait(string $entryIdentifier, callable $callback, string $cacheIdentifier, int $lifetime = 0, array $tags = []) { try { /** @var AbstractFrontend $cache */ $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheIdentifier); } catch (\Exception $ex) { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); $logger->error($ex->getMessage(), ['entryIdentifier' => $entryIdentifier, 'cacheIdentifier' => $cacheIdentifier]); return \call_user_func_array($callback, []); } // Do not use "has" because the cache is a shared resource $result = $cache->get($entryIdentifier); if (false !== $result) { return $result; } $result = \call_user_func_array($callback, []); $cache->set($entryIdentifier, $result, $tags, 0 === $lifetime ? null : $lifetime); return $result; }
[ "protected", "function", "cacheViaTrait", "(", "string", "$", "entryIdentifier", ",", "callable", "$", "callback", ",", "string", "$", "cacheIdentifier", ",", "int", "$", "lifetime", "=", "0", ",", "array", "$", "tags", "=", "[", "]", ")", "{", "try", "{...
Cache via Trait logic. @param string $entryIdentifier @param callable $callback @param string $cacheIdentifier @param int $lifetime @param array $tags @return mixed
[ "Cache", "via", "Trait", "logic", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Traits/CacheTrait.php#L96-L117
train
lochmueller/staticfilecache
Classes/Service/HttpPushService.php
HttpPushService.getHttpPushHeaders
public function getHttpPushHeaders(string $content): array { $headers = []; /** @var ConfigurationService $configurationService */ $configurationService = GeneralUtility::makeInstance(ConfigurationService::class); if ($configurationService->isBool('sendHttp2PushEnable')) { $limit = (int)$configurationService->get('sendHttp2PushFileLimit'); $extensions = GeneralUtility::trimExplode(',', (string)$configurationService->get('sendHttp2PushFileExtensions'), true); $handlers = $this->getHttpPushHandler(); foreach ($extensions as $extension) { foreach ($handlers as $handler) { /** @var AbstractHttpPush $handler */ if ($handler->canHandleExtension($extension)) { $headers = \array_merge($headers, $handler->getHeaders($content)); } } } $headers = \array_slice($headers, 0, $limit); } return $headers; }
php
public function getHttpPushHeaders(string $content): array { $headers = []; /** @var ConfigurationService $configurationService */ $configurationService = GeneralUtility::makeInstance(ConfigurationService::class); if ($configurationService->isBool('sendHttp2PushEnable')) { $limit = (int)$configurationService->get('sendHttp2PushFileLimit'); $extensions = GeneralUtility::trimExplode(',', (string)$configurationService->get('sendHttp2PushFileExtensions'), true); $handlers = $this->getHttpPushHandler(); foreach ($extensions as $extension) { foreach ($handlers as $handler) { /** @var AbstractHttpPush $handler */ if ($handler->canHandleExtension($extension)) { $headers = \array_merge($headers, $handler->getHeaders($content)); } } } $headers = \array_slice($headers, 0, $limit); } return $headers; }
[ "public", "function", "getHttpPushHeaders", "(", "string", "$", "content", ")", ":", "array", "{", "$", "headers", "=", "[", "]", ";", "/** @var ConfigurationService $configurationService */", "$", "configurationService", "=", "GeneralUtility", "::", "makeInstance", "...
Get http push headers. @param string $content @return array
[ "Get", "http", "push", "headers", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/HttpPushService.php#L33-L56
train
lochmueller/staticfilecache
Classes/Service/HttpPushService.php
HttpPushService.getHttpPushHandler
protected function getHttpPushHandler(): array { $arguments = [ 'httpPushServices' => [ StyleHttpPush::class, ScriptHttpPush::class, ImageHttpPush::class, FontHttpPush::class, ], ]; $objectManager = new ObjectManager(); /** @var Dispatcher $dispatcher */ $dispatcher = $objectManager->get(Dispatcher::class); try { $dispatcher->dispatch(__CLASS__, __METHOD__, $arguments); } catch (\Exception $exception) { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); $logger->error('Problems in publis signal: ' . $exception->getMessage() . ' / ' . $exception->getFile() . ':' . $exception->getLine()); } $objects = []; foreach ((array)$arguments['httpPushServices'] as $httpPushService) { $objects[] = GeneralUtility::makeInstance($httpPushService); } return $objects; }
php
protected function getHttpPushHandler(): array { $arguments = [ 'httpPushServices' => [ StyleHttpPush::class, ScriptHttpPush::class, ImageHttpPush::class, FontHttpPush::class, ], ]; $objectManager = new ObjectManager(); /** @var Dispatcher $dispatcher */ $dispatcher = $objectManager->get(Dispatcher::class); try { $dispatcher->dispatch(__CLASS__, __METHOD__, $arguments); } catch (\Exception $exception) { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); $logger->error('Problems in publis signal: ' . $exception->getMessage() . ' / ' . $exception->getFile() . ':' . $exception->getLine()); } $objects = []; foreach ((array)$arguments['httpPushServices'] as $httpPushService) { $objects[] = GeneralUtility::makeInstance($httpPushService); } return $objects; }
[ "protected", "function", "getHttpPushHandler", "(", ")", ":", "array", "{", "$", "arguments", "=", "[", "'httpPushServices'", "=>", "[", "StyleHttpPush", "::", "class", ",", "ScriptHttpPush", "::", "class", ",", "ImageHttpPush", "::", "class", ",", "FontHttpPush...
Get HTTP push handlers. @return array
[ "Get", "HTTP", "push", "handlers", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/HttpPushService.php#L63-L90
train
lochmueller/staticfilecache
Classes/Service/TypoScriptFrontendService.php
TypoScriptFrontendService.getTags
public function getTags(): array { $tsfe = $this->getTsfe(); if (!($tsfe instanceof TypoScriptFrontendController)) { return []; } return \array_unique((array)ObjectAccess::getProperty($tsfe, 'pageCacheTags', true)); }
php
public function getTags(): array { $tsfe = $this->getTsfe(); if (!($tsfe instanceof TypoScriptFrontendController)) { return []; } return \array_unique((array)ObjectAccess::getProperty($tsfe, 'pageCacheTags', true)); }
[ "public", "function", "getTags", "(", ")", ":", "array", "{", "$", "tsfe", "=", "$", "this", "->", "getTsfe", "(", ")", ";", "if", "(", "!", "(", "$", "tsfe", "instanceof", "TypoScriptFrontendController", ")", ")", "{", "return", "[", "]", ";", "}", ...
Get the tags and respect the configuration. @return array
[ "Get", "the", "tags", "and", "respect", "the", "configuration", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/TypoScriptFrontendService.php#L23-L31
train
lochmueller/staticfilecache
Classes/Service/TypoScriptFrontendService.php
TypoScriptFrontendService.getAdditionalHeaders
public function getAdditionalHeaders(): array { $headers = []; $tsfe = $this->getTsfe(); if (!($tsfe instanceof TypoScriptFrontendController)) { return $headers; } // Set headers, if any if (\is_array($tsfe->config['config']['additionalHeaders.'])) { \ksort($tsfe->config['config']['additionalHeaders.']); foreach ($tsfe->config['config']['additionalHeaders.'] as $options) { $complete = \trim($options['header']); $parts = \explode(':', $complete, 2); $headers[\trim($parts[0])] = \trim($parts[1]); } } return $headers; }
php
public function getAdditionalHeaders(): array { $headers = []; $tsfe = $this->getTsfe(); if (!($tsfe instanceof TypoScriptFrontendController)) { return $headers; } // Set headers, if any if (\is_array($tsfe->config['config']['additionalHeaders.'])) { \ksort($tsfe->config['config']['additionalHeaders.']); foreach ($tsfe->config['config']['additionalHeaders.'] as $options) { $complete = \trim($options['header']); $parts = \explode(':', $complete, 2); $headers[\trim($parts[0])] = \trim($parts[1]); } } return $headers; }
[ "public", "function", "getAdditionalHeaders", "(", ")", ":", "array", "{", "$", "headers", "=", "[", "]", ";", "$", "tsfe", "=", "$", "this", "->", "getTsfe", "(", ")", ";", "if", "(", "!", "(", "$", "tsfe", "instanceof", "TypoScriptFrontendController", ...
Get additional headers. @return array
[ "Get", "additional", "headers", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/TypoScriptFrontendService.php#L38-L56
train
lochmueller/staticfilecache
Classes/Cache/Rule/ValidDoktype.php
ValidDoktype.checkRule
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { $ignoreTypes = [ PageRepository::DOKTYPE_LINK, PageRepository::DOKTYPE_SYSFOLDER, PageRepository::DOKTYPE_RECYCLER, ]; $currentType = (int)$frontendController->page['doktype']; if (\in_array($currentType, $ignoreTypes, true)) { $explanation[__CLASS__] = 'The Page doktype ' . $currentType . ' is one of the following not allowed numbers: ' . \implode( ', ', $ignoreTypes ); $skipProcessing = true; } }
php
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { $ignoreTypes = [ PageRepository::DOKTYPE_LINK, PageRepository::DOKTYPE_SYSFOLDER, PageRepository::DOKTYPE_RECYCLER, ]; $currentType = (int)$frontendController->page['doktype']; if (\in_array($currentType, $ignoreTypes, true)) { $explanation[__CLASS__] = 'The Page doktype ' . $currentType . ' is one of the following not allowed numbers: ' . \implode( ', ', $ignoreTypes ); $skipProcessing = true; } }
[ "public", "function", "checkRule", "(", "TypoScriptFrontendController", "$", "frontendController", ",", "string", "$", "uri", ",", "array", "&", "$", "explanation", ",", "bool", "&", "$", "skipProcessing", ")", "{", "$", "ignoreTypes", "=", "[", "PageRepository"...
Check if the URI is valid. @param TypoScriptFrontendController $frontendController @param string $uri @param array $explanation @param bool $skipProcessing
[ "Check", "if", "the", "URI", "is", "valid", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/ValidDoktype.php#L27-L42
train
lochmueller/staticfilecache
Classes/Service/RemoveService.php
RemoveService.removeFile
public function removeFile(string $absoulteFileName): bool { if (!\is_file($absoulteFileName)) { return true; } return (bool)\unlink($absoulteFileName); }
php
public function removeFile(string $absoulteFileName): bool { if (!\is_file($absoulteFileName)) { return true; } return (bool)\unlink($absoulteFileName); }
[ "public", "function", "removeFile", "(", "string", "$", "absoulteFileName", ")", ":", "bool", "{", "if", "(", "!", "\\", "is_file", "(", "$", "absoulteFileName", ")", ")", "{", "return", "true", ";", "}", "return", "(", "bool", ")", "\\", "unlink", "("...
Remove the given file. If the file do not exists, the function return true. @param string $absoulteFileName @return bool
[ "Remove", "the", "given", "file", ".", "If", "the", "file", "do", "not", "exists", "the", "function", "return", "true", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/RemoveService.php#L31-L38
train
lochmueller/staticfilecache
Classes/Service/RemoveService.php
RemoveService.softRemoveDir
public function softRemoveDir(string $absoluteDirName) { if (\is_dir($absoluteDirName)) { $tempAbsoluteDir = \rtrim($absoluteDirName, '/') . '_' . GeneralUtility::milliseconds() . '/'; \rename($absoluteDirName, $tempAbsoluteDir); $this->removeDirs[] = $tempAbsoluteDir; } return $this; }
php
public function softRemoveDir(string $absoluteDirName) { if (\is_dir($absoluteDirName)) { $tempAbsoluteDir = \rtrim($absoluteDirName, '/') . '_' . GeneralUtility::milliseconds() . '/'; \rename($absoluteDirName, $tempAbsoluteDir); $this->removeDirs[] = $tempAbsoluteDir; } return $this; }
[ "public", "function", "softRemoveDir", "(", "string", "$", "absoluteDirName", ")", "{", "if", "(", "\\", "is_dir", "(", "$", "absoluteDirName", ")", ")", "{", "$", "tempAbsoluteDir", "=", "\\", "rtrim", "(", "$", "absoluteDirName", ",", "'/'", ")", ".", ...
Rename the dir and mark them as "to remove". Speed up the remove process. @param string $absoluteDirName @return RemoveService
[ "Rename", "the", "dir", "and", "mark", "them", "as", "to", "remove", ".", "Speed", "up", "the", "remove", "process", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/RemoveService.php#L48-L57
train
lochmueller/staticfilecache
Classes/Service/RemoveService.php
RemoveService.removeDirs
public function removeDirs() { foreach ($this->removeDirs as $removeDir) { GeneralUtility::rmdir($removeDir, true); } $this->removeDirs = []; }
php
public function removeDirs() { foreach ($this->removeDirs as $removeDir) { GeneralUtility::rmdir($removeDir, true); } $this->removeDirs = []; }
[ "public", "function", "removeDirs", "(", ")", "{", "foreach", "(", "$", "this", "->", "removeDirs", "as", "$", "removeDir", ")", "{", "GeneralUtility", "::", "rmdir", "(", "$", "removeDir", ",", "true", ")", ";", "}", "$", "this", "->", "removeDirs", "...
Finally remove the dirs.
[ "Finally", "remove", "the", "dirs", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/RemoveService.php#L62-L68
train
lochmueller/staticfilecache
Classes/Domain/Repository/DomainRepository.php
DomainRepository.findOneByDomainName
public function findOneByDomainName(string $domainName): array { $queryBuilder = $this->createQuery(); return (array)$queryBuilder->select('*') ->from($this->getTableName()) ->where($queryBuilder->expr()->eq( 'domainName', $queryBuilder->createNamedParameter($domainName, \PDO::PARAM_STR) )) ->execute() ->fetch(); }
php
public function findOneByDomainName(string $domainName): array { $queryBuilder = $this->createQuery(); return (array)$queryBuilder->select('*') ->from($this->getTableName()) ->where($queryBuilder->expr()->eq( 'domainName', $queryBuilder->createNamedParameter($domainName, \PDO::PARAM_STR) )) ->execute() ->fetch(); }
[ "public", "function", "findOneByDomainName", "(", "string", "$", "domainName", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQuery", "(", ")", ";", "return", "(", "array", ")", "$", "queryBuilder", "->", "select", "(", "'*'", ...
Find one record by domainName. @param string $domainName @return array
[ "Find", "one", "record", "by", "domainName", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/DomainRepository.php#L23-L35
train
lochmueller/staticfilecache
Classes/Domain/Repository/QueueRepository.php
QueueRepository.findOpen
public function findOpen($limit = 999): array { $queryBuilder = $this->createQuery(); return (array)$queryBuilder->select('*') ->from($this->getTableName()) ->where($queryBuilder->expr()->eq('call_date', $queryBuilder->createNamedParameter(0))) ->setMaxResults($limit) ->execute() ->fetchAll(); }
php
public function findOpen($limit = 999): array { $queryBuilder = $this->createQuery(); return (array)$queryBuilder->select('*') ->from($this->getTableName()) ->where($queryBuilder->expr()->eq('call_date', $queryBuilder->createNamedParameter(0))) ->setMaxResults($limit) ->execute() ->fetchAll(); }
[ "public", "function", "findOpen", "(", "$", "limit", "=", "999", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQuery", "(", ")", ";", "return", "(", "array", ")", "$", "queryBuilder", "->", "select", "(", "'*'", ")", "->...
Find the entries for the worker. @param int $limit @return array
[ "Find", "the", "entries", "for", "the", "worker", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/QueueRepository.php#L23-L33
train
lochmueller/staticfilecache
Classes/Domain/Repository/QueueRepository.php
QueueRepository.countOpenByIdentifier
public function countOpenByIdentifier($identifier): int { $queryBuilder = $this->createQuery(); $where = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq('cache_url', $queryBuilder->createNamedParameter($identifier)), $queryBuilder->expr()->eq('call_date', $queryBuilder->createNamedParameter(0)) ); return (int)$queryBuilder->select('uid') ->from($this->getTableName()) ->where($where) ->execute() ->rowCount(); }
php
public function countOpenByIdentifier($identifier): int { $queryBuilder = $this->createQuery(); $where = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq('cache_url', $queryBuilder->createNamedParameter($identifier)), $queryBuilder->expr()->eq('call_date', $queryBuilder->createNamedParameter(0)) ); return (int)$queryBuilder->select('uid') ->from($this->getTableName()) ->where($where) ->execute() ->rowCount(); }
[ "public", "function", "countOpenByIdentifier", "(", "$", "identifier", ")", ":", "int", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQuery", "(", ")", ";", "$", "where", "=", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "...
Find open by identnfier. @param string $identifier @return int
[ "Find", "open", "by", "identnfier", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/QueueRepository.php#L42-L55
train
lochmueller/staticfilecache
Classes/Domain/Repository/QueueRepository.php
QueueRepository.findOld
public function findOld(): array { $queryBuilder = $this->createQuery(); return (array)$queryBuilder->select('uid') ->from($this->getTableName()) ->where($queryBuilder->expr()->gt('call_date', $queryBuilder->createNamedParameter(0))) ->execute() ->fetchAll(); }
php
public function findOld(): array { $queryBuilder = $this->createQuery(); return (array)$queryBuilder->select('uid') ->from($this->getTableName()) ->where($queryBuilder->expr()->gt('call_date', $queryBuilder->createNamedParameter(0))) ->execute() ->fetchAll(); }
[ "public", "function", "findOld", "(", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQuery", "(", ")", ";", "return", "(", "array", ")", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "$", "thi...
Find old entries. @return array
[ "Find", "old", "entries", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/QueueRepository.php#L62-L71
train
lochmueller/staticfilecache
Classes/Configuration.php
Configuration.registerHooks
public static function registerHooks() { $configuration = self::getConfiguration(); // Register with "crawler" extension: $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions']['tx_staticfilecache_clearstaticfile'] = 'clear static cache file'; // Hook to process clearing static cached files if "crawler" extension is active: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache']['staticfilecache'] = Crawler::class . '->clearStaticFile'; // Log a cache miss if no_cache is true $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all']['staticfilecache'] = LogNoCache::class . '->log'; // Add the right cache hook $saveCacheHook = $configuration['saveCacheHook'] ?? ''; switch ($saveCacheHook) { case 'ContentPostProcOutput': $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output']['staticfilecache'] = ContentPostProcOutput::class . '->insert'; break; case 'Eofe': $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe']['staticfilecache'] = Eofe::class . '->insert'; break; case 'Middleware': // Will be handled via Middleware break; default: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache']['staticfilecache'] = InsertPageIncacheHook::class; break; } // Set cookie when User logs in $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser']['staticfilecache'] = InitFrontendUser::class . '->setFeUserCookie'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_post_processing']['staticfilecache'] = LogoffFrontendUser::class . '->logoff'; }
php
public static function registerHooks() { $configuration = self::getConfiguration(); // Register with "crawler" extension: $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions']['tx_staticfilecache_clearstaticfile'] = 'clear static cache file'; // Hook to process clearing static cached files if "crawler" extension is active: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache']['staticfilecache'] = Crawler::class . '->clearStaticFile'; // Log a cache miss if no_cache is true $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all']['staticfilecache'] = LogNoCache::class . '->log'; // Add the right cache hook $saveCacheHook = $configuration['saveCacheHook'] ?? ''; switch ($saveCacheHook) { case 'ContentPostProcOutput': $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output']['staticfilecache'] = ContentPostProcOutput::class . '->insert'; break; case 'Eofe': $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe']['staticfilecache'] = Eofe::class . '->insert'; break; case 'Middleware': // Will be handled via Middleware break; default: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache']['staticfilecache'] = InsertPageIncacheHook::class; break; } // Set cookie when User logs in $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser']['staticfilecache'] = InitFrontendUser::class . '->setFeUserCookie'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_post_processing']['staticfilecache'] = LogoffFrontendUser::class . '->logoff'; }
[ "public", "static", "function", "registerHooks", "(", ")", "{", "$", "configuration", "=", "self", "::", "getConfiguration", "(", ")", ";", "// Register with \"crawler\" extension:", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXTCONF'", "]", "[", "'craw...
Register hooks.
[ "Register", "hooks", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Configuration.php#L78-L111
train
lochmueller/staticfilecache
Classes/Configuration.php
Configuration.registerSlots
public static function registerSlots() { $ruleClasses = [ StaticCacheable::class, ValidUri::class, SiteCacheable::class, ValidDoktype::class, NoWorkspacePreview::class, NoUserOrGroupSet::class, NoIntScripts::class, LoginDeniedConfiguration::class, PageCacheable::class, DomainCacheable::class, NoNoCache::class, NoBackendUser::class, Enable::class, ValidRequestMethod::class, ForceStaticCache::class, NoFakeFrontend::class, ]; /** @var Dispatcher $signalSlotDispatcher */ $signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class); foreach ($ruleClasses as $class) { $signalSlotDispatcher->connect(StaticFileCache::class, 'cacheRule', $class, 'check'); } $signalSlotDispatcher->connect(InstallUtility::class, 'afterExtensionUninstall', UninstallProcess::class, 'afterExtensionUninstall'); }
php
public static function registerSlots() { $ruleClasses = [ StaticCacheable::class, ValidUri::class, SiteCacheable::class, ValidDoktype::class, NoWorkspacePreview::class, NoUserOrGroupSet::class, NoIntScripts::class, LoginDeniedConfiguration::class, PageCacheable::class, DomainCacheable::class, NoNoCache::class, NoBackendUser::class, Enable::class, ValidRequestMethod::class, ForceStaticCache::class, NoFakeFrontend::class, ]; /** @var Dispatcher $signalSlotDispatcher */ $signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class); foreach ($ruleClasses as $class) { $signalSlotDispatcher->connect(StaticFileCache::class, 'cacheRule', $class, 'check'); } $signalSlotDispatcher->connect(InstallUtility::class, 'afterExtensionUninstall', UninstallProcess::class, 'afterExtensionUninstall'); }
[ "public", "static", "function", "registerSlots", "(", ")", "{", "$", "ruleClasses", "=", "[", "StaticCacheable", "::", "class", ",", "ValidUri", "::", "class", ",", "SiteCacheable", "::", "class", ",", "ValidDoktype", "::", "class", ",", "NoWorkspacePreview", ...
Register slots.
[ "Register", "slots", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Configuration.php#L116-L144
train
lochmueller/staticfilecache
Classes/Configuration.php
Configuration.registerCachingFramework
public static function registerCachingFramework() { $configuration = self::getConfiguration(); $useNullBackend = isset($configuration['disableInDevelopment']) && $configuration['disableInDevelopment'] && GeneralUtility::getApplicationContext()->isDevelopment(); $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['staticfilecache'] = [ 'frontend' => UriFrontend::class, 'backend' => $useNullBackend ? NullBackend::class : StaticFileBackend::class, 'groups' => [ 'pages', 'all', ], ]; $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['remote_file'] = [ 'frontend' => UriFrontend::class, 'backend' => RemoteFileBackend::class, 'groups' => [ 'all', ], 'options' => [ 'defaultLifetime' => 3600, ], ]; }
php
public static function registerCachingFramework() { $configuration = self::getConfiguration(); $useNullBackend = isset($configuration['disableInDevelopment']) && $configuration['disableInDevelopment'] && GeneralUtility::getApplicationContext()->isDevelopment(); $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['staticfilecache'] = [ 'frontend' => UriFrontend::class, 'backend' => $useNullBackend ? NullBackend::class : StaticFileBackend::class, 'groups' => [ 'pages', 'all', ], ]; $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['remote_file'] = [ 'frontend' => UriFrontend::class, 'backend' => RemoteFileBackend::class, 'groups' => [ 'all', ], 'options' => [ 'defaultLifetime' => 3600, ], ]; }
[ "public", "static", "function", "registerCachingFramework", "(", ")", "{", "$", "configuration", "=", "self", "::", "getConfiguration", "(", ")", ";", "$", "useNullBackend", "=", "isset", "(", "$", "configuration", "[", "'disableInDevelopment'", "]", ")", "&&", ...
Register caching framework.
[ "Register", "caching", "framework", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Configuration.php#L149-L173
train
lochmueller/staticfilecache
Classes/Configuration.php
Configuration.registerIcons
public static function registerIcons() { $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); $iconRegistry->registerIcon( 'brand-amazon', FontawesomeIconProvider::class, ['name' => 'amazon'] ); $iconRegistry->registerIcon( 'brand-paypal', FontawesomeIconProvider::class, ['name' => 'paypal'] ); $iconRegistry->registerIcon( 'documentation-book', FontawesomeIconProvider::class, ['name' => 'book'] ); $iconRegistry->registerIcon( 'brand-patreon', SvgIconProvider::class, [ 'source' => 'EXT:staticfilecache/Resources/Public/Icons/Patreon.svg', ] ); }
php
public static function registerIcons() { $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); $iconRegistry->registerIcon( 'brand-amazon', FontawesomeIconProvider::class, ['name' => 'amazon'] ); $iconRegistry->registerIcon( 'brand-paypal', FontawesomeIconProvider::class, ['name' => 'paypal'] ); $iconRegistry->registerIcon( 'documentation-book', FontawesomeIconProvider::class, ['name' => 'book'] ); $iconRegistry->registerIcon( 'brand-patreon', SvgIconProvider::class, [ 'source' => 'EXT:staticfilecache/Resources/Public/Icons/Patreon.svg', ] ); }
[ "public", "static", "function", "registerIcons", "(", ")", "{", "$", "iconRegistry", "=", "GeneralUtility", "::", "makeInstance", "(", "IconRegistry", "::", "class", ")", ";", "$", "iconRegistry", "->", "registerIcon", "(", "'brand-amazon'", ",", "FontawesomeIconP...
Register icons.
[ "Register", "icons", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Configuration.php#L186-L211
train
lochmueller/staticfilecache
Classes/Configuration.php
Configuration.getConfiguration
public static function getConfiguration(): array { static $configuration; if (\is_array($configuration)) { return $configuration; } if (VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version())['version_main'] < 9) { $configuration = isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']) ? (array)\unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']) : []; } else { $configuration = (array)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('staticfilecache'); } return $configuration; }
php
public static function getConfiguration(): array { static $configuration; if (\is_array($configuration)) { return $configuration; } if (VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version())['version_main'] < 9) { $configuration = isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']) ? (array)\unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']) : []; } else { $configuration = (array)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('staticfilecache'); } return $configuration; }
[ "public", "static", "function", "getConfiguration", "(", ")", ":", "array", "{", "static", "$", "configuration", ";", "if", "(", "\\", "is_array", "(", "$", "configuration", ")", ")", "{", "return", "$", "configuration", ";", "}", "if", "(", "VersionNumber...
Get the current extension configuration. @return array
[ "Get", "the", "current", "extension", "configuration", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Configuration.php#L218-L231
train
lochmueller/staticfilecache
Classes/Cache/Rule/AbstractRule.php
AbstractRule.check
public function check(TypoScriptFrontendController $frontendController, string $uri, array $explanation, bool $skipProcessing): array { $this->checkRule($frontendController, $uri, $explanation, $skipProcessing); return [ 'frontendController' => $frontendController, 'uri' => $uri, 'explanation' => $explanation, 'skipProcessing' => $skipProcessing, ]; }
php
public function check(TypoScriptFrontendController $frontendController, string $uri, array $explanation, bool $skipProcessing): array { $this->checkRule($frontendController, $uri, $explanation, $skipProcessing); return [ 'frontendController' => $frontendController, 'uri' => $uri, 'explanation' => $explanation, 'skipProcessing' => $skipProcessing, ]; }
[ "public", "function", "check", "(", "TypoScriptFrontendController", "$", "frontendController", ",", "string", "$", "uri", ",", "array", "$", "explanation", ",", "bool", "$", "skipProcessing", ")", ":", "array", "{", "$", "this", "->", "checkRule", "(", "$", ...
Wrapper for the signal. @param TypoScriptFrontendController $frontendController @param string $uri @param array $explanation @param bool $skipProcessing @return array
[ "Wrapper", "for", "the", "signal", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/AbstractRule.php#L29-L39
train
lochmueller/staticfilecache
Classes/Cache/StaticFileBackend.php
StaticFileBackend.flushByTags
public function flushByTags(array $tags) { $this->throwExceptionIfFrontendDoesNotExist(); if (empty($tags)) { return; } $this->logger->debug('SFC flushByTags', [$tags]); $identifiers = []; foreach ($tags as $tag) { $identifiers = \array_merge($identifiers, $this->findIdentifiersByTagIncludingExpired($tag)); } if ($this->isBoostMode()) { $this->getQueue()->addIdentifiers($identifiers); return; } foreach ($identifiers as $identifier) { $this->removeStaticFiles($identifier); } parent::flushByTags($tags); }
php
public function flushByTags(array $tags) { $this->throwExceptionIfFrontendDoesNotExist(); if (empty($tags)) { return; } $this->logger->debug('SFC flushByTags', [$tags]); $identifiers = []; foreach ($tags as $tag) { $identifiers = \array_merge($identifiers, $this->findIdentifiersByTagIncludingExpired($tag)); } if ($this->isBoostMode()) { $this->getQueue()->addIdentifiers($identifiers); return; } foreach ($identifiers as $identifier) { $this->removeStaticFiles($identifier); } parent::flushByTags($tags); }
[ "public", "function", "flushByTags", "(", "array", "$", "tags", ")", "{", "$", "this", "->", "throwExceptionIfFrontendDoesNotExist", "(", ")", ";", "if", "(", "empty", "(", "$", "tags", ")", ")", "{", "return", ";", "}", "$", "this", "->", "logger", "-...
Removes all entries tagged by any of the specified tags. @param string[] $tags @throws \TYPO3\CMS\Core\Cache\Exception
[ "Removes", "all", "entries", "tagged", "by", "any", "of", "the", "specified", "tags", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticFileBackend.php#L181-L207
train
lochmueller/staticfilecache
Classes/Cache/StaticFileBackend.php
StaticFileBackend.getCacheFilename
protected function getCacheFilename(string $entryIdentifier): string { $urlParts = \parse_url($entryIdentifier); $parts = [ $urlParts['scheme'], $urlParts['host'], isset($urlParts['port']) ? (int)$urlParts['port'] : ('https' === $urlParts['scheme'] ? 443 : 80), ]; $path = \implode('/', $parts) . '/' . \trim($urlParts['path'], '/'); $cacheFilename = GeneralUtility::getFileAbsFileName(self::CACHE_DIRECTORY . $path); $fileExtension = (string)PathUtility::pathinfo(PathUtility::basename($cacheFilename), PATHINFO_EXTENSION); if (empty($fileExtension) || !GeneralUtility::inList($this->configuration->get('fileTypes'), $fileExtension)) { $cacheFilename = \rtrim($cacheFilename, '/') . '/index.html'; } return $cacheFilename; }
php
protected function getCacheFilename(string $entryIdentifier): string { $urlParts = \parse_url($entryIdentifier); $parts = [ $urlParts['scheme'], $urlParts['host'], isset($urlParts['port']) ? (int)$urlParts['port'] : ('https' === $urlParts['scheme'] ? 443 : 80), ]; $path = \implode('/', $parts) . '/' . \trim($urlParts['path'], '/'); $cacheFilename = GeneralUtility::getFileAbsFileName(self::CACHE_DIRECTORY . $path); $fileExtension = (string)PathUtility::pathinfo(PathUtility::basename($cacheFilename), PATHINFO_EXTENSION); if (empty($fileExtension) || !GeneralUtility::inList($this->configuration->get('fileTypes'), $fileExtension)) { $cacheFilename = \rtrim($cacheFilename, '/') . '/index.html'; } return $cacheFilename; }
[ "protected", "function", "getCacheFilename", "(", "string", "$", "entryIdentifier", ")", ":", "string", "{", "$", "urlParts", "=", "\\", "parse_url", "(", "$", "entryIdentifier", ")", ";", "$", "parts", "=", "[", "$", "urlParts", "[", "'scheme'", "]", ",",...
Get the cache folder for the given entry. @param $entryIdentifier @return string
[ "Get", "the", "cache", "folder", "for", "the", "given", "entry", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticFileBackend.php#L259-L276
train
lochmueller/staticfilecache
Classes/Cache/StaticFileBackend.php
StaticFileBackend.findIdentifiersByTagIncludingExpired
protected function findIdentifiersByTagIncludingExpired($tag): array { $base = (new DateTimeService())->getCurrentTime(); $GLOBALS['EXEC_TIME'] = 0; $identifiers = $this->findIdentifiersByTag($tag); $GLOBALS['EXEC_TIME'] = $base; return $identifiers; }
php
protected function findIdentifiersByTagIncludingExpired($tag): array { $base = (new DateTimeService())->getCurrentTime(); $GLOBALS['EXEC_TIME'] = 0; $identifiers = $this->findIdentifiersByTag($tag); $GLOBALS['EXEC_TIME'] = $base; return $identifiers; }
[ "protected", "function", "findIdentifiersByTagIncludingExpired", "(", "$", "tag", ")", ":", "array", "{", "$", "base", "=", "(", "new", "DateTimeService", "(", ")", ")", "->", "getCurrentTime", "(", ")", ";", "$", "GLOBALS", "[", "'EXEC_TIME'", "]", "=", "...
Call findIdentifiersByTag but ignore the expires check. @param string $tag @return array
[ "Call", "findIdentifiersByTag", "but", "ignore", "the", "expires", "check", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticFileBackend.php#L285-L293
train
lochmueller/staticfilecache
Classes/Cache/StaticFileBackend.php
StaticFileBackend.removeStaticFiles
protected function removeStaticFiles(string $entryIdentifier): bool { $fileName = $this->getCacheFilename($entryIdentifier); $dispatchArguments = [ 'entryIdentifier' => $entryIdentifier, 'fileName' => $fileName, 'files' => [ PathUtility::pathinfo($fileName, PATHINFO_DIRNAME) . '/.htaccess', ], ]; GeneralUtility::makeInstance(MetaGenerator::class)->remove($entryIdentifier, $fileName); $dispatched = $this->dispatch('removeStaticFiles', $dispatchArguments); $files = $dispatched['files']; $removeService = GeneralUtility::makeInstance(RemoveService::class); foreach ($files as $file) { if (false === $removeService->removeFile($file)) { return false; } } return true; }
php
protected function removeStaticFiles(string $entryIdentifier): bool { $fileName = $this->getCacheFilename($entryIdentifier); $dispatchArguments = [ 'entryIdentifier' => $entryIdentifier, 'fileName' => $fileName, 'files' => [ PathUtility::pathinfo($fileName, PATHINFO_DIRNAME) . '/.htaccess', ], ]; GeneralUtility::makeInstance(MetaGenerator::class)->remove($entryIdentifier, $fileName); $dispatched = $this->dispatch('removeStaticFiles', $dispatchArguments); $files = $dispatched['files']; $removeService = GeneralUtility::makeInstance(RemoveService::class); foreach ($files as $file) { if (false === $removeService->removeFile($file)) { return false; } } return true; }
[ "protected", "function", "removeStaticFiles", "(", "string", "$", "entryIdentifier", ")", ":", "bool", "{", "$", "fileName", "=", "$", "this", "->", "getCacheFilename", "(", "$", "entryIdentifier", ")", ";", "$", "dispatchArguments", "=", "[", "'entryIdentifier'...
Remove the static files of the given identifier. @param string $entryIdentifier @return bool success if the files are deleted
[ "Remove", "the", "static", "files", "of", "the", "given", "identifier", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticFileBackend.php#L302-L325
train
lochmueller/staticfilecache
Classes/Generator/MetaGenerator.php
MetaGenerator.getImplementationObjects
protected function getImplementationObjects(): array { $objects = []; foreach ($this->getImplementations() as $implementation) { $objects[] = GeneralUtility::makeInstance($implementation); } return $objects; }
php
protected function getImplementationObjects(): array { $objects = []; foreach ($this->getImplementations() as $implementation) { $objects[] = GeneralUtility::makeInstance($implementation); } return $objects; }
[ "protected", "function", "getImplementationObjects", "(", ")", ":", "array", "{", "$", "objects", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getImplementations", "(", ")", "as", "$", "implementation", ")", "{", "$", "objects", "[", "]", "=",...
Get implementation objects. @return array
[ "Get", "implementation", "objects", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Generator/MetaGenerator.php#L53-L61
train
lochmueller/staticfilecache
Classes/Generator/MetaGenerator.php
MetaGenerator.getImplementations
protected function getImplementations(): array { $generators = []; $configurationService = GeneralUtility::makeInstance(ConfigurationService::class); if ($configurationService->isBool('enableGeneratorPlain')) { $generators[] = PlainGenerator::class; } if ($configurationService->isBool('enableGeneratorGzip')) { $generators[] = GzipGenerator::class; } if ($configurationService->isBool('enableGeneratorBrotli')) { $generators[] = BrotliGenerator::class; } $signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class); $params = [ 'generators' => $generators, ]; try { $params = $signalSlotDispatcher->dispatch(__CLASS__, 'getImplementations', $params); } catch (\Exception $ex) { } return $params['generators']; }
php
protected function getImplementations(): array { $generators = []; $configurationService = GeneralUtility::makeInstance(ConfigurationService::class); if ($configurationService->isBool('enableGeneratorPlain')) { $generators[] = PlainGenerator::class; } if ($configurationService->isBool('enableGeneratorGzip')) { $generators[] = GzipGenerator::class; } if ($configurationService->isBool('enableGeneratorBrotli')) { $generators[] = BrotliGenerator::class; } $signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class); $params = [ 'generators' => $generators, ]; try { $params = $signalSlotDispatcher->dispatch(__CLASS__, 'getImplementations', $params); } catch (\Exception $ex) { } return $params['generators']; }
[ "protected", "function", "getImplementations", "(", ")", ":", "array", "{", "$", "generators", "=", "[", "]", ";", "$", "configurationService", "=", "GeneralUtility", "::", "makeInstance", "(", "ConfigurationService", "::", "class", ")", ";", "if", "(", "$", ...
Get implementations. @return array
[ "Get", "implementations", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Generator/MetaGenerator.php#L68-L93
train
lochmueller/staticfilecache
Classes/Cache/Rule/LoginDeniedConfiguration.php
LoginDeniedConfiguration.checkRule
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { $name = 'sendCacheHeaders_onlyWhenLoginDeniedInBranch'; $loginDeniedCfg = (!$frontendController->config['config'][$name] || !$frontendController->loginAllowedInBranch); if (!$loginDeniedCfg) { $explanation[__CLASS__] = 'LoginDeniedCfg is true'; } }
php
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { $name = 'sendCacheHeaders_onlyWhenLoginDeniedInBranch'; $loginDeniedCfg = (!$frontendController->config['config'][$name] || !$frontendController->loginAllowedInBranch); if (!$loginDeniedCfg) { $explanation[__CLASS__] = 'LoginDeniedCfg is true'; } }
[ "public", "function", "checkRule", "(", "TypoScriptFrontendController", "$", "frontendController", ",", "string", "$", "uri", ",", "array", "&", "$", "explanation", ",", "bool", "&", "$", "skipProcessing", ")", "{", "$", "name", "=", "'sendCacheHeaders_onlyWhenLog...
Check LoginDeniedConfiguration. @param TypoScriptFrontendController $frontendController @param string $uri @param array $explanation @param bool $skipProcessing
[ "Check", "LoginDeniedConfiguration", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/LoginDeniedConfiguration.php#L26-L33
train
lochmueller/staticfilecache
Classes/Service/ConfigurationService.php
ConfigurationService.getBackendDisplayMode
public function getBackendDisplayMode(): string { $backendDisplayMode = $this->get('backendDisplayMode'); $validModes = ['current', 'childs', 'both']; if (!\in_array($backendDisplayMode, $validModes, true)) { $backendDisplayMode = 'current'; } return $backendDisplayMode; }
php
public function getBackendDisplayMode(): string { $backendDisplayMode = $this->get('backendDisplayMode'); $validModes = ['current', 'childs', 'both']; if (!\in_array($backendDisplayMode, $validModes, true)) { $backendDisplayMode = 'current'; } return $backendDisplayMode; }
[ "public", "function", "getBackendDisplayMode", "(", ")", ":", "string", "{", "$", "backendDisplayMode", "=", "$", "this", "->", "get", "(", "'backendDisplayMode'", ")", ";", "$", "validModes", "=", "[", "'current'", ",", "'childs'", ",", "'both'", "]", ";", ...
Get backend display mode. @return string
[ "Get", "backend", "display", "mode", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/ConfigurationService.php#L65-L74
train
lochmueller/staticfilecache
Classes/Service/UriService.php
UriService.getUri
public function getUri(): string { $configuration = GeneralUtility::makeInstance(ConfigurationService::class); // Find host-name / IP, always in lowercase: $isHttp = (0 === \mb_strpos(GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST'), 'http://')); $uri = GeneralUtility::getIndpEnv('REQUEST_URI'); if ($configuration->isBool('recreateURI')) { $uri = $this->recreateUriPath($uri); } $uri = ($isHttp ? 'http://' : 'https://') . \mb_strtolower(GeneralUtility::getIndpEnv('HTTP_HOST')) . '/' . \ltrim($uri, '/'); try { $idnaConverter = GeneralUtility::makeInstance(IdnaConvert::class); return $idnaConverter->encode($uri); } catch (\InvalidArgumentException $exception) { // The URI is already in puny code (no logging needed) return $uri; } }
php
public function getUri(): string { $configuration = GeneralUtility::makeInstance(ConfigurationService::class); // Find host-name / IP, always in lowercase: $isHttp = (0 === \mb_strpos(GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST'), 'http://')); $uri = GeneralUtility::getIndpEnv('REQUEST_URI'); if ($configuration->isBool('recreateURI')) { $uri = $this->recreateUriPath($uri); } $uri = ($isHttp ? 'http://' : 'https://') . \mb_strtolower(GeneralUtility::getIndpEnv('HTTP_HOST')) . '/' . \ltrim($uri, '/'); try { $idnaConverter = GeneralUtility::makeInstance(IdnaConvert::class); return $idnaConverter->encode($uri); } catch (\InvalidArgumentException $exception) { // The URI is already in puny code (no logging needed) return $uri; } }
[ "public", "function", "getUri", "(", ")", ":", "string", "{", "$", "configuration", "=", "GeneralUtility", "::", "makeInstance", "(", "ConfigurationService", "::", "class", ")", ";", "// Find host-name / IP, always in lowercase:", "$", "isHttp", "=", "(", "0", "==...
get the URI for the current cache ident. @return string
[ "get", "the", "URI", "for", "the", "current", "cache", "ident", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/UriService.php#L28-L49
train
lochmueller/staticfilecache
Classes/Service/UriService.php
UriService.recreateUriPath
protected function recreateUriPath($uri): string { $objectManager = new ObjectManager(); /** @var UriBuilder $uriBuilder */ $uriBuilder = $objectManager->get(UriBuilder::class); if (null === ObjectAccess::getProperty($uriBuilder, 'contentObject', true)) { // there are situations without a valid contentObject in the URI builder // prevent this situation by return the original request URI return $uri; } $url = $uriBuilder->reset() ->setAddQueryString(true) ->setCreateAbsoluteUri(true) ->build(); $parts = (array)\parse_url($url); $unset = ['scheme', 'user', 'pass', 'host', 'port']; foreach ($unset as $u) { unset($parts[$u]); } return HttpUtility::buildUrl($parts); }
php
protected function recreateUriPath($uri): string { $objectManager = new ObjectManager(); /** @var UriBuilder $uriBuilder */ $uriBuilder = $objectManager->get(UriBuilder::class); if (null === ObjectAccess::getProperty($uriBuilder, 'contentObject', true)) { // there are situations without a valid contentObject in the URI builder // prevent this situation by return the original request URI return $uri; } $url = $uriBuilder->reset() ->setAddQueryString(true) ->setCreateAbsoluteUri(true) ->build(); $parts = (array)\parse_url($url); $unset = ['scheme', 'user', 'pass', 'host', 'port']; foreach ($unset as $u) { unset($parts[$u]); } return HttpUtility::buildUrl($parts); }
[ "protected", "function", "recreateUriPath", "(", "$", "uri", ")", ":", "string", "{", "$", "objectManager", "=", "new", "ObjectManager", "(", ")", ";", "/** @var UriBuilder $uriBuilder */", "$", "uriBuilder", "=", "$", "objectManager", "->", "get", "(", "UriBuil...
Recreates the URI of the current request. Especially in simulateStaticDocument context, the different URIs lead to the same result and static file caching would store the wrong URI that was used in the first request to the website (e.g. "TheGoodURI.13.0.html" is as well accepted as "TheFakeURI.13.0.html") @param string $uri @return string The recreated URI of the current request
[ "Recreates", "the", "URI", "of", "the", "current", "request", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/UriService.php#L62-L84
train
lochmueller/staticfilecache
Classes/Hook/InitFrontendUser.php
InitFrontendUser.setFeUserCookie
public function setFeUserCookie(&$parameters, $parentObject) { if ($parentObject->fe_user->dontSetCookie) { // do not set any cookie return; } $started = $parentObject->fe_user->loginSessionStarted; $cookieService = GeneralUtility::makeInstance(CookieService::class); if (($started || $parentObject->fe_user->forceSetCookie) && 0 === $parentObject->fe_user->lifetime) { // If new session and the cookie is a sessioncookie, we need to set it only once! // // isSetSessionCookie() $cookieService->setCookie(0); } elseif (($started || isset($_COOKIE[CookieService::FE_COOKIE_NAME])) && $parentObject->fe_user->lifetime > 0) { // If it is NOT a session-cookie, we need to refresh it. // isRefreshTimeBasedCookie() $cookieService->setCookie((new DateTimeService())->getCurrentTime() + $parentObject->fe_user->lifetime); } }
php
public function setFeUserCookie(&$parameters, $parentObject) { if ($parentObject->fe_user->dontSetCookie) { // do not set any cookie return; } $started = $parentObject->fe_user->loginSessionStarted; $cookieService = GeneralUtility::makeInstance(CookieService::class); if (($started || $parentObject->fe_user->forceSetCookie) && 0 === $parentObject->fe_user->lifetime) { // If new session and the cookie is a sessioncookie, we need to set it only once! // // isSetSessionCookie() $cookieService->setCookie(0); } elseif (($started || isset($_COOKIE[CookieService::FE_COOKIE_NAME])) && $parentObject->fe_user->lifetime > 0) { // If it is NOT a session-cookie, we need to refresh it. // isRefreshTimeBasedCookie() $cookieService->setCookie((new DateTimeService())->getCurrentTime() + $parentObject->fe_user->lifetime); } }
[ "public", "function", "setFeUserCookie", "(", "&", "$", "parameters", ",", "$", "parentObject", ")", "{", "if", "(", "$", "parentObject", "->", "fe_user", "->", "dontSetCookie", ")", "{", "// do not set any cookie", "return", ";", "}", "$", "started", "=", "...
Set a cookie if a user logs in or refresh it. This function is needed because TYPO3 always sets the fe_typo_user cookie, even if the user never logs in. We want to be able to check against logged in frontend users from mod_rewrite. So we need to set our own cookie (when a user actually logs in). Checking code taken from \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication @param array $parameters @param object $parentObject
[ "Set", "a", "cookie", "if", "a", "user", "logs", "in", "or", "refresh", "it", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Hook/InitFrontendUser.php#L33-L52
train
lochmueller/staticfilecache
Classes/Cache/Rule/SiteCacheable.php
SiteCacheable.checkRule
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { if (!($GLOBALS['TYPO3_REQUEST'] instanceof \TYPO3\CMS\Core\Http\ServerRequest)) { return; } $site = $GLOBALS['TYPO3_REQUEST']->getAttribute('site'); if (!($site instanceof \TYPO3\CMS\Core\Site\Entity\Site)) { return; } $config = $site->getConfiguration(); if (isset($config['disableStaticFileCache']) && $config['disableStaticFileCache']) { $explanation[__CLASS__] = 'static cache disabled on site configuration: ' . $site->getIdentifier(); } }
php
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { if (!($GLOBALS['TYPO3_REQUEST'] instanceof \TYPO3\CMS\Core\Http\ServerRequest)) { return; } $site = $GLOBALS['TYPO3_REQUEST']->getAttribute('site'); if (!($site instanceof \TYPO3\CMS\Core\Site\Entity\Site)) { return; } $config = $site->getConfiguration(); if (isset($config['disableStaticFileCache']) && $config['disableStaticFileCache']) { $explanation[__CLASS__] = 'static cache disabled on site configuration: ' . $site->getIdentifier(); } }
[ "public", "function", "checkRule", "(", "TypoScriptFrontendController", "$", "frontendController", ",", "string", "$", "uri", ",", "array", "&", "$", "explanation", ",", "bool", "&", "$", "skipProcessing", ")", "{", "if", "(", "!", "(", "$", "GLOBALS", "[", ...
Check if the current site is static cacheable. @param TypoScriptFrontendController $frontendController @param string $uri @param array $explanation @param bool $skipProcessing
[ "Check", "if", "the", "current", "site", "is", "static", "cacheable", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/SiteCacheable.php#L26-L39
train
lochmueller/staticfilecache
Classes/Domain/Repository/CacheRepository.php
CacheRepository.findExpiredIdentifiers
public function findExpiredIdentifiers(): array { $queryBuilder = $this->createQuery(); $rows = $queryBuilder->select('identifier') ->from($this->getTableName()) ->where($queryBuilder->expr()->lt( 'expires', $queryBuilder->createNamedParameter((new DateTimeService())->getCurrentTime(), \PDO::PARAM_INT) )) ->groupBy('identifier') ->execute() ->fetchAll(); $cacheIdentifiers = []; foreach ($rows as $row) { $cacheIdentifiers[] = $row['identifier']; } return $cacheIdentifiers; }
php
public function findExpiredIdentifiers(): array { $queryBuilder = $this->createQuery(); $rows = $queryBuilder->select('identifier') ->from($this->getTableName()) ->where($queryBuilder->expr()->lt( 'expires', $queryBuilder->createNamedParameter((new DateTimeService())->getCurrentTime(), \PDO::PARAM_INT) )) ->groupBy('identifier') ->execute() ->fetchAll(); $cacheIdentifiers = []; foreach ($rows as $row) { $cacheIdentifiers[] = $row['identifier']; } return $cacheIdentifiers; }
[ "public", "function", "findExpiredIdentifiers", "(", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQuery", "(", ")", ";", "$", "rows", "=", "$", "queryBuilder", "->", "select", "(", "'identifier'", ")", "->", "from", "(", "$...
Get the expired cache identifiers. @return array
[ "Get", "the", "expired", "cache", "identifiers", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/CacheRepository.php#L25-L44
train
lochmueller/staticfilecache
Classes/Domain/Repository/CacheRepository.php
CacheRepository.findAllIdentifiers
public function findAllIdentifiers(): array { $queryBuilder = $this->createQuery(); $rows = $queryBuilder->select('identifier') ->from($this->getTableName()) ->groupBy('identifier') ->execute() ->fetchAll(); $cacheIdentifiers = []; foreach ($rows as $row) { $cacheIdentifiers[] = $row['identifier']; } return $cacheIdentifiers; }
php
public function findAllIdentifiers(): array { $queryBuilder = $this->createQuery(); $rows = $queryBuilder->select('identifier') ->from($this->getTableName()) ->groupBy('identifier') ->execute() ->fetchAll(); $cacheIdentifiers = []; foreach ($rows as $row) { $cacheIdentifiers[] = $row['identifier']; } return $cacheIdentifiers; }
[ "public", "function", "findAllIdentifiers", "(", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQuery", "(", ")", ";", "$", "rows", "=", "$", "queryBuilder", "->", "select", "(", "'identifier'", ")", "->", "from", "(", "$", ...
Get all the cache identifiers. @return array
[ "Get", "all", "the", "cache", "identifiers", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/CacheRepository.php#L51-L66
train
lochmueller/staticfilecache
Classes/Domain/Repository/CacheRepository.php
CacheRepository.getTableName
protected function getTableName(): string { $prefix = 'cf_'; $configuration = GeneralUtility::makeInstance(ConfigurationService::class); if ($configuration->isBool('renameTablesToOtherPrefix')) { $prefix = 'sfc_'; } return $prefix . 'staticfilecache'; }
php
protected function getTableName(): string { $prefix = 'cf_'; $configuration = GeneralUtility::makeInstance(ConfigurationService::class); if ($configuration->isBool('renameTablesToOtherPrefix')) { $prefix = 'sfc_'; } return $prefix . 'staticfilecache'; }
[ "protected", "function", "getTableName", "(", ")", ":", "string", "{", "$", "prefix", "=", "'cf_'", ";", "$", "configuration", "=", "GeneralUtility", "::", "makeInstance", "(", "ConfigurationService", "::", "class", ")", ";", "if", "(", "$", "configuration", ...
Get the table name. @return string
[ "Get", "the", "table", "name", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/CacheRepository.php#L73-L82
train
lochmueller/staticfilecache
Classes/Service/HtaccessService.php
HtaccessService.write
public function write(string $originalFileName, int $lifetime, string $originalContent) { $configuration = GeneralUtility::makeInstance(ConfigurationService::class); $tagService = GeneralUtility::makeInstance(TagService::class); $fileName = PathUtility::pathinfo($originalFileName, PATHINFO_DIRNAME) . '/.htaccess'; $accessTimeout = (int)$configuration->get('htaccessTimeout'); $lifetime = $accessTimeout ? $accessTimeout : $lifetime; $tags = $tagService->isEnable() ? $tagService->getTags() : []; $variables = [ 'mode' => $accessTimeout ? 'A' : 'M', 'lifetime' => $lifetime, 'expires' => (new DateTimeService())->getCurrentTime() + $lifetime, 'typo3headers' => GeneralUtility::makeInstance(TypoScriptFrontendService::class)->getAdditionalHeaders(), 'sendCacheControlHeader' => $configuration->isBool('sendCacheControlHeader'), 'sendCacheControlHeaderRedirectAfterCacheTimeout' => $configuration->isBool('sendCacheControlHeaderRedirectAfterCacheTimeout'), 'sendTypo3Headers' => $configuration->isBool('sendTypo3Headers'), 'tags' => \implode(',', $tags), 'tagHeaderName' => $tagService->getHeaderName(), 'sendStaticFileCacheHeader' => $configuration->isBool('sendStaticFileCacheHeader'), 'httpPushHeaders' => GeneralUtility::makeInstance(HttpPushService::class)->getHttpPushHeaders($originalContent), ]; $this->renderTemplateToFile($this->getTemplateName(), $variables, $fileName); }
php
public function write(string $originalFileName, int $lifetime, string $originalContent) { $configuration = GeneralUtility::makeInstance(ConfigurationService::class); $tagService = GeneralUtility::makeInstance(TagService::class); $fileName = PathUtility::pathinfo($originalFileName, PATHINFO_DIRNAME) . '/.htaccess'; $accessTimeout = (int)$configuration->get('htaccessTimeout'); $lifetime = $accessTimeout ? $accessTimeout : $lifetime; $tags = $tagService->isEnable() ? $tagService->getTags() : []; $variables = [ 'mode' => $accessTimeout ? 'A' : 'M', 'lifetime' => $lifetime, 'expires' => (new DateTimeService())->getCurrentTime() + $lifetime, 'typo3headers' => GeneralUtility::makeInstance(TypoScriptFrontendService::class)->getAdditionalHeaders(), 'sendCacheControlHeader' => $configuration->isBool('sendCacheControlHeader'), 'sendCacheControlHeaderRedirectAfterCacheTimeout' => $configuration->isBool('sendCacheControlHeaderRedirectAfterCacheTimeout'), 'sendTypo3Headers' => $configuration->isBool('sendTypo3Headers'), 'tags' => \implode(',', $tags), 'tagHeaderName' => $tagService->getHeaderName(), 'sendStaticFileCacheHeader' => $configuration->isBool('sendStaticFileCacheHeader'), 'httpPushHeaders' => GeneralUtility::makeInstance(HttpPushService::class)->getHttpPushHeaders($originalContent), ]; $this->renderTemplateToFile($this->getTemplateName(), $variables, $fileName); }
[ "public", "function", "write", "(", "string", "$", "originalFileName", ",", "int", "$", "lifetime", ",", "string", "$", "originalContent", ")", "{", "$", "configuration", "=", "GeneralUtility", "::", "makeInstance", "(", "ConfigurationService", "::", "class", ")...
Write htaccess file. @param string $originalFileName @param int $lifetime @param string $originalContent
[ "Write", "htaccess", "file", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/HtaccessService.php#L27-L53
train
lochmueller/staticfilecache
Classes/Service/HtaccessService.php
HtaccessService.renderTemplateToFile
protected function renderTemplateToFile(string $templateName, array $variables, string $fileName) { /** @var StandaloneView $renderer */ $renderer = GeneralUtility::makeInstance(StandaloneView::class); $renderer->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateName)); $renderer->assignMultiple($variables); $content = \trim((string)$renderer->render()); // Note: Create even empty htaccess files (do not check!!!), so the delete is in sync GeneralUtility::writeFile($fileName, $content); }
php
protected function renderTemplateToFile(string $templateName, array $variables, string $fileName) { /** @var StandaloneView $renderer */ $renderer = GeneralUtility::makeInstance(StandaloneView::class); $renderer->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateName)); $renderer->assignMultiple($variables); $content = \trim((string)$renderer->render()); // Note: Create even empty htaccess files (do not check!!!), so the delete is in sync GeneralUtility::writeFile($fileName, $content); }
[ "protected", "function", "renderTemplateToFile", "(", "string", "$", "templateName", ",", "array", "$", "variables", ",", "string", "$", "fileName", ")", "{", "/** @var StandaloneView $renderer */", "$", "renderer", "=", "GeneralUtility", "::", "makeInstance", "(", ...
Render template to file. @param string $templateName @param array $variables @param string $fileName
[ "Render", "template", "to", "file", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/HtaccessService.php#L62-L71
train
lochmueller/staticfilecache
Classes/Service/HtaccessService.php
HtaccessService.getTemplateName
protected function getTemplateName(): string { $configuration = GeneralUtility::makeInstance(ConfigurationService::class); $templateName = \trim((string)$configuration->get('htaccessTemplateName')); if ('' === $templateName) { return 'EXT:staticfilecache/Resources/Private/Templates/Htaccess.html'; } return $templateName; }
php
protected function getTemplateName(): string { $configuration = GeneralUtility::makeInstance(ConfigurationService::class); $templateName = \trim((string)$configuration->get('htaccessTemplateName')); if ('' === $templateName) { return 'EXT:staticfilecache/Resources/Private/Templates/Htaccess.html'; } return $templateName; }
[ "protected", "function", "getTemplateName", "(", ")", ":", "string", "{", "$", "configuration", "=", "GeneralUtility", "::", "makeInstance", "(", "ConfigurationService", "::", "class", ")", ";", "$", "templateName", "=", "\\", "trim", "(", "(", "string", ")", ...
Get the template name. @return string
[ "Get", "the", "template", "name", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/HtaccessService.php#L78-L87
train
lochmueller/staticfilecache
Classes/Domain/Repository/AbstractRepository.php
AbstractRepository.update
public function update(array $data, array $identifiers) { $this->getConnection()->update( $this->getTableName(), $data, $identifiers ); }
php
public function update(array $data, array $identifiers) { $this->getConnection()->update( $this->getTableName(), $data, $identifiers ); }
[ "public", "function", "update", "(", "array", "$", "data", ",", "array", "$", "identifiers", ")", "{", "$", "this", "->", "getConnection", "(", ")", "->", "update", "(", "$", "this", "->", "getTableName", "(", ")", ",", "$", "data", ",", "$", "identi...
Update records. @param array $data @param array $identifiers
[ "Update", "records", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Domain/Repository/AbstractRepository.php#L46-L53
train
lochmueller/staticfilecache
Classes/Cache/Rule/NoBackendUser.php
NoBackendUser.checkRule
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { if ($frontendController->isBackendUserLoggedIn()) { $skipProcessing = true; $explanation[__CLASS__] = 'Active BE Login (TSFE:beUserLogin)'; } }
php
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) { if ($frontendController->isBackendUserLoggedIn()) { $skipProcessing = true; $explanation[__CLASS__] = 'Active BE Login (TSFE:beUserLogin)'; } }
[ "public", "function", "checkRule", "(", "TypoScriptFrontendController", "$", "frontendController", ",", "string", "$", "uri", ",", "array", "&", "$", "explanation", ",", "bool", "&", "$", "skipProcessing", ")", "{", "if", "(", "$", "frontendController", "->", ...
No active BE user. @param TypoScriptFrontendController $frontendController @param string $uri @param array $explanation @param bool $skipProcessing
[ "No", "active", "BE", "user", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/Rule/NoBackendUser.php#L26-L32
train
lochmueller/staticfilecache
Classes/Cache/UriFrontend.php
UriFrontend.isValidEntryIdentifier
public function isValidEntryIdentifier($identifier) { if (false === GeneralUtility::isValidUrl($identifier)) { return false; } $urlParts = \parse_url($identifier); $required = ['host', 'path', 'scheme']; foreach ($required as $item) { if (!isset($urlParts[$item]) || \mb_strlen($urlParts[$item]) <= 0) { return false; } } return true; }
php
public function isValidEntryIdentifier($identifier) { if (false === GeneralUtility::isValidUrl($identifier)) { return false; } $urlParts = \parse_url($identifier); $required = ['host', 'path', 'scheme']; foreach ($required as $item) { if (!isset($urlParts[$item]) || \mb_strlen($urlParts[$item]) <= 0) { return false; } } return true; }
[ "public", "function", "isValidEntryIdentifier", "(", "$", "identifier", ")", "{", "if", "(", "false", "===", "GeneralUtility", "::", "isValidUrl", "(", "$", "identifier", ")", ")", "{", "return", "false", ";", "}", "$", "urlParts", "=", "\\", "parse_url", ...
Check if the identifier is a valid URI incl. host and path. @param string $identifier @return bool
[ "Check", "if", "the", "identifier", "is", "a", "valid", "URI", "incl", ".", "host", "and", "path", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/UriFrontend.php#L27-L41
train
lochmueller/staticfilecache
Classes/Service/QueueService.php
QueueService.addIdentifier
public function addIdentifier(string $identifier) { $count = $this->queueRepository->countOpenByIdentifier($identifier); if ($count > 0) { return; } $this->logger->debug('SFC Queue add', [$identifier]); $data = [ 'cache_url' => $identifier, 'page_uid' => 0, 'invalid_date' => \time(), 'call_result' => '', ]; $this->queueRepository->insert($data); }
php
public function addIdentifier(string $identifier) { $count = $this->queueRepository->countOpenByIdentifier($identifier); if ($count > 0) { return; } $this->logger->debug('SFC Queue add', [$identifier]); $data = [ 'cache_url' => $identifier, 'page_uid' => 0, 'invalid_date' => \time(), 'call_result' => '', ]; $this->queueRepository->insert($data); }
[ "public", "function", "addIdentifier", "(", "string", "$", "identifier", ")", "{", "$", "count", "=", "$", "this", "->", "queueRepository", "->", "countOpenByIdentifier", "(", "$", "identifier", ")", ";", "if", "(", "$", "count", ">", "0", ")", "{", "ret...
Add identifier to Queue. @param string $identifier
[ "Add", "identifier", "to", "Queue", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/QueueService.php#L61-L78
train
lochmueller/staticfilecache
Classes/Service/QueueService.php
QueueService.runSingleRequest
public function runSingleRequest(array $runEntry) { if (!\defined('SFC_QUEUE_WORKER')) { \define('SFC_QUEUE_WORKER', true); } $this->logger->debug('SFC Queue run', $runEntry); $clientService = GeneralUtility::makeInstance(ClientService::class); $statusCode = $clientService->runSingleRequest($runEntry['cache_url']); $data = [ 'call_date' => \time(), 'call_result' => $statusCode, ]; if (200 !== $statusCode) { // Call the flush, if the page is not accessable $cache = GeneralUtility::makeInstance(CacheService::class)->get(); $cache->flushByTag('sfc_pageId_' . $runEntry['page_uid']); if ($cache->has($runEntry['cache_url'])) { $cache->remove($runEntry['cache_url']); } } $this->queueRepository->update($data, ['uid' => (int)$runEntry['uid']]); }
php
public function runSingleRequest(array $runEntry) { if (!\defined('SFC_QUEUE_WORKER')) { \define('SFC_QUEUE_WORKER', true); } $this->logger->debug('SFC Queue run', $runEntry); $clientService = GeneralUtility::makeInstance(ClientService::class); $statusCode = $clientService->runSingleRequest($runEntry['cache_url']); $data = [ 'call_date' => \time(), 'call_result' => $statusCode, ]; if (200 !== $statusCode) { // Call the flush, if the page is not accessable $cache = GeneralUtility::makeInstance(CacheService::class)->get(); $cache->flushByTag('sfc_pageId_' . $runEntry['page_uid']); if ($cache->has($runEntry['cache_url'])) { $cache->remove($runEntry['cache_url']); } } $this->queueRepository->update($data, ['uid' => (int)$runEntry['uid']]); }
[ "public", "function", "runSingleRequest", "(", "array", "$", "runEntry", ")", "{", "if", "(", "!", "\\", "defined", "(", "'SFC_QUEUE_WORKER'", ")", ")", "{", "\\", "define", "(", "'SFC_QUEUE_WORKER'", ",", "true", ")", ";", "}", "$", "this", "->", "logge...
Run a single request with guzzle. @param array $runEntry @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
[ "Run", "a", "single", "request", "with", "guzzle", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Service/QueueService.php#L87-L113
train
lochmueller/staticfilecache
Classes/Cache/StaticDatabaseBackend.php
StaticDatabaseBackend.setCache
public function setCache(FrontendInterface $cache) { parent::setCache($cache); if ($this->configuration->isBool('renameTablesToOtherPrefix')) { $this->cacheTable = 'sfc_' . $this->cacheIdentifier; $this->tagsTable = 'sfc_' . $this->cacheIdentifier . '_tags'; } }
php
public function setCache(FrontendInterface $cache) { parent::setCache($cache); if ($this->configuration->isBool('renameTablesToOtherPrefix')) { $this->cacheTable = 'sfc_' . $this->cacheIdentifier; $this->tagsTable = 'sfc_' . $this->cacheIdentifier . '_tags'; } }
[ "public", "function", "setCache", "(", "FrontendInterface", "$", "cache", ")", "{", "parent", "::", "setCache", "(", "$", "cache", ")", ";", "if", "(", "$", "this", "->", "configuration", "->", "isBool", "(", "'renameTablesToOtherPrefix'", ")", ")", "{", "...
Set cache frontend instance and calculate data and tags table name. @param FrontendInterface $cache The frontend for this backend
[ "Set", "cache", "frontend", "instance", "and", "calculate", "data", "and", "tags", "table", "name", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticDatabaseBackend.php#L67-L74
train
lochmueller/staticfilecache
Classes/Cache/StaticDatabaseBackend.php
StaticDatabaseBackend.getRealLifetime
protected function getRealLifetime($lifetime): int { if (null === $lifetime) { $lifetime = $this->defaultLifetime; } if (0 === $lifetime || $lifetime > $this->maximumLifetime) { $lifetime = $this->maximumLifetime; } return (int)$lifetime; }
php
protected function getRealLifetime($lifetime): int { if (null === $lifetime) { $lifetime = $this->defaultLifetime; } if (0 === $lifetime || $lifetime > $this->maximumLifetime) { $lifetime = $this->maximumLifetime; } return (int)$lifetime; }
[ "protected", "function", "getRealLifetime", "(", "$", "lifetime", ")", ":", "int", "{", "if", "(", "null", "===", "$", "lifetime", ")", "{", "$", "lifetime", "=", "$", "this", "->", "defaultLifetime", ";", "}", "if", "(", "0", "===", "$", "lifetime", ...
Get the real life time. @param int $lifetime @return int
[ "Get", "the", "real", "life", "time", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticDatabaseBackend.php#L83-L93
train
lochmueller/staticfilecache
Classes/Cache/StaticDatabaseBackend.php
StaticDatabaseBackend.dispatch
protected function dispatch(string $signalName, array $arguments) { try { return $this->signalSlotDispatcher->dispatch($this->signalClass, $signalName, $arguments); } catch (\Exception $exception) { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger($this->signalClass); $logger->error('Problems by calling signal: ' . $exception->getMessage() . ' / ' . $exception->getFile() . ':' . $exception->getLine()); return $arguments; } }
php
protected function dispatch(string $signalName, array $arguments) { try { return $this->signalSlotDispatcher->dispatch($this->signalClass, $signalName, $arguments); } catch (\Exception $exception) { $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger($this->signalClass); $logger->error('Problems by calling signal: ' . $exception->getMessage() . ' / ' . $exception->getFile() . ':' . $exception->getLine()); return $arguments; } }
[ "protected", "function", "dispatch", "(", "string", "$", "signalName", ",", "array", "$", "arguments", ")", "{", "try", "{", "return", "$", "this", "->", "signalSlotDispatcher", "->", "dispatch", "(", "$", "this", "->", "signalClass", ",", "$", "signalName",...
Call Dispatcher. @param string $signalName @param array $arguments @return mixed
[ "Call", "Dispatcher", "." ]
1435f20afb95f88ae6a9bd935b2fae1e7d034f60
https://github.com/lochmueller/staticfilecache/blob/1435f20afb95f88ae6a9bd935b2fae1e7d034f60/Classes/Cache/StaticDatabaseBackend.php#L103-L113
train
fre5h/DoctrineEnumBundle
DBAL/Types/AbstractEnumType.php
AbstractEnumType.getRandomValue
public static function getRandomValue() { $values = self::getValues(); $randomKey = \random_int(0, \count($values) - 1); return $values[$randomKey]; }
php
public static function getRandomValue() { $values = self::getValues(); $randomKey = \random_int(0, \count($values) - 1); return $values[$randomKey]; }
[ "public", "static", "function", "getRandomValue", "(", ")", "{", "$", "values", "=", "self", "::", "getValues", "(", ")", ";", "$", "randomKey", "=", "\\", "random_int", "(", "0", ",", "\\", "count", "(", "$", "values", ")", "-", "1", ")", ";", "re...
Get random value for the ENUM field. @static @return int|string
[ "Get", "random", "value", "for", "the", "ENUM", "field", "." ]
df04951301600f61debef6865aaf7608084dd471
https://github.com/fre5h/DoctrineEnumBundle/blob/df04951301600f61debef6865aaf7608084dd471/DBAL/Types/AbstractEnumType.php#L153-L159
train
fre5h/DoctrineEnumBundle
DBAL/Types/AbstractEnumType.php
AbstractEnumType.assertValidChoice
public static function assertValidChoice(string $value): void { if (!isset(static::$choices[$value])) { throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM type "%s".', $value, static::class)); } }
php
public static function assertValidChoice(string $value): void { if (!isset(static::$choices[$value])) { throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM type "%s".', $value, static::class)); } }
[ "public", "static", "function", "assertValidChoice", "(", "string", "$", "value", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "choices", "[", "$", "value", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException"...
Asserts that given choice exists in the array of ENUM values. @param string $value ENUM value @throws \InvalidArgumentException
[ "Asserts", "that", "given", "choice", "exists", "in", "the", "array", "of", "ENUM", "values", "." ]
df04951301600f61debef6865aaf7608084dd471
https://github.com/fre5h/DoctrineEnumBundle/blob/df04951301600f61debef6865aaf7608084dd471/DBAL/Types/AbstractEnumType.php#L180-L185
train
fre5h/DoctrineEnumBundle
DBAL/Types/AbstractEnumType.php
AbstractEnumType.getMappedDatabaseTypes
public function getMappedDatabaseTypes(AbstractPlatform $platform): array { if ($platform instanceof MySqlPlatform) { return \array_merge(parent::getMappedDatabaseTypes($platform), ['enum']); } return parent::getMappedDatabaseTypes($platform); }
php
public function getMappedDatabaseTypes(AbstractPlatform $platform): array { if ($platform instanceof MySqlPlatform) { return \array_merge(parent::getMappedDatabaseTypes($platform), ['enum']); } return parent::getMappedDatabaseTypes($platform); }
[ "public", "function", "getMappedDatabaseTypes", "(", "AbstractPlatform", "$", "platform", ")", ":", "array", "{", "if", "(", "$", "platform", "instanceof", "MySqlPlatform", ")", "{", "return", "\\", "array_merge", "(", "parent", "::", "getMappedDatabaseTypes", "("...
Gets an array of database types that map to this Doctrine type. @param AbstractPlatform $platform @return array
[ "Gets", "an", "array", "of", "database", "types", "that", "map", "to", "this", "Doctrine", "type", "." ]
df04951301600f61debef6865aaf7608084dd471
https://github.com/fre5h/DoctrineEnumBundle/blob/df04951301600f61debef6865aaf7608084dd471/DBAL/Types/AbstractEnumType.php#L224-L231
train
sokil/php-vast
src/Creative/InLine/Linear.php
Linear.setDuration
public function setDuration($duration) { // get dom element $durationDomElement = $this->getDomElement()->getElementsByTagName('Duration')->item(0); if (!$durationDomElement) { $durationDomElement = $this->getDomElement()->ownerDocument->createElement('Duration'); $this->getDomElement()->firstChild->appendChild($durationDomElement); } // set value if (is_numeric($duration)) { // in seconds $duration = $this->secondsToString($duration); } $durationDomElement->nodeValue = $duration; return $this; }
php
public function setDuration($duration) { // get dom element $durationDomElement = $this->getDomElement()->getElementsByTagName('Duration')->item(0); if (!$durationDomElement) { $durationDomElement = $this->getDomElement()->ownerDocument->createElement('Duration'); $this->getDomElement()->firstChild->appendChild($durationDomElement); } // set value if (is_numeric($duration)) { // in seconds $duration = $this->secondsToString($duration); } $durationDomElement->nodeValue = $duration; return $this; }
[ "public", "function", "setDuration", "(", "$", "duration", ")", "{", "// get dom element", "$", "durationDomElement", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "getElementsByTagName", "(", "'Duration'", ")", "->", "item", "(", "0", ")", ";", "...
Set duration value @param int|string $duration seconds or time in format "H:m:i" @return $this
[ "Set", "duration", "value" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/InLine/Linear.php#L28-L46
train
sokil/php-vast
src/Document/AbstractNode.php
AbstractNode.setScalarNodeCdata
protected function setScalarNodeCdata($name, $value) { // get tag $childDomElement = $this->getDomElement()->getElementsByTagName($name)->item(0); if ($childDomElement === null) { $childDomElement = $this->getDomElement()->ownerDocument->createElement($name); $this->getDomElement()->appendChild($childDomElement); } // upsert cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value); if ($childDomElement->hasChildNodes()) { // update cdata $childDomElement->replaceChild($cdata, $childDomElement->firstChild); } else { // insert cdata $childDomElement->appendChild($cdata); } return $this; }
php
protected function setScalarNodeCdata($name, $value) { // get tag $childDomElement = $this->getDomElement()->getElementsByTagName($name)->item(0); if ($childDomElement === null) { $childDomElement = $this->getDomElement()->ownerDocument->createElement($name); $this->getDomElement()->appendChild($childDomElement); } // upsert cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value); if ($childDomElement->hasChildNodes()) { // update cdata $childDomElement->replaceChild($cdata, $childDomElement->firstChild); } else { // insert cdata $childDomElement->appendChild($cdata); } return $this; }
[ "protected", "function", "setScalarNodeCdata", "(", "$", "name", ",", "$", "value", ")", "{", "// get tag", "$", "childDomElement", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "getElementsByTagName", "(", "$", "name", ")", "->", "item", "(", "...
Set cdata for given child node or create new child node @param string $name name of node @param string $value value of cdata @return $this
[ "Set", "cdata", "for", "given", "child", "node", "or", "create", "new", "child", "node" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Document/AbstractNode.php#L22-L42
train
sokil/php-vast
src/Document/AbstractNode.php
AbstractNode.addCdataNode
protected function addCdataNode($nodeName, $value, array $attributes = array()) { // create element $domElement = $this->getDomElement()->ownerDocument->createElement($nodeName); $this->getDomElement()->appendChild($domElement); // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value); $domElement->appendChild($cdata); // add attributes foreach ($attributes as $attributeId => $attributeValue) { $domElement->setAttribute($attributeId, $attributeValue); } return $this; }
php
protected function addCdataNode($nodeName, $value, array $attributes = array()) { // create element $domElement = $this->getDomElement()->ownerDocument->createElement($nodeName); $this->getDomElement()->appendChild($domElement); // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value); $domElement->appendChild($cdata); // add attributes foreach ($attributes as $attributeId => $attributeValue) { $domElement->setAttribute($attributeId, $attributeValue); } return $this; }
[ "protected", "function", "addCdataNode", "(", "$", "nodeName", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "// create element", "$", "domElement", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "ownerDocu...
Append new child node to node @param string $nodeName @param string $value @param array $attributes @return $this
[ "Append", "new", "child", "node", "to", "node" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Document/AbstractNode.php#L70-L86
train
sokil/php-vast
src/Factory.php
Factory.create
public function create($vastVersion = '2.0') { $xml = $this->createDomDocument(); // root $root = $xml->createElement('VAST'); $xml->appendChild($root); // version $vastVersionAttribute = $xml->createAttribute('version'); $vastVersionAttribute->value = $vastVersion; $root->appendChild($vastVersionAttribute); // return return new Document($xml); }
php
public function create($vastVersion = '2.0') { $xml = $this->createDomDocument(); // root $root = $xml->createElement('VAST'); $xml->appendChild($root); // version $vastVersionAttribute = $xml->createAttribute('version'); $vastVersionAttribute->value = $vastVersion; $root->appendChild($vastVersionAttribute); // return return new Document($xml); }
[ "public", "function", "create", "(", "$", "vastVersion", "=", "'2.0'", ")", "{", "$", "xml", "=", "$", "this", "->", "createDomDocument", "(", ")", ";", "// root", "$", "root", "=", "$", "xml", "->", "createElement", "(", "'VAST'", ")", ";", "$", "xm...
Create new VAST document @param string $vastVersion @return Document
[ "Create", "new", "VAST", "document" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Factory.php#L14-L29
train
sokil/php-vast
src/Factory.php
Factory.fromFile
public function fromFile($filename) { $xml = $this->createDomDocument(); $xml->load($filename); return new Document($xml); }
php
public function fromFile($filename) { $xml = $this->createDomDocument(); $xml->load($filename); return new Document($xml); }
[ "public", "function", "fromFile", "(", "$", "filename", ")", "{", "$", "xml", "=", "$", "this", "->", "createDomDocument", "(", ")", ";", "$", "xml", "->", "load", "(", "$", "filename", ")", ";", "return", "new", "Document", "(", "$", "xml", ")", "...
Create VAST document from file @param string $filename @return Document
[ "Create", "VAST", "document", "from", "file" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Factory.php#L38-L44
train
sokil/php-vast
src/Factory.php
Factory.fromString
public function fromString($xmlString) { $xml = $this->createDomDocument(); $xml->loadXml($xmlString); return new Document($xml); }
php
public function fromString($xmlString) { $xml = $this->createDomDocument(); $xml->loadXml($xmlString); return new Document($xml); }
[ "public", "function", "fromString", "(", "$", "xmlString", ")", "{", "$", "xml", "=", "$", "this", "->", "createDomDocument", "(", ")", ";", "$", "xml", "->", "loadXml", "(", "$", "xmlString", ")", ";", "return", "new", "Document", "(", "$", "xml", "...
Create VAST document from given string with xml @param string $xmlString @return Document
[ "Create", "VAST", "document", "from", "given", "string", "with", "xml" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Factory.php#L53-L59
train
sokil/php-vast
src/Document.php
Document.createAdSection
private function createAdSection($type) { // Check Ad type $adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $type; if (!class_exists($adTypeClassName)) { throw new \InvalidArgumentException(sprintf('Ad type %s not supported', $type)); } // create dom node $adDomElement = $this->domDocument->createElement('Ad'); $this->domDocument->documentElement->appendChild($adDomElement); // create type element $adTypeDomElement = $this->domDocument->createElement($type); $adDomElement->appendChild($adTypeDomElement); // create ad section $adSection = new $adTypeClassName($adDomElement); // cache $this->vastAdNodeList[] = $adSection; return $adSection; }
php
private function createAdSection($type) { // Check Ad type $adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $type; if (!class_exists($adTypeClassName)) { throw new \InvalidArgumentException(sprintf('Ad type %s not supported', $type)); } // create dom node $adDomElement = $this->domDocument->createElement('Ad'); $this->domDocument->documentElement->appendChild($adDomElement); // create type element $adTypeDomElement = $this->domDocument->createElement($type); $adDomElement->appendChild($adTypeDomElement); // create ad section $adSection = new $adTypeClassName($adDomElement); // cache $this->vastAdNodeList[] = $adSection; return $adSection; }
[ "private", "function", "createAdSection", "(", "$", "type", ")", "{", "// Check Ad type", "$", "adTypeClassName", "=", "'\\\\Sokil\\\\Vast\\\\Ad\\\\'", ".", "$", "type", ";", "if", "(", "!", "class_exists", "(", "$", "adTypeClassName", ")", ")", "{", "throw", ...
Create "Ad" section on "VAST" node @param string $type @throws \InvalidArgumentException @return AbstractAdNode
[ "Create", "Ad", "section", "on", "VAST", "node" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Document.php#L82-L105
train
sokil/php-vast
src/Document.php
Document.getAdSections
public function getAdSections() { if (!empty($this->vastAdNodeList)) { return $this->vastAdNodeList; } foreach ($this->domDocument->documentElement->childNodes as $adDomElement) { // get Ad tag if (!$adDomElement instanceof \DOMElement) { continue; } if ('ad' !== strtolower($adDomElement->tagName)) { continue; } // get Ad type tag foreach ($adDomElement->childNodes as $node) { if (!($node instanceof \DOMElement)) { continue; } $type = $node->tagName; // create ad section $adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $type; if (!class_exists($adTypeClassName)) { throw new \Exception('Ad type ' . $type . ' not supported'); } $this->vastAdNodeList[] = new $adTypeClassName($adDomElement); } } return $this->vastAdNodeList; }
php
public function getAdSections() { if (!empty($this->vastAdNodeList)) { return $this->vastAdNodeList; } foreach ($this->domDocument->documentElement->childNodes as $adDomElement) { // get Ad tag if (!$adDomElement instanceof \DOMElement) { continue; } if ('ad' !== strtolower($adDomElement->tagName)) { continue; } // get Ad type tag foreach ($adDomElement->childNodes as $node) { if (!($node instanceof \DOMElement)) { continue; } $type = $node->tagName; // create ad section $adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $type; if (!class_exists($adTypeClassName)) { throw new \Exception('Ad type ' . $type . ' not supported'); } $this->vastAdNodeList[] = new $adTypeClassName($adDomElement); } } return $this->vastAdNodeList; }
[ "public", "function", "getAdSections", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "vastAdNodeList", ")", ")", "{", "return", "$", "this", "->", "vastAdNodeList", ";", "}", "foreach", "(", "$", "this", "->", "domDocument", "->", "do...
Get document ad sections @return AbstractAdNode[] @throws \Exception
[ "Get", "document", "ad", "sections" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Document.php#L134-L169
train
sokil/php-vast
src/Ad/AbstractAdNode.php
AbstractAdNode.buildCreative
protected function buildCreative($type) { // check type $creativeClassName = $this->buildCreativeClassName($type); if (!class_exists($creativeClassName)) { throw new \Exception('Wrong creative specified: ' . var_export($creativeClassName, true)); } // get container if (!$this->creativesDomElement) { // get creatives tag $this->creativesDomElement = $this->adDomElement->getElementsByTagName('Creatives')->item(0); if (!$this->creativesDomElement) { $this->creativesDomElement = $this->adDomElement->ownerDocument->createElement('Creatives'); $this->getDomElement()->appendChild($this->creativesDomElement); } } // Creative dom element: <Creative></Creative> $creativeDomElement = $this->creativesDomElement->ownerDocument->createElement('Creative'); $this->creativesDomElement->appendChild($creativeDomElement); // Creative type dom element: <Creative><Linear></Linear></Creative> $creativeTypeDomElement = $this->adDomElement->ownerDocument->createElement($type); $creativeDomElement->appendChild($creativeTypeDomElement); // object $creative = new $creativeClassName($creativeDomElement); $this->creatives[] = $creative; return $creative; }
php
protected function buildCreative($type) { // check type $creativeClassName = $this->buildCreativeClassName($type); if (!class_exists($creativeClassName)) { throw new \Exception('Wrong creative specified: ' . var_export($creativeClassName, true)); } // get container if (!$this->creativesDomElement) { // get creatives tag $this->creativesDomElement = $this->adDomElement->getElementsByTagName('Creatives')->item(0); if (!$this->creativesDomElement) { $this->creativesDomElement = $this->adDomElement->ownerDocument->createElement('Creatives'); $this->getDomElement()->appendChild($this->creativesDomElement); } } // Creative dom element: <Creative></Creative> $creativeDomElement = $this->creativesDomElement->ownerDocument->createElement('Creative'); $this->creativesDomElement->appendChild($creativeDomElement); // Creative type dom element: <Creative><Linear></Linear></Creative> $creativeTypeDomElement = $this->adDomElement->ownerDocument->createElement($type); $creativeDomElement->appendChild($creativeTypeDomElement); // object $creative = new $creativeClassName($creativeDomElement); $this->creatives[] = $creative; return $creative; }
[ "protected", "function", "buildCreative", "(", "$", "type", ")", "{", "// check type", "$", "creativeClassName", "=", "$", "this", "->", "buildCreativeClassName", "(", "$", "type", ")", ";", "if", "(", "!", "class_exists", "(", "$", "creativeClassName", ")", ...
Create "creative" object of given type @param string $type @throws \Exception @return AbstractLinearCreative
[ "Create", "creative", "object", "of", "given", "type" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Ad/AbstractAdNode.php#L161-L192
train
sokil/php-vast
src/Ad/AbstractAdNode.php
AbstractAdNode.addImpression
public function addImpression($url, $id = null) { $attributes = array(); if ($id !== null) { $attributes['id'] = $id; } $this->addCdataNode( 'Impression', $url, $attributes ); return $this; }
php
public function addImpression($url, $id = null) { $attributes = array(); if ($id !== null) { $attributes['id'] = $id; } $this->addCdataNode( 'Impression', $url, $attributes ); return $this; }
[ "public", "function", "addImpression", "(", "$", "url", ",", "$", "id", "=", "null", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "if", "(", "$", "id", "!==", "null", ")", "{", "$", "attributes", "[", "'id'", "]", "=", "$", "id", "...
Add Impression tracking url Allowed multiple impressions @param string $url A URI that directs the video player to a tracking resource file that the video player ust use to notify the ad server when the impression occurs. @param string|null $id An ad server id for the impression. Impression URIs of the same id for an ad should be requested at the same time or as close in time as possible to help prevent discrepancies. @return $this
[ "Add", "Impression", "tracking", "url", "Allowed", "multiple", "impressions" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Ad/AbstractAdNode.php#L231-L245
train
sokil/php-vast
src/Creative/AbstractLinearCreative.php
AbstractLinearCreative.getEventList
public static function getEventList() { return array( self::EVENT_TYPE_CREATIVEVIEW, self::EVENT_TYPE_START, self::EVENT_TYPE_FIRSTQUARTILE, self::EVENT_TYPE_MIDPOINT, self::EVENT_TYPE_THIRDQUARTILE, self::EVENT_TYPE_COMPLETE, self::EVENT_TYPE_MUTE, self::EVENT_TYPE_UNMUTE, self::EVENT_TYPE_PAUSE, self::EVENT_TYPE_REWIND, self::EVENT_TYPE_RESUME, self::EVENT_TYPE_FULLSCREEN, self::EVENT_TYPE_EXITFULLSCREEN, self::EVENT_TYPE_EXPAND, self::EVENT_TYPE_COLLAPSE, self::EVENT_TYPE_ACCEPTINVITATIONLINEAR, self::EVENT_TYPE_CLOSELINEAR, self::EVENT_TYPE_SKIP, self::EVENT_TYPE_PROGRESS, ); }
php
public static function getEventList() { return array( self::EVENT_TYPE_CREATIVEVIEW, self::EVENT_TYPE_START, self::EVENT_TYPE_FIRSTQUARTILE, self::EVENT_TYPE_MIDPOINT, self::EVENT_TYPE_THIRDQUARTILE, self::EVENT_TYPE_COMPLETE, self::EVENT_TYPE_MUTE, self::EVENT_TYPE_UNMUTE, self::EVENT_TYPE_PAUSE, self::EVENT_TYPE_REWIND, self::EVENT_TYPE_RESUME, self::EVENT_TYPE_FULLSCREEN, self::EVENT_TYPE_EXITFULLSCREEN, self::EVENT_TYPE_EXPAND, self::EVENT_TYPE_COLLAPSE, self::EVENT_TYPE_ACCEPTINVITATIONLINEAR, self::EVENT_TYPE_CLOSELINEAR, self::EVENT_TYPE_SKIP, self::EVENT_TYPE_PROGRESS, ); }
[ "public", "static", "function", "getEventList", "(", ")", "{", "return", "array", "(", "self", "::", "EVENT_TYPE_CREATIVEVIEW", ",", "self", "::", "EVENT_TYPE_START", ",", "self", "::", "EVENT_TYPE_FIRSTQUARTILE", ",", "self", "::", "EVENT_TYPE_MIDPOINT", ",", "se...
List of allowed events @return array
[ "List", "of", "allowed", "events" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/AbstractLinearCreative.php#L132-L155
train
sokil/php-vast
src/Creative/AbstractLinearCreative.php
AbstractLinearCreative.getVideoClicksDomElement
protected function getVideoClicksDomElement() { // create container if (!empty($this->videoClicksDomElement)) { return $this->videoClicksDomElement; } $this->videoClicksDomElement = $this->linearCreativeDomElement->getElementsByTagName('VideoClicks')->item(0); if (!empty($this->videoClicksDomElement)) { return $this->videoClicksDomElement; } $this->videoClicksDomElement = $this->linearCreativeDomElement->ownerDocument->createElement('VideoClicks'); $this->linearCreativeDomElement->firstChild->appendChild($this->videoClicksDomElement); return $this->videoClicksDomElement; }
php
protected function getVideoClicksDomElement() { // create container if (!empty($this->videoClicksDomElement)) { return $this->videoClicksDomElement; } $this->videoClicksDomElement = $this->linearCreativeDomElement->getElementsByTagName('VideoClicks')->item(0); if (!empty($this->videoClicksDomElement)) { return $this->videoClicksDomElement; } $this->videoClicksDomElement = $this->linearCreativeDomElement->ownerDocument->createElement('VideoClicks'); $this->linearCreativeDomElement->firstChild->appendChild($this->videoClicksDomElement); return $this->videoClicksDomElement; }
[ "protected", "function", "getVideoClicksDomElement", "(", ")", "{", "// create container", "if", "(", "!", "empty", "(", "$", "this", "->", "videoClicksDomElement", ")", ")", "{", "return", "$", "this", "->", "videoClicksDomElement", ";", "}", "$", "this", "->...
Get VideoClicks DomElement @return \DOMElement
[ "Get", "VideoClicks", "DomElement" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/AbstractLinearCreative.php#L162-L178
train
sokil/php-vast
src/Creative/AbstractLinearCreative.php
AbstractLinearCreative.addVideoClicksClickTracking
public function addVideoClicksClickTracking($url) { // create ClickTracking $clickTrackingDomElement = $this->getDomElement()->ownerDocument->createElement('ClickTracking'); $this->getVideoClicksDomElement()->appendChild($clickTrackingDomElement); // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($url); $clickTrackingDomElement->appendChild($cdata); return $this; }
php
public function addVideoClicksClickTracking($url) { // create ClickTracking $clickTrackingDomElement = $this->getDomElement()->ownerDocument->createElement('ClickTracking'); $this->getVideoClicksDomElement()->appendChild($clickTrackingDomElement); // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($url); $clickTrackingDomElement->appendChild($cdata); return $this; }
[ "public", "function", "addVideoClicksClickTracking", "(", "$", "url", ")", "{", "// create ClickTracking", "$", "clickTrackingDomElement", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "ownerDocument", "->", "createElement", "(", "'ClickTracking'", ")", "...
Add click tracking url @param string $url @return $this
[ "Add", "click", "tracking", "url" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/AbstractLinearCreative.php#L186-L197
train
sokil/php-vast
src/Creative/AbstractLinearCreative.php
AbstractLinearCreative.addVideoClicksCustomClick
public function addVideoClicksCustomClick($url) { // create CustomClick $customClickDomElement = $this->getDomElement()->ownerDocument->createElement('CustomClick'); $this->getVideoClicksDomElement()->appendChild($customClickDomElement); // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($url); $customClickDomElement->appendChild($cdata); return $this; }
php
public function addVideoClicksCustomClick($url) { // create CustomClick $customClickDomElement = $this->getDomElement()->ownerDocument->createElement('CustomClick'); $this->getVideoClicksDomElement()->appendChild($customClickDomElement); // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($url); $customClickDomElement->appendChild($cdata); return $this; }
[ "public", "function", "addVideoClicksCustomClick", "(", "$", "url", ")", "{", "// create CustomClick", "$", "customClickDomElement", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "ownerDocument", "->", "createElement", "(", "'CustomClick'", ")", ";", "$...
Add custom click url @param string $url @return $this
[ "Add", "custom", "click", "url" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/AbstractLinearCreative.php#L205-L216
train
sokil/php-vast
src/Creative/AbstractLinearCreative.php
AbstractLinearCreative.setVideoClicksClickThrough
public function setVideoClicksClickThrough($url) { // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($url); // create ClickThrough $clickThroughDomElement = $this->getVideoClicksDomElement()->getElementsByTagName('ClickThrough')->item(0); if (!$clickThroughDomElement) { $clickThroughDomElement = $this->getDomElement()->ownerDocument->createElement('ClickThrough'); $this->getVideoClicksDomElement()->appendChild($clickThroughDomElement); } // update CData if ($clickThroughDomElement->hasChildNodes()) { $clickThroughDomElement->replaceChild($cdata, $clickThroughDomElement->firstChild); } else { // insert CData $clickThroughDomElement->appendChild($cdata); } return $this; }
php
public function setVideoClicksClickThrough($url) { // create cdata $cdata = $this->getDomElement()->ownerDocument->createCDATASection($url); // create ClickThrough $clickThroughDomElement = $this->getVideoClicksDomElement()->getElementsByTagName('ClickThrough')->item(0); if (!$clickThroughDomElement) { $clickThroughDomElement = $this->getDomElement()->ownerDocument->createElement('ClickThrough'); $this->getVideoClicksDomElement()->appendChild($clickThroughDomElement); } // update CData if ($clickThroughDomElement->hasChildNodes()) { $clickThroughDomElement->replaceChild($cdata, $clickThroughDomElement->firstChild); } else { // insert CData $clickThroughDomElement->appendChild($cdata); } return $this; }
[ "public", "function", "setVideoClicksClickThrough", "(", "$", "url", ")", "{", "// create cdata", "$", "cdata", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "ownerDocument", "->", "createCDATASection", "(", "$", "url", ")", ";", "// create ClickThrou...
Set video click through url @param string $url @return $this
[ "Set", "video", "click", "through", "url" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/AbstractLinearCreative.php#L224-L244
train
sokil/php-vast
src/Creative/AbstractLinearCreative.php
AbstractLinearCreative.getTrackingEventsDomElement
protected function getTrackingEventsDomElement() { // create container if ($this->trackingEventsDomElement) { return $this->trackingEventsDomElement; } $this->trackingEventsDomElement = $this->linearCreativeDomElement ->getElementsByTagName('TrackingEvents') ->item(0); if ($this->trackingEventsDomElement) { return $this->trackingEventsDomElement; } $this->trackingEventsDomElement = $this->linearCreativeDomElement ->ownerDocument ->createElement('TrackingEvents'); $this->linearCreativeDomElement->firstChild->appendChild($this->trackingEventsDomElement); return $this->trackingEventsDomElement; }
php
protected function getTrackingEventsDomElement() { // create container if ($this->trackingEventsDomElement) { return $this->trackingEventsDomElement; } $this->trackingEventsDomElement = $this->linearCreativeDomElement ->getElementsByTagName('TrackingEvents') ->item(0); if ($this->trackingEventsDomElement) { return $this->trackingEventsDomElement; } $this->trackingEventsDomElement = $this->linearCreativeDomElement ->ownerDocument ->createElement('TrackingEvents'); $this->linearCreativeDomElement->firstChild->appendChild($this->trackingEventsDomElement); return $this->trackingEventsDomElement; }
[ "protected", "function", "getTrackingEventsDomElement", "(", ")", "{", "// create container", "if", "(", "$", "this", "->", "trackingEventsDomElement", ")", "{", "return", "$", "this", "->", "trackingEventsDomElement", ";", "}", "$", "this", "->", "trackingEventsDom...
Get TrackingEvents DomElement @return \DOMElement
[ "Get", "TrackingEvents", "DomElement" ]
7710ba75df5808de149567cdd23c1cb2da1d2ab2
https://github.com/sokil/php-vast/blob/7710ba75df5808de149567cdd23c1cb2da1d2ab2/src/Creative/AbstractLinearCreative.php#L251-L273
train
opauth/opauth
lib/Opauth/Opauth.php
Opauth.parseUri
private function parseUri() { $this->env['request'] = substr($this->env['request_uri'], strlen($this->env['path']) - 1); if (preg_match_all('/\/([A-Za-z0-9-_]+)/', $this->env['request'], $matches)) { foreach ($matches[1] as $match) { $this->env['params'][] = $match; } } if (!empty($this->env['params'][0])) { $this->env['params']['strategy'] = $this->env['params'][0]; } if (!empty($this->env['params'][1])) { $this->env['params']['action'] = $this->env['params'][1]; } }
php
private function parseUri() { $this->env['request'] = substr($this->env['request_uri'], strlen($this->env['path']) - 1); if (preg_match_all('/\/([A-Za-z0-9-_]+)/', $this->env['request'], $matches)) { foreach ($matches[1] as $match) { $this->env['params'][] = $match; } } if (!empty($this->env['params'][0])) { $this->env['params']['strategy'] = $this->env['params'][0]; } if (!empty($this->env['params'][1])) { $this->env['params']['action'] = $this->env['params'][1]; } }
[ "private", "function", "parseUri", "(", ")", "{", "$", "this", "->", "env", "[", "'request'", "]", "=", "substr", "(", "$", "this", "->", "env", "[", "'request_uri'", "]", ",", "strlen", "(", "$", "this", "->", "env", "[", "'path'", "]", ")", "-", ...
Parses Request URI
[ "Parses", "Request", "URI" ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/Opauth.php#L131-L146
train
opauth/opauth
lib/Opauth/OpauthStrategy.php
OpauthStrategy.callAction
public function callAction($action, $defaultAction = 'request') { if (method_exists($this, $action)) return $this->{$action}(); else return $this->{$defaultAction}(); }
php
public function callAction($action, $defaultAction = 'request') { if (method_exists($this, $action)) return $this->{$action}(); else return $this->{$defaultAction}(); }
[ "public", "function", "callAction", "(", "$", "action", ",", "$", "defaultAction", "=", "'request'", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "$", "action", ")", ")", "return", "$", "this", "->", "{", "$", "action", "}", "(", ")",...
Call an action from a defined strategy @param string $action Action name to call @param string $defaultAction If an action is not defined in a strategy, calls $defaultAction
[ "Call", "an", "action", "from", "a", "defined", "strategy" ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/OpauthStrategy.php#L189-L192
train
opauth/opauth
lib/Opauth/OpauthStrategy.php
OpauthStrategy.expects
protected function expects($key, $not = null) { if (!array_key_exists($key, $this->strategy)) { trigger_error($this->name." config parameter for \"$key\" expected.", E_USER_ERROR); exit(); } $value = $this->strategy[$key]; if (empty($value) || $value == $not) { trigger_error($this->name." config parameter for \"$key\" expected.", E_USER_ERROR); exit(); } return $value; }
php
protected function expects($key, $not = null) { if (!array_key_exists($key, $this->strategy)) { trigger_error($this->name." config parameter for \"$key\" expected.", E_USER_ERROR); exit(); } $value = $this->strategy[$key]; if (empty($value) || $value == $not) { trigger_error($this->name." config parameter for \"$key\" expected.", E_USER_ERROR); exit(); } return $value; }
[ "protected", "function", "expects", "(", "$", "key", ",", "$", "not", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "strategy", ")", ")", "{", "trigger_error", "(", "$", "this", "->", "name", "....
Ensures that a compulsory value is set, throws an error if it's not set @param string $key Expected configuration key @param string $not If value is set as $not, trigger E_USER_ERROR @return mixed The loaded value
[ "Ensures", "that", "a", "compulsory", "value", "is", "set", "throws", "an", "error", "if", "it", "s", "not", "set" ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/OpauthStrategy.php#L201-L214
train
opauth/opauth
lib/Opauth/OpauthStrategy.php
OpauthStrategy.mapProfile
protected function mapProfile($profile, $profile_path, $auth_path) { $from = explode('.', $profile_path); $base = $profile; foreach ($from as $element) { if (is_array($base) && array_key_exists($element, $base)) { $base = $base[$element]; } else { return false; } } $value = $base; $to = explode('.', $auth_path); $auth = &$this->auth; foreach ($to as $element) { $auth = &$auth[$element]; } $auth = $value; return true; }
php
protected function mapProfile($profile, $profile_path, $auth_path) { $from = explode('.', $profile_path); $base = $profile; foreach ($from as $element) { if (is_array($base) && array_key_exists($element, $base)) { $base = $base[$element]; } else { return false; } } $value = $base; $to = explode('.', $auth_path); $auth = &$this->auth; foreach ($to as $element) { $auth = &$auth[$element]; } $auth = $value; return true; }
[ "protected", "function", "mapProfile", "(", "$", "profile", ",", "$", "profile_path", ",", "$", "auth_path", ")", "{", "$", "from", "=", "explode", "(", "'.'", ",", "$", "profile_path", ")", ";", "$", "base", "=", "$", "profile", ";", "foreach", "(", ...
Maps user profile to auth response @param array $profile User profile obtained from provider @param string $profile_path Path to a $profile property. Use dot(.) to separate levels. eg. Path to $profile['a']['b']['c'] would be 'a.b.c' @param string $auth_path Path to $this->auth that is to be set.
[ "Maps", "user", "profile", "to", "auth", "response" ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/OpauthStrategy.php#L255-L277
train
opauth/opauth
lib/Opauth/OpauthStrategy.php
OpauthStrategy.hash
public static function hash($input, $timestamp, $iteration, $salt) { $iteration = intval($iteration); if ($iteration <= 0) { return false; } for ($i = 0; $i < $iteration; ++$i) { $input = base_convert(sha1($input.$salt.$timestamp), 16, 36); } return $input; }
php
public static function hash($input, $timestamp, $iteration, $salt) { $iteration = intval($iteration); if ($iteration <= 0) { return false; } for ($i = 0; $i < $iteration; ++$i) { $input = base_convert(sha1($input.$salt.$timestamp), 16, 36); } return $input; }
[ "public", "static", "function", "hash", "(", "$", "input", ",", "$", "timestamp", ",", "$", "iteration", ",", "$", "salt", ")", "{", "$", "iteration", "=", "intval", "(", "$", "iteration", ")", ";", "if", "(", "$", "iteration", "<=", "0", ")", "{",...
Static hashing function @param string $input Input string @param string $timestamp ISO 8601 formatted date @param int $iteration Number of hash iterations @param string $salt @return string Resulting hash
[ "Static", "hashing", "function" ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/OpauthStrategy.php#L296-L306
train
opauth/opauth
lib/Opauth/OpauthStrategy.php
OpauthStrategy.recursiveGetObjectVars
public static function recursiveGetObjectVars($obj) { $arr = array(); $_arr = is_object($obj) ? get_object_vars($obj) : $obj; foreach ($_arr as $key => $val) { $val = (is_array($val) || is_object($val)) ? self::recursiveGetObjectVars($val) : $val; // Transform boolean into 1 or 0 to make it safe across all Opauth HTTP transports if (is_bool($val)) $val = ($val) ? 1 : 0; $arr[$key] = $val; } return $arr; }
php
public static function recursiveGetObjectVars($obj) { $arr = array(); $_arr = is_object($obj) ? get_object_vars($obj) : $obj; foreach ($_arr as $key => $val) { $val = (is_array($val) || is_object($val)) ? self::recursiveGetObjectVars($val) : $val; // Transform boolean into 1 or 0 to make it safe across all Opauth HTTP transports if (is_bool($val)) $val = ($val) ? 1 : 0; $arr[$key] = $val; } return $arr; }
[ "public", "static", "function", "recursiveGetObjectVars", "(", "$", "obj", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "$", "_arr", "=", "is_object", "(", "$", "obj", ")", "?", "get_object_vars", "(", "$", "obj", ")", ":", "$", "obj", ";", "...
Recursively converts object into array Basically get_object_vars, but recursive. @param mixed $obj Object @return array Array of object properties
[ "Recursively", "converts", "object", "into", "array", "Basically", "get_object_vars", "but", "recursive", "." ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/OpauthStrategy.php#L436-L450
train
opauth/opauth
lib/Opauth/OpauthStrategy.php
OpauthStrategy.flattenArray
public static function flattenArray($array, $prefix = null, $results = array()) { foreach ($array as $key => $val) { $name = (empty($prefix)) ? $key : $prefix."[$key]"; if (is_array($val)) { $results = array_merge($results, self::flattenArray($val, $name)); } else { $results[$name] = $val; } } return $results; }
php
public static function flattenArray($array, $prefix = null, $results = array()) { foreach ($array as $key => $val) { $name = (empty($prefix)) ? $key : $prefix."[$key]"; if (is_array($val)) { $results = array_merge($results, self::flattenArray($val, $name)); } else { $results[$name] = $val; } } return $results; }
[ "public", "static", "function", "flattenArray", "(", "$", "array", ",", "$", "prefix", "=", "null", ",", "$", "results", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "name", "=...
Recursively converts multidimensional array into POST-friendly single dimensional array @param array $array Array to be flatten @param string $prefix String to be prefixed to flattened variable name @param array $results Existing array of flattened inputs to be merged upon @return array A single dimensional array with POST-friendly name
[ "Recursively", "converts", "multidimensional", "array", "into", "POST", "-", "friendly", "single", "dimensional", "array" ]
3f979012d0bdf2d447bb02b97f7f7d9f482c77e8
https://github.com/opauth/opauth/blob/3f979012d0bdf2d447bb02b97f7f7d9f482c77e8/lib/Opauth/OpauthStrategy.php#L461-L473
train
sokil/php-isocodes
src/AbstractDatabase.php
AbstractDatabase.loadDatabase
private function loadDatabase(string $databaseFile): void { $isoNumber = $this->getISONumber(); // add gettext domain \bindtextdomain( $isoNumber, $this->getLocalMessagesDirPath() ); \bind_textdomain_codeset( $isoNumber, 'UTF-8' ); // load database from json file $json = \json_decode( file_get_contents($databaseFile), true ); // build cluster index from database $this->clusterIndex = $json[$isoNumber]; }
php
private function loadDatabase(string $databaseFile): void { $isoNumber = $this->getISONumber(); // add gettext domain \bindtextdomain( $isoNumber, $this->getLocalMessagesDirPath() ); \bind_textdomain_codeset( $isoNumber, 'UTF-8' ); // load database from json file $json = \json_decode( file_get_contents($databaseFile), true ); // build cluster index from database $this->clusterIndex = $json[$isoNumber]; }
[ "private", "function", "loadDatabase", "(", "string", "$", "databaseFile", ")", ":", "void", "{", "$", "isoNumber", "=", "$", "this", "->", "getISONumber", "(", ")", ";", "// add gettext domain", "\\", "bindtextdomain", "(", "$", "isoNumber", ",", "$", "this...
Build cluster index for iteration @throws \Exception
[ "Build", "cluster", "index", "for", "iteration" ]
089807eff883a6c3d3c7e9631f411d1ebc1619ec
https://github.com/sokil/php-isocodes/blob/089807eff883a6c3d3c7e9631f411d1ebc1619ec/src/AbstractDatabase.php#L114-L137
train
marcioAlmada/yay
src/ExpressionParser.php
ExpressionParser.validateBitTable
private function validateBitTable(int $flags, string $message) { if (! ($flags && !($flags & ($flags-1)))) throw new \Exception($message); }
php
private function validateBitTable(int $flags, string $message) { if (! ($flags && !($flags & ($flags-1)))) throw new \Exception($message); }
[ "private", "function", "validateBitTable", "(", "int", "$", "flags", ",", "string", "$", "message", ")", "{", "if", "(", "!", "(", "$", "flags", "&&", "!", "(", "$", "flags", "&", "(", "$", "flags", "-", "1", ")", ")", ")", ")", "throw", "new", ...
Checks if at least one and only one single bit is active or fails
[ "Checks", "if", "at", "least", "one", "and", "only", "one", "single", "bit", "is", "active", "or", "fails" ]
490d24dc9a0a64a7c62c219a5a6261c41150ff1c
https://github.com/marcioAlmada/yay/blob/490d24dc9a0a64a7c62c219a5a6261c41150ff1c/src/ExpressionParser.php#L415-L418
train
winzou/state-machine
src/SM/Factory/AbstractFactory.php
AbstractFactory.addConfig
public function addConfig(array $config, $graph = 'default') { if (!isset($config['graph'])) { $config['graph'] = $graph; } if (!isset($config['class'])) { throw new SMException(sprintf( 'Index "class" needed for the state machine configuration of graph "%s"', $config['graph'] )); } $this->configs[] = $config; }
php
public function addConfig(array $config, $graph = 'default') { if (!isset($config['graph'])) { $config['graph'] = $graph; } if (!isset($config['class'])) { throw new SMException(sprintf( 'Index "class" needed for the state machine configuration of graph "%s"', $config['graph'] )); } $this->configs[] = $config; }
[ "public", "function", "addConfig", "(", "array", "$", "config", ",", "$", "graph", "=", "'default'", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'graph'", "]", ")", ")", "{", "$", "config", "[", "'graph'", "]", "=", "$", "graph", ...
Adds a new config @param array $config @param string $graph @throws SMException If the index "class" is not configured
[ "Adds", "a", "new", "config" ]
37f03a316b9a461ed443906e158bab8d358542df
https://github.com/winzou/state-machine/blob/37f03a316b9a461ed443906e158bab8d358542df/src/SM/Factory/AbstractFactory.php#L79-L93
train
winzou/state-machine
src/SM/StateMachine/StateMachine.php
StateMachine.setState
protected function setState($state) { if (!in_array($state, $this->config['states'])) { throw new SMException(sprintf( 'Cannot set the state to "%s" to object "%s" with graph %s because it is not pre-defined.', $state, get_class($this->object), $this->config['graph'] )); } $accessor = new PropertyAccessor(); $accessor->setValue($this->object, $this->config['property_path'], $state); }
php
protected function setState($state) { if (!in_array($state, $this->config['states'])) { throw new SMException(sprintf( 'Cannot set the state to "%s" to object "%s" with graph %s because it is not pre-defined.', $state, get_class($this->object), $this->config['graph'] )); } $accessor = new PropertyAccessor(); $accessor->setValue($this->object, $this->config['property_path'], $state); }
[ "protected", "function", "setState", "(", "$", "state", ")", "{", "if", "(", "!", "in_array", "(", "$", "state", ",", "$", "this", "->", "config", "[", "'states'", "]", ")", ")", "{", "throw", "new", "SMException", "(", "sprintf", "(", "'Cannot set the...
Set a new state to the underlying object @param string $state @throws SMException
[ "Set", "a", "new", "state", "to", "the", "underlying", "object" ]
37f03a316b9a461ed443906e158bab8d358542df
https://github.com/winzou/state-machine/blob/37f03a316b9a461ed443906e158bab8d358542df/src/SM/StateMachine/StateMachine.php#L197-L210
train
winzou/state-machine
src/SM/StateMachine/StateMachine.php
StateMachine.callCallbacks
protected function callCallbacks(TransitionEvent $event, $position) { if (!isset($this->config['callbacks'][$position])) { return true; } $result = true; foreach ($this->config['callbacks'][$position] as &$callback) { if (!$callback instanceof CallbackInterface) { $callback = $this->callbackFactory->get($callback); } $result = call_user_func($callback, $event) && $result; } return $result; }
php
protected function callCallbacks(TransitionEvent $event, $position) { if (!isset($this->config['callbacks'][$position])) { return true; } $result = true; foreach ($this->config['callbacks'][$position] as &$callback) { if (!$callback instanceof CallbackInterface) { $callback = $this->callbackFactory->get($callback); } $result = call_user_func($callback, $event) && $result; } return $result; }
[ "protected", "function", "callCallbacks", "(", "TransitionEvent", "$", "event", ",", "$", "position", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'callbacks'", "]", "[", "$", "position", "]", ")", ")", "{", "return", "tru...
Builds and calls the defined callbacks @param TransitionEvent $event @param string $position @return bool
[ "Builds", "and", "calls", "the", "defined", "callbacks" ]
37f03a316b9a461ed443906e158bab8d358542df
https://github.com/winzou/state-machine/blob/37f03a316b9a461ed443906e158bab8d358542df/src/SM/StateMachine/StateMachine.php#L219-L234
train
winzou/state-machine
src/SM/Callback/CascadeTransitionCallback.php
CascadeTransitionCallback.apply
public function apply($objects, TransitionEvent $event, $transition = null, $graph = null, $soft = true) { if (!is_array($objects) && !$objects instanceof \Traversable) { $objects = array($objects); } if (null === $transition) { $transition = $event->getTransition(); } if (null === $graph) { $graph = $event->getStateMachine()->getGraph(); } foreach ($objects as $object) { $this->factory->get($object, $graph)->apply($transition, $soft); } }
php
public function apply($objects, TransitionEvent $event, $transition = null, $graph = null, $soft = true) { if (!is_array($objects) && !$objects instanceof \Traversable) { $objects = array($objects); } if (null === $transition) { $transition = $event->getTransition(); } if (null === $graph) { $graph = $event->getStateMachine()->getGraph(); } foreach ($objects as $object) { $this->factory->get($object, $graph)->apply($transition, $soft); } }
[ "public", "function", "apply", "(", "$", "objects", ",", "TransitionEvent", "$", "event", ",", "$", "transition", "=", "null", ",", "$", "graph", "=", "null", ",", "$", "soft", "=", "true", ")", "{", "if", "(", "!", "is_array", "(", "$", "objects", ...
Apply a transition to the object that has just undergone a transition @param \Traversable|array $objects Object or array|traversable of objects to apply the transition on @param TransitionEvent $event Transition event @param string|null $transition Transition that is to be applied (if null, same as the trigger) @param string|null $graph Graph on which the new transition will apply (if null, same as the trigger) @param bool $soft If true, check if it can apply the transition first (no Exception thrown)
[ "Apply", "a", "transition", "to", "the", "object", "that", "has", "just", "undergone", "a", "transition" ]
37f03a316b9a461ed443906e158bab8d358542df
https://github.com/winzou/state-machine/blob/37f03a316b9a461ed443906e158bab8d358542df/src/SM/Callback/CascadeTransitionCallback.php#L46-L63
train
ausi/slug-generator
src/SlugOptions.php
SlugOptions.getIterator
public function getIterator(): \Traversable { $options = []; foreach ($this->setOptions as $option => $value) { $options[$option] = $this->{'get'.ucfirst($option)}(); } return new \ArrayIterator($options); }
php
public function getIterator(): \Traversable { $options = []; foreach ($this->setOptions as $option => $value) { $options[$option] = $this->{'get'.ucfirst($option)}(); } return new \ArrayIterator($options); }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Traversable", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "setOptions", "as", "$", "option", "=>", "$", "value", ")", "{", "$", "options", "[", "$", "option", ...
Get an iterator for all options that have been explicitly set. {@inheritdoc}
[ "Get", "an", "iterator", "for", "all", "options", "that", "have", "been", "explicitly", "set", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugOptions.php#L77-L86
train
ausi/slug-generator
src/SlugOptions.php
SlugOptions.merge
public function merge(iterable $options): self { $merged = clone $this; foreach ($options as $option => $value) { $this->assertOptionName($option); $merged->{'set'.ucfirst($option)}($value); } return $merged; }
php
public function merge(iterable $options): self { $merged = clone $this; foreach ($options as $option => $value) { $this->assertOptionName($option); $merged->{'set'.ucfirst($option)}($value); } return $merged; }
[ "public", "function", "merge", "(", "iterable", "$", "options", ")", ":", "self", "{", "$", "merged", "=", "clone", "$", "this", ";", "foreach", "(", "$", "options", "as", "$", "option", "=>", "$", "value", ")", "{", "$", "this", "->", "assertOptionN...
Merge the options with and return a new options object. @param iterable $options SlugOptions object or options array @return static
[ "Merge", "the", "options", "with", "and", "return", "a", "new", "options", "object", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugOptions.php#L95-L105
train
ausi/slug-generator
src/SlugOptions.php
SlugOptions.setPreTransforms
public function setPreTransforms(iterable $transforms): self { if (!is_array($transforms)) { $transforms = iterator_to_array($transforms, false); } foreach (array_reverse($transforms) as $transform) { $this->assertTransform($transform); $this->addTransform($transform); } return $this; }
php
public function setPreTransforms(iterable $transforms): self { if (!is_array($transforms)) { $transforms = iterator_to_array($transforms, false); } foreach (array_reverse($transforms) as $transform) { $this->assertTransform($transform); $this->addTransform($transform); } return $this; }
[ "public", "function", "setPreTransforms", "(", "iterable", "$", "transforms", ")", ":", "self", "{", "if", "(", "!", "is_array", "(", "$", "transforms", ")", ")", "{", "$", "transforms", "=", "iterator_to_array", "(", "$", "transforms", ",", "false", ")", ...
Add transforms before existing ones. @param iterable $transforms List of rules or rulesets to be used by the Transliterator, like `Lower`, `ASCII` or `a > b; c > d` @return static
[ "Add", "transforms", "before", "existing", "ones", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugOptions.php#L266-L278
train
ausi/slug-generator
src/SlugOptions.php
SlugOptions.setPostTransforms
public function setPostTransforms(iterable $transforms): self { foreach ($transforms as $transform) { $this->assertTransform($transform); $this->addTransform($transform, false); } return $this; }
php
public function setPostTransforms(iterable $transforms): self { foreach ($transforms as $transform) { $this->assertTransform($transform); $this->addTransform($transform, false); } return $this; }
[ "public", "function", "setPostTransforms", "(", "iterable", "$", "transforms", ")", ":", "self", "{", "foreach", "(", "$", "transforms", "as", "$", "transform", ")", "{", "$", "this", "->", "assertTransform", "(", "$", "transform", ")", ";", "$", "this", ...
Add transforms after existing ones. @param iterable $transforms List of rules or rulesets to be used by the Transliterator, like `Lower`, `ASCII` or `a > b; c > d` @return static
[ "Add", "transforms", "after", "existing", "ones", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugOptions.php#L288-L296
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.removeIgnored
private function removeIgnored(string $text, string $ignore): string { if ($ignore === '') { return $text; } return preg_replace('(['.$ignore.'])us', '', $text); }
php
private function removeIgnored(string $text, string $ignore): string { if ($ignore === '') { return $text; } return preg_replace('(['.$ignore.'])us', '', $text); }
[ "private", "function", "removeIgnored", "(", "string", "$", "text", ",", "string", "$", "ignore", ")", ":", "string", "{", "if", "(", "$", "ignore", "===", "''", ")", "{", "return", "$", "text", ";", "}", "return", "preg_replace", "(", "'(['", ".", "...
Remove ignored characters from text. @param string $text @param string $ignore @return string
[ "Remove", "ignored", "characters", "from", "text", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L97-L104
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.replaceWithDelimiter
private function replaceWithDelimiter(string $text, string $valid, string $delimiter): string { $quoted = preg_quote($delimiter); // Replace all invalid characters with a single delimiter $text = preg_replace( '((?:[^'.$valid.']|'.$quoted.')+)us', $delimiter, $text ); // Remove delimiters from the beginning and the end $text = preg_replace('(^(?:'.$quoted.')+|(?:'.$quoted.')+$)us', '', $text); return $text; }
php
private function replaceWithDelimiter(string $text, string $valid, string $delimiter): string { $quoted = preg_quote($delimiter); // Replace all invalid characters with a single delimiter $text = preg_replace( '((?:[^'.$valid.']|'.$quoted.')+)us', $delimiter, $text ); // Remove delimiters from the beginning and the end $text = preg_replace('(^(?:'.$quoted.')+|(?:'.$quoted.')+$)us', '', $text); return $text; }
[ "private", "function", "replaceWithDelimiter", "(", "string", "$", "text", ",", "string", "$", "valid", ",", "string", "$", "delimiter", ")", ":", "string", "{", "$", "quoted", "=", "preg_quote", "(", "$", "delimiter", ")", ";", "// Replace all invalid charact...
Replace all invalid characters with a delimiter and strip the delimiter from the beginning and the end. @param string $text @param string $valid @param string $delimiter @return string
[ "Replace", "all", "invalid", "characters", "with", "a", "delimiter", "and", "strip", "the", "delimiter", "from", "the", "beginning", "and", "the", "end", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L116-L131
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.transform
private function transform(string $text, string $valid, iterable $transforms, string $locale): string { $regexRegular = '([^'.$valid.']+)us'; $regexCase = $this->createCaseRegex($valid); foreach ($transforms as $transform) { $regex = ($transform === 'Lower' || $transform === 'Upper') ? $regexCase : $regexRegular; if ($locale) { $text = $this->applyTransformRule($text, $transform, $locale, $regex); } $text = $this->applyTransformRule($text, $transform, '', $regex); } return $text; }
php
private function transform(string $text, string $valid, iterable $transforms, string $locale): string { $regexRegular = '([^'.$valid.']+)us'; $regexCase = $this->createCaseRegex($valid); foreach ($transforms as $transform) { $regex = ($transform === 'Lower' || $transform === 'Upper') ? $regexCase : $regexRegular; if ($locale) { $text = $this->applyTransformRule($text, $transform, $locale, $regex); } $text = $this->applyTransformRule($text, $transform, '', $regex); } return $text; }
[ "private", "function", "transform", "(", "string", "$", "text", ",", "string", "$", "valid", ",", "iterable", "$", "transforms", ",", "string", "$", "locale", ")", ":", "string", "{", "$", "regexRegular", "=", "'([^'", ".", "$", "valid", ".", "']+)us'", ...
Apply all transforms with the specified locale to the invalid parts of the text. @param string $text @param string $valid @param iterable $transforms @param string $locale @return string
[ "Apply", "all", "transforms", "with", "the", "specified", "locale", "to", "the", "invalid", "parts", "of", "the", "text", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L144-L158
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.applyTransformRule
private function applyTransformRule(string $text, string $rule, string $locale, string $regex): string { $transliterator = $this->getTransliterator($rule, $locale); $newText = ''; $offset = 0; foreach ($this->getRanges($text, $regex) as $range) { $newText .= substr($text, $offset, $range[0] - $offset); $newText .= $this->transformWithContext($transliterator, $text, $range[0], $range[1]); $offset = $range[0] + $range[1]; } $newText .= substr($text, $offset); return $newText; }
php
private function applyTransformRule(string $text, string $rule, string $locale, string $regex): string { $transliterator = $this->getTransliterator($rule, $locale); $newText = ''; $offset = 0; foreach ($this->getRanges($text, $regex) as $range) { $newText .= substr($text, $offset, $range[0] - $offset); $newText .= $this->transformWithContext($transliterator, $text, $range[0], $range[1]); $offset = $range[0] + $range[1]; } $newText .= substr($text, $offset); return $newText; }
[ "private", "function", "applyTransformRule", "(", "string", "$", "text", ",", "string", "$", "rule", ",", "string", "$", "locale", ",", "string", "$", "regex", ")", ":", "string", "{", "$", "transliterator", "=", "$", "this", "->", "getTransliterator", "("...
Apply a transform rule with the specified locale to the parts that match the regular expression. @param string $text @param string $rule @param string $locale @param string $regex @return string
[ "Apply", "a", "transform", "rule", "with", "the", "specified", "locale", "to", "the", "parts", "that", "match", "the", "regular", "expression", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L195-L210
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.transformWithContext
private function transformWithContext(\Transliterator $transliterator, string $text, int $index, int $length): string { $left = mb_substr(substr($text, 0, $index), -1, null, 'UTF-8'); $right = mb_substr(substr($text, $index + $length), 0, 1, 'UTF-8'); $leftLength = strlen($left); $rightLength = strlen($right); $text = substr($text, $index, $length); $transformed = $transliterator->transliterate($left.$text.$right); if ( (!$leftLength || strncmp($transformed, $left, $leftLength) === 0) && (!$rightLength || substr_compare($transformed, $right, -$rightLength) === 0) ) { return substr($transformed, $leftLength, $rightLength ? -$rightLength : strlen($transformed)); } else { return $transliterator->transliterate($text); } }
php
private function transformWithContext(\Transliterator $transliterator, string $text, int $index, int $length): string { $left = mb_substr(substr($text, 0, $index), -1, null, 'UTF-8'); $right = mb_substr(substr($text, $index + $length), 0, 1, 'UTF-8'); $leftLength = strlen($left); $rightLength = strlen($right); $text = substr($text, $index, $length); $transformed = $transliterator->transliterate($left.$text.$right); if ( (!$leftLength || strncmp($transformed, $left, $leftLength) === 0) && (!$rightLength || substr_compare($transformed, $right, -$rightLength) === 0) ) { return substr($transformed, $leftLength, $rightLength ? -$rightLength : strlen($transformed)); } else { return $transliterator->transliterate($text); } }
[ "private", "function", "transformWithContext", "(", "\\", "Transliterator", "$", "transliterator", ",", "string", "$", "text", ",", "int", "$", "index", ",", "int", "$", "length", ")", ":", "string", "{", "$", "left", "=", "mb_substr", "(", "substr", "(", ...
Transform the text at the specified position and use a one character context if possible. `Transliterator::transliterate()` doesn’t yet support context parameters of the underlying ICU implementation. Because of that, we add the context before the transform and check afterwards that the context didn’t change. @param \Transliterator $transliterator @param string $text @param int $index @param int $length @return string
[ "Transform", "the", "text", "at", "the", "specified", "position", "and", "use", "a", "one", "character", "context", "if", "possible", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L228-L248
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.getTransliterator
private function getTransliterator(string $rule, string $locale): \Transliterator { $key = $rule.'|'.$locale; if (!isset($this->transliterators[$key])) { $this->transliterators[$key] = $this->findMatchingTransliterator($rule, $locale); } return $this->transliterators[$key]; }
php
private function getTransliterator(string $rule, string $locale): \Transliterator { $key = $rule.'|'.$locale; if (!isset($this->transliterators[$key])) { $this->transliterators[$key] = $this->findMatchingTransliterator($rule, $locale); } return $this->transliterators[$key]; }
[ "private", "function", "getTransliterator", "(", "string", "$", "rule", ",", "string", "$", "locale", ")", ":", "\\", "Transliterator", "{", "$", "key", "=", "$", "rule", ".", "'|'", ".", "$", "locale", ";", "if", "(", "!", "isset", "(", "$", "this",...
Get the Transliterator for the specified transform rule and locale. @param string $rule @param string $locale @return \Transliterator
[ "Get", "the", "Transliterator", "for", "the", "specified", "transform", "rule", "and", "locale", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L258-L267
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.findMatchingTransliterator
private function findMatchingTransliterator(string $rule, string $locale): \Transliterator { $candidates = [ 'Latin-'.$rule, $rule, ]; if ($locale) { array_unshift( $candidates, $locale.'-'.$rule, \Locale::getPrimaryLanguage($locale).'-'.$rule ); } $errorLevel = ini_set('intl.error_level', '0'); $useExceptions = ini_set('intl.use_exceptions', '0'); try { foreach ($candidates as $candidate) { $candidate = $this->fixTransliteratorRule($candidate); if ($transliterator = \Transliterator::create($candidate)) { return $transliterator; } if ($transliterator = \Transliterator::createFromRules($candidate)) { return $transliterator; } } } finally { ini_set('intl.error_level', $errorLevel); ini_set('intl.use_exceptions', $useExceptions); } throw new \InvalidArgumentException( sprintf('No Transliterator transform rule found for "%s" with locale "%s".', $rule, $locale) ); }
php
private function findMatchingTransliterator(string $rule, string $locale): \Transliterator { $candidates = [ 'Latin-'.$rule, $rule, ]; if ($locale) { array_unshift( $candidates, $locale.'-'.$rule, \Locale::getPrimaryLanguage($locale).'-'.$rule ); } $errorLevel = ini_set('intl.error_level', '0'); $useExceptions = ini_set('intl.use_exceptions', '0'); try { foreach ($candidates as $candidate) { $candidate = $this->fixTransliteratorRule($candidate); if ($transliterator = \Transliterator::create($candidate)) { return $transliterator; } if ($transliterator = \Transliterator::createFromRules($candidate)) { return $transliterator; } } } finally { ini_set('intl.error_level', $errorLevel); ini_set('intl.use_exceptions', $useExceptions); } throw new \InvalidArgumentException( sprintf('No Transliterator transform rule found for "%s" with locale "%s".', $rule, $locale) ); }
[ "private", "function", "findMatchingTransliterator", "(", "string", "$", "rule", ",", "string", "$", "locale", ")", ":", "\\", "Transliterator", "{", "$", "candidates", "=", "[", "'Latin-'", ".", "$", "rule", ",", "$", "rule", ",", "]", ";", "if", "(", ...
Find the best matching Transliterator for the specified transform rule and locale. @param string $rule @param string $locale @return \Transliterator
[ "Find", "the", "best", "matching", "Transliterator", "for", "the", "specified", "transform", "rule", "and", "locale", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L278-L314
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.fixTransliteratorRule
private function fixTransliteratorRule(string $rule): string { static $latinAsciiFix; static $deAsciiFix; if ($latinAsciiFix === null) { $latinAsciiFix = \in_array('Latin-ASCII', \Transliterator::listIDs(), true) ? false : file_get_contents(__DIR__.'/Resources/Latin-ASCII.txt') ; } if ($deAsciiFix === null) { $deAsciiFix = \in_array('de-ASCII', \Transliterator::listIDs(), true) ? false : file_get_contents(__DIR__.'/Resources/de-ASCII.txt') ; if ($latinAsciiFix) { $deAsciiFix = str_replace('::Latin-ASCII;', $latinAsciiFix, $deAsciiFix); } } // Add the de-ASCII transform if a CLDR version lower than 32.0 is used. if ($deAsciiFix && $rule === 'de-ASCII') { return $deAsciiFix; } // Add the Latin-ASCII transform if a CLDR version lower than 1.9 is used. if ($latinAsciiFix && $rule === 'Latin-ASCII') { return $latinAsciiFix; } return $rule; }
php
private function fixTransliteratorRule(string $rule): string { static $latinAsciiFix; static $deAsciiFix; if ($latinAsciiFix === null) { $latinAsciiFix = \in_array('Latin-ASCII', \Transliterator::listIDs(), true) ? false : file_get_contents(__DIR__.'/Resources/Latin-ASCII.txt') ; } if ($deAsciiFix === null) { $deAsciiFix = \in_array('de-ASCII', \Transliterator::listIDs(), true) ? false : file_get_contents(__DIR__.'/Resources/de-ASCII.txt') ; if ($latinAsciiFix) { $deAsciiFix = str_replace('::Latin-ASCII;', $latinAsciiFix, $deAsciiFix); } } // Add the de-ASCII transform if a CLDR version lower than 32.0 is used. if ($deAsciiFix && $rule === 'de-ASCII') { return $deAsciiFix; } // Add the Latin-ASCII transform if a CLDR version lower than 1.9 is used. if ($latinAsciiFix && $rule === 'Latin-ASCII') { return $latinAsciiFix; } return $rule; }
[ "private", "function", "fixTransliteratorRule", "(", "string", "$", "rule", ")", ":", "string", "{", "static", "$", "latinAsciiFix", ";", "static", "$", "deAsciiFix", ";", "if", "(", "$", "latinAsciiFix", "===", "null", ")", "{", "$", "latinAsciiFix", "=", ...
Apply fixes to a transform rule for older versions of the Intl extension. @param string $rule @return string
[ "Apply", "fixes", "to", "a", "transform", "rule", "for", "older", "versions", "of", "the", "Intl", "extension", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L323-L356
train
ausi/slug-generator
src/SlugGenerator.php
SlugGenerator.getRanges
private function getRanges(string $text, string $regex): array { preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE); $ranges = array_map(function ($match) { return [$match[1], strlen($match[0])]; }, $matches[0]); return $ranges; }
php
private function getRanges(string $text, string $regex): array { preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE); $ranges = array_map(function ($match) { return [$match[1], strlen($match[0])]; }, $matches[0]); return $ranges; }
[ "private", "function", "getRanges", "(", "string", "$", "text", ",", "string", "$", "regex", ")", ":", "array", "{", "preg_match_all", "(", "$", "regex", ",", "$", "text", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ";", "$", "ranges", "=", "...
Get all matching ranges. @param string $text @param string $regex @return array Array of range arrays, each consisting of index and length
[ "Get", "all", "matching", "ranges", "." ]
87a661ab766fa5bca78629fc223307a66e61c605
https://github.com/ausi/slug-generator/blob/87a661ab766fa5bca78629fc223307a66e61c605/src/SlugGenerator.php#L366-L375
train
helios-ag/FMElfinderBundle
src/Loader/ElFinderLoader.php
ElFinderLoader.initBridge
public function initBridge($instance) { $this->setInstance($instance); $this->config = $this->configure(); $this->bridge = new ElFinderBridge($this->config); if ($this->session) { $this->bridge->setSession($this->session); } }
php
public function initBridge($instance) { $this->setInstance($instance); $this->config = $this->configure(); $this->bridge = new ElFinderBridge($this->config); if ($this->session) { $this->bridge->setSession($this->session); } }
[ "public", "function", "initBridge", "(", "$", "instance", ")", "{", "$", "this", "->", "setInstance", "(", "$", "instance", ")", ";", "$", "this", "->", "config", "=", "$", "this", "->", "configure", "(", ")", ";", "$", "this", "->", "bridge", "=", ...
Configure the Bridge to ElFinder. @var string @throws \Exception
[ "Configure", "the", "Bridge", "to", "ElFinder", "." ]
eb51696c7e72c7c53ffa26850faca20402fa9236
https://github.com/helios-ag/FMElfinderBundle/blob/eb51696c7e72c7c53ffa26850faca20402fa9236/src/Loader/ElFinderLoader.php#L62-L70
train
helios-ag/FMElfinderBundle
src/Loader/ElFinderLoader.php
ElFinderLoader.load
public function load(Request $request) { $connector = new ElFinderConnector($this->bridge); if ($this->config['corsSupport']) { return $connector->execute($request->query->all()); } else { $connector->run($request->query->all()); } }
php
public function load(Request $request) { $connector = new ElFinderConnector($this->bridge); if ($this->config['corsSupport']) { return $connector->execute($request->query->all()); } else { $connector->run($request->query->all()); } }
[ "public", "function", "load", "(", "Request", "$", "request", ")", "{", "$", "connector", "=", "new", "ElFinderConnector", "(", "$", "this", "->", "bridge", ")", ";", "if", "(", "$", "this", "->", "config", "[", "'corsSupport'", "]", ")", "{", "return"...
Starts ElFinder. @var Request @return void|array
[ "Starts", "ElFinder", "." ]
eb51696c7e72c7c53ffa26850faca20402fa9236
https://github.com/helios-ag/FMElfinderBundle/blob/eb51696c7e72c7c53ffa26850faca20402fa9236/src/Loader/ElFinderLoader.php#L79-L88
train
helios-ag/FMElfinderBundle
src/Loader/ElFinderLoader.php
ElFinderLoader.encode
public function encode($path) { $aPathEncoded = array(); $volumes = $this->bridge->getVolumes(); foreach ($volumes as $hashId => $volume) { $aPathEncoded[$hashId] = $volume->getPath($path); } if (1 == count($aPathEncoded)) { return array_values($aPathEncoded)[0]; } elseif (count($aPathEncoded) > 1) { return $aPathEncoded; } else { return false; } }
php
public function encode($path) { $aPathEncoded = array(); $volumes = $this->bridge->getVolumes(); foreach ($volumes as $hashId => $volume) { $aPathEncoded[$hashId] = $volume->getPath($path); } if (1 == count($aPathEncoded)) { return array_values($aPathEncoded)[0]; } elseif (count($aPathEncoded) > 1) { return $aPathEncoded; } else { return false; } }
[ "public", "function", "encode", "(", "$", "path", ")", "{", "$", "aPathEncoded", "=", "array", "(", ")", ";", "$", "volumes", "=", "$", "this", "->", "bridge", "->", "getVolumes", "(", ")", ";", "foreach", "(", "$", "volumes", "as", "$", "hashId", ...
Encode path into hash. @param string $path @return mixed
[ "Encode", "path", "into", "hash", "." ]
eb51696c7e72c7c53ffa26850faca20402fa9236
https://github.com/helios-ag/FMElfinderBundle/blob/eb51696c7e72c7c53ffa26850faca20402fa9236/src/Loader/ElFinderLoader.php#L113-L130
train
helios-ag/FMElfinderBundle
src/Loader/ElFinderLoader.php
ElFinderLoader.decode
public function decode($hash) { $volume = $this->bridge->getVolume($hash); /* @var $volume \elFinderVolumeDriver */ return (!empty($volume)) ? $volume->getPath($hash) : false; }
php
public function decode($hash) { $volume = $this->bridge->getVolume($hash); /* @var $volume \elFinderVolumeDriver */ return (!empty($volume)) ? $volume->getPath($hash) : false; }
[ "public", "function", "decode", "(", "$", "hash", ")", "{", "$", "volume", "=", "$", "this", "->", "bridge", "->", "getVolume", "(", "$", "hash", ")", ";", "/* @var $volume \\elFinderVolumeDriver */", "return", "(", "!", "empty", "(", "$", "volume", ")", ...
Decode path from hash. @param string $hash @return string
[ "Decode", "path", "from", "hash", "." ]
eb51696c7e72c7c53ffa26850faca20402fa9236
https://github.com/helios-ag/FMElfinderBundle/blob/eb51696c7e72c7c53ffa26850faca20402fa9236/src/Loader/ElFinderLoader.php#L139-L145
train
helios-ag/FMElfinderBundle
src/Event/ElFinderPreExecutionEvent.php
ElFinderPreExecutionEvent.subRequest
public function subRequest(array $path, array $query) { $path['_controller'] = 'FMElfinderBundle:ElFinder:load'; $subRequest = $this->request->duplicate($query, null, $path); return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); }
php
public function subRequest(array $path, array $query) { $path['_controller'] = 'FMElfinderBundle:ElFinder:load'; $subRequest = $this->request->duplicate($query, null, $path); return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); }
[ "public", "function", "subRequest", "(", "array", "$", "path", ",", "array", "$", "query", ")", "{", "$", "path", "[", "'_controller'", "]", "=", "'FMElfinderBundle:ElFinder:load'", ";", "$", "subRequest", "=", "$", "this", "->", "request", "->", "duplicate"...
Makes a sub request to elFinder. Function based on 'forward' function from Symfony controllers. @see https://github.com/symfony/symfony/blob/2.5/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @param array $path An array of path parameters @param array $query An array of query parameters @return Symfony\Component\HttpFoundation\Response A Response instance
[ "Makes", "a", "sub", "request", "to", "elFinder", ".", "Function", "based", "on", "forward", "function", "from", "Symfony", "controllers", "." ]
eb51696c7e72c7c53ffa26850faca20402fa9236
https://github.com/helios-ag/FMElfinderBundle/blob/eb51696c7e72c7c53ffa26850faca20402fa9236/src/Event/ElFinderPreExecutionEvent.php#L68-L74
train
helios-ag/FMElfinderBundle
src/Controller/ElFinderController.php
ElFinderController.loadAction
public function loadAction(Request $request, $instance, $homeFolder) { $loader = $this->get('fm_elfinder.loader'); $loader->initBridge($instance); // builds up the Bridge object for the loader with the given instance if ($loader instanceof ElFinderLoader) { $loader->setSession(new ElFinderSession($this->get('session'))); } $httpKernel = $this->get('http_kernel'); $preExecutionEvent = new ElFinderPreExecutionEvent($request, $httpKernel, $instance, $homeFolder); $this->get('event_dispatcher')->dispatch(ElFinderEvents::PRE_EXECUTION, $preExecutionEvent); $result = $loader->load($request); // the instance is already set $postExecutionEvent = new ElFinderPostExecutionEvent($request, $httpKernel, $instance, $homeFolder, $result); $this->get('event_dispatcher')->dispatch(ElFinderEvents::POST_EXECUTION, $postExecutionEvent); // returning result (who may have been modified by a post execution event listener) return new JsonResponse($postExecutionEvent->getResult()); }
php
public function loadAction(Request $request, $instance, $homeFolder) { $loader = $this->get('fm_elfinder.loader'); $loader->initBridge($instance); // builds up the Bridge object for the loader with the given instance if ($loader instanceof ElFinderLoader) { $loader->setSession(new ElFinderSession($this->get('session'))); } $httpKernel = $this->get('http_kernel'); $preExecutionEvent = new ElFinderPreExecutionEvent($request, $httpKernel, $instance, $homeFolder); $this->get('event_dispatcher')->dispatch(ElFinderEvents::PRE_EXECUTION, $preExecutionEvent); $result = $loader->load($request); // the instance is already set $postExecutionEvent = new ElFinderPostExecutionEvent($request, $httpKernel, $instance, $homeFolder, $result); $this->get('event_dispatcher')->dispatch(ElFinderEvents::POST_EXECUTION, $postExecutionEvent); // returning result (who may have been modified by a post execution event listener) return new JsonResponse($postExecutionEvent->getResult()); }
[ "public", "function", "loadAction", "(", "Request", "$", "request", ",", "$", "instance", ",", "$", "homeFolder", ")", "{", "$", "loader", "=", "$", "this", "->", "get", "(", "'fm_elfinder.loader'", ")", ";", "$", "loader", "->", "initBridge", "(", "$", ...
Loader service init. @param Request $request @param string $instance @param string $homeFolder @return JsonResponse/void
[ "Loader", "service", "init", "." ]
eb51696c7e72c7c53ffa26850faca20402fa9236
https://github.com/helios-ag/FMElfinderBundle/blob/eb51696c7e72c7c53ffa26850faca20402fa9236/src/Controller/ElFinderController.php#L220-L238
train