repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeProxyClasses
public static function initializeProxyClasses(Bootstrap $bootstrap) { $objectConfigurationCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Configuration'); if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === true) { return; } $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow'); // The compile sub command will only be run if the code cache is completely empty: OpcodeCacheHelper::clearAllActive(FLOW_PATH_CONFIGURATION); OpcodeCacheHelper::clearAllActive(FLOW_PATH_DATA); self::executeCommand('neos.flow:core:compile', $settings); if (isset($settings['persistence']['doctrine']['enable']) && $settings['persistence']['doctrine']['enable'] === true) { self::compileDoctrineProxies($bootstrap); } // As the available proxy classes were already loaded earlier we need to refresh them if the proxies where recompiled. $proxyClassLoader = $bootstrap->getEarlyInstance(ProxyClassLoader::class); $proxyClassLoader->initializeAvailableProxyClasses($bootstrap->getContext()); // Check if code was updated, if not something went wrong if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === false) { if (DIRECTORY_SEPARATOR === '/') { $phpBinaryPathAndFilename = '"' . escapeshellcmd(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])) . '"'; } else { $phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])); } $command = sprintf('%s -c %s -v', $phpBinaryPathAndFilename, escapeshellarg(php_ini_loaded_file())); exec($command, $output, $result); if ($result !== 0) { if (!file_exists($phpBinaryPathAndFilename)) { throw new FlowException(sprintf('It seems like the PHP binary "%s" cannot be executed by Flow. Set the correct path to the PHP executable in Configuration/Settings.yaml, setting Neos.Flow.core.phpBinaryPathAndFilename.', $settings['core']['phpBinaryPathAndFilename']), 1315561483); } throw new FlowException(sprintf('It seems like the PHP binary "%s" cannot be executed by Flow. The command executed was "%s" and returned the following: %s', $settings['core']['phpBinaryPathAndFilename'], $command, PHP_EOL . implode(PHP_EOL, $output)), 1354704332); } echo PHP_EOL . 'Flow: The compile run failed. Please check the error output or system log for more information.' . PHP_EOL; exit(1); } }
php
public static function initializeProxyClasses(Bootstrap $bootstrap) { $objectConfigurationCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Configuration'); if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === true) { return; } $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow'); // The compile sub command will only be run if the code cache is completely empty: OpcodeCacheHelper::clearAllActive(FLOW_PATH_CONFIGURATION); OpcodeCacheHelper::clearAllActive(FLOW_PATH_DATA); self::executeCommand('neos.flow:core:compile', $settings); if (isset($settings['persistence']['doctrine']['enable']) && $settings['persistence']['doctrine']['enable'] === true) { self::compileDoctrineProxies($bootstrap); } // As the available proxy classes were already loaded earlier we need to refresh them if the proxies where recompiled. $proxyClassLoader = $bootstrap->getEarlyInstance(ProxyClassLoader::class); $proxyClassLoader->initializeAvailableProxyClasses($bootstrap->getContext()); // Check if code was updated, if not something went wrong if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === false) { if (DIRECTORY_SEPARATOR === '/') { $phpBinaryPathAndFilename = '"' . escapeshellcmd(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])) . '"'; } else { $phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])); } $command = sprintf('%s -c %s -v', $phpBinaryPathAndFilename, escapeshellarg(php_ini_loaded_file())); exec($command, $output, $result); if ($result !== 0) { if (!file_exists($phpBinaryPathAndFilename)) { throw new FlowException(sprintf('It seems like the PHP binary "%s" cannot be executed by Flow. Set the correct path to the PHP executable in Configuration/Settings.yaml, setting Neos.Flow.core.phpBinaryPathAndFilename.', $settings['core']['phpBinaryPathAndFilename']), 1315561483); } throw new FlowException(sprintf('It seems like the PHP binary "%s" cannot be executed by Flow. The command executed was "%s" and returned the following: %s', $settings['core']['phpBinaryPathAndFilename'], $command, PHP_EOL . implode(PHP_EOL, $output)), 1354704332); } echo PHP_EOL . 'Flow: The compile run failed. Please check the error output or system log for more information.' . PHP_EOL; exit(1); } }
[ "public", "static", "function", "initializeProxyClasses", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "objectConfigurationCache", "=", "$", "bootstrap", "->", "getEarlyInstance", "(", "CacheManager", "::", "class", ")", "->", "getCache", "(", "'Flow_Object_Co...
Runs the compile step if necessary @param Bootstrap $bootstrap @return void @throws FlowException
[ "Runs", "the", "compile", "step", "if", "necessary" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L390-L430
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeObjectManagerCompileTimeCreate
public static function initializeObjectManagerCompileTimeCreate(Bootstrap $bootstrap) { $objectManager = new CompileTimeObjectManager($bootstrap->getContext()); $bootstrap->setEarlyInstance(ObjectManagerInterface::class, $objectManager); $signalSlotDispatcher = $bootstrap->getEarlyInstance(Dispatcher::class); $signalSlotDispatcher->injectObjectManager($objectManager); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } Bootstrap::$staticObjectManager = $objectManager; }
php
public static function initializeObjectManagerCompileTimeCreate(Bootstrap $bootstrap) { $objectManager = new CompileTimeObjectManager($bootstrap->getContext()); $bootstrap->setEarlyInstance(ObjectManagerInterface::class, $objectManager); $signalSlotDispatcher = $bootstrap->getEarlyInstance(Dispatcher::class); $signalSlotDispatcher->injectObjectManager($objectManager); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } Bootstrap::$staticObjectManager = $objectManager; }
[ "public", "static", "function", "initializeObjectManagerCompileTimeCreate", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "objectManager", "=", "new", "CompileTimeObjectManager", "(", "$", "bootstrap", "->", "getContext", "(", ")", ")", ";", "$", "bootstrap", ...
Initializes the Compiletime Object Manager (phase 1) @param Bootstrap $bootstrap
[ "Initializes", "the", "Compiletime", "Object", "Manager", "(", "phase", "1", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L450-L463
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeObjectManagerCompileTimeFinalize
public static function initializeObjectManagerCompileTimeFinalize(Bootstrap $bootstrap) { /** @var CompileTimeObjectManager $objectManager */ $objectManager = $bootstrap->getObjectManager(); $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $reflectionService = $objectManager->get(ReflectionService::class); $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class); $logger = $bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger'); $packageManager = $bootstrap->getEarlyInstance(PackageManager::class); $objectManager->injectAllSettings($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS)); $objectManager->injectReflectionService($reflectionService); $objectManager->injectConfigurationManager($configurationManager); $objectManager->injectConfigurationCache($cacheManager->getCache('Flow_Object_Configuration')); $objectManager->injectLogger($logger); $objectManager->initialize($packageManager->getAvailablePackages()); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } Debugger::injectObjectManager($objectManager); }
php
public static function initializeObjectManagerCompileTimeFinalize(Bootstrap $bootstrap) { /** @var CompileTimeObjectManager $objectManager */ $objectManager = $bootstrap->getObjectManager(); $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $reflectionService = $objectManager->get(ReflectionService::class); $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class); $logger = $bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger'); $packageManager = $bootstrap->getEarlyInstance(PackageManager::class); $objectManager->injectAllSettings($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS)); $objectManager->injectReflectionService($reflectionService); $objectManager->injectConfigurationManager($configurationManager); $objectManager->injectConfigurationCache($cacheManager->getCache('Flow_Object_Configuration')); $objectManager->injectLogger($logger); $objectManager->initialize($packageManager->getAvailablePackages()); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } Debugger::injectObjectManager($objectManager); }
[ "public", "static", "function", "initializeObjectManagerCompileTimeFinalize", "(", "Bootstrap", "$", "bootstrap", ")", "{", "/** @var CompileTimeObjectManager $objectManager */", "$", "objectManager", "=", "$", "bootstrap", "->", "getObjectManager", "(", ")", ";", "$", "c...
Initializes the Compiletime Object Manager (phase 2) @param Bootstrap $bootstrap @return void
[ "Initializes", "the", "Compiletime", "Object", "Manager", "(", "phase", "2", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L471-L493
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeObjectManager
public static function initializeObjectManager(Bootstrap $bootstrap) { $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $objectConfigurationCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Configuration'); $objectManager = new ObjectManager($bootstrap->getContext()); $objectManager->injectAllSettings($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS)); $objectManager->setObjects($objectConfigurationCache->get('objects')); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } $objectManager->get(Dispatcher::class)->injectObjectManager($objectManager); Debugger::injectObjectManager($objectManager); $bootstrap->setEarlyInstance(ObjectManagerInterface::class, $objectManager); Bootstrap::$staticObjectManager = $objectManager; }
php
public static function initializeObjectManager(Bootstrap $bootstrap) { $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $objectConfigurationCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Configuration'); $objectManager = new ObjectManager($bootstrap->getContext()); $objectManager->injectAllSettings($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS)); $objectManager->setObjects($objectConfigurationCache->get('objects')); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } $objectManager->get(Dispatcher::class)->injectObjectManager($objectManager); Debugger::injectObjectManager($objectManager); $bootstrap->setEarlyInstance(ObjectManagerInterface::class, $objectManager); Bootstrap::$staticObjectManager = $objectManager; }
[ "public", "static", "function", "initializeObjectManager", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "configurationManager", "=", "$", "bootstrap", "->", "getEarlyInstance", "(", "ConfigurationManager", "::", "class", ")", ";", "$", "objectConfigurationCache"...
Initializes the runtime Object Manager @param Bootstrap $bootstrap @return void
[ "Initializes", "the", "runtime", "Object", "Manager" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L501-L520
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeReflectionServiceFactory
public static function initializeReflectionServiceFactory(Bootstrap $bootstrap) { $reflectionServiceFactory = new ReflectionServiceFactory($bootstrap); $bootstrap->setEarlyInstance(ReflectionServiceFactory::class, $reflectionServiceFactory); $bootstrap->getObjectManager()->setInstance(ReflectionServiceFactory::class, $reflectionServiceFactory); }
php
public static function initializeReflectionServiceFactory(Bootstrap $bootstrap) { $reflectionServiceFactory = new ReflectionServiceFactory($bootstrap); $bootstrap->setEarlyInstance(ReflectionServiceFactory::class, $reflectionServiceFactory); $bootstrap->getObjectManager()->setInstance(ReflectionServiceFactory::class, $reflectionServiceFactory); }
[ "public", "static", "function", "initializeReflectionServiceFactory", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "reflectionServiceFactory", "=", "new", "ReflectionServiceFactory", "(", "$", "bootstrap", ")", ";", "$", "bootstrap", "->", "setEarlyInstance", "(...
Initializes the Reflection Service Factory @param Bootstrap $bootstrap @return void
[ "Initializes", "the", "Reflection", "Service", "Factory" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L528-L533
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeReflectionService
public static function initializeReflectionService(Bootstrap $bootstrap) { $reflectionService = $bootstrap->getEarlyInstance(ReflectionServiceFactory::class)->create(); $bootstrap->setEarlyInstance(ReflectionService::class, $reflectionService); $bootstrap->getObjectManager()->setInstance(ReflectionService::class, $reflectionService); }
php
public static function initializeReflectionService(Bootstrap $bootstrap) { $reflectionService = $bootstrap->getEarlyInstance(ReflectionServiceFactory::class)->create(); $bootstrap->setEarlyInstance(ReflectionService::class, $reflectionService); $bootstrap->getObjectManager()->setInstance(ReflectionService::class, $reflectionService); }
[ "public", "static", "function", "initializeReflectionService", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "reflectionService", "=", "$", "bootstrap", "->", "getEarlyInstance", "(", "ReflectionServiceFactory", "::", "class", ")", "->", "create", "(", ")", "...
Initializes the Reflection Service @param Bootstrap $bootstrap @throws FlowException
[ "Initializes", "the", "Reflection", "Service" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L541-L546
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.initializeSystemFileMonitor
public static function initializeSystemFileMonitor(Bootstrap $bootstrap) { /** @var FileMonitor[] $fileMonitors */ $fileMonitors = [ 'Flow_ClassFiles' => FileMonitor::createFileMonitorAtBoot('Flow_ClassFiles', $bootstrap), 'Flow_ConfigurationFiles' => FileMonitor::createFileMonitorAtBoot('Flow_ConfigurationFiles', $bootstrap), 'Flow_TranslationFiles' => FileMonitor::createFileMonitorAtBoot('Flow_TranslationFiles', $bootstrap) ]; $context = $bootstrap->getContext(); /** @var PackageManager $packageManager */ $packageManager = $bootstrap->getEarlyInstance(PackageManager::class); $packagesWithConfiguredObjects = static::getListOfPackagesWithConfiguredObjects($bootstrap); /** @var FlowPackageInterface $package */ foreach ($packageManager->getFlowPackages() as $packageKey => $package) { if ($packageManager->isPackageFrozen($packageKey)) { continue; } self::monitorDirectoryIfItExists($fileMonitors['Flow_ConfigurationFiles'], $package->getConfigurationPath(), '\.y(a)?ml$'); self::monitorDirectoryIfItExists($fileMonitors['Flow_TranslationFiles'], $package->getResourcesPath() . 'Private/Translations/', '\.xlf'); if (!in_array($packageKey, $packagesWithConfiguredObjects)) { continue; } foreach ($package->getAutoloadPaths() as $autoloadPath) { self::monitorDirectoryIfItExists($fileMonitors['Flow_ClassFiles'], $autoloadPath, '\.php$'); } // Note that getFunctionalTestsPath is currently not part of any interface... We might want to add it or find a better way. if ($context->isTesting()) { self::monitorDirectoryIfItExists($fileMonitors['Flow_ClassFiles'], $package->getFunctionalTestsPath(), '\.php$'); } } self::monitorDirectoryIfItExists($fileMonitors['Flow_TranslationFiles'], FLOW_PATH_DATA . 'Translations/', '\.xlf'); self::monitorDirectoryIfItExists($fileMonitors['Flow_ConfigurationFiles'], FLOW_PATH_CONFIGURATION, '\.y(a)?ml$'); foreach ($fileMonitors as $fileMonitor) { $fileMonitor->detectChanges(); } foreach ($fileMonitors as $fileMonitor) { $fileMonitor->shutdownObject(); } }
php
public static function initializeSystemFileMonitor(Bootstrap $bootstrap) { /** @var FileMonitor[] $fileMonitors */ $fileMonitors = [ 'Flow_ClassFiles' => FileMonitor::createFileMonitorAtBoot('Flow_ClassFiles', $bootstrap), 'Flow_ConfigurationFiles' => FileMonitor::createFileMonitorAtBoot('Flow_ConfigurationFiles', $bootstrap), 'Flow_TranslationFiles' => FileMonitor::createFileMonitorAtBoot('Flow_TranslationFiles', $bootstrap) ]; $context = $bootstrap->getContext(); /** @var PackageManager $packageManager */ $packageManager = $bootstrap->getEarlyInstance(PackageManager::class); $packagesWithConfiguredObjects = static::getListOfPackagesWithConfiguredObjects($bootstrap); /** @var FlowPackageInterface $package */ foreach ($packageManager->getFlowPackages() as $packageKey => $package) { if ($packageManager->isPackageFrozen($packageKey)) { continue; } self::monitorDirectoryIfItExists($fileMonitors['Flow_ConfigurationFiles'], $package->getConfigurationPath(), '\.y(a)?ml$'); self::monitorDirectoryIfItExists($fileMonitors['Flow_TranslationFiles'], $package->getResourcesPath() . 'Private/Translations/', '\.xlf'); if (!in_array($packageKey, $packagesWithConfiguredObjects)) { continue; } foreach ($package->getAutoloadPaths() as $autoloadPath) { self::monitorDirectoryIfItExists($fileMonitors['Flow_ClassFiles'], $autoloadPath, '\.php$'); } // Note that getFunctionalTestsPath is currently not part of any interface... We might want to add it or find a better way. if ($context->isTesting()) { self::monitorDirectoryIfItExists($fileMonitors['Flow_ClassFiles'], $package->getFunctionalTestsPath(), '\.php$'); } } self::monitorDirectoryIfItExists($fileMonitors['Flow_TranslationFiles'], FLOW_PATH_DATA . 'Translations/', '\.xlf'); self::monitorDirectoryIfItExists($fileMonitors['Flow_ConfigurationFiles'], FLOW_PATH_CONFIGURATION, '\.y(a)?ml$'); foreach ($fileMonitors as $fileMonitor) { $fileMonitor->detectChanges(); } foreach ($fileMonitors as $fileMonitor) { $fileMonitor->shutdownObject(); } }
[ "public", "static", "function", "initializeSystemFileMonitor", "(", "Bootstrap", "$", "bootstrap", ")", "{", "/** @var FileMonitor[] $fileMonitors */", "$", "fileMonitors", "=", "[", "'Flow_ClassFiles'", "=>", "FileMonitor", "::", "createFileMonitorAtBoot", "(", "'Flow_Clas...
Checks if classes (i.e. php files containing classes), Policy.yaml, Objects.yaml or localization files have been altered and if so flushes the related caches. This function only triggers the detection of changes in the file monitors. The actual cache flushing is handled by other functions which are triggered by the file monitor through a signal. For Flow, those signal-slot connections are defined in the class \Neos\Flow\Package. @param Bootstrap $bootstrap @return void
[ "Checks", "if", "classes", "(", "i", ".", "e", ".", "php", "files", "containing", "classes", ")", "Policy", ".", "yaml", "Objects", ".", "yaml", "or", "localization", "files", "have", "been", "altered", "and", "if", "so", "flushes", "the", "related", "ca...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L560-L603
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.monitorDirectoryIfItExists
protected static function monitorDirectoryIfItExists(FileMonitor $fileMonitor, string $path, string $filenamePattern = null) { if (is_dir($path)) { $fileMonitor->monitorDirectory($path, $filenamePattern); } }
php
protected static function monitorDirectoryIfItExists(FileMonitor $fileMonitor, string $path, string $filenamePattern = null) { if (is_dir($path)) { $fileMonitor->monitorDirectory($path, $filenamePattern); } }
[ "protected", "static", "function", "monitorDirectoryIfItExists", "(", "FileMonitor", "$", "fileMonitor", ",", "string", "$", "path", ",", "string", "$", "filenamePattern", "=", "null", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "f...
Let the given file monitor track changes of the specified directory if it exists. @param FileMonitor $fileMonitor @param string $path @param string $filenamePattern Optional pattern for filenames to consider for file monitoring (regular expression). @see FileMonitor::monitorDirectory() @return void
[ "Let", "the", "given", "file", "monitor", "track", "changes", "of", "the", "specified", "directory", "if", "it", "exists", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L631-L636
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.compileDoctrineProxies
protected static function compileDoctrineProxies(Bootstrap $bootstrap) { $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class); $objectConfigurationCache = $cacheManager->getCache('Flow_Object_Configuration'); $coreCache = $cacheManager->getCache('Flow_Core'); $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow'); if ($objectConfigurationCache->has('doctrineProxyCodeUpToDate') === false && $coreCache->has('doctrineSetupRunning') === false) { $logger = $bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger'); $coreCache->set('doctrineSetupRunning', 'White Russian', [], 60); $logger->debug('Compiling Doctrine proxies'); self::executeCommand('neos.flow:doctrine:compileproxies', $settings); $coreCache->remove('doctrineSetupRunning'); $objectConfigurationCache->set('doctrineProxyCodeUpToDate', true); } }
php
protected static function compileDoctrineProxies(Bootstrap $bootstrap) { $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class); $objectConfigurationCache = $cacheManager->getCache('Flow_Object_Configuration'); $coreCache = $cacheManager->getCache('Flow_Core'); $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow'); if ($objectConfigurationCache->has('doctrineProxyCodeUpToDate') === false && $coreCache->has('doctrineSetupRunning') === false) { $logger = $bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger'); $coreCache->set('doctrineSetupRunning', 'White Russian', [], 60); $logger->debug('Compiling Doctrine proxies'); self::executeCommand('neos.flow:doctrine:compileproxies', $settings); $coreCache->remove('doctrineSetupRunning'); $objectConfigurationCache->set('doctrineProxyCodeUpToDate', true); } }
[ "protected", "static", "function", "compileDoctrineProxies", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "cacheManager", "=", "$", "bootstrap", "->", "getEarlyInstance", "(", "CacheManager", "::", "class", ")", ";", "$", "objectConfigurationCache", "=", "$"...
Update Doctrine 2 proxy classes This is not simply bound to the finishedCompilationRun signal because it needs the advised proxy classes to run. When that signal is fired, they have been written, but not loaded. @param Bootstrap $bootstrap @return void
[ "Update", "Doctrine", "2", "proxy", "classes" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L648-L664
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.executeCommand
public static function executeCommand(string $commandIdentifier, array $settings, bool $outputResults = true, array $commandArguments = []): bool { $command = self::buildSubprocessCommand($commandIdentifier, $settings, $commandArguments); $output = []; // Output errors in response $command .= ' 2>&1'; exec($command, $output, $result); if ($result !== 0) { if (count($output) > 0) { $exceptionMessage = implode(PHP_EOL, $output); } else { $exceptionMessage = sprintf('Execution of subprocess failed with exit code %d without any further output. (Please check your PHP error log for possible Fatal errors)', $result); // If the command is too long, it'll just produce /usr/bin/php: Argument list too long but this will be invisible // If anything else goes wrong, it may as well not produce any $output, but might do so when run on an interactive // shell. Thus we dump the command next to the exception dumps. $exceptionMessage .= ' Try to run the command manually, to hopefully get some hint on the actual error.'; if (!file_exists(FLOW_PATH_DATA . 'Logs/Exceptions')) { Files::createDirectoryRecursively(FLOW_PATH_DATA . 'Logs/Exceptions'); } if (file_exists(FLOW_PATH_DATA . 'Logs/Exceptions') && is_dir(FLOW_PATH_DATA . 'Logs/Exceptions') && is_writable(FLOW_PATH_DATA . 'Logs/Exceptions')) { $referenceCode = date('YmdHis', $_SERVER['REQUEST_TIME']) . substr(md5(rand()), 0, 6); $errorDumpPathAndFilename = FLOW_PATH_DATA . 'Logs/Exceptions/' . $referenceCode . '-command.txt'; file_put_contents($errorDumpPathAndFilename, $command); $exceptionMessage .= sprintf(' It has been stored in: %s', basename($errorDumpPathAndFilename)); } else { $exceptionMessage .= sprintf(' (could not write command into %s because the directory could not be created or is not writable.)', FLOW_PATH_DATA . 'Logs/Exceptions/'); } } throw new Exception\SubProcessException($exceptionMessage, 1355480641); } if ($outputResults) { echo implode(PHP_EOL, $output); } return $result === 0; }
php
public static function executeCommand(string $commandIdentifier, array $settings, bool $outputResults = true, array $commandArguments = []): bool { $command = self::buildSubprocessCommand($commandIdentifier, $settings, $commandArguments); $output = []; // Output errors in response $command .= ' 2>&1'; exec($command, $output, $result); if ($result !== 0) { if (count($output) > 0) { $exceptionMessage = implode(PHP_EOL, $output); } else { $exceptionMessage = sprintf('Execution of subprocess failed with exit code %d without any further output. (Please check your PHP error log for possible Fatal errors)', $result); // If the command is too long, it'll just produce /usr/bin/php: Argument list too long but this will be invisible // If anything else goes wrong, it may as well not produce any $output, but might do so when run on an interactive // shell. Thus we dump the command next to the exception dumps. $exceptionMessage .= ' Try to run the command manually, to hopefully get some hint on the actual error.'; if (!file_exists(FLOW_PATH_DATA . 'Logs/Exceptions')) { Files::createDirectoryRecursively(FLOW_PATH_DATA . 'Logs/Exceptions'); } if (file_exists(FLOW_PATH_DATA . 'Logs/Exceptions') && is_dir(FLOW_PATH_DATA . 'Logs/Exceptions') && is_writable(FLOW_PATH_DATA . 'Logs/Exceptions')) { $referenceCode = date('YmdHis', $_SERVER['REQUEST_TIME']) . substr(md5(rand()), 0, 6); $errorDumpPathAndFilename = FLOW_PATH_DATA . 'Logs/Exceptions/' . $referenceCode . '-command.txt'; file_put_contents($errorDumpPathAndFilename, $command); $exceptionMessage .= sprintf(' It has been stored in: %s', basename($errorDumpPathAndFilename)); } else { $exceptionMessage .= sprintf(' (could not write command into %s because the directory could not be created or is not writable.)', FLOW_PATH_DATA . 'Logs/Exceptions/'); } } throw new Exception\SubProcessException($exceptionMessage, 1355480641); } if ($outputResults) { echo implode(PHP_EOL, $output); } return $result === 0; }
[ "public", "static", "function", "executeCommand", "(", "string", "$", "commandIdentifier", ",", "array", "$", "settings", ",", "bool", "$", "outputResults", "=", "true", ",", "array", "$", "commandArguments", "=", "[", "]", ")", ":", "bool", "{", "$", "com...
Executes the given command as a sub-request to the Flow CLI system. @param string $commandIdentifier E.g. neos.flow:cache:flush @param array $settings The Neos.Flow settings @param boolean $outputResults if false the output of this command is only echoed if the execution was not successful @param array $commandArguments Command arguments @return boolean true if the command execution was successful (exit code = 0) @api @throws Exception\SubProcessException if execution of the sub process failed
[ "Executes", "the", "given", "command", "as", "a", "sub", "-", "request", "to", "the", "Flow", "CLI", "system", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L688-L724
neos/flow-development-collection
Neos.Flow/Classes/Core/Booting/Scripts.php
Scripts.executeCommandAsync
public static function executeCommandAsync(string $commandIdentifier, array $settings, array $commandArguments = []) { $command = self::buildSubprocessCommand($commandIdentifier, $settings, $commandArguments); if (DIRECTORY_SEPARATOR === '/') { exec($command . ' > /dev/null 2>/dev/null &'); } else { pclose(popen('START /B CMD /S /C "' . $command . '" > NUL 2> NUL &', 'r')); } }
php
public static function executeCommandAsync(string $commandIdentifier, array $settings, array $commandArguments = []) { $command = self::buildSubprocessCommand($commandIdentifier, $settings, $commandArguments); if (DIRECTORY_SEPARATOR === '/') { exec($command . ' > /dev/null 2>/dev/null &'); } else { pclose(popen('START /B CMD /S /C "' . $command . '" > NUL 2> NUL &', 'r')); } }
[ "public", "static", "function", "executeCommandAsync", "(", "string", "$", "commandIdentifier", ",", "array", "$", "settings", ",", "array", "$", "commandArguments", "=", "[", "]", ")", "{", "$", "command", "=", "self", "::", "buildSubprocessCommand", "(", "$"...
Executes the given command as a sub-request to the Flow CLI system without waiting for the output. Note: As the command execution is done in a separate thread potential exceptions or failures will *not* be reported @param string $commandIdentifier E.g. neos.flow:cache:flush @param array $settings The Neos.Flow settings @param array $commandArguments Command arguments @return void @api
[ "Executes", "the", "given", "command", "as", "a", "sub", "-", "request", "to", "the", "Flow", "CLI", "system", "without", "waiting", "for", "the", "output", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/Booting/Scripts.php#L737-L745
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Format/DateViewHelper.php
DateViewHelper.render
public function render() { $date = $this->arguments['date']; $cldrFormat = $this->arguments['cldrFormat']; if ($date === null) { $date = $this->renderChildren(); if ($date === null) { return ''; } } if (!$date instanceof \DateTimeInterface) { try { $date = new \DateTime($date); } catch (\Exception $exception) { throw new ViewHelperException('"' . $date . '" could not be parsed by \DateTime constructor.', 1241722579, $exception); } } $useLocale = $this->getLocale(); if ($useLocale !== null) { try { if ($cldrFormat !== null) { $output = $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale); } else { $output = $this->datetimeFormatter->format($date, $useLocale, [$this->arguments['localeFormatType'], $this->arguments['localeFormatLength']]); } } catch (I18nException $exception) { throw new ViewHelperException(sprintf('An error occurred while trying to format the given date/time: "%s"', $exception->getMessage()), 1342610987, $exception); } } else { $output = $date->format($this->arguments['format']); } return $output; }
php
public function render() { $date = $this->arguments['date']; $cldrFormat = $this->arguments['cldrFormat']; if ($date === null) { $date = $this->renderChildren(); if ($date === null) { return ''; } } if (!$date instanceof \DateTimeInterface) { try { $date = new \DateTime($date); } catch (\Exception $exception) { throw new ViewHelperException('"' . $date . '" could not be parsed by \DateTime constructor.', 1241722579, $exception); } } $useLocale = $this->getLocale(); if ($useLocale !== null) { try { if ($cldrFormat !== null) { $output = $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale); } else { $output = $this->datetimeFormatter->format($date, $useLocale, [$this->arguments['localeFormatType'], $this->arguments['localeFormatLength']]); } } catch (I18nException $exception) { throw new ViewHelperException(sprintf('An error occurred while trying to format the given date/time: "%s"', $exception->getMessage()), 1342610987, $exception); } } else { $output = $date->format($this->arguments['format']); } return $output; }
[ "public", "function", "render", "(", ")", "{", "$", "date", "=", "$", "this", "->", "arguments", "[", "'date'", "]", ";", "$", "cldrFormat", "=", "$", "this", "->", "arguments", "[", "'cldrFormat'", "]", ";", "if", "(", "$", "date", "===", "null", ...
Render the supplied DateTime object as a formatted date. @param mixed $date either a \DateTime object or a string that is accepted by \DateTime constructor @param string $format Format String which is taken to format the Date/Time if none of the locale options are set. @param string $localeFormatType Whether to format (according to locale set in $forceLocale) date, time or dateTime. Must be one of Neos\Flow\I18n\Cldr\Reader\DatesReader::FORMAT_TYPE_*'s constants. @param string $localeFormatLength Format length if locale set in $forceLocale. Must be one of Neos\Flow\I18n\Cldr\Reader\DatesReader::FORMAT_LENGTH_*'s constants. @param string $cldrFormat Format string in CLDR format (see http://cldr.unicode.org/translation/date-time) @throws ViewHelperException @return string Formatted date @api
[ "Render", "the", "supplied", "DateTime", "object", "as", "a", "formatted", "date", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/DateViewHelper.php#L131-L166
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php
ProxyMethod.render
public function render() { $methodDocumentation = $this->buildMethodDocumentation($this->fullOriginalClassName, $this->methodName); $methodParametersCode = ($this->methodParametersCode !== '' ? $this->methodParametersCode : $this->buildMethodParametersCode($this->fullOriginalClassName, $this->methodName)); $callParentMethodCode = $this->buildCallParentMethodCode($this->fullOriginalClassName, $this->methodName); $finalKeyword = $this->reflectionService->isMethodFinal($this->fullOriginalClassName, $this->methodName) ? 'final ' : ''; $staticKeyword = $this->reflectionService->isMethodStatic($this->fullOriginalClassName, $this->methodName) ? 'static ' : ''; $visibility = ($this->visibility === null ? $this->getMethodVisibilityString() : $this->visibility); $returnType = $this->reflectionService->getMethodDeclaredReturnType($this->fullOriginalClassName, $this->methodName); $returnTypeIsVoid = $returnType === 'void'; $returnTypeDeclaration = ($returnType !== null ? ' : ' . $returnType : ''); $code = ''; if ($this->addedPreParentCallCode !== '' || $this->addedPostParentCallCode !== '' || $this->methodBody !== '') { $code = "\n" . $methodDocumentation . ' ' . $finalKeyword . $staticKeyword . $visibility . ' function ' . $this->methodName . '(' . $methodParametersCode . ")$returnTypeDeclaration\n {\n"; if ($this->methodBody !== '') { $code .= "\n" . $this->methodBody . "\n"; } else { $code .= $this->addedPreParentCallCode; if ($this->addedPostParentCallCode !== '') { if ($returnTypeIsVoid) { if ($callParentMethodCode !== '') { $code .= ' ' . $callParentMethodCode; } } else { $code .= ' $result = ' . ($callParentMethodCode === '' ? "NULL;\n" : $callParentMethodCode); } $code .= $this->addedPostParentCallCode; if (!$returnTypeIsVoid) { $code .= " return \$result;\n"; } } else { if (!$returnTypeIsVoid && $callParentMethodCode !== '') { $code .= ' return ' . $callParentMethodCode . ";\n"; } } } $code .= " }\n"; } return $code; }
php
public function render() { $methodDocumentation = $this->buildMethodDocumentation($this->fullOriginalClassName, $this->methodName); $methodParametersCode = ($this->methodParametersCode !== '' ? $this->methodParametersCode : $this->buildMethodParametersCode($this->fullOriginalClassName, $this->methodName)); $callParentMethodCode = $this->buildCallParentMethodCode($this->fullOriginalClassName, $this->methodName); $finalKeyword = $this->reflectionService->isMethodFinal($this->fullOriginalClassName, $this->methodName) ? 'final ' : ''; $staticKeyword = $this->reflectionService->isMethodStatic($this->fullOriginalClassName, $this->methodName) ? 'static ' : ''; $visibility = ($this->visibility === null ? $this->getMethodVisibilityString() : $this->visibility); $returnType = $this->reflectionService->getMethodDeclaredReturnType($this->fullOriginalClassName, $this->methodName); $returnTypeIsVoid = $returnType === 'void'; $returnTypeDeclaration = ($returnType !== null ? ' : ' . $returnType : ''); $code = ''; if ($this->addedPreParentCallCode !== '' || $this->addedPostParentCallCode !== '' || $this->methodBody !== '') { $code = "\n" . $methodDocumentation . ' ' . $finalKeyword . $staticKeyword . $visibility . ' function ' . $this->methodName . '(' . $methodParametersCode . ")$returnTypeDeclaration\n {\n"; if ($this->methodBody !== '') { $code .= "\n" . $this->methodBody . "\n"; } else { $code .= $this->addedPreParentCallCode; if ($this->addedPostParentCallCode !== '') { if ($returnTypeIsVoid) { if ($callParentMethodCode !== '') { $code .= ' ' . $callParentMethodCode; } } else { $code .= ' $result = ' . ($callParentMethodCode === '' ? "NULL;\n" : $callParentMethodCode); } $code .= $this->addedPostParentCallCode; if (!$returnTypeIsVoid) { $code .= " return \$result;\n"; } } else { if (!$returnTypeIsVoid && $callParentMethodCode !== '') { $code .= ' return ' . $callParentMethodCode . ";\n"; } } } $code .= " }\n"; } return $code; }
[ "public", "function", "render", "(", ")", "{", "$", "methodDocumentation", "=", "$", "this", "->", "buildMethodDocumentation", "(", "$", "this", "->", "fullOriginalClassName", ",", "$", "this", "->", "methodName", ")", ";", "$", "methodParametersCode", "=", "(...
Renders the PHP code for this Proxy Method @return string PHP code
[ "Renders", "the", "PHP", "code", "for", "this", "Proxy", "Method" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php#L145-L191
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php
ProxyMethod.buildMethodDocumentation
protected function buildMethodDocumentation($className, $methodName) { $methodDocumentation = " /**\n * Autogenerated Proxy Method\n"; if ($this->reflectionService->hasMethod($className, $methodName)) { $methodTags = $this->reflectionService->getMethodTagsValues($className, $methodName); $allowedTags = ['param', 'return', 'throws']; foreach ($methodTags as $tag => $values) { if (in_array($tag, $allowedTags)) { if (count($values) === 0) { $methodDocumentation .= ' * @' . $tag . "\n"; } else { foreach ($values as $value) { $methodDocumentation .= ' * @' . $tag . ' ' . $value . "\n"; } } } } $methodAnnotations = $this->reflectionService->getMethodAnnotations($className, $methodName); foreach ($methodAnnotations as $annotation) { $methodDocumentation .= ' * ' . Compiler::renderAnnotation($annotation) . "\n"; } } $methodDocumentation .= " */\n"; return $methodDocumentation; }
php
protected function buildMethodDocumentation($className, $methodName) { $methodDocumentation = " /**\n * Autogenerated Proxy Method\n"; if ($this->reflectionService->hasMethod($className, $methodName)) { $methodTags = $this->reflectionService->getMethodTagsValues($className, $methodName); $allowedTags = ['param', 'return', 'throws']; foreach ($methodTags as $tag => $values) { if (in_array($tag, $allowedTags)) { if (count($values) === 0) { $methodDocumentation .= ' * @' . $tag . "\n"; } else { foreach ($values as $value) { $methodDocumentation .= ' * @' . $tag . ' ' . $value . "\n"; } } } } $methodAnnotations = $this->reflectionService->getMethodAnnotations($className, $methodName); foreach ($methodAnnotations as $annotation) { $methodDocumentation .= ' * ' . Compiler::renderAnnotation($annotation) . "\n"; } } $methodDocumentation .= " */\n"; return $methodDocumentation; }
[ "protected", "function", "buildMethodDocumentation", "(", "$", "className", ",", "$", "methodName", ")", "{", "$", "methodDocumentation", "=", "\" /**\\n * Autogenerated Proxy Method\\n\"", ";", "if", "(", "$", "this", "->", "reflectionService", "->", "hasMethod"...
Builds the method documentation block for the specified method keeping the vital annotations @param string $className Name of the class the method is declared in @param string $methodName Name of the method to create the parameters code for @return string $methodDocumentation DocComment for the given method
[ "Builds", "the", "method", "documentation", "block", "for", "the", "specified", "method", "keeping", "the", "vital", "annotations" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php#L211-L237
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php
ProxyMethod.buildMethodParametersCode
public function buildMethodParametersCode($fullClassName, $methodName, $addTypeAndDefaultValue = true) { $methodParametersCode = ''; $methodParameterTypeName = ''; $nullableSign = ''; $defaultValue = ''; $byReferenceSign = ''; if ($fullClassName === null || $methodName === null) { return ''; } $methodParameters = $this->reflectionService->getMethodParameters($fullClassName, $methodName); if (count($methodParameters) > 0) { $methodParametersCount = 0; foreach ($methodParameters as $methodParameterName => $methodParameterInfo) { if ($addTypeAndDefaultValue) { if ($methodParameterInfo['array'] === true) { $methodParameterTypeName = 'array'; } elseif ($methodParameterInfo['scalarDeclaration']) { $methodParameterTypeName = $methodParameterInfo['type']; } elseif ($methodParameterInfo['class'] !== null) { $methodParameterTypeName = '\\' . $methodParameterInfo['class']; } else { $methodParameterTypeName = ''; } if (\PHP_MAJOR_VERSION >= 7 && \PHP_MINOR_VERSION >= 1) { $nullableSign = $methodParameterInfo['allowsNull'] ? '?' : ''; } if ($methodParameterInfo['optional'] === true) { $rawDefaultValue = $methodParameterInfo['defaultValue'] ?? null; if ($rawDefaultValue === null) { $defaultValue = ' = NULL'; } elseif (is_bool($rawDefaultValue)) { $defaultValue = ($rawDefaultValue ? ' = true' : ' = false'); } elseif (is_numeric($rawDefaultValue)) { $defaultValue = ' = ' . $rawDefaultValue; } elseif (is_string($rawDefaultValue)) { $defaultValue = " = '" . $rawDefaultValue . "'"; } elseif (is_array($rawDefaultValue)) { $defaultValue = ' = ' . $this->buildArraySetupCode($rawDefaultValue); } } $byReferenceSign = ($methodParameterInfo['byReference'] ? '&' : ''); } $methodParametersCode .= ($methodParametersCount > 0 ? ', ' : '') . ($methodParameterTypeName ? $nullableSign . $methodParameterTypeName . ' ' : '') . $byReferenceSign . '$' . $methodParameterName . $defaultValue ; $methodParametersCount++; } } return $methodParametersCode; }
php
public function buildMethodParametersCode($fullClassName, $methodName, $addTypeAndDefaultValue = true) { $methodParametersCode = ''; $methodParameterTypeName = ''; $nullableSign = ''; $defaultValue = ''; $byReferenceSign = ''; if ($fullClassName === null || $methodName === null) { return ''; } $methodParameters = $this->reflectionService->getMethodParameters($fullClassName, $methodName); if (count($methodParameters) > 0) { $methodParametersCount = 0; foreach ($methodParameters as $methodParameterName => $methodParameterInfo) { if ($addTypeAndDefaultValue) { if ($methodParameterInfo['array'] === true) { $methodParameterTypeName = 'array'; } elseif ($methodParameterInfo['scalarDeclaration']) { $methodParameterTypeName = $methodParameterInfo['type']; } elseif ($methodParameterInfo['class'] !== null) { $methodParameterTypeName = '\\' . $methodParameterInfo['class']; } else { $methodParameterTypeName = ''; } if (\PHP_MAJOR_VERSION >= 7 && \PHP_MINOR_VERSION >= 1) { $nullableSign = $methodParameterInfo['allowsNull'] ? '?' : ''; } if ($methodParameterInfo['optional'] === true) { $rawDefaultValue = $methodParameterInfo['defaultValue'] ?? null; if ($rawDefaultValue === null) { $defaultValue = ' = NULL'; } elseif (is_bool($rawDefaultValue)) { $defaultValue = ($rawDefaultValue ? ' = true' : ' = false'); } elseif (is_numeric($rawDefaultValue)) { $defaultValue = ' = ' . $rawDefaultValue; } elseif (is_string($rawDefaultValue)) { $defaultValue = " = '" . $rawDefaultValue . "'"; } elseif (is_array($rawDefaultValue)) { $defaultValue = ' = ' . $this->buildArraySetupCode($rawDefaultValue); } } $byReferenceSign = ($methodParameterInfo['byReference'] ? '&' : ''); } $methodParametersCode .= ($methodParametersCount > 0 ? ', ' : '') . ($methodParameterTypeName ? $nullableSign . $methodParameterTypeName . ' ' : '') . $byReferenceSign . '$' . $methodParameterName . $defaultValue ; $methodParametersCount++; } } return $methodParametersCode; }
[ "public", "function", "buildMethodParametersCode", "(", "$", "fullClassName", ",", "$", "methodName", ",", "$", "addTypeAndDefaultValue", "=", "true", ")", "{", "$", "methodParametersCode", "=", "''", ";", "$", "methodParameterTypeName", "=", "''", ";", "$", "nu...
Builds the PHP code for the parameters of the specified method to be used in a method interceptor in the proxy class @param string $fullClassName Name of the class the method is declared in @param string $methodName Name of the method to create the parameters code for @param boolean $addTypeAndDefaultValue If the type and default value for each parameters should be rendered @return string A comma speparated list of parameters
[ "Builds", "the", "PHP", "code", "for", "the", "parameters", "of", "the", "specified", "method", "to", "be", "used", "in", "a", "method", "interceptor", "in", "the", "proxy", "class" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php#L248-L306
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php
ProxyMethod.buildCallParentMethodCode
protected function buildCallParentMethodCode($fullClassName, $methodName) { if (!$this->reflectionService->hasMethod($fullClassName, $methodName)) { return ''; } return 'parent::' . $methodName . '(' . $this->buildMethodParametersCode($fullClassName, $methodName, false) . ");\n"; }
php
protected function buildCallParentMethodCode($fullClassName, $methodName) { if (!$this->reflectionService->hasMethod($fullClassName, $methodName)) { return ''; } return 'parent::' . $methodName . '(' . $this->buildMethodParametersCode($fullClassName, $methodName, false) . ");\n"; }
[ "protected", "function", "buildCallParentMethodCode", "(", "$", "fullClassName", ",", "$", "methodName", ")", "{", "if", "(", "!", "$", "this", "->", "reflectionService", "->", "hasMethod", "(", "$", "fullClassName", ",", "$", "methodName", ")", ")", "{", "r...
Builds PHP code which calls the original (ie. parent) method after the added code has been executed. @param string $fullClassName Fully qualified name of the original class @param string $methodName Name of the original method @return string PHP code
[ "Builds", "PHP", "code", "which", "calls", "the", "original", "(", "ie", ".", "parent", ")", "method", "after", "the", "added", "code", "has", "been", "executed", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php#L315-L321
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php
ProxyMethod.buildArraySetupCode
protected function buildArraySetupCode(array $array) { $code = 'array('; foreach ($array as $key => $value) { $code .= (is_string($key)) ? "'" . $key . "'" : $key; $code .= ' => '; if ($value === null) { $code .= 'NULL'; } elseif (is_bool($value)) { $code .= ($value ? 'true' : 'false'); } elseif (is_numeric($value)) { $code .= $value; } elseif (is_string($value)) { $code .= "'" . $value . "'"; } $code .= ', '; } return rtrim($code, ', ') . ')'; }
php
protected function buildArraySetupCode(array $array) { $code = 'array('; foreach ($array as $key => $value) { $code .= (is_string($key)) ? "'" . $key . "'" : $key; $code .= ' => '; if ($value === null) { $code .= 'NULL'; } elseif (is_bool($value)) { $code .= ($value ? 'true' : 'false'); } elseif (is_numeric($value)) { $code .= $value; } elseif (is_string($value)) { $code .= "'" . $value . "'"; } $code .= ', '; } return rtrim($code, ', ') . ')'; }
[ "protected", "function", "buildArraySetupCode", "(", "array", "$", "array", ")", "{", "$", "code", "=", "'array('", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "code", ".=", "(", "is_string", "(", "$", "key...
Builds a string containing PHP code to build the array given as input. @param array $array @return string e.g. 'array()' or 'array(1 => 'bar')
[ "Builds", "a", "string", "containing", "PHP", "code", "to", "build", "the", "array", "given", "as", "input", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php#L329-L347
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php
ProxyMethod.getMethodVisibilityString
protected function getMethodVisibilityString() { if ($this->reflectionService->isMethodProtected($this->fullOriginalClassName, $this->methodName)) { return 'protected'; } elseif ($this->reflectionService->isMethodPrivate($this->fullOriginalClassName, $this->methodName)) { return 'private'; } return 'public'; }
php
protected function getMethodVisibilityString() { if ($this->reflectionService->isMethodProtected($this->fullOriginalClassName, $this->methodName)) { return 'protected'; } elseif ($this->reflectionService->isMethodPrivate($this->fullOriginalClassName, $this->methodName)) { return 'private'; } return 'public'; }
[ "protected", "function", "getMethodVisibilityString", "(", ")", "{", "if", "(", "$", "this", "->", "reflectionService", "->", "isMethodProtected", "(", "$", "this", "->", "fullOriginalClassName", ",", "$", "this", "->", "methodName", ")", ")", "{", "return", "...
Returns the method's visibility string found by the reflection service Note: If the reflection service has no information about this method, 'public' is returned. @return string One of 'public', 'protected' or 'private'
[ "Returns", "the", "method", "s", "visibility", "string", "found", "by", "the", "reflection", "service", "Note", ":", "If", "the", "reflection", "service", "has", "no", "information", "about", "this", "method", "public", "is", "returned", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyMethod.php#L356-L364
neos/flow-development-collection
Neos.Flow/Classes/Security/RequestPattern/Uri.php
Uri.matchRequest
public function matchRequest(RequestInterface $request) { if (!$request instanceof ActionRequest) { return false; } if (!isset($this->options['uriPattern'])) { throw new InvalidRequestPatternException('Missing option "uriPattern" in the Uri request pattern configuration', 1446224530); } return (boolean)preg_match('/^' . str_replace('/', '\/', $this->options['uriPattern']) . '$/', $request->getHttpRequest()->getUri()->getPath()); }
php
public function matchRequest(RequestInterface $request) { if (!$request instanceof ActionRequest) { return false; } if (!isset($this->options['uriPattern'])) { throw new InvalidRequestPatternException('Missing option "uriPattern" in the Uri request pattern configuration', 1446224530); } return (boolean)preg_match('/^' . str_replace('/', '\/', $this->options['uriPattern']) . '$/', $request->getHttpRequest()->getUri()->getPath()); }
[ "public", "function", "matchRequest", "(", "RequestInterface", "$", "request", ")", "{", "if", "(", "!", "$", "request", "instanceof", "ActionRequest", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "["...
Matches a \Neos\Flow\Mvc\RequestInterface against its set URL pattern rules @param RequestInterface $request The request that should be matched @return boolean true if the pattern matched, false otherwise @throws InvalidRequestPatternException
[ "Matches", "a", "\\", "Neos", "\\", "Flow", "\\", "Mvc", "\\", "RequestInterface", "against", "its", "set", "URL", "pattern", "rules" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/RequestPattern/Uri.php#L46-L55
neos/flow-development-collection
Neos.Flow/Classes/Http/Component/StandardsComplianceComponent.php
StandardsComplianceComponent.handle
public function handle(ComponentContext $componentContext) { $response = $componentContext->getHttpResponse(); $response = ResponseInformationHelper::makeStandardsCompliant($response, $componentContext->getHttpRequest()); $componentContext->replaceHttpResponse($response); }
php
public function handle(ComponentContext $componentContext) { $response = $componentContext->getHttpResponse(); $response = ResponseInformationHelper::makeStandardsCompliant($response, $componentContext->getHttpRequest()); $componentContext->replaceHttpResponse($response); }
[ "public", "function", "handle", "(", "ComponentContext", "$", "componentContext", ")", "{", "$", "response", "=", "$", "componentContext", "->", "getHttpResponse", "(", ")", ";", "$", "response", "=", "ResponseInformationHelper", "::", "makeStandardsCompliant", "(",...
Just call makeStandardsCompliant on the Response for now @param ComponentContext $componentContext @return void
[ "Just", "call", "makeStandardsCompliant", "on", "the", "Response", "for", "now" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/StandardsComplianceComponent.php#L41-L46
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Format/Base64DecodeViewHelper.php
Base64DecodeViewHelper.render
public function render() { $value = $this->arguments['value']; if ($value === null) { $value = $this->renderChildren(); } if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { return $value; } return base64_decode($value); }
php
public function render() { $value = $this->arguments['value']; if ($value === null) { $value = $this->renderChildren(); } if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { return $value; } return base64_decode($value); }
[ "public", "function", "render", "(", ")", "{", "$", "value", "=", "$", "this", "->", "arguments", "[", "'value'", "]", ";", "if", "(", "$", "value", "===", "null", ")", "{", "$", "value", "=", "$", "this", "->", "renderChildren", "(", ")", ";", "...
Converts all HTML entities to their applicable characters as needed using PHPs html_entity_decode() function. @return string the altered string @api
[ "Converts", "all", "HTML", "entities", "to", "their", "applicable", "characters", "as", "needed", "using", "PHPs", "html_entity_decode", "()", "function", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/Base64DecodeViewHelper.php#L72-L83
neos/flow-development-collection
Neos.Flow/Classes/Error/ProductionExceptionHandler.php
ProductionExceptionHandler.echoExceptionWeb
protected function echoExceptionWeb($exception) { $statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500; $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode); $referenceCode = ($exception instanceof WithReferenceCodeInterface) ? $exception->getReferenceCode() : null; if (!headers_sent()) { header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage)); } try { if (isset($this->renderingOptions['templatePathAndFilename'])) { try { echo $this->buildView($exception, $this->renderingOptions)->render(); } catch (\Throwable $throwable) { $this->renderStatically($statusCode, $throwable); } } else { echo $this->renderStatically($statusCode, $referenceCode); } } catch (\Exception $innerException) { $message = $this->throwableStorage->logThrowable($innerException); $this->logger->critical($message); } }
php
protected function echoExceptionWeb($exception) { $statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500; $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode); $referenceCode = ($exception instanceof WithReferenceCodeInterface) ? $exception->getReferenceCode() : null; if (!headers_sent()) { header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage)); } try { if (isset($this->renderingOptions['templatePathAndFilename'])) { try { echo $this->buildView($exception, $this->renderingOptions)->render(); } catch (\Throwable $throwable) { $this->renderStatically($statusCode, $throwable); } } else { echo $this->renderStatically($statusCode, $referenceCode); } } catch (\Exception $innerException) { $message = $this->throwableStorage->logThrowable($innerException); $this->logger->critical($message); } }
[ "protected", "function", "echoExceptionWeb", "(", "$", "exception", ")", "{", "$", "statusCode", "=", "(", "$", "exception", "instanceof", "WithHttpStatusInterface", ")", "?", "$", "exception", "->", "getStatusCode", "(", ")", ":", "500", ";", "$", "statusMess...
Echoes an exception for the web. @param \Throwable $exception @return void
[ "Echoes", "an", "exception", "for", "the", "web", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/ProductionExceptionHandler.php#L30-L53
neos/flow-development-collection
Neos.Flow/Classes/Error/ProductionExceptionHandler.php
ProductionExceptionHandler.renderStatically
protected function renderStatically(int $statusCode, ?string $referenceCode): string { $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode); $referenceCodeMessage = ($referenceCode !== null) ? '<p>When contacting the maintainer of this application please mention the following reference code:<br /><br />' . $referenceCode . '</p>' : ''; return '<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>' . $statusCode . ' ' . $statusMessage . '</title> <style type="text/css"> body { font-family: Helvetica, Arial, sans-serif; margin: 50px; } h1 { color: #00ADEE; font-weight: normal; } </style> </head> <body> <h1>' . $statusCode . ' ' . $statusMessage . '</h1> <p>An internal error occurred.</p> ' . $referenceCodeMessage . ' </body> </html>'; }
php
protected function renderStatically(int $statusCode, ?string $referenceCode): string { $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode); $referenceCodeMessage = ($referenceCode !== null) ? '<p>When contacting the maintainer of this application please mention the following reference code:<br /><br />' . $referenceCode . '</p>' : ''; return '<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>' . $statusCode . ' ' . $statusMessage . '</title> <style type="text/css"> body { font-family: Helvetica, Arial, sans-serif; margin: 50px; } h1 { color: #00ADEE; font-weight: normal; } </style> </head> <body> <h1>' . $statusCode . ' ' . $statusMessage . '</h1> <p>An internal error occurred.</p> ' . $referenceCodeMessage . ' </body> </html>'; }
[ "protected", "function", "renderStatically", "(", "int", "$", "statusCode", ",", "?", "string", "$", "referenceCode", ")", ":", "string", "{", "$", "statusMessage", "=", "ResponseInformationHelper", "::", "getStatusMessageByCode", "(", "$", "statusCode", ")", ";",...
Returns the statically rendered exception message @param integer $statusCode @param string $referenceCode @return string
[ "Returns", "the", "statically", "rendered", "exception", "message" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/ProductionExceptionHandler.php#L62-L90
neos/flow-development-collection
Neos.Flow/Classes/Mvc/ActionResponse.php
ActionResponse.setContentType
public function setContentType(string $contentType): void { $this->contentType = $contentType; // TODO: This can be removed after the full changes are done for next major. $this->headers->set('Content-Type', $contentType, true); }
php
public function setContentType(string $contentType): void { $this->contentType = $contentType; // TODO: This can be removed after the full changes are done for next major. $this->headers->set('Content-Type', $contentType, true); }
[ "public", "function", "setContentType", "(", "string", "$", "contentType", ")", ":", "void", "{", "$", "this", "->", "contentType", "=", "$", "contentType", ";", "// TODO: This can be removed after the full changes are done for next major.", "$", "this", "->", "headers"...
Set content mime type for this response. @param string $contentType @return void @api
[ "Set", "content", "mime", "type", "for", "this", "response", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/ActionResponse.php#L53-L58
neos/flow-development-collection
Neos.Flow/Classes/Mvc/ActionResponse.php
ActionResponse.setRedirectUri
public function setRedirectUri(UriInterface $uri, int $statusCode = 303): void { $this->redirectUri = $uri; $this->statusCode = $statusCode; // TODO: This can be removed after the full changes are done for next major. $this->headers->set('Location', (string)$uri, true); $this->setStatusCode($statusCode); }
php
public function setRedirectUri(UriInterface $uri, int $statusCode = 303): void { $this->redirectUri = $uri; $this->statusCode = $statusCode; // TODO: This can be removed after the full changes are done for next major. $this->headers->set('Location', (string)$uri, true); $this->setStatusCode($statusCode); }
[ "public", "function", "setRedirectUri", "(", "UriInterface", "$", "uri", ",", "int", "$", "statusCode", "=", "303", ")", ":", "void", "{", "$", "this", "->", "redirectUri", "=", "$", "uri", ";", "$", "this", "->", "statusCode", "=", "$", "statusCode", ...
Set a redirect URI and according status for this response. @param UriInterface $uri @param int $statusCode @return void @api
[ "Set", "a", "redirect", "URI", "and", "according", "status", "for", "this", "response", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/ActionResponse.php#L68-L75
neos/flow-development-collection
Neos.Flow/Classes/Mvc/ActionResponse.php
ActionResponse.setComponentParameter
public function setComponentParameter(string $componentClassName, string $parameterName, $value): void { if (!isset($this->componentParameters[$componentClassName])) { $this->componentParameters[$componentClassName] = []; } $this->componentParameters[$componentClassName][$parameterName] = $value; }
php
public function setComponentParameter(string $componentClassName, string $parameterName, $value): void { if (!isset($this->componentParameters[$componentClassName])) { $this->componentParameters[$componentClassName] = []; } $this->componentParameters[$componentClassName][$parameterName] = $value; }
[ "public", "function", "setComponentParameter", "(", "string", "$", "componentClassName", ",", "string", "$", "parameterName", ",", "$", "value", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "componentParameters", "[", "$", "compone...
Set a (HTTP) component parameter for use later in the chain. This can be used to adjust all aspects of the later processing if needed. @param string $componentClassName @param string $parameterName @param mixed $value @return void @api
[ "Set", "a", "(", "HTTP", ")", "component", "parameter", "for", "use", "later", "in", "the", "chain", ".", "This", "can", "be", "used", "to", "adjust", "all", "aspects", "of", "the", "later", "processing", "if", "needed", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/ActionResponse.php#L100-L106
neos/flow-development-collection
Neos.Flow/Migrations/Mysql/Version20141015125841.php
Version20141015125841.postUp
public function postUp(Schema $schema) { if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) { return; } $resourcesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, sha1, filename FROM typo3_flow_resource_resource'); while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) { $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1']; $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1'][0] . '/' . $resourceInfo['sha1'][1] . '/' . $resourceInfo['sha1'][2] . '/' . $resourceInfo['sha1'][3] . '/' . $resourceInfo['sha1']; $mediaType = MediaTypes::getMediaTypeFromFilename($resourceInfo['filename']); if (file_exists($resourcePathAndFilename)) { $md5 = md5_file($resourcePathAndFilename); $filesize = filesize($resourcePathAndFilename); if (!file_exists(dirname($newResourcePathAndFilename))) { Files::createDirectoryRecursively(dirname($newResourcePathAndFilename)); } $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename); } elseif (file_exists($newResourcePathAndFilename)) { $md5 = md5_file($newResourcePathAndFilename); $filesize = filesize($newResourcePathAndFilename); $result = true; } else { $this->write(sprintf('Error while migrating database for the new resource management: the resource file "%s" (original filename: %s) was not found, but the resource object with uuid %s needs this file.', $resourcePathAndFilename, $resourceInfo['filename'], $resourceInfo['persistence_object_identifier'])); continue; } $this->connection->executeUpdate( 'UPDATE typo3_flow_resource_resource SET collectionname = ?, mediatype = ?, md5 = ?, filesize = ? WHERE persistence_object_identifier = ?', array('persistent', $mediaType, $md5, $filesize, $resourceInfo['persistence_object_identifier']) ); if ($result === false) { $this->write(sprintf('Could not move the data file of resource "%s" from its legacy location at %s to the correct location %s.', $resourceInfo['sha1'], $resourcePathAndFilename, $newResourcePathAndFilename)); } } $this->connection->exec('ALTER TABLE typo3_flow_resource_resource CHANGE collectionname collectionname VARCHAR(255) NOT NULL, CHANGE mediatype mediatype VARCHAR(100) NOT NULL, CHANGE md5 md5 VARCHAR(32) NOT NULL, CHANGE filesize filesize NUMERIC(20, 0) NOT NULL'); }
php
public function postUp(Schema $schema) { if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) { return; } $resourcesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, sha1, filename FROM typo3_flow_resource_resource'); while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) { $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1']; $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['sha1'][0] . '/' . $resourceInfo['sha1'][1] . '/' . $resourceInfo['sha1'][2] . '/' . $resourceInfo['sha1'][3] . '/' . $resourceInfo['sha1']; $mediaType = MediaTypes::getMediaTypeFromFilename($resourceInfo['filename']); if (file_exists($resourcePathAndFilename)) { $md5 = md5_file($resourcePathAndFilename); $filesize = filesize($resourcePathAndFilename); if (!file_exists(dirname($newResourcePathAndFilename))) { Files::createDirectoryRecursively(dirname($newResourcePathAndFilename)); } $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename); } elseif (file_exists($newResourcePathAndFilename)) { $md5 = md5_file($newResourcePathAndFilename); $filesize = filesize($newResourcePathAndFilename); $result = true; } else { $this->write(sprintf('Error while migrating database for the new resource management: the resource file "%s" (original filename: %s) was not found, but the resource object with uuid %s needs this file.', $resourcePathAndFilename, $resourceInfo['filename'], $resourceInfo['persistence_object_identifier'])); continue; } $this->connection->executeUpdate( 'UPDATE typo3_flow_resource_resource SET collectionname = ?, mediatype = ?, md5 = ?, filesize = ? WHERE persistence_object_identifier = ?', array('persistent', $mediaType, $md5, $filesize, $resourceInfo['persistence_object_identifier']) ); if ($result === false) { $this->write(sprintf('Could not move the data file of resource "%s" from its legacy location at %s to the correct location %s.', $resourceInfo['sha1'], $resourcePathAndFilename, $newResourcePathAndFilename)); } } $this->connection->exec('ALTER TABLE typo3_flow_resource_resource CHANGE collectionname collectionname VARCHAR(255) NOT NULL, CHANGE mediatype mediatype VARCHAR(100) NOT NULL, CHANGE md5 md5 VARCHAR(32) NOT NULL, CHANGE filesize filesize NUMERIC(20, 0) NOT NULL'); }
[ "public", "function", "postUp", "(", "Schema", "$", "schema", ")", "{", "if", "(", "!", "$", "this", "->", "sm", "->", "tablesExist", "(", "[", "'typo3_flow_resource_resource'", "]", ")", ")", "{", "return", ";", "}", "$", "resourcesResult", "=", "$", ...
Move resource files to the new locations and adjust records. @param Schema $schema @return void
[ "Move", "resource", "files", "to", "the", "new", "locations", "and", "adjust", "records", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Mysql/Version20141015125841.php#L41-L80
neos/flow-development-collection
Neos.Flow/Migrations/Mysql/Version20141015125841.php
Version20141015125841.postDown
public function postDown(Schema $schema) { if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) { return; } $resourcesResult = $this->connection->executeQuery('SELECT DISTINCT resourcepointer FROM typo3_flow_resource_resource'); while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) { $this->connection->executeQuery( 'INSERT INTO typo3_flow_resource_resourcepointer (hash) VALUES (?)', array($resourceInfo['resourcepointer']) ); $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'][0] . '/' . $resourceInfo['resourcepointer'][1] . '/' . $resourceInfo['resourcepointer'][2] . '/' . $resourceInfo['resourcepointer'][3] . '/' . $resourceInfo['resourcepointer']; if (!file_exists($resourcePathAndFilename)) { $this->write(sprintf('Error while migrating database for the old resource management: the resource file "%s" was not found.', $resourcePathAndFilename)); continue; } $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer']; $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename); if ($result === false) { $this->write(sprintf('Could not move the data file of resource "%s" from its location at %s to the legacy location %s.', $resourceInfo['resourcepointer'], $resourcePathAndFilename, $newResourcePathAndFilename)); } Files::removeEmptyDirectoriesOnPath(dirname($resourcePathAndFilename)); } $this->connection->exec('UPDATE typo3_flow_resource_resource SET fileextension = SUBSTRING_INDEX(filename, \'.\', -1)'); $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ADD CONSTRAINT typo3_flow_resource_resource_ibfk_1 FOREIGN KEY (resourcepointer) REFERENCES typo3_flow_resource_resourcepointer (hash)'); }
php
public function postDown(Schema $schema) { if (!$this->sm->tablesExist(['typo3_flow_resource_resource'])) { return; } $resourcesResult = $this->connection->executeQuery('SELECT DISTINCT resourcepointer FROM typo3_flow_resource_resource'); while ($resourceInfo = $resourcesResult->fetch(\PDO::FETCH_ASSOC)) { $this->connection->executeQuery( 'INSERT INTO typo3_flow_resource_resourcepointer (hash) VALUES (?)', array($resourceInfo['resourcepointer']) ); $resourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer'][0] . '/' . $resourceInfo['resourcepointer'][1] . '/' . $resourceInfo['resourcepointer'][2] . '/' . $resourceInfo['resourcepointer'][3] . '/' . $resourceInfo['resourcepointer']; if (!file_exists($resourcePathAndFilename)) { $this->write(sprintf('Error while migrating database for the old resource management: the resource file "%s" was not found.', $resourcePathAndFilename)); continue; } $newResourcePathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resourceInfo['resourcepointer']; $result = @rename($resourcePathAndFilename, $newResourcePathAndFilename); if ($result === false) { $this->write(sprintf('Could not move the data file of resource "%s" from its location at %s to the legacy location %s.', $resourceInfo['resourcepointer'], $resourcePathAndFilename, $newResourcePathAndFilename)); } Files::removeEmptyDirectoriesOnPath(dirname($resourcePathAndFilename)); } $this->connection->exec('UPDATE typo3_flow_resource_resource SET fileextension = SUBSTRING_INDEX(filename, \'.\', -1)'); $this->connection->exec('ALTER TABLE typo3_flow_resource_resource ADD CONSTRAINT typo3_flow_resource_resource_ibfk_1 FOREIGN KEY (resourcepointer) REFERENCES typo3_flow_resource_resourcepointer (hash)'); }
[ "public", "function", "postDown", "(", "Schema", "$", "schema", ")", "{", "if", "(", "!", "$", "this", "->", "sm", "->", "tablesExist", "(", "[", "'typo3_flow_resource_resource'", "]", ")", ")", "{", "return", ";", "}", "$", "resourcesResult", "=", "$", ...
Move resource files back to the old locations and adjust records. @param Schema $schema @return void
[ "Move", "resource", "files", "back", "to", "the", "old", "locations", "and", "adjust", "records", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Mysql/Version20141015125841.php#L103-L130
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.withoutAuthorizationChecks
public function withoutAuthorizationChecks(\Closure $callback) { $authorizationChecksAreAlreadyDisabled = $this->authorizationChecksDisabled; $this->authorizationChecksDisabled = true; try { /** @noinspection PhpUndefinedMethodInspection */ $callback->__invoke(); } catch (\Exception $exception) { $this->authorizationChecksDisabled = false; throw $exception; } if ($authorizationChecksAreAlreadyDisabled === false) { $this->authorizationChecksDisabled = false; } }
php
public function withoutAuthorizationChecks(\Closure $callback) { $authorizationChecksAreAlreadyDisabled = $this->authorizationChecksDisabled; $this->authorizationChecksDisabled = true; try { /** @noinspection PhpUndefinedMethodInspection */ $callback->__invoke(); } catch (\Exception $exception) { $this->authorizationChecksDisabled = false; throw $exception; } if ($authorizationChecksAreAlreadyDisabled === false) { $this->authorizationChecksDisabled = false; } }
[ "public", "function", "withoutAuthorizationChecks", "(", "\\", "Closure", "$", "callback", ")", "{", "$", "authorizationChecksAreAlreadyDisabled", "=", "$", "this", "->", "authorizationChecksDisabled", ";", "$", "this", "->", "authorizationChecksDisabled", "=", "true", ...
Lets you switch off authorization checks (CSRF token, policies, content security, ...) for the runtime of $callback Usage: $this->securityContext->withoutAuthorizationChecks(function () use ($accountRepository, $username, $providerName, &$account) { // this will disable the PersistenceQueryRewritingAspect for this one call $account = $accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($username, $providerName) }); @param \Closure $callback @return void @throws \Exception
[ "Lets", "you", "switch", "off", "authorization", "checks", "(", "CSRF", "token", "policies", "content", "security", "...", ")", "for", "the", "runtime", "of", "$callback" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L212-L226
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.injectSettings
public function injectSettings(array $settings) { if (isset($settings['security']['authentication']['authenticationStrategy'])) { $authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy']; switch ($authenticationStrategyName) { case 'allTokens': $this->authenticationStrategy = self::AUTHENTICATE_ALL_TOKENS; break; case 'oneToken': $this->authenticationStrategy = self::AUTHENTICATE_ONE_TOKEN; break; case 'atLeastOneToken': $this->authenticationStrategy = self::AUTHENTICATE_AT_LEAST_ONE_TOKEN; break; case 'anyToken': $this->authenticationStrategy = self::AUTHENTICATE_ANY_TOKEN; break; default: throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022); } } if (isset($settings['security']['csrf']['csrfStrategy'])) { $csrfStrategyName = $settings['security']['csrf']['csrfStrategy']; switch ($csrfStrategyName) { case 'onePerRequest': $this->csrfProtectionStrategy = self::CSRF_ONE_PER_REQUEST; break; case 'onePerSession': $this->csrfProtectionStrategy = self::CSRF_ONE_PER_SESSION; break; case 'onePerUri': $this->csrfProtectionStrategy = self::CSRF_ONE_PER_URI; break; default: throw new Exception('Invalid setting "' . $csrfStrategyName . '" for security.csrf.csrfStrategy', 1291043024); } } }
php
public function injectSettings(array $settings) { if (isset($settings['security']['authentication']['authenticationStrategy'])) { $authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy']; switch ($authenticationStrategyName) { case 'allTokens': $this->authenticationStrategy = self::AUTHENTICATE_ALL_TOKENS; break; case 'oneToken': $this->authenticationStrategy = self::AUTHENTICATE_ONE_TOKEN; break; case 'atLeastOneToken': $this->authenticationStrategy = self::AUTHENTICATE_AT_LEAST_ONE_TOKEN; break; case 'anyToken': $this->authenticationStrategy = self::AUTHENTICATE_ANY_TOKEN; break; default: throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022); } } if (isset($settings['security']['csrf']['csrfStrategy'])) { $csrfStrategyName = $settings['security']['csrf']['csrfStrategy']; switch ($csrfStrategyName) { case 'onePerRequest': $this->csrfProtectionStrategy = self::CSRF_ONE_PER_REQUEST; break; case 'onePerSession': $this->csrfProtectionStrategy = self::CSRF_ONE_PER_SESSION; break; case 'onePerUri': $this->csrfProtectionStrategy = self::CSRF_ONE_PER_URI; break; default: throw new Exception('Invalid setting "' . $csrfStrategyName . '" for security.csrf.csrfStrategy', 1291043024); } } }
[ "public", "function", "injectSettings", "(", "array", "$", "settings", ")", "{", "if", "(", "isset", "(", "$", "settings", "[", "'security'", "]", "[", "'authentication'", "]", "[", "'authenticationStrategy'", "]", ")", ")", "{", "$", "authenticationStrategyNa...
Injects the configuration settings @param array $settings @return void @throws Exception
[ "Injects", "the", "configuration", "settings" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L262-L300
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.initialize
public function initialize() { if ($this->initialized === true) { return; } if ($this->canBeInitialized() === false) { throw new Exception('The security Context cannot be initialized yet. Please check if it can be initialized with $securityContext->canBeInitialized() before trying to do so.', 1358513802); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $factoryTokens = $this->tokenAndProviderFactory->getTokens(); $tokens = $this->mergeTokens($factoryTokens, $sessionDataContainer->getSecurityTokens()); $this->separateActiveAndInactiveTokens($tokens); $this->updateTokens($this->activeTokens); $this->initialized = true; }
php
public function initialize() { if ($this->initialized === true) { return; } if ($this->canBeInitialized() === false) { throw new Exception('The security Context cannot be initialized yet. Please check if it can be initialized with $securityContext->canBeInitialized() before trying to do so.', 1358513802); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $factoryTokens = $this->tokenAndProviderFactory->getTokens(); $tokens = $this->mergeTokens($factoryTokens, $sessionDataContainer->getSecurityTokens()); $this->separateActiveAndInactiveTokens($tokens); $this->updateTokens($this->activeTokens); $this->initialized = true; }
[ "public", "function", "initialize", "(", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "true", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "canBeInitialized", "(", ")", "===", "false", ")", "{", "throw", "new", "Except...
Initializes the security context for the given request. @return void @throws Exception
[ "Initializes", "the", "security", "context", "for", "the", "given", "request", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L308-L324
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.getAuthenticationTokensOfType
public function getAuthenticationTokensOfType($className) { if ($this->initialized === false) { $this->initialize(); } $activeTokens = []; foreach ($this->activeTokens as $token) { if ($token instanceof $className) { $activeTokens[] = $token; } } return $activeTokens; }
php
public function getAuthenticationTokensOfType($className) { if ($this->initialized === false) { $this->initialize(); } $activeTokens = []; foreach ($this->activeTokens as $token) { if ($token instanceof $className) { $activeTokens[] = $token; } } return $activeTokens; }
[ "public", "function", "getAuthenticationTokensOfType", "(", "$", "className", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "$", "activeTokens", "=", "[", "]", ";", ...
Returns all Authentication\Tokens of the security context which are active for the current request and of the given type. If a token has a request pattern that cannot match against the current request it is determined as not active. @param string $className The class name @return TokenInterface[] Array of set tokens of the specified type
[ "Returns", "all", "Authentication", "\\", "Tokens", "of", "the", "security", "context", "which", "are", "active", "for", "the", "current", "request", "and", "of", "the", "given", "type", ".", "If", "a", "token", "has", "a", "request", "pattern", "that", "c...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L372-L386
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.getRoles
public function getRoles() { if ($this->initialized === false) { $this->initialize(); } if ($this->roles !== null) { return $this->roles; } $this->roles = ['Neos.Flow:Everybody' => $this->policyService->getRole('Neos.Flow:Everybody')]; $authenticatedTokens = array_filter($this->getAuthenticationTokens(), function (TokenInterface $token) { return $token->isAuthenticated(); }); if (empty($authenticatedTokens)) { $this->roles['Neos.Flow:Anonymous'] = $this->policyService->getRole('Neos.Flow:Anonymous'); return $this->roles; } $this->roles['Neos.Flow:AuthenticatedUser'] = $this->policyService->getRole('Neos.Flow:AuthenticatedUser'); /** @var $token TokenInterface */ foreach ($authenticatedTokens as $token) { $account = $token->getAccount(); if ($account === null) { continue; } $this->roles = array_merge($this->roles, $this->collectRolesAndParentRolesFromAccount($account)); } return $this->roles; }
php
public function getRoles() { if ($this->initialized === false) { $this->initialize(); } if ($this->roles !== null) { return $this->roles; } $this->roles = ['Neos.Flow:Everybody' => $this->policyService->getRole('Neos.Flow:Everybody')]; $authenticatedTokens = array_filter($this->getAuthenticationTokens(), function (TokenInterface $token) { return $token->isAuthenticated(); }); if (empty($authenticatedTokens)) { $this->roles['Neos.Flow:Anonymous'] = $this->policyService->getRole('Neos.Flow:Anonymous'); return $this->roles; } $this->roles['Neos.Flow:AuthenticatedUser'] = $this->policyService->getRole('Neos.Flow:AuthenticatedUser'); /** @var $token TokenInterface */ foreach ($authenticatedTokens as $token) { $account = $token->getAccount(); if ($account === null) { continue; } $this->roles = array_merge($this->roles, $this->collectRolesAndParentRolesFromAccount($account)); } return $this->roles; }
[ "public", "function", "getRoles", "(", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "if", "(", "$", "this", "->", "roles", "!==", "null", ")", "{", "return", ...
Returns the roles of all authenticated accounts, including inherited roles. If no authenticated roles could be found the "Anonymous" role is returned. The "Neos.Flow:Everybody" roles is always returned. @return Role[] @throws Exception @throws Exception\NoSuchRoleException
[ "Returns", "the", "roles", "of", "all", "authenticated", "accounts", "including", "inherited", "roles", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L399-L433
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.hasRole
public function hasRole($roleIdentifier) { if ($roleIdentifier === 'Neos.Flow:Everybody') { return true; } $roles = $this->getRoles(); return isset($roles[$roleIdentifier]); }
php
public function hasRole($roleIdentifier) { if ($roleIdentifier === 'Neos.Flow:Everybody') { return true; } $roles = $this->getRoles(); return isset($roles[$roleIdentifier]); }
[ "public", "function", "hasRole", "(", "$", "roleIdentifier", ")", "{", "if", "(", "$", "roleIdentifier", "===", "'Neos.Flow:Everybody'", ")", "{", "return", "true", ";", "}", "$", "roles", "=", "$", "this", "->", "getRoles", "(", ")", ";", "return", "iss...
Returns true, if at least one of the currently authenticated accounts holds a role with the given identifier, also recursively. @param string $roleIdentifier The string representation of the role to search for @return boolean true, if a role with the given string representation was found @throws Exception @throws Exception\NoSuchRoleException
[ "Returns", "true", "if", "at", "least", "one", "of", "the", "currently", "authenticated", "accounts", "holds", "a", "role", "with", "the", "given", "identifier", "also", "recursively", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L444-L452
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.getAccountByAuthenticationProviderName
public function getAccountByAuthenticationProviderName($authenticationProviderName) { if ($this->initialized === false) { $this->initialize(); } if (isset($this->activeTokens[$authenticationProviderName]) && $this->activeTokens[$authenticationProviderName]->isAuthenticated() === true) { return $this->activeTokens[$authenticationProviderName]->getAccount(); } return null; }
php
public function getAccountByAuthenticationProviderName($authenticationProviderName) { if ($this->initialized === false) { $this->initialize(); } if (isset($this->activeTokens[$authenticationProviderName]) && $this->activeTokens[$authenticationProviderName]->isAuthenticated() === true) { return $this->activeTokens[$authenticationProviderName]->getAccount(); } return null; }
[ "public", "function", "getAccountByAuthenticationProviderName", "(", "$", "authenticationProviderName", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "if", "(", "isset", ...
Returns an authenticated account for the given provider or NULL if no account was authenticated or no token was registered for the given authentication provider name. @param string $authenticationProviderName Authentication provider name of the account to find @return Account The authenticated account
[ "Returns", "an", "authenticated", "account", "for", "the", "given", "provider", "or", "NULL", "if", "no", "account", "was", "authenticated", "or", "no", "token", "was", "registered", "for", "the", "given", "authentication", "provider", "name", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L487-L497
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.getCsrfProtectionToken
public function getCsrfProtectionToken() { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens(); if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_SESSION && count($csrfProtectionTokens) === 1) { reset($csrfProtectionTokens); return key($csrfProtectionTokens); } if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_REQUEST) { if (empty($this->requestCsrfToken)) { $this->requestCsrfToken = Algorithms::generateRandomToken(16); $csrfProtectionTokens[$this->requestCsrfToken] = true; $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens); } return $this->requestCsrfToken; } $newToken = Algorithms::generateRandomToken(16); $csrfProtectionTokens[$newToken] = true; $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens); return $newToken; }
php
public function getCsrfProtectionToken() { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens(); if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_SESSION && count($csrfProtectionTokens) === 1) { reset($csrfProtectionTokens); return key($csrfProtectionTokens); } if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_REQUEST) { if (empty($this->requestCsrfToken)) { $this->requestCsrfToken = Algorithms::generateRandomToken(16); $csrfProtectionTokens[$this->requestCsrfToken] = true; $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens); } return $this->requestCsrfToken; } $newToken = Algorithms::generateRandomToken(16); $csrfProtectionTokens[$newToken] = true; $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens); return $newToken; }
[ "public", "function", "getCsrfProtectionToken", "(", ")", "{", "$", "sessionDataContainer", "=", "$", "this", "->", "objectManager", "->", "get", "(", "SessionDataContainer", "::", "class", ")", ";", "$", "csrfProtectionTokens", "=", "$", "sessionDataContainer", "...
Returns the current CSRF protection token. A new one is created when needed, depending on the configured CSRF protection strategy. @return string @Flow\Session(autoStart=true)
[ "Returns", "the", "current", "CSRF", "protection", "token", ".", "A", "new", "one", "is", "created", "when", "needed", "depending", "on", "the", "configured", "CSRF", "protection", "strategy", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L506-L530
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.hasCsrfProtectionTokens
public function hasCsrfProtectionTokens() { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens(); return count($csrfProtectionTokens) > 0; }
php
public function hasCsrfProtectionTokens() { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens(); return count($csrfProtectionTokens) > 0; }
[ "public", "function", "hasCsrfProtectionTokens", "(", ")", "{", "$", "sessionDataContainer", "=", "$", "this", "->", "objectManager", "->", "get", "(", "SessionDataContainer", "::", "class", ")", ";", "$", "csrfProtectionTokens", "=", "$", "sessionDataContainer", ...
Returns true if the context has CSRF protection tokens. @return boolean true, if the token is valid. false otherwise.
[ "Returns", "true", "if", "the", "context", "has", "CSRF", "protection", "tokens", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L537-L542
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.isCsrfProtectionTokenValid
public function isCsrfProtectionTokenValid($csrfToken) { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens(); if (!isset($csrfProtectionTokens[$csrfToken]) && !isset($this->csrfTokensRemovedAfterCurrentRequest[$csrfToken])) { return false; } if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_URI) { unset($csrfProtectionTokens[$csrfToken]); } if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_REQUEST) { $this->csrfTokensRemovedAfterCurrentRequest[$csrfToken] = true; unset($csrfProtectionTokens[$csrfToken]); } $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens); return true; }
php
public function isCsrfProtectionTokenValid($csrfToken) { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens(); if (!isset($csrfProtectionTokens[$csrfToken]) && !isset($this->csrfTokensRemovedAfterCurrentRequest[$csrfToken])) { return false; } if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_URI) { unset($csrfProtectionTokens[$csrfToken]); } if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_REQUEST) { $this->csrfTokensRemovedAfterCurrentRequest[$csrfToken] = true; unset($csrfProtectionTokens[$csrfToken]); } $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens); return true; }
[ "public", "function", "isCsrfProtectionTokenValid", "(", "$", "csrfToken", ")", "{", "$", "sessionDataContainer", "=", "$", "this", "->", "objectManager", "->", "get", "(", "SessionDataContainer", "::", "class", ")", ";", "$", "csrfProtectionTokens", "=", "$", "...
Returns true if the given string is a valid CSRF protection token. The token will be removed if the configured csrf strategy is 'onePerUri'. @param string $csrfToken The token string to be validated @return boolean true, if the token is valid. false otherwise. @throws Exception
[ "Returns", "true", "if", "the", "given", "string", "is", "a", "valid", "CSRF", "protection", "token", ".", "The", "token", "will", "be", "removed", "if", "the", "configured", "csrf", "strategy", "is", "onePerUri", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L552-L572
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.setInterceptedRequest
public function setInterceptedRequest(ActionRequest $interceptedRequest = null) { if ($this->initialized === false) { $this->initialize(); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $sessionDataContainer->setInterceptedRequest($interceptedRequest); }
php
public function setInterceptedRequest(ActionRequest $interceptedRequest = null) { if ($this->initialized === false) { $this->initialize(); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $sessionDataContainer->setInterceptedRequest($interceptedRequest); }
[ "public", "function", "setInterceptedRequest", "(", "ActionRequest", "$", "interceptedRequest", "=", "null", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "$", "session...
Sets an action request, to be stored for later resuming after it has been intercepted by a security exception. @param ActionRequest $interceptedRequest @return void @Flow\Session(autoStart=true)
[ "Sets", "an", "action", "request", "to", "be", "stored", "for", "later", "resuming", "after", "it", "has", "been", "intercepted", "by", "a", "security", "exception", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L582-L590
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.getInterceptedRequest
public function getInterceptedRequest() { if ($this->initialized === false) { $this->initialize(); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); return $sessionDataContainer->getInterceptedRequest(); }
php
public function getInterceptedRequest() { if ($this->initialized === false) { $this->initialize(); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); return $sessionDataContainer->getInterceptedRequest(); }
[ "public", "function", "getInterceptedRequest", "(", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "$", "sessionDataContainer", "=", "$", "this", "->", "objectManager", ...
Returns the request, that has been stored for later resuming after it has been intercepted by a security exception, NULL if there is none. @return ActionRequest|null TODO: Revisit type (ActionRequest / HTTP request)
[ "Returns", "the", "request", "that", "has", "been", "stored", "for", "later", "resuming", "after", "it", "has", "been", "intercepted", "by", "a", "security", "exception", "NULL", "if", "there", "is", "none", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L599-L607
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.clearContext
public function clearContext() { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $sessionDataContainer->reset(); $this->roles = null; $this->contextHash = null; $this->activeTokens = []; $this->inactiveTokens = []; $this->request = null; $this->authorizationChecksDisabled = false; $this->initialized = false; }
php
public function clearContext() { $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $sessionDataContainer->reset(); $this->roles = null; $this->contextHash = null; $this->activeTokens = []; $this->inactiveTokens = []; $this->request = null; $this->authorizationChecksDisabled = false; $this->initialized = false; }
[ "public", "function", "clearContext", "(", ")", "{", "$", "sessionDataContainer", "=", "$", "this", "->", "objectManager", "->", "get", "(", "SessionDataContainer", "::", "class", ")", ";", "$", "sessionDataContainer", "->", "reset", "(", ")", ";", "$", "thi...
Clears the security context. @return void
[ "Clears", "the", "security", "context", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L614-L626
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.separateActiveAndInactiveTokens
protected function separateActiveAndInactiveTokens(array $tokens) { if ($this->request === null) { return; } /** @var $token TokenInterface */ foreach ($tokens as $token) { if ($this->isTokenActive($token)) { $this->activeTokens[$token->getAuthenticationProviderName()] = $token; } else { $this->inactiveTokens[$token->getAuthenticationProviderName()] = $token; } } }
php
protected function separateActiveAndInactiveTokens(array $tokens) { if ($this->request === null) { return; } /** @var $token TokenInterface */ foreach ($tokens as $token) { if ($this->isTokenActive($token)) { $this->activeTokens[$token->getAuthenticationProviderName()] = $token; } else { $this->inactiveTokens[$token->getAuthenticationProviderName()] = $token; } } }
[ "protected", "function", "separateActiveAndInactiveTokens", "(", "array", "$", "tokens", ")", "{", "if", "(", "$", "this", "->", "request", "===", "null", ")", "{", "return", ";", "}", "/** @var $token TokenInterface */", "foreach", "(", "$", "tokens", "as", "...
Stores all active tokens in $this->activeTokens, all others in $this->inactiveTokens @param TokenInterface[] $tokens @return void
[ "Stores", "all", "active", "tokens", "in", "$this", "-", ">", "activeTokens", "all", "others", "in", "$this", "-", ">", "inactiveTokens" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L664-L678
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.isTokenActive
protected function isTokenActive(TokenInterface $token) { if (!$token->hasRequestPatterns()) { return true; } $requestPatternsByType = []; /** @var $requestPattern RequestPatternInterface */ foreach ($token->getRequestPatterns() as $requestPattern) { $patternType = TypeHandling::getTypeForValue($requestPattern); if (isset($requestPatternsByType[$patternType]) && $requestPatternsByType[$patternType] === true) { continue; } $requestPatternsByType[$patternType] = $requestPattern->matchRequest($this->request); } return !in_array(false, $requestPatternsByType, true); }
php
protected function isTokenActive(TokenInterface $token) { if (!$token->hasRequestPatterns()) { return true; } $requestPatternsByType = []; /** @var $requestPattern RequestPatternInterface */ foreach ($token->getRequestPatterns() as $requestPattern) { $patternType = TypeHandling::getTypeForValue($requestPattern); if (isset($requestPatternsByType[$patternType]) && $requestPatternsByType[$patternType] === true) { continue; } $requestPatternsByType[$patternType] = $requestPattern->matchRequest($this->request); } return !in_array(false, $requestPatternsByType, true); }
[ "protected", "function", "isTokenActive", "(", "TokenInterface", "$", "token", ")", "{", "if", "(", "!", "$", "token", "->", "hasRequestPatterns", "(", ")", ")", "{", "return", "true", ";", "}", "$", "requestPatternsByType", "=", "[", "]", ";", "/** @var $...
Evaluates any RequestPatterns of the given token to determine whether it is active for the current request - If no RequestPattern is configured for this token, it is active - Otherwise it is active only if at least one configured RequestPattern per type matches the request @param TokenInterface $token @return bool true if the given token is active, otherwise false
[ "Evaluates", "any", "RequestPatterns", "of", "the", "given", "token", "to", "determine", "whether", "it", "is", "active", "for", "the", "current", "request", "-", "If", "no", "RequestPattern", "is", "configured", "for", "this", "token", "it", "is", "active", ...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L688-L703
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.mergeTokens
protected function mergeTokens($managerTokens, $sessionTokens) { $resultTokens = []; if (!is_array($managerTokens)) { return $resultTokens; } $sessionTokens = $sessionTokens ?? []; /** @var $managerToken TokenInterface */ foreach ($managerTokens as $managerToken) { $resultTokens[$managerToken->getAuthenticationProviderName()] = $this->findBestMatchingToken($managerToken, $sessionTokens); } return $resultTokens; }
php
protected function mergeTokens($managerTokens, $sessionTokens) { $resultTokens = []; if (!is_array($managerTokens)) { return $resultTokens; } $sessionTokens = $sessionTokens ?? []; /** @var $managerToken TokenInterface */ foreach ($managerTokens as $managerToken) { $resultTokens[$managerToken->getAuthenticationProviderName()] = $this->findBestMatchingToken($managerToken, $sessionTokens); } return $resultTokens; }
[ "protected", "function", "mergeTokens", "(", "$", "managerTokens", ",", "$", "sessionTokens", ")", "{", "$", "resultTokens", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "managerTokens", ")", ")", "{", "return", "$", "resultTokens", ";", "}"...
Merges the session and manager tokens. All manager tokens types will be in the result array If a specific type is found in the session this token replaces the one (of the same type) given by the manager. @param array $managerTokens Array of tokens provided by the authentication manager @param array $sessionTokens Array of tokens restored from the session @return array Array of Authentication\TokenInterface objects
[ "Merges", "the", "session", "and", "manager", "tokens", ".", "All", "manager", "tokens", "types", "will", "be", "in", "the", "result", "array", "If", "a", "specific", "type", "is", "found", "in", "the", "session", "this", "token", "replaces", "the", "one",...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L714-L730
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.findBestMatchingToken
protected function findBestMatchingToken(TokenInterface $managerToken, array $sessionTokens): TokenInterface { $matchingSessionTokens = array_filter($sessionTokens, function (TokenInterface $sessionToken) use ($managerToken) { return ($sessionToken->getAuthenticationProviderName() === $managerToken->getAuthenticationProviderName()); }); if (empty($matchingSessionTokens)) { return $managerToken; } $matchingSessionToken = reset($matchingSessionTokens); $session = $this->sessionManager->getCurrentSession(); $this->securityLogger->debug( sprintf( 'Session %s contains auth token %s for provider %s. Status: %s', $session->getId(), get_class($matchingSessionToken), $matchingSessionToken->getAuthenticationProviderName(), $this->tokenStatusLabels[$matchingSessionToken->getAuthenticationStatus()] ), LogEnvironment::fromMethodName(__METHOD__) ); return $matchingSessionToken; }
php
protected function findBestMatchingToken(TokenInterface $managerToken, array $sessionTokens): TokenInterface { $matchingSessionTokens = array_filter($sessionTokens, function (TokenInterface $sessionToken) use ($managerToken) { return ($sessionToken->getAuthenticationProviderName() === $managerToken->getAuthenticationProviderName()); }); if (empty($matchingSessionTokens)) { return $managerToken; } $matchingSessionToken = reset($matchingSessionTokens); $session = $this->sessionManager->getCurrentSession(); $this->securityLogger->debug( sprintf( 'Session %s contains auth token %s for provider %s. Status: %s', $session->getId(), get_class($matchingSessionToken), $matchingSessionToken->getAuthenticationProviderName(), $this->tokenStatusLabels[$matchingSessionToken->getAuthenticationStatus()] ), LogEnvironment::fromMethodName(__METHOD__) ); return $matchingSessionToken; }
[ "protected", "function", "findBestMatchingToken", "(", "TokenInterface", "$", "managerToken", ",", "array", "$", "sessionTokens", ")", ":", "TokenInterface", "{", "$", "matchingSessionTokens", "=", "array_filter", "(", "$", "sessionTokens", ",", "function", "(", "To...
Tries to find a token matchting the given manager token in the session tokens, will return that or the manager token. @param TokenInterface $managerToken @param TokenInterface[] $sessionTokens @return TokenInterface @throws \Neos\Flow\Session\Exception\SessionNotStartedException
[ "Tries", "to", "find", "a", "token", "matchting", "the", "given", "manager", "token", "in", "the", "session", "tokens", "will", "return", "that", "or", "the", "manager", "token", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L740-L764
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.updateTokens
protected function updateTokens(array $tokens) { $this->roles = null; $this->contextHash = null; if ($this->request === null) { return; } /** @var $token TokenInterface */ foreach ($tokens as $token) { $token->updateCredentials($this->request); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $sessionDataContainer->setSecurityTokens(array_merge($this->inactiveTokens, $this->activeTokens)); }
php
protected function updateTokens(array $tokens) { $this->roles = null; $this->contextHash = null; if ($this->request === null) { return; } /** @var $token TokenInterface */ foreach ($tokens as $token) { $token->updateCredentials($this->request); } $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class); $sessionDataContainer->setSecurityTokens(array_merge($this->inactiveTokens, $this->activeTokens)); }
[ "protected", "function", "updateTokens", "(", "array", "$", "tokens", ")", "{", "$", "this", "->", "roles", "=", "null", ";", "$", "this", "->", "contextHash", "=", "null", ";", "if", "(", "$", "this", "->", "request", "===", "null", ")", "{", "retur...
Updates the token credentials for all tokens in the given array. @param array $tokens Array of authentication tokens the credentials should be updated for @return void
[ "Updates", "the", "token", "credentials", "for", "all", "tokens", "in", "the", "given", "array", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L772-L788
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.refreshTokens
public function refreshTokens() { if ($this->initialized === false) { $this->initialize(); } $this->updateTokens($this->activeTokens); }
php
public function refreshTokens() { if ($this->initialized === false) { $this->initialize(); } $this->updateTokens($this->activeTokens); }
[ "public", "function", "refreshTokens", "(", ")", "{", "if", "(", "$", "this", "->", "initialized", "===", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "$", "this", "->", "updateTokens", "(", "$", "this", "->", "activeTokens",...
Refreshes all active tokens by updating the credentials. This is useful when doing an explicit authentication inside a request. @return void
[ "Refreshes", "all", "active", "tokens", "by", "updating", "the", "credentials", ".", "This", "is", "useful", "when", "doing", "an", "explicit", "authentication", "inside", "a", "request", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L796-L803
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.getContextHash
public function getContextHash() { if ($this->areAuthorizationChecksDisabled()) { return self::CONTEXT_HASH_UNINITIALIZED; } if (!$this->isInitialized()) { if (!$this->canBeInitialized()) { return self::CONTEXT_HASH_UNINITIALIZED; } $this->initialize(); } if ($this->contextHash !== null) { return $this->contextHash; } $contextHashSoFar = implode('|', array_keys($this->getRoles())); $this->withoutAuthorizationChecks(function () use (&$contextHashSoFar) { foreach ($this->globalObjects as $globalObjectsRegisteredClassName) { if (is_subclass_of($globalObjectsRegisteredClassName, CacheAwareInterface::class)) { $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName); $contextHashSoFar .= '<' . $globalObject->getCacheEntryIdentifier(); } } }); $this->contextHash = md5($contextHashSoFar); return $this->contextHash; }
php
public function getContextHash() { if ($this->areAuthorizationChecksDisabled()) { return self::CONTEXT_HASH_UNINITIALIZED; } if (!$this->isInitialized()) { if (!$this->canBeInitialized()) { return self::CONTEXT_HASH_UNINITIALIZED; } $this->initialize(); } if ($this->contextHash !== null) { return $this->contextHash; } $contextHashSoFar = implode('|', array_keys($this->getRoles())); $this->withoutAuthorizationChecks(function () use (&$contextHashSoFar) { foreach ($this->globalObjects as $globalObjectsRegisteredClassName) { if (is_subclass_of($globalObjectsRegisteredClassName, CacheAwareInterface::class)) { $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName); $contextHashSoFar .= '<' . $globalObject->getCacheEntryIdentifier(); } } }); $this->contextHash = md5($contextHashSoFar); return $this->contextHash; }
[ "public", "function", "getContextHash", "(", ")", "{", "if", "(", "$", "this", "->", "areAuthorizationChecksDisabled", "(", ")", ")", "{", "return", "self", "::", "CONTEXT_HASH_UNINITIALIZED", ";", "}", "if", "(", "!", "$", "this", "->", "isInitialized", "("...
Returns a hash that is unique for the current context, depending on hash components, @see setContextHashComponent() @return string
[ "Returns", "a", "hash", "that", "is", "unique", "for", "the", "current", "context", "depending", "on", "hash", "components", "@see", "setContextHashComponent", "()" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L839-L869
neos/flow-development-collection
Neos.Flow/Classes/Security/Context.php
Context.destroySessionsForAccount
public function destroySessionsForAccount(Account $account, string $reason = ''): void { $this->sessionManager->destroySessionsByTag($this->getSessionTagForAccount($account), $reason); }
php
public function destroySessionsForAccount(Account $account, string $reason = ''): void { $this->sessionManager->destroySessionsByTag($this->getSessionTagForAccount($account), $reason); }
[ "public", "function", "destroySessionsForAccount", "(", "Account", "$", "account", ",", "string", "$", "reason", "=", "''", ")", ":", "void", "{", "$", "this", "->", "sessionManager", "->", "destroySessionsByTag", "(", "$", "this", "->", "getSessionTagForAccount...
destroys all sessions belonging to the given $account @param Account $account @param string $reason @return void
[ "destroys", "all", "sessions", "belonging", "to", "the", "given", "$account" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Context.php#L889-L892
neos/flow-development-collection
Neos.Flow/Classes/Validation/Validator/FloatValidator.php
FloatValidator.isValid
protected function isValid($value) { if (is_float($value)) { return; } if (!is_string($value) || strpos($value, '.') === false || preg_match('/^[0-9.e+-]+$/', $value) !== 1) { $this->addError('A valid float number is expected.', 1221560288); } }
php
protected function isValid($value) { if (is_float($value)) { return; } if (!is_string($value) || strpos($value, '.') === false || preg_match('/^[0-9.e+-]+$/', $value) !== 1) { $this->addError('A valid float number is expected.', 1221560288); } }
[ "protected", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "is_float", "(", "$", "value", ")", ")", "{", "return", ";", "}", "if", "(", "!", "is_string", "(", "$", "value", ")", "||", "strpos", "(", "$", "value", ",", "'.'", ")",...
The given value is valid if it is of type float or a string matching the regular expression [0-9.e+-] @param mixed $value The value that should be validated @return void @api
[ "The", "given", "value", "is", "valid", "if", "it", "is", "of", "type", "float", "or", "a", "string", "matching", "the", "regular", "expression", "[", "0", "-", "9", ".", "e", "+", "-", "]" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/FloatValidator.php#L31-L39
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
AbstractTagBasedViewHelper.initialize
public function initialize() { parent::initialize(); $this->tag->reset(); $this->tag->setTagName($this->tagName); if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) { $this->tag->addAttributes($this->arguments['additionalAttributes']); } if ($this->hasArgument('data') && is_array($this->arguments['data'])) { foreach ($this->arguments['data'] as $dataAttributeKey => $dataAttributeValue) { $this->tag->addAttribute('data-' . $dataAttributeKey, $dataAttributeValue); } } if (isset(self::$tagAttributes[get_class($this)])) { foreach (self::$tagAttributes[get_class($this)] as $attributeName) { if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '' && $this->arguments[$attributeName] !== false) { if ($this->arguments[$attributeName] === true) { $this->tag->addAttribute($attributeName, ''); continue; } $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]); } } } }
php
public function initialize() { parent::initialize(); $this->tag->reset(); $this->tag->setTagName($this->tagName); if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) { $this->tag->addAttributes($this->arguments['additionalAttributes']); } if ($this->hasArgument('data') && is_array($this->arguments['data'])) { foreach ($this->arguments['data'] as $dataAttributeKey => $dataAttributeValue) { $this->tag->addAttribute('data-' . $dataAttributeKey, $dataAttributeValue); } } if (isset(self::$tagAttributes[get_class($this)])) { foreach (self::$tagAttributes[get_class($this)] as $attributeName) { if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '' && $this->arguments[$attributeName] !== false) { if ($this->arguments[$attributeName] === true) { $this->tag->addAttribute($attributeName, ''); continue; } $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]); } } } }
[ "public", "function", "initialize", "(", ")", "{", "parent", "::", "initialize", "(", ")", ";", "$", "this", "->", "tag", "->", "reset", "(", ")", ";", "$", "this", "->", "tag", "->", "setTagName", "(", "$", "this", "->", "tagName", ")", ";", "if",...
Sets the tag name to $this->tagName. Additionally, sets all tag attributes which were registered in $this->tagAttributes and additionalArguments. Will be invoked just before the render method. @return void @api
[ "Sets", "the", "tag", "name", "to", "$this", "-", ">", "tagName", ".", "Additionally", "sets", "all", "tag", "attributes", "which", "were", "registered", "in", "$this", "-", ">", "tagAttributes", "and", "additionalArguments", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php#L87-L113
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
AbstractTagBasedViewHelper.registerUniversalTagAttributes
protected function registerUniversalTagAttributes() { $this->registerTagAttribute('class', 'string', 'CSS class(es) for this element'); $this->registerTagAttribute('dir', 'string', 'Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)'); $this->registerTagAttribute('id', 'string', 'Unique (in this file) identifier for this HTML element.'); $this->registerTagAttribute('lang', 'string', 'Language for this element. Use short names specified in RFC 1766'); $this->registerTagAttribute('style', 'string', 'Individual CSS styles for this element'); $this->registerTagAttribute('title', 'string', 'Tooltip text of element'); $this->registerTagAttribute('accesskey', 'string', 'Keyboard shortcut to access this element'); $this->registerTagAttribute('tabindex', 'integer', 'Specifies the tab order of this element'); $this->registerTagAttribute('onclick', 'string', 'JavaScript evaluated for the onclick event'); }
php
protected function registerUniversalTagAttributes() { $this->registerTagAttribute('class', 'string', 'CSS class(es) for this element'); $this->registerTagAttribute('dir', 'string', 'Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)'); $this->registerTagAttribute('id', 'string', 'Unique (in this file) identifier for this HTML element.'); $this->registerTagAttribute('lang', 'string', 'Language for this element. Use short names specified in RFC 1766'); $this->registerTagAttribute('style', 'string', 'Individual CSS styles for this element'); $this->registerTagAttribute('title', 'string', 'Tooltip text of element'); $this->registerTagAttribute('accesskey', 'string', 'Keyboard shortcut to access this element'); $this->registerTagAttribute('tabindex', 'integer', 'Specifies the tab order of this element'); $this->registerTagAttribute('onclick', 'string', 'JavaScript evaluated for the onclick event'); }
[ "protected", "function", "registerUniversalTagAttributes", "(", ")", "{", "$", "this", "->", "registerTagAttribute", "(", "'class'", ",", "'string'", ",", "'CSS class(es) for this element'", ")", ";", "$", "this", "->", "registerTagAttribute", "(", "'dir'", ",", "'s...
Registers all standard HTML universal attributes. Should be used inside registerArguments(); @return void @api
[ "Registers", "all", "standard", "HTML", "universal", "attributes", ".", "Should", "be", "used", "inside", "registerArguments", "()", ";" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php#L139-L150
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
AbstractTagBasedViewHelper.handleAdditionalArguments
public function handleAdditionalArguments(array $arguments) { $unassigned = []; foreach ($arguments as $argumentName => $argumentValue) { if (strpos($argumentName, 'data-') === 0) { $this->tag->addAttribute($argumentName, $argumentValue); } else { $unassigned[$argumentName] = $argumentValue; } } parent::handleAdditionalArguments($unassigned); }
php
public function handleAdditionalArguments(array $arguments) { $unassigned = []; foreach ($arguments as $argumentName => $argumentValue) { if (strpos($argumentName, 'data-') === 0) { $this->tag->addAttribute($argumentName, $argumentValue); } else { $unassigned[$argumentName] = $argumentValue; } } parent::handleAdditionalArguments($unassigned); }
[ "public", "function", "handleAdditionalArguments", "(", "array", "$", "arguments", ")", "{", "$", "unassigned", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "argumentName", "=>", "$", "argumentValue", ")", "{", "if", "(", "strpos", "(",...
Handles additional arguments, sorting out any data- prefixed tag attributes and assigning them. Then passes the unassigned arguments to the parent class' method, which in the default implementation will throw an error about "undeclared argument used". @param array $arguments @return void
[ "Handles", "additional", "arguments", "sorting", "out", "any", "data", "-", "prefixed", "tag", "attributes", "and", "assigning", "them", ".", "Then", "passes", "the", "unassigned", "arguments", "to", "the", "parent", "class", "method", "which", "in", "the", "d...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php#L162-L173
neos/flow-development-collection
Neos.Flow/Migrations/Postgresql/Version20130319131500.php
Version20130319131500.migrateAccountRolesUp
protected function migrateAccountRolesUp() { if (!$this->sm->tablesExist(['typo3_flow_security_account'])) { return; } $rolesSql = array(); $accountRolesSql = array(); $rolesToMigrate = array(); $accountsResult = $this->connection->executeQuery('SELECT DISTINCT(roles) FROM typo3_flow_security_account'); while ($accountIdentifierAndRoles = $accountsResult->fetch(\PDO::FETCH_ASSOC)) { $roleIdentifiers = unserialize($accountIdentifierAndRoles['roles']); foreach ($roleIdentifiers as $roleIdentifier) { $rolesToMigrate[$roleIdentifier] = true; } } $roleIdentifierMap = $this->getRoleIdentifierMap($rolesToMigrate); $accountsResult = $this->connection->executeQuery('SELECT persistence_object_identifier, roles FROM typo3_flow_security_account'); while ($accountIdentifierAndRoles = $accountsResult->fetch(\PDO::FETCH_ASSOC)) { $accountIdentifier = $accountIdentifierAndRoles['persistence_object_identifier']; $roleIdentifiers = unserialize($accountIdentifierAndRoles['roles']); foreach ($roleIdentifiers as $roleIdentifier) { $roleIdentifier = $roleIdentifierMap[$roleIdentifier]; $rolesSql[$roleIdentifier] = "INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES (" . $this->connection->quote($roleIdentifier) . ", 'policy')"; $accountRolesSql[] = "INSERT INTO typo3_flow_security_account_roles_join (flow_security_account, flow_policy_role) VALUES (" . $this->connection->quote($accountIdentifier) . ", " . $this->connection->quote($roleIdentifier) . ")"; } } foreach ($rolesSql as $sql) { $this->addSql($sql); } foreach ($accountRolesSql as $sql) { $this->addSql($sql); } }
php
protected function migrateAccountRolesUp() { if (!$this->sm->tablesExist(['typo3_flow_security_account'])) { return; } $rolesSql = array(); $accountRolesSql = array(); $rolesToMigrate = array(); $accountsResult = $this->connection->executeQuery('SELECT DISTINCT(roles) FROM typo3_flow_security_account'); while ($accountIdentifierAndRoles = $accountsResult->fetch(\PDO::FETCH_ASSOC)) { $roleIdentifiers = unserialize($accountIdentifierAndRoles['roles']); foreach ($roleIdentifiers as $roleIdentifier) { $rolesToMigrate[$roleIdentifier] = true; } } $roleIdentifierMap = $this->getRoleIdentifierMap($rolesToMigrate); $accountsResult = $this->connection->executeQuery('SELECT persistence_object_identifier, roles FROM typo3_flow_security_account'); while ($accountIdentifierAndRoles = $accountsResult->fetch(\PDO::FETCH_ASSOC)) { $accountIdentifier = $accountIdentifierAndRoles['persistence_object_identifier']; $roleIdentifiers = unserialize($accountIdentifierAndRoles['roles']); foreach ($roleIdentifiers as $roleIdentifier) { $roleIdentifier = $roleIdentifierMap[$roleIdentifier]; $rolesSql[$roleIdentifier] = "INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES (" . $this->connection->quote($roleIdentifier) . ", 'policy')"; $accountRolesSql[] = "INSERT INTO typo3_flow_security_account_roles_join (flow_security_account, flow_policy_role) VALUES (" . $this->connection->quote($accountIdentifier) . ", " . $this->connection->quote($roleIdentifier) . ")"; } } foreach ($rolesSql as $sql) { $this->addSql($sql); } foreach ($accountRolesSql as $sql) { $this->addSql($sql); } }
[ "protected", "function", "migrateAccountRolesUp", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sm", "->", "tablesExist", "(", "[", "'typo3_flow_security_account'", "]", ")", ")", "{", "return", ";", "}", "$", "rolesSql", "=", "array", "(", ")", ";"...
Generate SQL statements to migrate accounts up to referenced roles. @return void
[ "Generate", "SQL", "statements", "to", "migrate", "accounts", "up", "to", "referenced", "roles", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Postgresql/Version20130319131500.php#L66-L102
neos/flow-development-collection
Neos.Flow/Migrations/Postgresql/Version20130319131500.php
Version20130319131500.migrateAccountRolesDown
protected function migrateAccountRolesDown() { if (!$this->sm->tablesExist(['typo3_flow_security_account_roles_join', 'typo3_flow_security_policy_role'])) { return; } $accountsWithRoles = array(); $accountRolesResult = $this->connection->executeQuery('SELECT j.flow_security_account, r.identifier FROM typo3_flow_security_account_roles_join as j LEFT JOIN typo3_flow_security_policy_role AS r ON j.flow_policy_role = r.identifier'); while ($accountIdentifierAndRole = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) { $accountIdentifier = $accountIdentifierAndRole['flow_security_account']; $roleIdentifier = $accountIdentifierAndRole['identifier']; $accountsWithRoles[$accountIdentifier][] = substr($roleIdentifier, strrpos($roleIdentifier, ':') + 1); } foreach ($accountsWithRoles as $accountIdentifier => $roles) { $this->addSql("UPDATE typo3_flow_security_account SET roles = " . $this->connection->quote(serialize($roles)) . " WHERE persistence_object_identifier = " . $this->connection->quote($accountIdentifier)); } }
php
protected function migrateAccountRolesDown() { if (!$this->sm->tablesExist(['typo3_flow_security_account_roles_join', 'typo3_flow_security_policy_role'])) { return; } $accountsWithRoles = array(); $accountRolesResult = $this->connection->executeQuery('SELECT j.flow_security_account, r.identifier FROM typo3_flow_security_account_roles_join as j LEFT JOIN typo3_flow_security_policy_role AS r ON j.flow_policy_role = r.identifier'); while ($accountIdentifierAndRole = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) { $accountIdentifier = $accountIdentifierAndRole['flow_security_account']; $roleIdentifier = $accountIdentifierAndRole['identifier']; $accountsWithRoles[$accountIdentifier][] = substr($roleIdentifier, strrpos($roleIdentifier, ':') + 1); } foreach ($accountsWithRoles as $accountIdentifier => $roles) { $this->addSql("UPDATE typo3_flow_security_account SET roles = " . $this->connection->quote(serialize($roles)) . " WHERE persistence_object_identifier = " . $this->connection->quote($accountIdentifier)); } }
[ "protected", "function", "migrateAccountRolesDown", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sm", "->", "tablesExist", "(", "[", "'typo3_flow_security_account_roles_join'", ",", "'typo3_flow_security_policy_role'", "]", ")", ")", "{", "return", ";", "}",...
Generate SQL statements to migrate accounts down to embedded roles. @return void
[ "Generate", "SQL", "statements", "to", "migrate", "accounts", "down", "to", "embedded", "roles", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Postgresql/Version20130319131500.php#L109-L126
neos/flow-development-collection
Neos.Flow/Migrations/Postgresql/Version20130319131500.php
Version20130319131500.getRoleIdentifierMap
protected function getRoleIdentifierMap(array $map) { $rolesFromPolicy = $this->loadRolesFromPolicyFiles(); foreach ($rolesFromPolicy as $newRoleIdentifier) { $map[substr($newRoleIdentifier, strrpos($newRoleIdentifier, ':') + 1)] = $newRoleIdentifier; } $map['Anonymous'] ='Anonymous'; $map['Everybody'] = 'Everybody'; return $map; }
php
protected function getRoleIdentifierMap(array $map) { $rolesFromPolicy = $this->loadRolesFromPolicyFiles(); foreach ($rolesFromPolicy as $newRoleIdentifier) { $map[substr($newRoleIdentifier, strrpos($newRoleIdentifier, ':') + 1)] = $newRoleIdentifier; } $map['Anonymous'] ='Anonymous'; $map['Everybody'] = 'Everybody'; return $map; }
[ "protected", "function", "getRoleIdentifierMap", "(", "array", "$", "map", ")", "{", "$", "rolesFromPolicy", "=", "$", "this", "->", "loadRolesFromPolicyFiles", "(", ")", ";", "foreach", "(", "$", "rolesFromPolicy", "as", "$", "newRoleIdentifier", ")", "{", "$...
Returns the given array indexed by "old" role identifiers with the "new" identifiers added as values to their matching index. @param array $map @return array
[ "Returns", "the", "given", "array", "indexed", "by", "old", "role", "identifiers", "with", "the", "new", "identifiers", "added", "as", "values", "to", "their", "matching", "index", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Postgresql/Version20130319131500.php#L135-L147
neos/flow-development-collection
Neos.Flow/Migrations/Postgresql/Version20130319131500.php
Version20130319131500.loadRolesFromPolicyFiles
protected function loadRolesFromPolicyFiles() { $roles = array(); $yamlPathsAndFilenames = Files::readDirectoryRecursively(__DIR__ . '/../../../../../Packages', 'yaml', true); $configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames, function ($pathAndFileName) { if (basename($pathAndFileName) === 'Policy.yaml') { return true; } else { return false; } } ); $yamlSource = new \Neos\Flow\Configuration\Source\YamlSource(); foreach ($configurationPathsAndFilenames as $pathAndFilename) { if (preg_match('%Packages/[^/]+/([^/]+)/Configuration/(?:Development/|Production/)?[^/]+%', $pathAndFilename, $matches) === 0) { continue; }; $packageKey = $matches[1]; $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5)); if (isset($configuration['roles']) && is_array($configuration['roles'])) { foreach ($configuration['roles'] as $roleIdentifier => $parentRoles) { $roles[$packageKey . ':' . $roleIdentifier] = true; } } } return array_keys($roles); }
php
protected function loadRolesFromPolicyFiles() { $roles = array(); $yamlPathsAndFilenames = Files::readDirectoryRecursively(__DIR__ . '/../../../../../Packages', 'yaml', true); $configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames, function ($pathAndFileName) { if (basename($pathAndFileName) === 'Policy.yaml') { return true; } else { return false; } } ); $yamlSource = new \Neos\Flow\Configuration\Source\YamlSource(); foreach ($configurationPathsAndFilenames as $pathAndFilename) { if (preg_match('%Packages/[^/]+/([^/]+)/Configuration/(?:Development/|Production/)?[^/]+%', $pathAndFilename, $matches) === 0) { continue; }; $packageKey = $matches[1]; $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5)); if (isset($configuration['roles']) && is_array($configuration['roles'])) { foreach ($configuration['roles'] as $roleIdentifier => $parentRoles) { $roles[$packageKey . ':' . $roleIdentifier] = true; } } } return array_keys($roles); }
[ "protected", "function", "loadRolesFromPolicyFiles", "(", ")", "{", "$", "roles", "=", "array", "(", ")", ";", "$", "yamlPathsAndFilenames", "=", "Files", "::", "readDirectoryRecursively", "(", "__DIR__", ".", "'/../../../../../Packages'", ",", "'yaml'", ",", "tru...
Reads all Policy.yaml files below Packages, extracts the roles and prepends them with the package key "guessed" from the path. @return array
[ "Reads", "all", "Policy", ".", "yaml", "files", "below", "Packages", "extracts", "the", "roles", "and", "prepends", "them", "with", "the", "package", "key", "guessed", "from", "the", "path", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Postgresql/Version20130319131500.php#L155-L185
neos/flow-development-collection
Neos.Flow.Log/Classes/PlainTextFormatter.php
PlainTextFormatter.renderVariableAsPlaintext
protected function renderVariableAsPlaintext($var, $spaces = 4, $continuationSpaces = 0) { $currentIndent = str_repeat(' ', $spaces + $continuationSpaces); if ($continuationSpaces > 100) { return null; } $output = ''; $output .= $currentIndent . '[' . gettype($var) . '] => '; if (is_string($var) || is_numeric($var)) { $output .= $var; } if (is_bool($var)) { $output .= $var ? 'true' : 'false'; } if (is_null($var)) { $output .= '␀'; } if (is_array($var)) { $output .= PHP_EOL; foreach ($var as $k => $v) { $output .= $this->renderKeyValue($k, $v, $spaces, $continuationSpaces); } } if (is_object($var)) { $output .= '[' . get_class($var) . ']:' . PHP_EOL; foreach (get_object_vars($var) as $objVarName => $objVarValue) { $output .= $this->renderKeyValue($objVarName, $objVarValue, $spaces, $continuationSpaces); } } $output .= PHP_EOL; return $output; }
php
protected function renderVariableAsPlaintext($var, $spaces = 4, $continuationSpaces = 0) { $currentIndent = str_repeat(' ', $spaces + $continuationSpaces); if ($continuationSpaces > 100) { return null; } $output = ''; $output .= $currentIndent . '[' . gettype($var) . '] => '; if (is_string($var) || is_numeric($var)) { $output .= $var; } if (is_bool($var)) { $output .= $var ? 'true' : 'false'; } if (is_null($var)) { $output .= '␀'; } if (is_array($var)) { $output .= PHP_EOL; foreach ($var as $k => $v) { $output .= $this->renderKeyValue($k, $v, $spaces, $continuationSpaces); } } if (is_object($var)) { $output .= '[' . get_class($var) . ']:' . PHP_EOL; foreach (get_object_vars($var) as $objVarName => $objVarValue) { $output .= $this->renderKeyValue($objVarName, $objVarValue, $spaces, $continuationSpaces); } } $output .= PHP_EOL; return $output; }
[ "protected", "function", "renderVariableAsPlaintext", "(", "$", "var", ",", "$", "spaces", "=", "4", ",", "$", "continuationSpaces", "=", "0", ")", "{", "$", "currentIndent", "=", "str_repeat", "(", "' '", ",", "$", "spaces", "+", "$", "continuationSpaces", ...
Returns a suitable form of a variable (be it a string, array, object ...) for logfile output @param mixed $var The variable @param integer $spaces Indent for this var dump @param int $continuationSpaces Running total indentation (INTERNAL) @return string text output
[ "Returns", "a", "suitable", "form", "of", "a", "variable", "(", "be", "it", "a", "string", "array", "object", "...", ")", "for", "logfile", "output" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/PlainTextFormatter.php#L41-L77
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Aspect/EmbeddedValueObjectPointcutFilter.php
EmbeddedValueObjectPointcutFilter.matches
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier) { $valueObjectAnnotation = $this->reflectionService->getClassAnnotation($className, Flow\ValueObject::class); if ($valueObjectAnnotation !== null && $valueObjectAnnotation->embedded === true) { return true; } return false; }
php
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier) { $valueObjectAnnotation = $this->reflectionService->getClassAnnotation($className, Flow\ValueObject::class); if ($valueObjectAnnotation !== null && $valueObjectAnnotation->embedded === true) { return true; } return false; }
[ "public", "function", "matches", "(", "$", "className", ",", "$", "methodName", ",", "$", "methodDeclaringClassName", ",", "$", "pointcutQueryIdentifier", ")", "{", "$", "valueObjectAnnotation", "=", "$", "this", "->", "reflectionService", "->", "getClassAnnotation"...
Checks if the specified class and method matches against the filter @param string $className Name of the class to check against @param string $methodName Name of the method to check against @param string $methodDeclaringClassName Name of the class the method was originally declared in @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection. @return boolean true if the class / method match, otherwise false
[ "Checks", "if", "the", "specified", "class", "and", "method", "matches", "against", "the", "filter" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Aspect/EmbeddedValueObjectPointcutFilter.php#L48-L57
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Aspect/EmbeddedValueObjectPointcutFilter.php
EmbeddedValueObjectPointcutFilter.reduceTargetClassNames
public function reduceTargetClassNames(\Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex) { $classNames = $this->reflectionService->getClassNamesByAnnotation(Flow\ValueObject::class); $annotatedIndex = new \Neos\Flow\Aop\Builder\ClassNameIndex(); $annotatedIndex->setClassNames($classNames); return $classNameIndex->intersect($annotatedIndex); }
php
public function reduceTargetClassNames(\Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex) { $classNames = $this->reflectionService->getClassNamesByAnnotation(Flow\ValueObject::class); $annotatedIndex = new \Neos\Flow\Aop\Builder\ClassNameIndex(); $annotatedIndex->setClassNames($classNames); return $classNameIndex->intersect($annotatedIndex); }
[ "public", "function", "reduceTargetClassNames", "(", "\\", "Neos", "\\", "Flow", "\\", "Aop", "\\", "Builder", "\\", "ClassNameIndex", "$", "classNameIndex", ")", "{", "$", "classNames", "=", "$", "this", "->", "reflectionService", "->", "getClassNamesByAnnotation...
This method is used to optimize the matching process. @param \Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex @return \Neos\Flow\Aop\Builder\ClassNameIndex
[ "This", "method", "is", "used", "to", "optimize", "the", "matching", "process", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Aspect/EmbeddedValueObjectPointcutFilter.php#L85-L91
neos/flow-development-collection
Neos.Cache/Classes/Backend/TransientMemoryBackend.php
TransientMemoryBackend.set
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null) { if (!$this->cache instanceof FrontendInterface) { throw new Exception('No cache frontend has been set yet via setCache().', 1238244992); } $this->entries[$entryIdentifier] = $data; foreach ($tags as $tag) { $this->tagsAndEntries[$tag][$entryIdentifier] = true; } }
php
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null) { if (!$this->cache instanceof FrontendInterface) { throw new Exception('No cache frontend has been set yet via setCache().', 1238244992); } $this->entries[$entryIdentifier] = $data; foreach ($tags as $tag) { $this->tagsAndEntries[$tag][$entryIdentifier] = true; } }
[ "public", "function", "set", "(", "string", "$", "entryIdentifier", ",", "string", "$", "data", ",", "array", "$", "tags", "=", "[", "]", ",", "int", "$", "lifetime", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "cache", "instanceof", ...
Saves data in the cache. @param string $entryIdentifier An identifier for this specific cache entry @param string $data The data to be stored @param array $tags Tags to associate with this cache entry @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime. @return void @throws Exception if no cache frontend has been set. @api
[ "Saves", "data", "in", "the", "cache", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/TransientMemoryBackend.php#L46-L57
neos/flow-development-collection
Neos.Cache/Classes/Backend/TransientMemoryBackend.php
TransientMemoryBackend.remove
public function remove(string $entryIdentifier): bool { if (!isset($this->entries[$entryIdentifier])) { return false; } unset($this->entries[$entryIdentifier]); foreach (array_keys($this->tagsAndEntries) as $tag) { if (isset($this->tagsAndEntries[$tag][$entryIdentifier])) { unset($this->tagsAndEntries[$tag][$entryIdentifier]); } } return true; }
php
public function remove(string $entryIdentifier): bool { if (!isset($this->entries[$entryIdentifier])) { return false; } unset($this->entries[$entryIdentifier]); foreach (array_keys($this->tagsAndEntries) as $tag) { if (isset($this->tagsAndEntries[$tag][$entryIdentifier])) { unset($this->tagsAndEntries[$tag][$entryIdentifier]); } } return true; }
[ "public", "function", "remove", "(", "string", "$", "entryIdentifier", ")", ":", "bool", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "entries", "[", "$", "entryIdentifier", "]", ")", ")", "{", "return", "false", ";", "}", "unset", "(", "$",...
Removes all cache entries matching the specified identifier. @param string $entryIdentifier Specifies the cache entry to remove @return boolean true if the entry could be removed or false if no entry was found @api
[ "Removes", "all", "cache", "entries", "matching", "the", "specified", "identifier", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/TransientMemoryBackend.php#L90-L102
neos/flow-development-collection
Neos.Cache/Classes/Backend/TransientMemoryBackend.php
TransientMemoryBackend.findIdentifiersByTag
public function findIdentifiersByTag(string $tag): array { if (isset($this->tagsAndEntries[$tag])) { return array_keys($this->tagsAndEntries[$tag]); } return []; }
php
public function findIdentifiersByTag(string $tag): array { if (isset($this->tagsAndEntries[$tag])) { return array_keys($this->tagsAndEntries[$tag]); } return []; }
[ "public", "function", "findIdentifiersByTag", "(", "string", "$", "tag", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "tagsAndEntries", "[", "$", "tag", "]", ")", ")", "{", "return", "array_keys", "(", "$", "this", "->", "tagsAnd...
Finds and returns all cache entry identifiers which are tagged by the specified tag. @param string $tag The tag to search for @return array An array with identifiers of all matching entries. An empty array if no entries matched @api
[ "Finds", "and", "returns", "all", "cache", "entry", "identifiers", "which", "are", "tagged", "by", "the", "specified", "tag", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/TransientMemoryBackend.php#L112-L118
neos/flow-development-collection
Neos.Flow/Classes/Http/Helper/MediaTypeHelper.php
MediaTypeHelper.determineAcceptedMediaTypes
public static function determineAcceptedMediaTypes(RequestInterface $request): array { $rawValues = $request->getHeader('Accept'); if (empty($rawValues) || !is_string($rawValues)) { return ['*/*']; } $acceptedMediaTypes = self::parseContentNegotiationQualityValues($rawValues); return $acceptedMediaTypes; }
php
public static function determineAcceptedMediaTypes(RequestInterface $request): array { $rawValues = $request->getHeader('Accept'); if (empty($rawValues) || !is_string($rawValues)) { return ['*/*']; } $acceptedMediaTypes = self::parseContentNegotiationQualityValues($rawValues); return $acceptedMediaTypes; }
[ "public", "static", "function", "determineAcceptedMediaTypes", "(", "RequestInterface", "$", "request", ")", ":", "array", "{", "$", "rawValues", "=", "$", "request", "->", "getHeader", "(", "'Accept'", ")", ";", "if", "(", "empty", "(", "$", "rawValues", ")...
Get accepted media types for the given request. If no "Accept" header was found all media types are acceptable. @param RequestInterface $request @return array
[ "Get", "accepted", "media", "types", "for", "the", "given", "request", ".", "If", "no", "Accept", "header", "was", "found", "all", "media", "types", "are", "acceptable", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/MediaTypeHelper.php#L29-L38
neos/flow-development-collection
Neos.Flow/Classes/Http/Helper/MediaTypeHelper.php
MediaTypeHelper.negotiateMediaType
public static function negotiateMediaType(array $acceptedMediaTypes, array $supportedMediaTypes, bool $trim = true):? string { $negotiatedMediaType = null; foreach ($acceptedMediaTypes as $acceptedMediaType) { foreach ($supportedMediaTypes as $supportedMediaType) { if (MediaTypes::mediaRangeMatches($acceptedMediaType, $supportedMediaType)) { $negotiatedMediaType = $supportedMediaType; break 2; } } } return ($trim && $negotiatedMediaType !== null ? MediaTypes::trimMediaType($negotiatedMediaType) : $negotiatedMediaType); }
php
public static function negotiateMediaType(array $acceptedMediaTypes, array $supportedMediaTypes, bool $trim = true):? string { $negotiatedMediaType = null; foreach ($acceptedMediaTypes as $acceptedMediaType) { foreach ($supportedMediaTypes as $supportedMediaType) { if (MediaTypes::mediaRangeMatches($acceptedMediaType, $supportedMediaType)) { $negotiatedMediaType = $supportedMediaType; break 2; } } } return ($trim && $negotiatedMediaType !== null ? MediaTypes::trimMediaType($negotiatedMediaType) : $negotiatedMediaType); }
[ "public", "static", "function", "negotiateMediaType", "(", "array", "$", "acceptedMediaTypes", ",", "array", "$", "supportedMediaTypes", ",", "bool", "$", "trim", "=", "true", ")", ":", "?", "string", "{", "$", "negotiatedMediaType", "=", "null", ";", "foreach...
Returns the best fitting IANA media type after applying the content negotiation rules on the accepted media types. @param array $acceptedMediaTypes A list of accepted media types according to a request. @param array $supportedMediaTypes A list of media types which are supported by the application / controller @param bool $trim If TRUE, only the type/subtype of the media type is returned. If FALSE, the full original media type string is returned. @return string The media type and sub type which matched, NULL if none matched
[ "Returns", "the", "best", "fitting", "IANA", "media", "type", "after", "applying", "the", "content", "negotiation", "rules", "on", "the", "accepted", "media", "types", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/MediaTypeHelper.php#L49-L62
neos/flow-development-collection
Neos.Flow/Classes/Http/Helper/MediaTypeHelper.php
MediaTypeHelper.parseContentNegotiationQualityValues
public static function parseContentNegotiationQualityValues(string $rawValues): array { $acceptedTypes = array_map( function ($acceptType) { $typeAndQuality = preg_split('/;\s*q=/', $acceptType); return [$typeAndQuality[0], (isset($typeAndQuality[1]) ? (float)$typeAndQuality[1] : '')]; }, preg_split('/,\s*/', $rawValues) ); $flattenedAcceptedTypes = []; $valuesWithoutQualityValue = [[], [], [], []]; foreach ($acceptedTypes as $typeAndQuality) { if ($typeAndQuality[1] === '') { $parsedType = MediaTypes::parseMediaType($typeAndQuality[0]); if ($parsedType['type'] === '*') { $valuesWithoutQualityValue[3][$typeAndQuality[0]] = true; } elseif ($parsedType['subtype'] === '*') { $valuesWithoutQualityValue[2][$typeAndQuality[0]] = true; } elseif ($parsedType['parameters'] === []) { $valuesWithoutQualityValue[1][$typeAndQuality[0]] = true; } else { $valuesWithoutQualityValue[0][$typeAndQuality[0]] = true; } } else { $flattenedAcceptedTypes[$typeAndQuality[0]] = $typeAndQuality[1]; } } $valuesWithoutQualityValue = array_merge(array_keys($valuesWithoutQualityValue[0]), array_keys($valuesWithoutQualityValue[1]), array_keys($valuesWithoutQualityValue[2]), array_keys($valuesWithoutQualityValue[3])); arsort($flattenedAcceptedTypes); $parsedValues = array_merge($valuesWithoutQualityValue, array_keys($flattenedAcceptedTypes)); return $parsedValues; }
php
public static function parseContentNegotiationQualityValues(string $rawValues): array { $acceptedTypes = array_map( function ($acceptType) { $typeAndQuality = preg_split('/;\s*q=/', $acceptType); return [$typeAndQuality[0], (isset($typeAndQuality[1]) ? (float)$typeAndQuality[1] : '')]; }, preg_split('/,\s*/', $rawValues) ); $flattenedAcceptedTypes = []; $valuesWithoutQualityValue = [[], [], [], []]; foreach ($acceptedTypes as $typeAndQuality) { if ($typeAndQuality[1] === '') { $parsedType = MediaTypes::parseMediaType($typeAndQuality[0]); if ($parsedType['type'] === '*') { $valuesWithoutQualityValue[3][$typeAndQuality[0]] = true; } elseif ($parsedType['subtype'] === '*') { $valuesWithoutQualityValue[2][$typeAndQuality[0]] = true; } elseif ($parsedType['parameters'] === []) { $valuesWithoutQualityValue[1][$typeAndQuality[0]] = true; } else { $valuesWithoutQualityValue[0][$typeAndQuality[0]] = true; } } else { $flattenedAcceptedTypes[$typeAndQuality[0]] = $typeAndQuality[1]; } } $valuesWithoutQualityValue = array_merge(array_keys($valuesWithoutQualityValue[0]), array_keys($valuesWithoutQualityValue[1]), array_keys($valuesWithoutQualityValue[2]), array_keys($valuesWithoutQualityValue[3])); arsort($flattenedAcceptedTypes); $parsedValues = array_merge($valuesWithoutQualityValue, array_keys($flattenedAcceptedTypes)); return $parsedValues; }
[ "public", "static", "function", "parseContentNegotiationQualityValues", "(", "string", "$", "rawValues", ")", ":", "array", "{", "$", "acceptedTypes", "=", "array_map", "(", "function", "(", "$", "acceptType", ")", "{", "$", "typeAndQuality", "=", "preg_split", ...
Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference. @param string $rawValues The raw Accept* Header field value @return array The parsed list of field values, ordered by user preference
[ "Parses", "a", "RFC", "2616", "content", "negotiation", "header", "field", "by", "evaluating", "the", "Quality", "Values", "and", "splitting", "the", "options", "into", "an", "array", "list", "ordered", "by", "user", "preference", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/MediaTypeHelper.php#L71-L104
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Uri/ResourceViewHelper.php
ResourceViewHelper.initializeArguments
public function initializeArguments() { $this->registerArgument('path', 'string', 'Location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI', false, null); $this->registerArgument('package', 'string', 'Target package key. If not set, the current package key will be used', false, null); $this->registerArgument('resource', PersistentResource::class, 'If specified, this resource object is used instead of the path and package information', false, null); $this->registerArgument('localize', 'bool', 'Whether resource localization should be attempted or not.', false, true); }
php
public function initializeArguments() { $this->registerArgument('path', 'string', 'Location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI', false, null); $this->registerArgument('package', 'string', 'Target package key. If not set, the current package key will be used', false, null); $this->registerArgument('resource', PersistentResource::class, 'If specified, this resource object is used instead of the path and package information', false, null); $this->registerArgument('localize', 'bool', 'Whether resource localization should be attempted or not.', false, true); }
[ "public", "function", "initializeArguments", "(", ")", "{", "$", "this", "->", "registerArgument", "(", "'path'", ",", "'string'", ",", "'Location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI'", ",", "false",...
Initialize and register all arguments. @return void
[ "Initialize", "and", "register", "all", "arguments", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Uri/ResourceViewHelper.php#L81-L87
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.setCacheConfigurations
public function setCacheConfigurations(array $cacheConfigurations): void { foreach ($cacheConfigurations as $identifier => $configuration) { if (!is_array($configuration)) { throw new \InvalidArgumentException('The cache configuration for cache "' . $identifier . '" was not an array as expected.', 1231259656); } $this->cacheConfigurations[$identifier] = $configuration; } }
php
public function setCacheConfigurations(array $cacheConfigurations): void { foreach ($cacheConfigurations as $identifier => $configuration) { if (!is_array($configuration)) { throw new \InvalidArgumentException('The cache configuration for cache "' . $identifier . '" was not an array as expected.', 1231259656); } $this->cacheConfigurations[$identifier] = $configuration; } }
[ "public", "function", "setCacheConfigurations", "(", "array", "$", "cacheConfigurations", ")", ":", "void", "{", "foreach", "(", "$", "cacheConfigurations", "as", "$", "identifier", "=>", "$", "configuration", ")", "{", "if", "(", "!", "is_array", "(", "$", ...
Sets configurations for caches. The key of each entry specifies the cache identifier and the value is an array of configuration options. Possible options are: frontend backend backendOptions persistent If one of the options is not specified, the default value is assumed. Existing cache configurations are preserved. @param array $cacheConfigurations The cache configurations to set @return void @throws \InvalidArgumentException
[ "Sets", "configurations", "for", "caches", ".", "The", "key", "of", "each", "entry", "specifies", "the", "cache", "identifier", "and", "the", "value", "is", "an", "array", "of", "configuration", "options", ".", "Possible", "options", "are", ":" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L132-L140
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.registerCache
public function registerCache(FrontendInterface $cache, bool $persistent = false): void { $identifier = $cache->getIdentifier(); if (isset($this->caches[$identifier])) { throw new DuplicateIdentifierException('A cache with identifier "' . $identifier . '" has already been registered.', 1203698223); } $this->caches[$identifier] = $cache; if ($persistent === true) { $this->persistentCaches[$identifier] = $cache; } }
php
public function registerCache(FrontendInterface $cache, bool $persistent = false): void { $identifier = $cache->getIdentifier(); if (isset($this->caches[$identifier])) { throw new DuplicateIdentifierException('A cache with identifier "' . $identifier . '" has already been registered.', 1203698223); } $this->caches[$identifier] = $cache; if ($persistent === true) { $this->persistentCaches[$identifier] = $cache; } }
[ "public", "function", "registerCache", "(", "FrontendInterface", "$", "cache", ",", "bool", "$", "persistent", "=", "false", ")", ":", "void", "{", "$", "identifier", "=", "$", "cache", "->", "getIdentifier", "(", ")", ";", "if", "(", "isset", "(", "$", ...
Registers a cache so it can be retrieved at a later point. @param FrontendInterface $cache The cache frontend to be registered @param bool $persistent @return void @throws DuplicateIdentifierException if a cache with the given identifier has already been registered. @api
[ "Registers", "a", "cache", "so", "it", "can", "be", "retrieved", "at", "a", "later", "point", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L151-L161
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.getCache
public function getCache(string $identifier): FrontendInterface { if ($this->hasCache($identifier) === false) { throw new NoSuchCacheException('A cache with identifier "' . $identifier . '" does not exist.', 1203699034); } if (!isset($this->caches[$identifier])) { $this->createCache($identifier); } return $this->caches[$identifier]; }
php
public function getCache(string $identifier): FrontendInterface { if ($this->hasCache($identifier) === false) { throw new NoSuchCacheException('A cache with identifier "' . $identifier . '" does not exist.', 1203699034); } if (!isset($this->caches[$identifier])) { $this->createCache($identifier); } return $this->caches[$identifier]; }
[ "public", "function", "getCache", "(", "string", "$", "identifier", ")", ":", "FrontendInterface", "{", "if", "(", "$", "this", "->", "hasCache", "(", "$", "identifier", ")", "===", "false", ")", "{", "throw", "new", "NoSuchCacheException", "(", "'A cache wi...
Returns the cache specified by $identifier @param string $identifier Identifies which cache to return @return FrontendInterface The specified cache frontend @throws NoSuchCacheException @api
[ "Returns", "the", "cache", "specified", "by", "$identifier" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L171-L181
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.hasCache
public function hasCache(string $identifier): bool { return isset($this->caches[$identifier]) || isset($this->cacheConfigurations[$identifier]); }
php
public function hasCache(string $identifier): bool { return isset($this->caches[$identifier]) || isset($this->cacheConfigurations[$identifier]); }
[ "public", "function", "hasCache", "(", "string", "$", "identifier", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "caches", "[", "$", "identifier", "]", ")", "||", "isset", "(", "$", "this", "->", "cacheConfigurations", "[", "$", "i...
Checks if the specified cache has been registered. @param string $identifier The identifier of the cache @return boolean true if a cache with the given identifier exists, otherwise false @api
[ "Checks", "if", "the", "specified", "cache", "has", "been", "registered", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L190-L193
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.flushCaches
public function flushCaches(bool $flushPersistentCaches = false): void { $this->createAllCaches(); /** @var FrontendInterface $cache */ foreach ($this->caches as $identifier => $cache) { if (!$flushPersistentCaches && $this->isCachePersistent($identifier)) { continue; } $cache->flush(); } $this->configurationManager->flushConfigurationCache(); $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory(); Files::unlink($dataTemporaryPath . 'AvailableProxyClasses.php'); }
php
public function flushCaches(bool $flushPersistentCaches = false): void { $this->createAllCaches(); /** @var FrontendInterface $cache */ foreach ($this->caches as $identifier => $cache) { if (!$flushPersistentCaches && $this->isCachePersistent($identifier)) { continue; } $cache->flush(); } $this->configurationManager->flushConfigurationCache(); $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory(); Files::unlink($dataTemporaryPath . 'AvailableProxyClasses.php'); }
[ "public", "function", "flushCaches", "(", "bool", "$", "flushPersistentCaches", "=", "false", ")", ":", "void", "{", "$", "this", "->", "createAllCaches", "(", ")", ";", "/** @var FrontendInterface $cache */", "foreach", "(", "$", "this", "->", "caches", "as", ...
Flushes all registered caches @param boolean $flushPersistentCaches If set to true, even those caches which are flagged as "persistent" will be flushed @return void @api
[ "Flushes", "all", "registered", "caches" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L213-L226
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.flushCachesByTag
public function flushCachesByTag(string $tag, bool $flushPersistentCaches = false): void { $this->createAllCaches(); /** @var FrontendInterface $cache */ foreach ($this->caches as $identifier => $cache) { if (!$flushPersistentCaches && $this->isCachePersistent($identifier)) { continue; } $cache->flushByTag($tag); } }
php
public function flushCachesByTag(string $tag, bool $flushPersistentCaches = false): void { $this->createAllCaches(); /** @var FrontendInterface $cache */ foreach ($this->caches as $identifier => $cache) { if (!$flushPersistentCaches && $this->isCachePersistent($identifier)) { continue; } $cache->flushByTag($tag); } }
[ "public", "function", "flushCachesByTag", "(", "string", "$", "tag", ",", "bool", "$", "flushPersistentCaches", "=", "false", ")", ":", "void", "{", "$", "this", "->", "createAllCaches", "(", ")", ";", "/** @var FrontendInterface $cache */", "foreach", "(", "$",...
Flushes entries tagged by the specified tag of all registered caches. @param string $tag Tag to search for @param boolean $flushPersistentCaches If set to true, even those caches which are flagged as "persistent" will be flushed @return void @api
[ "Flushes", "entries", "tagged", "by", "the", "specified", "tag", "of", "all", "registered", "caches", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L237-L247
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.flushSystemCachesByChangedFiles
public function flushSystemCachesByChangedFiles(string $fileMonitorIdentifier, array $changedFiles): void { switch ($fileMonitorIdentifier) { case 'Flow_ClassFiles': $this->flushClassCachesByChangedFiles($changedFiles); break; case 'Flow_ConfigurationFiles': $this->flushConfigurationCachesByChangedFiles($changedFiles); break; case 'Flow_TranslationFiles': $this->flushTranslationCachesByChangedFiles($changedFiles); break; } }
php
public function flushSystemCachesByChangedFiles(string $fileMonitorIdentifier, array $changedFiles): void { switch ($fileMonitorIdentifier) { case 'Flow_ClassFiles': $this->flushClassCachesByChangedFiles($changedFiles); break; case 'Flow_ConfigurationFiles': $this->flushConfigurationCachesByChangedFiles($changedFiles); break; case 'Flow_TranslationFiles': $this->flushTranslationCachesByChangedFiles($changedFiles); break; } }
[ "public", "function", "flushSystemCachesByChangedFiles", "(", "string", "$", "fileMonitorIdentifier", ",", "array", "$", "changedFiles", ")", ":", "void", "{", "switch", "(", "$", "fileMonitorIdentifier", ")", "{", "case", "'Flow_ClassFiles'", ":", "$", "this", "-...
Flushes entries tagged with class names if their class source files have changed. Also flushes AOP proxy caches if a policy was modified. This method is used as a slot for a signal sent by the system file monitor defined in the bootstrap scripts. Note: Policy configuration handling is implemented here as well as other parts of Flow (like the security framework) are not fully initialized at the time needed. @param string $fileMonitorIdentifier Identifier of the File Monitor @param array $changedFiles A list of full paths to changed files @return void
[ "Flushes", "entries", "tagged", "with", "class", "names", "if", "their", "class", "source", "files", "have", "changed", ".", "Also", "flushes", "AOP", "proxy", "caches", "if", "a", "policy", "was", "modified", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L274-L287
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.flushClassCachesByChangedFiles
protected function flushClassCachesByChangedFiles(array $changedFiles): void { $objectClassesCache = $this->getCache('Flow_Object_Classes'); $objectConfigurationCache = $this->getCache('Flow_Object_Configuration'); $modifiedAspectClassNamesWithUnderscores = []; $modifiedClassNamesWithUnderscores = []; foreach ($changedFiles as $pathAndFilename => $status) { if (!file_exists($pathAndFilename)) { continue; } $fileContents = file_get_contents($pathAndFilename); $className = (new PhpAnalyzer($fileContents))->extractFullyQualifiedClassName(); if ($className === null) { continue; } $classNameWithUnderscores = str_replace('\\', '_', $className); $modifiedClassNamesWithUnderscores[$classNameWithUnderscores] = true; // If an aspect was modified, the whole code cache needs to be flushed, so keep track of them: if (substr($classNameWithUnderscores, -6, 6) === 'Aspect') { $modifiedAspectClassNamesWithUnderscores[$classNameWithUnderscores] = true; } // As long as no modified aspect was found, we are optimistic that only part of the cache needs to be flushed: if (count($modifiedAspectClassNamesWithUnderscores) === 0) { $objectClassesCache->remove($classNameWithUnderscores); } } $flushDoctrineProxyCache = false; $flushPolicyCache = false; if (count($modifiedClassNamesWithUnderscores) > 0) { $reflectionStatusCache = $this->getCache('Flow_Reflection_Status'); foreach (array_keys($modifiedClassNamesWithUnderscores) as $classNameWithUnderscores) { $reflectionStatusCache->remove($classNameWithUnderscores); if ($flushDoctrineProxyCache === false && preg_match('/_Domain_Model_(.+)/', $classNameWithUnderscores) === 1) { $flushDoctrineProxyCache = true; } if ($flushPolicyCache === false && preg_match('/_Controller_(.+)Controller/', $classNameWithUnderscores) === 1) { $flushPolicyCache = true; } } $objectConfigurationCache->remove('allCompiledCodeUpToDate'); } if (count($modifiedAspectClassNamesWithUnderscores) > 0) { $this->logger->info('Aspect classes have been modified, flushing the whole proxy classes cache.', LogEnvironment::fromMethodName(__METHOD__)); $objectClassesCache->flush(); } if ($flushDoctrineProxyCache === true) { $this->logger->info('Domain model changes have been detected, triggering Doctrine 2 proxy rebuilding.', LogEnvironment::fromMethodName(__METHOD__)); $this->getCache('Flow_Persistence_Doctrine')->flush(); $objectConfigurationCache->remove('doctrineProxyCodeUpToDate'); } if ($flushPolicyCache === true) { $this->logger->info('Controller changes have been detected, trigger AOP rebuild.', LogEnvironment::fromMethodName(__METHOD__)); $this->getCache('Flow_Security_Authorization_Privilege_Method')->flush(); $objectConfigurationCache->remove('allAspectClassesUpToDate'); $objectConfigurationCache->remove('allCompiledCodeUpToDate'); } }
php
protected function flushClassCachesByChangedFiles(array $changedFiles): void { $objectClassesCache = $this->getCache('Flow_Object_Classes'); $objectConfigurationCache = $this->getCache('Flow_Object_Configuration'); $modifiedAspectClassNamesWithUnderscores = []; $modifiedClassNamesWithUnderscores = []; foreach ($changedFiles as $pathAndFilename => $status) { if (!file_exists($pathAndFilename)) { continue; } $fileContents = file_get_contents($pathAndFilename); $className = (new PhpAnalyzer($fileContents))->extractFullyQualifiedClassName(); if ($className === null) { continue; } $classNameWithUnderscores = str_replace('\\', '_', $className); $modifiedClassNamesWithUnderscores[$classNameWithUnderscores] = true; // If an aspect was modified, the whole code cache needs to be flushed, so keep track of them: if (substr($classNameWithUnderscores, -6, 6) === 'Aspect') { $modifiedAspectClassNamesWithUnderscores[$classNameWithUnderscores] = true; } // As long as no modified aspect was found, we are optimistic that only part of the cache needs to be flushed: if (count($modifiedAspectClassNamesWithUnderscores) === 0) { $objectClassesCache->remove($classNameWithUnderscores); } } $flushDoctrineProxyCache = false; $flushPolicyCache = false; if (count($modifiedClassNamesWithUnderscores) > 0) { $reflectionStatusCache = $this->getCache('Flow_Reflection_Status'); foreach (array_keys($modifiedClassNamesWithUnderscores) as $classNameWithUnderscores) { $reflectionStatusCache->remove($classNameWithUnderscores); if ($flushDoctrineProxyCache === false && preg_match('/_Domain_Model_(.+)/', $classNameWithUnderscores) === 1) { $flushDoctrineProxyCache = true; } if ($flushPolicyCache === false && preg_match('/_Controller_(.+)Controller/', $classNameWithUnderscores) === 1) { $flushPolicyCache = true; } } $objectConfigurationCache->remove('allCompiledCodeUpToDate'); } if (count($modifiedAspectClassNamesWithUnderscores) > 0) { $this->logger->info('Aspect classes have been modified, flushing the whole proxy classes cache.', LogEnvironment::fromMethodName(__METHOD__)); $objectClassesCache->flush(); } if ($flushDoctrineProxyCache === true) { $this->logger->info('Domain model changes have been detected, triggering Doctrine 2 proxy rebuilding.', LogEnvironment::fromMethodName(__METHOD__)); $this->getCache('Flow_Persistence_Doctrine')->flush(); $objectConfigurationCache->remove('doctrineProxyCodeUpToDate'); } if ($flushPolicyCache === true) { $this->logger->info('Controller changes have been detected, trigger AOP rebuild.', LogEnvironment::fromMethodName(__METHOD__)); $this->getCache('Flow_Security_Authorization_Privilege_Method')->flush(); $objectConfigurationCache->remove('allAspectClassesUpToDate'); $objectConfigurationCache->remove('allCompiledCodeUpToDate'); } }
[ "protected", "function", "flushClassCachesByChangedFiles", "(", "array", "$", "changedFiles", ")", ":", "void", "{", "$", "objectClassesCache", "=", "$", "this", "->", "getCache", "(", "'Flow_Object_Classes'", ")", ";", "$", "objectConfigurationCache", "=", "$", "...
Flushes entries tagged with class names if their class source files have changed. @param array $changedFiles A list of full paths to changed files @return void @see flushSystemCachesByChangedFiles()
[ "Flushes", "entries", "tagged", "with", "class", "names", "if", "their", "class", "source", "files", "have", "changed", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L296-L353
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.flushConfigurationCachesByChangedFiles
protected function flushConfigurationCachesByChangedFiles(array $changedFiles): void { $aopProxyClassRebuildIsNeeded = false; $aopProxyClassInfluencers = '/(?:Policy|Objects|Settings)(?:\..*)*\.yaml/'; $objectClassesCache = $this->getCache('Flow_Object_Classes'); $objectConfigurationCache = $this->getCache('Flow_Object_Configuration'); $caches = [ '/Policy\.yaml/' => ['Flow_Security_Authorization_Privilege_Method', 'Flow_Persistence_Doctrine', 'Flow_Persistence_Doctrine_Results', 'Flow_Aop_RuntimeExpressions'], '/Routes([^\/]*)\.yaml/' => ['Flow_Mvc_Routing_Route', 'Flow_Mvc_Routing_Resolve'], '/Views\.yaml/' => ['Flow_Mvc_ViewConfigurations'] ]; $cachesToFlush = []; foreach (array_keys($changedFiles) as $pathAndFilename) { foreach ($caches as $cacheFilePattern => $cacheNames) { if (preg_match($aopProxyClassInfluencers, $pathAndFilename) === 1) { $aopProxyClassRebuildIsNeeded = true; } if (preg_match($cacheFilePattern, $pathAndFilename) !== 1) { continue; } foreach ($caches[$cacheFilePattern] as $cacheName) { $cachesToFlush[$cacheName] = $cacheFilePattern; } } } foreach ($cachesToFlush as $cacheName => $cacheFilePattern) { $this->logger->info(sprintf('A configuration file matching the pattern "%s" has been changed, flushing related cache "%s"', $cacheFilePattern, $cacheName), LogEnvironment::fromMethodName(__METHOD__)); $this->getCache($cacheName)->flush(); } $this->logger->info('A configuration file has been changed, refreshing compiled configuration cache', LogEnvironment::fromMethodName(__METHOD__)); $this->configurationManager->refreshConfiguration(); if ($aopProxyClassRebuildIsNeeded) { $this->logger->info('The configuration has changed, triggering an AOP proxy class rebuild.', LogEnvironment::fromMethodName(__METHOD__)); $objectConfigurationCache->remove('allAspectClassesUpToDate'); $objectConfigurationCache->remove('allCompiledCodeUpToDate'); $objectClassesCache->flush(); } }
php
protected function flushConfigurationCachesByChangedFiles(array $changedFiles): void { $aopProxyClassRebuildIsNeeded = false; $aopProxyClassInfluencers = '/(?:Policy|Objects|Settings)(?:\..*)*\.yaml/'; $objectClassesCache = $this->getCache('Flow_Object_Classes'); $objectConfigurationCache = $this->getCache('Flow_Object_Configuration'); $caches = [ '/Policy\.yaml/' => ['Flow_Security_Authorization_Privilege_Method', 'Flow_Persistence_Doctrine', 'Flow_Persistence_Doctrine_Results', 'Flow_Aop_RuntimeExpressions'], '/Routes([^\/]*)\.yaml/' => ['Flow_Mvc_Routing_Route', 'Flow_Mvc_Routing_Resolve'], '/Views\.yaml/' => ['Flow_Mvc_ViewConfigurations'] ]; $cachesToFlush = []; foreach (array_keys($changedFiles) as $pathAndFilename) { foreach ($caches as $cacheFilePattern => $cacheNames) { if (preg_match($aopProxyClassInfluencers, $pathAndFilename) === 1) { $aopProxyClassRebuildIsNeeded = true; } if (preg_match($cacheFilePattern, $pathAndFilename) !== 1) { continue; } foreach ($caches[$cacheFilePattern] as $cacheName) { $cachesToFlush[$cacheName] = $cacheFilePattern; } } } foreach ($cachesToFlush as $cacheName => $cacheFilePattern) { $this->logger->info(sprintf('A configuration file matching the pattern "%s" has been changed, flushing related cache "%s"', $cacheFilePattern, $cacheName), LogEnvironment::fromMethodName(__METHOD__)); $this->getCache($cacheName)->flush(); } $this->logger->info('A configuration file has been changed, refreshing compiled configuration cache', LogEnvironment::fromMethodName(__METHOD__)); $this->configurationManager->refreshConfiguration(); if ($aopProxyClassRebuildIsNeeded) { $this->logger->info('The configuration has changed, triggering an AOP proxy class rebuild.', LogEnvironment::fromMethodName(__METHOD__)); $objectConfigurationCache->remove('allAspectClassesUpToDate'); $objectConfigurationCache->remove('allCompiledCodeUpToDate'); $objectClassesCache->flush(); } }
[ "protected", "function", "flushConfigurationCachesByChangedFiles", "(", "array", "$", "changedFiles", ")", ":", "void", "{", "$", "aopProxyClassRebuildIsNeeded", "=", "false", ";", "$", "aopProxyClassInfluencers", "=", "'/(?:Policy|Objects|Settings)(?:\\..*)*\\.yaml/'", ";", ...
Flushes caches as needed if settings, routes or policies have changed @param array $changedFiles A list of full paths to changed files @return void @see flushSystemCachesByChangedFiles()
[ "Flushes", "caches", "as", "needed", "if", "settings", "routes", "or", "policies", "have", "changed" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L362-L403
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.flushTranslationCachesByChangedFiles
protected function flushTranslationCachesByChangedFiles(array $changedFiles): void { foreach ($changedFiles as $pathAndFilename => $status) { if (preg_match('/\/Translations\/.+\.xlf/', $pathAndFilename) === 1) { $this->logger->info('The localization files have changed, thus flushing the I18n XML model cache.', LogEnvironment::fromMethodName(__METHOD__)); $this->getCache('Flow_I18n_XmlModelCache')->flush(); break; } } }
php
protected function flushTranslationCachesByChangedFiles(array $changedFiles): void { foreach ($changedFiles as $pathAndFilename => $status) { if (preg_match('/\/Translations\/.+\.xlf/', $pathAndFilename) === 1) { $this->logger->info('The localization files have changed, thus flushing the I18n XML model cache.', LogEnvironment::fromMethodName(__METHOD__)); $this->getCache('Flow_I18n_XmlModelCache')->flush(); break; } } }
[ "protected", "function", "flushTranslationCachesByChangedFiles", "(", "array", "$", "changedFiles", ")", ":", "void", "{", "foreach", "(", "$", "changedFiles", "as", "$", "pathAndFilename", "=>", "$", "status", ")", "{", "if", "(", "preg_match", "(", "'/\\/Trans...
Flushes I18n caches if translation files have changed @param array $changedFiles A list of full paths to changed files @return void @see flushSystemCachesByChangedFiles()
[ "Flushes", "I18n", "caches", "if", "translation", "files", "have", "changed" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L412-L421
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.createAllCaches
protected function createAllCaches(): void { foreach (array_keys($this->cacheConfigurations) as $identifier) { if ($identifier !== 'Default' && !isset($this->caches[$identifier])) { $this->createCache($identifier); } } }
php
protected function createAllCaches(): void { foreach (array_keys($this->cacheConfigurations) as $identifier) { if ($identifier !== 'Default' && !isset($this->caches[$identifier])) { $this->createCache($identifier); } } }
[ "protected", "function", "createAllCaches", "(", ")", ":", "void", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "cacheConfigurations", ")", "as", "$", "identifier", ")", "{", "if", "(", "$", "identifier", "!==", "'Default'", "&&", "!", "isset...
Instantiates all registered caches. @return void
[ "Instantiates", "all", "registered", "caches", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L428-L435
neos/flow-development-collection
Neos.Flow/Classes/Cache/CacheManager.php
CacheManager.createCache
protected function createCache(string $identifier): void { $frontend = isset($this->cacheConfigurations[$identifier]['frontend']) ? $this->cacheConfigurations[$identifier]['frontend'] : $this->cacheConfigurations['Default']['frontend']; $backend = isset($this->cacheConfigurations[$identifier]['backend']) ? $this->cacheConfigurations[$identifier]['backend'] : $this->cacheConfigurations['Default']['backend']; $backendOptions = isset($this->cacheConfigurations[$identifier]['backendOptions']) ? $this->cacheConfigurations[$identifier]['backendOptions'] : $this->cacheConfigurations['Default']['backendOptions']; $persistent = isset($this->cacheConfigurations[$identifier]['persistent']) ? $this->cacheConfigurations[$identifier]['persistent'] : $this->cacheConfigurations['Default']['persistent']; $cache = $this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions, $persistent); $this->registerCache($cache, $persistent); }
php
protected function createCache(string $identifier): void { $frontend = isset($this->cacheConfigurations[$identifier]['frontend']) ? $this->cacheConfigurations[$identifier]['frontend'] : $this->cacheConfigurations['Default']['frontend']; $backend = isset($this->cacheConfigurations[$identifier]['backend']) ? $this->cacheConfigurations[$identifier]['backend'] : $this->cacheConfigurations['Default']['backend']; $backendOptions = isset($this->cacheConfigurations[$identifier]['backendOptions']) ? $this->cacheConfigurations[$identifier]['backendOptions'] : $this->cacheConfigurations['Default']['backendOptions']; $persistent = isset($this->cacheConfigurations[$identifier]['persistent']) ? $this->cacheConfigurations[$identifier]['persistent'] : $this->cacheConfigurations['Default']['persistent']; $cache = $this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions, $persistent); $this->registerCache($cache, $persistent); }
[ "protected", "function", "createCache", "(", "string", "$", "identifier", ")", ":", "void", "{", "$", "frontend", "=", "isset", "(", "$", "this", "->", "cacheConfigurations", "[", "$", "identifier", "]", "[", "'frontend'", "]", ")", "?", "$", "this", "->...
Instantiates the cache for $identifier. @param string $identifier @return void
[ "Instantiates", "the", "cache", "for", "$identifier", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheManager.php#L443-L451
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20151113161300.php
Version20151113161300.processRequestPatterns
public function processRequestPatterns(array &$configuration) { if (!isset($configuration['TYPO3']['Flow']['security']['authentication']['providers'])) { return; } foreach ($configuration['TYPO3']['Flow']['security']['authentication']['providers'] as $providerName => &$providerOptions) { if (!isset($providerOptions['requestPatterns'])) { continue; } foreach ($providerOptions['requestPatterns'] as $requestPatternName => $requestPatternOptions) { // already converted? if (isset($requestPatternOptions['pattern'])) { continue; } switch (strtolower($requestPatternName)) { case 'controllerobjectname': $requestPatternOptions = [ 'pattern' => 'ControllerObjectName', 'patternOptions' => ['controllerObjectNamePattern' => $requestPatternOptions] ]; break; case 'csrfprotection': $requestPatternOptions = [ 'pattern' => 'CsrfProtection', ]; break; case 'host': $requestPatternOptions = [ 'pattern' => 'Host', 'patternOptions' => ['hostPattern' => $requestPatternOptions] ]; break; case 'ip': $requestPatternOptions = [ 'pattern' => 'Ip', 'patternOptions' => ['cidrPattern' => $requestPatternOptions] ]; break; case 'uri': $requestPatternOptions = [ 'pattern' => 'Uri', 'patternOptions' => ['uriPattern' => $requestPatternOptions] ]; break; default: $this->showWarning(sprintf('Could not automatically convert the syntax of the custom request pattern "%s". Please adjust it manually as described in the documentation.', $requestPatternName)); continue 2; } $patternIdentifier = $this->targetPackageData['packageKey'] . ':' . $this->getShortClassName($requestPatternName); $providerOptions['requestPatterns'][$patternIdentifier] = $requestPatternOptions; unset($providerOptions['requestPatterns'][$requestPatternName]); $this->showNote(sprintf('Adjusted configuration syntax of the "%s" request pattern.', $requestPatternName)); } } }
php
public function processRequestPatterns(array &$configuration) { if (!isset($configuration['TYPO3']['Flow']['security']['authentication']['providers'])) { return; } foreach ($configuration['TYPO3']['Flow']['security']['authentication']['providers'] as $providerName => &$providerOptions) { if (!isset($providerOptions['requestPatterns'])) { continue; } foreach ($providerOptions['requestPatterns'] as $requestPatternName => $requestPatternOptions) { // already converted? if (isset($requestPatternOptions['pattern'])) { continue; } switch (strtolower($requestPatternName)) { case 'controllerobjectname': $requestPatternOptions = [ 'pattern' => 'ControllerObjectName', 'patternOptions' => ['controllerObjectNamePattern' => $requestPatternOptions] ]; break; case 'csrfprotection': $requestPatternOptions = [ 'pattern' => 'CsrfProtection', ]; break; case 'host': $requestPatternOptions = [ 'pattern' => 'Host', 'patternOptions' => ['hostPattern' => $requestPatternOptions] ]; break; case 'ip': $requestPatternOptions = [ 'pattern' => 'Ip', 'patternOptions' => ['cidrPattern' => $requestPatternOptions] ]; break; case 'uri': $requestPatternOptions = [ 'pattern' => 'Uri', 'patternOptions' => ['uriPattern' => $requestPatternOptions] ]; break; default: $this->showWarning(sprintf('Could not automatically convert the syntax of the custom request pattern "%s". Please adjust it manually as described in the documentation.', $requestPatternName)); continue 2; } $patternIdentifier = $this->targetPackageData['packageKey'] . ':' . $this->getShortClassName($requestPatternName); $providerOptions['requestPatterns'][$patternIdentifier] = $requestPatternOptions; unset($providerOptions['requestPatterns'][$requestPatternName]); $this->showNote(sprintf('Adjusted configuration syntax of the "%s" request pattern.', $requestPatternName)); } } }
[ "public", "function", "processRequestPatterns", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "isset", "(", "$", "configuration", "[", "'TYPO3'", "]", "[", "'Flow'", "]", "[", "'security'", "]", "[", "'authentication'", "]", "[", "'pro...
Adjust TYPO3.Flow.security.authentication.providers.<providerName>.requestPatterns syntax @param array $configuration @return void
[ "Adjust", "TYPO3", ".", "Flow", ".", "security", ".", "authentication", ".", "providers", ".", "<providerName", ">", ".", "requestPatterns", "syntax" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20151113161300.php#L52-L106
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20151113161300.php
Version20151113161300.processFirewallFilters
public function processFirewallFilters(array &$configuration) { if (!isset($configuration['TYPO3']['Flow']['security']['firewall']['filters'])) { return; } $filtersConfiguration = &$configuration['TYPO3']['Flow']['security']['firewall']['filters']; foreach ($filtersConfiguration as $filterIndex => &$filterOptions) { // already converted? if (isset($filterOptions['pattern']) || !isset($filterOptions['patternType'])) { continue; } $patternValue = isset($filterOptions['patternValue']) ? $filterOptions['patternValue'] : ''; switch (strtolower($filterOptions['patternType'])) { case 'controllerobjectname': $patternClassName = ControllerObjectName::class; $filterOptions['pattern'] = 'ControllerObjectName'; $filterOptions['patternOptions'] = ['controllerObjectNamePattern' => $patternValue]; break; case 'csrfprotection': $patternClassName = CsrfProtection::class; $filterOptions['pattern'] = 'CsrfProtection'; break; case 'host': $patternClassName = Host::class; $filterOptions['pattern'] = 'Host'; $filterOptions['patternOptions'] = ['hostPattern' => $patternValue]; break; case 'ip': $patternClassName = Ip::class; $filterOptions['pattern'] = 'Ip'; $filterOptions['patternOptions'] = ['cidrPattern' => $patternValue]; break; case 'uri': $patternClassName = Uri::class; $filterOptions['pattern'] = 'Uri'; $filterOptions['patternOptions'] = ['uriPattern' => $patternValue]; break; default: $this->showWarning(sprintf('Could not automatically convert the syntax of the custom firewall filter "%s". Please adjust it manually as described in the documentation.', $filterOptions['patternType'])); $patternClassName = $filterOptions['patternType']; } if (isset($filterOptions['pattern'])) { unset($filterOptions['patternType'], $filterOptions['patternValue']); } if (is_numeric($filterIndex)) { $patternIdentifier = $this->targetPackageData['packageKey'] . ':' . $this->getShortClassName($patternClassName); $uniquePatternIdentifier = $patternIdentifier; $loopCounter = 1; while (isset($filtersConfiguration[$uniquePatternIdentifier])) { $uniquePatternIdentifier = $patternIdentifier . '_' . (++ $loopCounter); } unset($filtersConfiguration[$filterIndex]); $filtersConfiguration[$uniquePatternIdentifier] = $filterOptions; } $this->showNote(sprintf('Adjusted configuration syntax of the "%s" firewall filter.', $patternClassName)); } }
php
public function processFirewallFilters(array &$configuration) { if (!isset($configuration['TYPO3']['Flow']['security']['firewall']['filters'])) { return; } $filtersConfiguration = &$configuration['TYPO3']['Flow']['security']['firewall']['filters']; foreach ($filtersConfiguration as $filterIndex => &$filterOptions) { // already converted? if (isset($filterOptions['pattern']) || !isset($filterOptions['patternType'])) { continue; } $patternValue = isset($filterOptions['patternValue']) ? $filterOptions['patternValue'] : ''; switch (strtolower($filterOptions['patternType'])) { case 'controllerobjectname': $patternClassName = ControllerObjectName::class; $filterOptions['pattern'] = 'ControllerObjectName'; $filterOptions['patternOptions'] = ['controllerObjectNamePattern' => $patternValue]; break; case 'csrfprotection': $patternClassName = CsrfProtection::class; $filterOptions['pattern'] = 'CsrfProtection'; break; case 'host': $patternClassName = Host::class; $filterOptions['pattern'] = 'Host'; $filterOptions['patternOptions'] = ['hostPattern' => $patternValue]; break; case 'ip': $patternClassName = Ip::class; $filterOptions['pattern'] = 'Ip'; $filterOptions['patternOptions'] = ['cidrPattern' => $patternValue]; break; case 'uri': $patternClassName = Uri::class; $filterOptions['pattern'] = 'Uri'; $filterOptions['patternOptions'] = ['uriPattern' => $patternValue]; break; default: $this->showWarning(sprintf('Could not automatically convert the syntax of the custom firewall filter "%s". Please adjust it manually as described in the documentation.', $filterOptions['patternType'])); $patternClassName = $filterOptions['patternType']; } if (isset($filterOptions['pattern'])) { unset($filterOptions['patternType'], $filterOptions['patternValue']); } if (is_numeric($filterIndex)) { $patternIdentifier = $this->targetPackageData['packageKey'] . ':' . $this->getShortClassName($patternClassName); $uniquePatternIdentifier = $patternIdentifier; $loopCounter = 1; while (isset($filtersConfiguration[$uniquePatternIdentifier])) { $uniquePatternIdentifier = $patternIdentifier . '_' . (++ $loopCounter); } unset($filtersConfiguration[$filterIndex]); $filtersConfiguration[$uniquePatternIdentifier] = $filterOptions; } $this->showNote(sprintf('Adjusted configuration syntax of the "%s" firewall filter.', $patternClassName)); } }
[ "public", "function", "processFirewallFilters", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "isset", "(", "$", "configuration", "[", "'TYPO3'", "]", "[", "'Flow'", "]", "[", "'security'", "]", "[", "'firewall'", "]", "[", "'filters'"...
Adjust TYPO3.Flow.security.authentication.providers.<providerName>.requestPatterns syntax @param array $configuration @return void
[ "Adjust", "TYPO3", ".", "Flow", ".", "security", ".", "authentication", ".", "providers", ".", "<providerName", ">", ".", "requestPatterns", "syntax" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20151113161300.php#L114-L171
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Doctrine/ObjectValidationAndDeDuplicationListener.php
ObjectValidationAndDeDuplicationListener.onFlush
public function onFlush(OnFlushEventArgs $eventArgs) { $this->entityManager = $eventArgs->getEntityManager(); $validatedInstancesContainer = new \SplObjectStorage(); $this->deduplicateValueObjectInsertions(); $unitOfWork = $this->entityManager->getUnitOfWork(); foreach ($unitOfWork->getScheduledEntityInsertions() as $entity) { $this->validateObject($entity, $validatedInstancesContainer); } foreach ($unitOfWork->getScheduledEntityUpdates() as $entity) { $this->validateObject($entity, $validatedInstancesContainer); } }
php
public function onFlush(OnFlushEventArgs $eventArgs) { $this->entityManager = $eventArgs->getEntityManager(); $validatedInstancesContainer = new \SplObjectStorage(); $this->deduplicateValueObjectInsertions(); $unitOfWork = $this->entityManager->getUnitOfWork(); foreach ($unitOfWork->getScheduledEntityInsertions() as $entity) { $this->validateObject($entity, $validatedInstancesContainer); } foreach ($unitOfWork->getScheduledEntityUpdates() as $entity) { $this->validateObject($entity, $validatedInstancesContainer); } }
[ "public", "function", "onFlush", "(", "OnFlushEventArgs", "$", "eventArgs", ")", "{", "$", "this", "->", "entityManager", "=", "$", "eventArgs", "->", "getEntityManager", "(", ")", ";", "$", "validatedInstancesContainer", "=", "new", "\\", "SplObjectStorage", "(...
An onFlush event listener used to act upon persistence. @param OnFlushEventArgs $eventArgs @return void @throws ObjectValidationFailedException
[ "An", "onFlush", "event", "listener", "used", "to", "act", "upon", "persistence", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/ObjectValidationAndDeDuplicationListener.php#L64-L79
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Doctrine/ObjectValidationAndDeDuplicationListener.php
ObjectValidationAndDeDuplicationListener.deduplicateValueObjectInsertions
private function deduplicateValueObjectInsertions() { $unitOfWork = $this->entityManager->getUnitOfWork(); $entityInsertions = $unitOfWork->getScheduledEntityInsertions(); $knownValueObjects = []; foreach ($entityInsertions as $entity) { $className = TypeHandling::getTypeForValue($entity); if ($this->reflectionService->getClassSchema($className)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) { $identifier = $this->persistenceManager->getIdentifierByObject($entity); if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) { unset($entityInsertions[spl_object_hash($entity)]); continue; } $knownValueObjects[$className][$identifier] = true; } } ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, true); }
php
private function deduplicateValueObjectInsertions() { $unitOfWork = $this->entityManager->getUnitOfWork(); $entityInsertions = $unitOfWork->getScheduledEntityInsertions(); $knownValueObjects = []; foreach ($entityInsertions as $entity) { $className = TypeHandling::getTypeForValue($entity); if ($this->reflectionService->getClassSchema($className)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) { $identifier = $this->persistenceManager->getIdentifierByObject($entity); if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) { unset($entityInsertions[spl_object_hash($entity)]); continue; } $knownValueObjects[$className][$identifier] = true; } } ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, true); }
[ "private", "function", "deduplicateValueObjectInsertions", "(", ")", "{", "$", "unitOfWork", "=", "$", "this", "->", "entityManager", "->", "getUnitOfWork", "(", ")", ";", "$", "entityInsertions", "=", "$", "unitOfWork", "->", "getScheduledEntityInsertions", "(", ...
Loops over scheduled insertions and checks for duplicate value objects. Any duplicates are unset from the list of scheduled insertions. @return void
[ "Loops", "over", "scheduled", "insertions", "and", "checks", "for", "duplicate", "value", "objects", ".", "Any", "duplicates", "are", "unset", "from", "the", "list", "of", "scheduled", "insertions", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/ObjectValidationAndDeDuplicationListener.php#L87-L108
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Doctrine/ObjectValidationAndDeDuplicationListener.php
ObjectValidationAndDeDuplicationListener.validateObject
private function validateObject($object, \SplObjectStorage $validatedInstancesContainer) { $className = $this->entityManager->getClassMetadata(get_class($object))->getName(); $validator = $this->validatorResolver->getBaseValidatorConjunction($className, ['Persistence', 'Default']); if ($validator === null) { return; } $validator->setValidatedInstancesContainer($validatedInstancesContainer); $validationResult = $validator->validate($object); if ($validationResult->hasErrors()) { $errorMessages = ''; $errorCount = 0; $allErrors = $validationResult->getFlattenedErrors(); foreach ($allErrors as $path => $errors) { $errorMessages .= $path . ':' . PHP_EOL; foreach ($errors as $error) { $errorCount++; $errorMessages .= (string)$error . PHP_EOL; } } throw new ObjectValidationFailedException('An instance of "' . get_class($object) . '" failed to pass validation with ' . $errorCount . ' error(s): ' . PHP_EOL . $errorMessages, 1322585164); } }
php
private function validateObject($object, \SplObjectStorage $validatedInstancesContainer) { $className = $this->entityManager->getClassMetadata(get_class($object))->getName(); $validator = $this->validatorResolver->getBaseValidatorConjunction($className, ['Persistence', 'Default']); if ($validator === null) { return; } $validator->setValidatedInstancesContainer($validatedInstancesContainer); $validationResult = $validator->validate($object); if ($validationResult->hasErrors()) { $errorMessages = ''; $errorCount = 0; $allErrors = $validationResult->getFlattenedErrors(); foreach ($allErrors as $path => $errors) { $errorMessages .= $path . ':' . PHP_EOL; foreach ($errors as $error) { $errorCount++; $errorMessages .= (string)$error . PHP_EOL; } } throw new ObjectValidationFailedException('An instance of "' . get_class($object) . '" failed to pass validation with ' . $errorCount . ' error(s): ' . PHP_EOL . $errorMessages, 1322585164); } }
[ "private", "function", "validateObject", "(", "$", "object", ",", "\\", "SplObjectStorage", "$", "validatedInstancesContainer", ")", "{", "$", "className", "=", "$", "this", "->", "entityManager", "->", "getClassMetadata", "(", "get_class", "(", "$", "object", "...
Validates the given object and throws an exception if validation fails. @param object $object @param \SplObjectStorage $validatedInstancesContainer @return void @throws ObjectValidationFailedException
[ "Validates", "the", "given", "object", "and", "throws", "an", "exception", "if", "validation", "fails", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/ObjectValidationAndDeDuplicationListener.php#L118-L141
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.getBaseUri
public function getBaseUri() { if ($this->baseUri === null) { $this->baseUri = $this->detectBaseUri(); } return $this->baseUri; }
php
public function getBaseUri() { if ($this->baseUri === null) { $this->baseUri = $this->detectBaseUri(); } return $this->baseUri; }
[ "public", "function", "getBaseUri", "(", ")", "{", "if", "(", "$", "this", "->", "baseUri", "===", "null", ")", "{", "$", "this", "->", "baseUri", "=", "$", "this", "->", "detectBaseUri", "(", ")", ";", "}", "return", "$", "this", "->", "baseUri", ...
Returns the detected base URI @return UriInterface|Uri @deprecated Since Flow 5.1, no replacement on BaseRequest, use attribute on ServerRequestInterface @see Request::getAttribute(Request::ATTRIBUTE_BASE_URI)
[ "Returns", "the", "detected", "base", "URI" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L90-L97
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.setBaseUri
public function setBaseUri($baseUri) { if (is_string($baseUri)) { $baseUri = new Uri($baseUri); } $this->baseUri = $baseUri; }
php
public function setBaseUri($baseUri) { if (is_string($baseUri)) { $baseUri = new Uri($baseUri); } $this->baseUri = $baseUri; }
[ "public", "function", "setBaseUri", "(", "$", "baseUri", ")", "{", "if", "(", "is_string", "(", "$", "baseUri", ")", ")", "{", "$", "baseUri", "=", "new", "Uri", "(", "$", "baseUri", ")", ";", "}", "$", "this", "->", "baseUri", "=", "$", "baseUri",...
Set the base URI of this request. @param string|UriInterface $baseUri @deprecated Since Flow 5.1, set as an attribute on ServerRequestInterface instead. @see Request::withAttribute(Request::ATTRIBUTE_BASE_URI)
[ "Set", "the", "base", "URI", "of", "this", "request", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L106-L113
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.setContent
public function setContent($content) { if (is_resource($content) && get_resource_type($content) === 'stream' && stream_is_local($content)) { $streamMetaData = stream_get_meta_data($content); $this->headers->set('Content-Length', filesize($streamMetaData['uri'])); $this->headers->set('Content-Type', MediaTypes::getMediaTypeFromFilename($streamMetaData['uri'])); } parent::setContent($content); }
php
public function setContent($content) { if (is_resource($content) && get_resource_type($content) === 'stream' && stream_is_local($content)) { $streamMetaData = stream_get_meta_data($content); $this->headers->set('Content-Length', filesize($streamMetaData['uri'])); $this->headers->set('Content-Type', MediaTypes::getMediaTypeFromFilename($streamMetaData['uri'])); } parent::setContent($content); }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "if", "(", "is_resource", "(", "$", "content", ")", "&&", "get_resource_type", "(", "$", "content", ")", "===", "'stream'", "&&", "stream_is_local", "(", "$", "content", ")", ")", "{", "$...
Explicitly sets the content of the request body In most cases, content is just a string representation of the request body. In order to reduce memory consumption for uploads and other big data, it is also possible to pass a stream resource. The easies way to convert a local file into a stream resource is probably: $resource = fopen('file://path/to/file', 'rb'); @param string|resource $content The body content, for example arguments of a PUT request, or a stream resource @return void @deprecated Since Flow 5.1, use withBody @see withBody()
[ "Explicitly", "sets", "the", "content", "of", "the", "request", "body" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L167-L176
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.getContent
public function getContent($asResource = false) { if ($asResource === true) { if ($this->content !== null) { throw new Exception('Cannot return request content as resource because it has already been retrieved.', 1332942478); } $this->content = ''; return fopen($this->inputStreamUri, 'rb'); } if ($this->content === null) { $this->content = file_get_contents($this->inputStreamUri); } return $this->content; }
php
public function getContent($asResource = false) { if ($asResource === true) { if ($this->content !== null) { throw new Exception('Cannot return request content as resource because it has already been retrieved.', 1332942478); } $this->content = ''; return fopen($this->inputStreamUri, 'rb'); } if ($this->content === null) { $this->content = file_get_contents($this->inputStreamUri); } return $this->content; }
[ "public", "function", "getContent", "(", "$", "asResource", "=", "false", ")", "{", "if", "(", "$", "asResource", "===", "true", ")", "{", "if", "(", "$", "this", "->", "content", "!==", "null", ")", "{", "throw", "new", "Exception", "(", "'Cannot retu...
Returns the content of the request body If the request body has not been set with setContent() previously, this method will try to retrieve it from the input stream. If $asResource was set to true, the stream resource will be returned instead of a string. If the content which has been set by setContent() originally was a stream resource, that resource will be returned, no matter if $asResource is set. @param boolean $asResource If set, the content is returned as a resource pointing to PHP's input stream @return string|resource @throws Exception @deprecated Since Flow 5.1, use getBody @see getBody()
[ "Returns", "the", "content", "of", "the", "request", "body" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L195-L211
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.renderHeaders
public function renderHeaders() { $headers = RequestInformationHelper::generateRequestLine($this); $headers .= RequestInformationHelper::renderRequestHeaders($this); return $headers; }
php
public function renderHeaders() { $headers = RequestInformationHelper::generateRequestLine($this); $headers .= RequestInformationHelper::renderRequestHeaders($this); return $headers; }
[ "public", "function", "renderHeaders", "(", ")", "{", "$", "headers", "=", "RequestInformationHelper", "::", "generateRequestLine", "(", "$", "this", ")", ";", "$", "headers", ".=", "RequestInformationHelper", "::", "renderRequestHeaders", "(", "$", "this", ")", ...
Renders the HTTP headers - including the status header - of this request @return string The HTTP headers, one per line, separated by \r\n as required by RFC 2616 sec 5 @deprecated Since Flow 5.1, use the RequestInformationHelper @see RequestInformationHelper::generateRequestLine() and RequestInformationHelper::renderRequestHeaders()
[ "Renders", "the", "HTTP", "headers", "-", "including", "the", "status", "header", "-", "of", "this", "request" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L249-L255
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.getRequestTarget
public function getRequestTarget() { if ($this->requestTarget !== null) { return $this->requestTarget; } $uri = $this->getUri(); if ($uri === null) { return '/'; } $requestUri = $uri->getPath() . ($uri->getQuery() ? '?' . $uri->getQuery() : '') . ($uri->getFragment() ? '#' . $uri->getFragment() : ''); return $requestUri; }
php
public function getRequestTarget() { if ($this->requestTarget !== null) { return $this->requestTarget; } $uri = $this->getUri(); if ($uri === null) { return '/'; } $requestUri = $uri->getPath() . ($uri->getQuery() ? '?' . $uri->getQuery() : '') . ($uri->getFragment() ? '#' . $uri->getFragment() : ''); return $requestUri; }
[ "public", "function", "getRequestTarget", "(", ")", "{", "if", "(", "$", "this", "->", "requestTarget", "!==", "null", ")", "{", "return", "$", "this", "->", "requestTarget", ";", "}", "$", "uri", "=", "$", "this", "->", "getUri", "(", ")", ";", "if"...
Retrieves the message's request target. Retrieves the message's request-target either as it will appear (for clients), as it appeared at request (for servers), or as it was specified for the instance (see withRequestTarget()). In most cases, this will be the origin-form of the composed URI, unless a value was provided to the concrete implementation (see withRequestTarget() below). If no URI is available, and no request-target has been specifically provided, this method MUST return the string "/". @return string
[ "Retrieves", "the", "message", "s", "request", "target", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L273-L289
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.withUri
public function withUri(UriInterface $uri, $preserveHost = false) { if ((string)$this->uri === (string)$uri) { return $this; } $newRequest = clone $this; $newRequest->uri = $uri; if ($preserveHost === false || !$this->hasHeader('Host')) { $newRequest->updateHostFromUri(); } return $newRequest; }
php
public function withUri(UriInterface $uri, $preserveHost = false) { if ((string)$this->uri === (string)$uri) { return $this; } $newRequest = clone $this; $newRequest->uri = $uri; if ($preserveHost === false || !$this->hasHeader('Host')) { $newRequest->updateHostFromUri(); } return $newRequest; }
[ "public", "function", "withUri", "(", "UriInterface", "$", "uri", ",", "$", "preserveHost", "=", "false", ")", "{", "if", "(", "(", "string", ")", "$", "this", "->", "uri", "===", "(", "string", ")", "$", "uri", ")", "{", "return", "$", "this", ";"...
Returns an instance with the provided URI. This method MUST update the Host header of the returned request by default if the URI contains a host component. If the URI does not contain a host component, any pre-existing Host header MUST be carried over to the returned request. You can opt-in to preserving the original state of the Host header by setting `$preserveHost` to `true`. When `$preserveHost` is set to `true`, this method interacts with the Host header in the following ways: - If the the Host header is missing or empty, and the new URI contains a host component, this method MUST update the Host header in the returned request. - If the Host header is missing or empty, and the new URI does not contain a host component, this method MUST NOT update the Host header in the returned request. - If a Host header is present and non-empty, this method MUST NOT update the Host header in the returned request. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new UriInterface instance. @link http://tools.ietf.org/html/rfc3986#section-4.3 @param UriInterface $uri New request URI to use. @param bool $preserveHost Preserve the original state of the Host header. @return self @api PSR-7
[ "Returns", "an", "instance", "with", "the", "provided", "URI", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L371-L386
neos/flow-development-collection
Neos.Flow/Classes/Http/BaseRequest.php
BaseRequest.updateHostFromUri
private function updateHostFromUri() { $host = $this->uri->getHost(); if ($host == '') { return; } if (($port = $this->uri->getPort()) !== null) { $host .= ':' . $port; } $this->setHeader('Host', $host); }
php
private function updateHostFromUri() { $host = $this->uri->getHost(); if ($host == '') { return; } if (($port = $this->uri->getPort()) !== null) { $host .= ':' . $port; } $this->setHeader('Host', $host); }
[ "private", "function", "updateHostFromUri", "(", ")", "{", "$", "host", "=", "$", "this", "->", "uri", "->", "getHost", "(", ")", ";", "if", "(", "$", "host", "==", "''", ")", "{", "return", ";", "}", "if", "(", "(", "$", "port", "=", "$", "thi...
Update the current Host header based on the current Uri
[ "Update", "the", "current", "Host", "header", "based", "on", "the", "current", "Uri" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/BaseRequest.php#L391-L404
neos/flow-development-collection
Neos.Flow/Classes/Exception.php
Exception.getReferenceCode
public function getReferenceCode() { if (!isset($this->referenceCode)) { $this->referenceCode = date('YmdHis', $_SERVER['REQUEST_TIME']) . substr(md5(rand()), 0, 6); } return $this->referenceCode; }
php
public function getReferenceCode() { if (!isset($this->referenceCode)) { $this->referenceCode = date('YmdHis', $_SERVER['REQUEST_TIME']) . substr(md5(rand()), 0, 6); } return $this->referenceCode; }
[ "public", "function", "getReferenceCode", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "referenceCode", ")", ")", "{", "$", "this", "->", "referenceCode", "=", "date", "(", "'YmdHis'", ",", "$", "_SERVER", "[", "'REQUEST_TIME'", "]", ...
Returns a code which can be communicated publicly so that whoever experiences the exception can refer to it and a developer can find more information about it in the system log. @return string @api
[ "Returns", "a", "code", "which", "can", "be", "communicated", "publicly", "so", "that", "whoever", "experiences", "the", "exception", "can", "refer", "to", "it", "and", "a", "developer", "can", "find", "more", "information", "about", "it", "in", "the", "syst...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Exception.php#L41-L47
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/RoutingComponent.php
RoutingComponent.handle
public function handle(ComponentContext $componentContext) { $parameters = $componentContext->getParameter(RoutingComponent::class, 'parameters'); if ($parameters === null) { $parameters = RouteParameters::createEmpty(); } $routeContext = new RouteContext($componentContext->getHttpRequest(), $parameters); try { $matchResults = $this->router->route($routeContext); } catch (NoMatchingRouteException $exception) { $matchResults = null; } $componentContext->setParameter(RoutingComponent::class, 'matchResults', $matchResults); }
php
public function handle(ComponentContext $componentContext) { $parameters = $componentContext->getParameter(RoutingComponent::class, 'parameters'); if ($parameters === null) { $parameters = RouteParameters::createEmpty(); } $routeContext = new RouteContext($componentContext->getHttpRequest(), $parameters); try { $matchResults = $this->router->route($routeContext); } catch (NoMatchingRouteException $exception) { $matchResults = null; } $componentContext->setParameter(RoutingComponent::class, 'matchResults', $matchResults); }
[ "public", "function", "handle", "(", "ComponentContext", "$", "componentContext", ")", "{", "$", "parameters", "=", "$", "componentContext", "->", "getParameter", "(", "RoutingComponent", "::", "class", ",", "'parameters'", ")", ";", "if", "(", "$", "parameters"...
Resolve a route for the request Stores the resolved route values in the ComponentContext to pass them to other components. They can be accessed via ComponentContext::getParameter(outingComponent::class, 'matchResults'); @param ComponentContext $componentContext @return void
[ "Resolve", "a", "route", "for", "the", "request" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/RoutingComponent.php#L54-L69
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Collection.php
Collection.importResource
public function importResource($source) { if (!$this->storage instanceof WritableStorageInterface) { throw new ResourceException(sprintf('Could not import resource into collection "%s" because its storage "%s" is a read-only storage.', $this->name, $this->storage->getName()), 1375197288); } return $this->storage->importResource($source, $this->name); }
php
public function importResource($source) { if (!$this->storage instanceof WritableStorageInterface) { throw new ResourceException(sprintf('Could not import resource into collection "%s" because its storage "%s" is a read-only storage.', $this->name, $this->storage->getName()), 1375197288); } return $this->storage->importResource($source, $this->name); }
[ "public", "function", "importResource", "(", "$", "source", ")", "{", "if", "(", "!", "$", "this", "->", "storage", "instanceof", "WritableStorageInterface", ")", "{", "throw", "new", "ResourceException", "(", "sprintf", "(", "'Could not import resource into collect...
Imports a resource (file) from the given URI or PHP resource stream into this collection. On a successful import this method returns a PersistentResource object representing the newly imported persistent resource. Note that this collection must have a writable storage in order to import resources. @param string | resource $source The URI (or local path and filename) or the PHP resource stream to import the resource from @return PersistentResource A resource object representing the imported resource @throws ResourceException
[ "Imports", "a", "resource", "(", "file", ")", "from", "the", "given", "URI", "or", "PHP", "resource", "stream", "into", "this", "collection", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Collection.php#L110-L116
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Collection.php
Collection.importResourceFromContent
public function importResourceFromContent($content) { if (!$this->storage instanceof WritableStorageInterface) { throw new ResourceException(sprintf('Could not import resource into collection "%s" because its storage "%s" is a read-only storage.', $this->name, $this->storage->getName()), 1381155740); } return $this->storage->importResourceFromContent($content, $this->name); }
php
public function importResourceFromContent($content) { if (!$this->storage instanceof WritableStorageInterface) { throw new ResourceException(sprintf('Could not import resource into collection "%s" because its storage "%s" is a read-only storage.', $this->name, $this->storage->getName()), 1381155740); } return $this->storage->importResourceFromContent($content, $this->name); }
[ "public", "function", "importResourceFromContent", "(", "$", "content", ")", "{", "if", "(", "!", "$", "this", "->", "storage", "instanceof", "WritableStorageInterface", ")", "{", "throw", "new", "ResourceException", "(", "sprintf", "(", "'Could not import resource ...
Imports a resource from the given string content into this collection. On a successful import this method returns a PersistentResource object representing the newly imported persistent resource. Note that this collection must have a writable storage in order to import resources. The specified filename will be used when presenting the resource to a user. Its file extension is important because the resource management will derive the IANA Media Type from it. @param string $content The actual content to import @return PersistentResource A resource object representing the imported resource @throws ResourceException
[ "Imports", "a", "resource", "from", "the", "given", "string", "content", "into", "this", "collection", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Collection.php#L133-L139
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Collection.php
Collection.getObjects
public function getObjects(callable $callback = null) { $objects = []; if ($this->storage instanceof PackageStorage && $this->pathPatterns !== []) { $objects = new \AppendIterator(); foreach ($this->pathPatterns as $pathPattern) { $objects->append($this->storage->getObjectsByPathPattern($pathPattern, $callback)); } } else { $objects = $this->storage->getObjectsByCollection($this, $callback); } // TODO: Implement filter manipulation here: // foreach ($objects as $object) { // $object->setStream(function() { return fopen('/tmp/test.txt', 'rb');}); // } return $objects; }
php
public function getObjects(callable $callback = null) { $objects = []; if ($this->storage instanceof PackageStorage && $this->pathPatterns !== []) { $objects = new \AppendIterator(); foreach ($this->pathPatterns as $pathPattern) { $objects->append($this->storage->getObjectsByPathPattern($pathPattern, $callback)); } } else { $objects = $this->storage->getObjectsByCollection($this, $callback); } // TODO: Implement filter manipulation here: // foreach ($objects as $object) { // $object->setStream(function() { return fopen('/tmp/test.txt', 'rb');}); // } return $objects; }
[ "public", "function", "getObjects", "(", "callable", "$", "callback", "=", "null", ")", "{", "$", "objects", "=", "[", "]", ";", "if", "(", "$", "this", "->", "storage", "instanceof", "PackageStorage", "&&", "$", "this", "->", "pathPatterns", "!==", "[",...
Returns all internal data objects of the storage attached to this collection. @param callable $callback Function called after each object @return \Generator<Storage\Object>
[ "Returns", "all", "internal", "data", "objects", "of", "the", "storage", "attached", "to", "this", "collection", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Collection.php#L157-L175
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Collection.php
Collection.getStreamByResource
public function getStreamByResource(PersistentResource $resource) { $stream = $this->getStorage()->getStreamByResource($resource); if ($stream !== false) { $meta = stream_get_meta_data($stream); if ($meta['seekable']) { rewind($stream); } } return $stream; }
php
public function getStreamByResource(PersistentResource $resource) { $stream = $this->getStorage()->getStreamByResource($resource); if ($stream !== false) { $meta = stream_get_meta_data($stream); if ($meta['seekable']) { rewind($stream); } } return $stream; }
[ "public", "function", "getStreamByResource", "(", "PersistentResource", "$", "resource", ")", "{", "$", "stream", "=", "$", "this", "->", "getStorage", "(", ")", "->", "getStreamByResource", "(", "$", "resource", ")", ";", "if", "(", "$", "stream", "!==", ...
Returns a stream handle of the given persistent resource which allows for opening / copying the resource's data. Note that this stream handle may only be used read-only. @param PersistentResource $resource The resource to retrieve the stream for @return resource | boolean The resource stream or false if the stream could not be obtained
[ "Returns", "a", "stream", "handle", "of", "the", "given", "persistent", "resource", "which", "allows", "for", "opening", "/", "copying", "the", "resource", "s", "data", ".", "Note", "that", "this", "stream", "handle", "may", "only", "be", "used", "read", "...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Collection.php#L184-L194
neos/flow-development-collection
Neos.Flow.Log/Classes/Backend/FileBackend.php
FileBackend.open
public function open() { $this->severityLabels = [ LOG_EMERG => 'EMERGENCY', LOG_ALERT => 'ALERT ', LOG_CRIT => 'CRITICAL ', LOG_ERR => 'ERROR ', LOG_WARNING => 'WARNING ', LOG_NOTICE => 'NOTICE ', LOG_INFO => 'INFO ', LOG_DEBUG => 'DEBUG ', ]; if (file_exists($this->logFileUrl) && $this->maximumLogFileSize > 0 && filesize($this->logFileUrl) > $this->maximumLogFileSize) { $this->rotateLogFile(); } if (file_exists($this->logFileUrl)) { $this->fileHandle = fopen($this->logFileUrl, 'ab'); } else { $logPath = dirname($this->logFileUrl); if (!file_exists($logPath) || (!is_dir($logPath) && !is_link($logPath))) { if ($this->createParentDirectories === false) { throw new CouldNotOpenResourceException('Could not open log file "' . $this->logFileUrl . '" for write access because the parent directory does not exist.', 1243931200); } Files::createDirectoryRecursively($logPath); } $this->fileHandle = fopen($this->logFileUrl, 'ab'); if ($this->fileHandle === false) { throw new CouldNotOpenResourceException('Could not open log file "' . $this->logFileUrl . '" for write access.', 1243588980); } $streamMeta = stream_get_meta_data($this->fileHandle); if ($streamMeta['wrapper_type'] === 'plainfile') { fclose($this->fileHandle); chmod($this->logFileUrl, 0666); $this->fileHandle = fopen($this->logFileUrl, 'ab'); } } if ($this->fileHandle === false) { throw new CouldNotOpenResourceException('Could not open log file "' . $this->logFileUrl . '" for write access.', 1229448440); } }
php
public function open() { $this->severityLabels = [ LOG_EMERG => 'EMERGENCY', LOG_ALERT => 'ALERT ', LOG_CRIT => 'CRITICAL ', LOG_ERR => 'ERROR ', LOG_WARNING => 'WARNING ', LOG_NOTICE => 'NOTICE ', LOG_INFO => 'INFO ', LOG_DEBUG => 'DEBUG ', ]; if (file_exists($this->logFileUrl) && $this->maximumLogFileSize > 0 && filesize($this->logFileUrl) > $this->maximumLogFileSize) { $this->rotateLogFile(); } if (file_exists($this->logFileUrl)) { $this->fileHandle = fopen($this->logFileUrl, 'ab'); } else { $logPath = dirname($this->logFileUrl); if (!file_exists($logPath) || (!is_dir($logPath) && !is_link($logPath))) { if ($this->createParentDirectories === false) { throw new CouldNotOpenResourceException('Could not open log file "' . $this->logFileUrl . '" for write access because the parent directory does not exist.', 1243931200); } Files::createDirectoryRecursively($logPath); } $this->fileHandle = fopen($this->logFileUrl, 'ab'); if ($this->fileHandle === false) { throw new CouldNotOpenResourceException('Could not open log file "' . $this->logFileUrl . '" for write access.', 1243588980); } $streamMeta = stream_get_meta_data($this->fileHandle); if ($streamMeta['wrapper_type'] === 'plainfile') { fclose($this->fileHandle); chmod($this->logFileUrl, 0666); $this->fileHandle = fopen($this->logFileUrl, 'ab'); } } if ($this->fileHandle === false) { throw new CouldNotOpenResourceException('Could not open log file "' . $this->logFileUrl . '" for write access.', 1229448440); } }
[ "public", "function", "open", "(", ")", "{", "$", "this", "->", "severityLabels", "=", "[", "LOG_EMERG", "=>", "'EMERGENCY'", ",", "LOG_ALERT", "=>", "'ALERT '", ",", "LOG_CRIT", "=>", "'CRITICAL '", ",", "LOG_ERR", "=>", "'ERROR '", ",", "LOG_WARNING", ...
Carries out all actions necessary to prepare the logging backend, such as opening the log file or opening a database connection. @return void @throws CouldNotOpenResourceException @api
[ "Carries", "out", "all", "actions", "necessary", "to", "prepare", "the", "logging", "backend", "such", "as", "opening", "the", "log", "file", "or", "opening", "a", "database", "connection", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/Backend/FileBackend.php#L137-L180
neos/flow-development-collection
Neos.Flow.Log/Classes/Backend/FileBackend.php
FileBackend.rotateLogFile
protected function rotateLogFile() { if (file_exists($this->logFileUrl . '.lock')) { return; } else { touch($this->logFileUrl . '.lock'); } if ($this->logFilesToKeep === 0) { unlink($this->logFileUrl); } else { for ($logFileCount = $this->logFilesToKeep; $logFileCount > 0; --$logFileCount) { $rotatedLogFileUrl = $this->logFileUrl . '.' . $logFileCount; if (file_exists($rotatedLogFileUrl)) { if ($logFileCount == $this->logFilesToKeep) { unlink($rotatedLogFileUrl); } else { rename($rotatedLogFileUrl, $this->logFileUrl . '.' . ($logFileCount + 1)); } } } rename($this->logFileUrl, $this->logFileUrl . '.1'); } unlink($this->logFileUrl . '.lock'); }
php
protected function rotateLogFile() { if (file_exists($this->logFileUrl . '.lock')) { return; } else { touch($this->logFileUrl . '.lock'); } if ($this->logFilesToKeep === 0) { unlink($this->logFileUrl); } else { for ($logFileCount = $this->logFilesToKeep; $logFileCount > 0; --$logFileCount) { $rotatedLogFileUrl = $this->logFileUrl . '.' . $logFileCount; if (file_exists($rotatedLogFileUrl)) { if ($logFileCount == $this->logFilesToKeep) { unlink($rotatedLogFileUrl); } else { rename($rotatedLogFileUrl, $this->logFileUrl . '.' . ($logFileCount + 1)); } } } rename($this->logFileUrl, $this->logFileUrl . '.1'); } unlink($this->logFileUrl . '.lock'); }
[ "protected", "function", "rotateLogFile", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "logFileUrl", ".", "'.lock'", ")", ")", "{", "return", ";", "}", "else", "{", "touch", "(", "$", "this", "->", "logFileUrl", ".", "'.lock'", ")",...
Rotate the log file and make sure the configured number of files is kept. @return void
[ "Rotate", "the", "log", "file", "and", "make", "sure", "the", "configured", "number", "of", "files", "is", "kept", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/Backend/FileBackend.php#L188-L213