repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
phpList/core
src/Composer/ModuleFinder.php
ModuleFinder.findBundleClasses
public function findBundleClasses(): array { /** @var string[][] $bundleSets */ $bundleSets = []; $modules = $this->packageRepository->findModules(); foreach ($modules as $module) { $extra = $module->getExtra(); $this->validateBundlesSectionInExtra($extra); if (empty($extra['phplist/core']['bundles'])) { continue; } $bundleSets[$module->getName()] = $extra['phplist/core']['bundles']; } return $bundleSets; }
php
public function findBundleClasses(): array { /** @var string[][] $bundleSets */ $bundleSets = []; $modules = $this->packageRepository->findModules(); foreach ($modules as $module) { $extra = $module->getExtra(); $this->validateBundlesSectionInExtra($extra); if (empty($extra['phplist/core']['bundles'])) { continue; } $bundleSets[$module->getName()] = $extra['phplist/core']['bundles']; } return $bundleSets; }
[ "public", "function", "findBundleClasses", "(", ")", ":", "array", "{", "/** @var string[][] $bundleSets */", "$", "bundleSets", "=", "[", "]", ";", "$", "modules", "=", "$", "this", "->", "packageRepository", "->", "findModules", "(", ")", ";", "foreach", "("...
Finds the bundles class in all installed modules. @return string[][] class names of the bundles of all installed phpList modules: ['module package name' => ['bundle class name 1', 'bundle class name 2']] @throws \InvalidArgumentException
[ "Finds", "the", "bundles", "class", "in", "all", "installed", "modules", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ModuleFinder.php#L43-L60
train
phpList/core
src/Composer/ModuleFinder.php
ModuleFinder.validateBundlesSectionInExtra
private function validateBundlesSectionInExtra(array $extra) { if (!isset($extra['phplist/core'])) { return; } $this->validatePhpListSectionInExtra($extra); if (!isset($extra['phplist/core']['bundles'])) { return; } if (!is_array($extra['phplist/core']['bundles'])) { throw new \InvalidArgumentException( 'The extras.phplist/core.bundles section in the composer.json must be an array.', 1505411665 ); } /** @var array $bundleExtras */ $bundleExtras = $extra['phplist/core']['bundles']; foreach ($bundleExtras as $key => $bundleName) { if (!is_string($bundleName)) { throw new \InvalidArgumentException( 'The extras.phplist/core.bundles. ' . $key . '" section in the composer.json must be a string.', 1505412184 ); } } }
php
private function validateBundlesSectionInExtra(array $extra) { if (!isset($extra['phplist/core'])) { return; } $this->validatePhpListSectionInExtra($extra); if (!isset($extra['phplist/core']['bundles'])) { return; } if (!is_array($extra['phplist/core']['bundles'])) { throw new \InvalidArgumentException( 'The extras.phplist/core.bundles section in the composer.json must be an array.', 1505411665 ); } /** @var array $bundleExtras */ $bundleExtras = $extra['phplist/core']['bundles']; foreach ($bundleExtras as $key => $bundleName) { if (!is_string($bundleName)) { throw new \InvalidArgumentException( 'The extras.phplist/core.bundles. ' . $key . '" section in the composer.json must be a string.', 1505412184 ); } } }
[ "private", "function", "validateBundlesSectionInExtra", "(", "array", "$", "extra", ")", "{", "if", "(", "!", "isset", "(", "$", "extra", "[", "'phplist/core'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "validatePhpListSectionInExtra", "(", ...
Validates the bundles section in the "extra" section of the composer.json of a module. @param array $extra @return void @throws \InvalidArgumentException if $extra has an invalid bundles configuration
[ "Validates", "the", "bundles", "section", "in", "the", "extra", "section", "of", "the", "composer", ".", "json", "of", "a", "module", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ModuleFinder.php#L71-L98
train
phpList/core
src/Composer/ModuleFinder.php
ModuleFinder.findRoutes
public function findRoutes(): array { /** @var array[] $routes */ $routes = []; $modules = $this->packageRepository->findModules(); foreach ($modules as $module) { $extra = $module->getExtra(); $this->validateRoutesSectionInExtra($extra); if (empty($extra['phplist/core']['routes'])) { continue; } /** @var array $moduleRoutes */ $moduleRoutes = $extra['phplist/core']['routes']; foreach ($moduleRoutes as $name => $route) { $prefixedRouteName = $module->getName() . '.' . $name; $routes[$prefixedRouteName] = $route; } } return $routes; }
php
public function findRoutes(): array { /** @var array[] $routes */ $routes = []; $modules = $this->packageRepository->findModules(); foreach ($modules as $module) { $extra = $module->getExtra(); $this->validateRoutesSectionInExtra($extra); if (empty($extra['phplist/core']['routes'])) { continue; } /** @var array $moduleRoutes */ $moduleRoutes = $extra['phplist/core']['routes']; foreach ($moduleRoutes as $name => $route) { $prefixedRouteName = $module->getName() . '.' . $name; $routes[$prefixedRouteName] = $route; } } return $routes; }
[ "public", "function", "findRoutes", "(", ")", ":", "array", "{", "/** @var array[] $routes */", "$", "routes", "=", "[", "]", ";", "$", "modules", "=", "$", "this", "->", "packageRepository", "->", "findModules", "(", ")", ";", "foreach", "(", "$", "module...
Finds the routes in all installed modules. @return array[] class names of the routes of all installed phpList modules: ['route name' => [route configuration] @throws \InvalidArgumentException
[ "Finds", "the", "routes", "in", "all", "installed", "modules", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ModuleFinder.php#L139-L161
train
phpList/core
src/Composer/ModuleFinder.php
ModuleFinder.validateRoutesSectionInExtra
private function validateRoutesSectionInExtra(array $extra) { if (!isset($extra['phplist/core'])) { return; } $this->validatePhpListSectionInExtra($extra); if (!isset($extra['phplist/core']['routes'])) { return; } if (!is_array($extra['phplist/core']['routes'])) { throw new \InvalidArgumentException( 'The extras.phplist/core.routes section in the composer.json must be an array.', 1506429004 ); } /** @var array $bundleExtras */ $bundleExtras = $extra['phplist/core']['routes']; foreach ($bundleExtras as $routeName => $routeConfiguration) { if (!is_array($routeConfiguration)) { throw new \InvalidArgumentException( 'The extras.phplist/core.routes. ' . $routeName . '" section in the composer.json must be an array.', 1506429860 ); } } }
php
private function validateRoutesSectionInExtra(array $extra) { if (!isset($extra['phplist/core'])) { return; } $this->validatePhpListSectionInExtra($extra); if (!isset($extra['phplist/core']['routes'])) { return; } if (!is_array($extra['phplist/core']['routes'])) { throw new \InvalidArgumentException( 'The extras.phplist/core.routes section in the composer.json must be an array.', 1506429004 ); } /** @var array $bundleExtras */ $bundleExtras = $extra['phplist/core']['routes']; foreach ($bundleExtras as $routeName => $routeConfiguration) { if (!is_array($routeConfiguration)) { throw new \InvalidArgumentException( 'The extras.phplist/core.routes. ' . $routeName . '" section in the composer.json must be an array.', 1506429860 ); } } }
[ "private", "function", "validateRoutesSectionInExtra", "(", "array", "$", "extra", ")", "{", "if", "(", "!", "isset", "(", "$", "extra", "[", "'phplist/core'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "validatePhpListSectionInExtra", "(", ...
Validates the routes section in the "extra" section of the composer.json of a module. @param array $extra @return void @throws \InvalidArgumentException if $extra has an invalid routes configuration
[ "Validates", "the", "routes", "section", "in", "the", "extra", "section", "of", "the", "composer", ".", "json", "of", "a", "module", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ModuleFinder.php#L172-L200
train
phpList/core
src/Composer/ModuleFinder.php
ModuleFinder.findGeneralConfiguration
public function findGeneralConfiguration(): array { /** @var array[] $configurationSets */ $configurationSets = [[]]; $modules = $this->packageRepository->findModules(); foreach ($modules as $module) { $extra = $module->getExtra(); $this->validateGeneralConfigurationSectionInExtra($extra); if (!isset($extra['phplist/core']['configuration'])) { continue; } $configurationSets[] = $extra['phplist/core']['configuration']; } return /** @scrutinizer ignore-call */ array_replace_recursive(...$configurationSets); }
php
public function findGeneralConfiguration(): array { /** @var array[] $configurationSets */ $configurationSets = [[]]; $modules = $this->packageRepository->findModules(); foreach ($modules as $module) { $extra = $module->getExtra(); $this->validateGeneralConfigurationSectionInExtra($extra); if (!isset($extra['phplist/core']['configuration'])) { continue; } $configurationSets[] = $extra['phplist/core']['configuration']; } return /** @scrutinizer ignore-call */ array_replace_recursive(...$configurationSets); }
[ "public", "function", "findGeneralConfiguration", "(", ")", ":", "array", "{", "/** @var array[] $configurationSets */", "$", "configurationSets", "=", "[", "[", "]", "]", ";", "$", "modules", "=", "$", "this", "->", "packageRepository", "->", "findModules", "(", ...
Finds and merges the configuration in all installed modules. @return array configuration which can be dumped in a config_modules.yml file @throws \InvalidArgumentException
[ "Finds", "and", "merges", "the", "configuration", "in", "all", "installed", "modules", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ModuleFinder.php#L221-L238
train
phpList/core
src/Composer/ModuleFinder.php
ModuleFinder.validateGeneralConfigurationSectionInExtra
private function validateGeneralConfigurationSectionInExtra(array $extra) { if (!isset($extra['phplist/core'])) { return; } $this->validatePhpListSectionInExtra($extra); if (!isset($extra['phplist/core']['configuration'])) { return; } if (!is_array($extra['phplist/core']['configuration'])) { throw new \InvalidArgumentException( 'The extras.phplist/core.configuration section in the composer.json must be an array.', 1508165934 ); } }
php
private function validateGeneralConfigurationSectionInExtra(array $extra) { if (!isset($extra['phplist/core'])) { return; } $this->validatePhpListSectionInExtra($extra); if (!isset($extra['phplist/core']['configuration'])) { return; } if (!is_array($extra['phplist/core']['configuration'])) { throw new \InvalidArgumentException( 'The extras.phplist/core.configuration section in the composer.json must be an array.', 1508165934 ); } }
[ "private", "function", "validateGeneralConfigurationSectionInExtra", "(", "array", "$", "extra", ")", "{", "if", "(", "!", "isset", "(", "$", "extra", "[", "'phplist/core'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "validatePhpListSectionInEx...
Validates the configuration in the "extra" section of the composer.json of a module. @param array $extra @return void @throws \InvalidArgumentException if $extra has an invalid routes configuration
[ "Validates", "the", "configuration", "in", "the", "extra", "section", "of", "the", "composer", ".", "json", "of", "a", "module", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ModuleFinder.php#L249-L265
train
phpList/core
src/Domain/Repository/Identity/AdministratorTokenRepository.php
AdministratorTokenRepository.findOneUnexpiredByKey
public function findOneUnexpiredByKey(string $key) { $criteria = new Criteria(); $criteria->where(Criteria::expr()->eq('key', $key)) ->andWhere(Criteria::expr()->gt('expiry', new \DateTime())); $firstMatch = $this->matching($criteria)->first(); // $firstMatch will be false if there is no match, not null. return $firstMatch ?: null; }
php
public function findOneUnexpiredByKey(string $key) { $criteria = new Criteria(); $criteria->where(Criteria::expr()->eq('key', $key)) ->andWhere(Criteria::expr()->gt('expiry', new \DateTime())); $firstMatch = $this->matching($criteria)->first(); // $firstMatch will be false if there is no match, not null. return $firstMatch ?: null; }
[ "public", "function", "findOneUnexpiredByKey", "(", "string", "$", "key", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", ")", ";", "$", "criteria", "->", "where", "(", "Criteria", "::", "expr", "(", ")", "->", "eq", "(", "'key'", ",", "$", "...
Finds one unexpired token by the given key. Returns null if there is no match. This method is intended to check for the validity of a session token. @param string $key @return AdministratorToken|null
[ "Finds", "one", "unexpired", "token", "by", "the", "given", "key", ".", "Returns", "null", "if", "there", "is", "no", "match", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Domain/Repository/Identity/AdministratorTokenRepository.php#L26-L36
train
phpList/core
src/Domain/Repository/Identity/AdministratorTokenRepository.php
AdministratorTokenRepository.removeExpired
public function removeExpired(): int { $queryBuilder = $this->getEntityManager()->createQueryBuilder(); $queryBuilder->delete(AdministratorToken::class, 'token')->where('token.expiry <= CURRENT_TIMESTAMP()'); return (int)$queryBuilder->getQuery()->execute(); }
php
public function removeExpired(): int { $queryBuilder = $this->getEntityManager()->createQueryBuilder(); $queryBuilder->delete(AdministratorToken::class, 'token')->where('token.expiry <= CURRENT_TIMESTAMP()'); return (int)$queryBuilder->getQuery()->execute(); }
[ "public", "function", "removeExpired", "(", ")", ":", "int", "{", "$", "queryBuilder", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "delete", "(", "AdministratorToken", "::", "cla...
Removes all expired tokens. This method should be called regularly to clean up the tokens. @return int the number of removed tokens
[ "Removes", "all", "expired", "tokens", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Domain/Repository/Identity/AdministratorTokenRepository.php#L45-L51
train
phpList/core
src/Core/ApplicationKernel.php
ApplicationKernel.bundlesFromConfiguration
private function bundlesFromConfiguration(): array { $bundles = []; /** @var string[] $packageBundles */ foreach ($this->readBundleConfiguration() as $packageBundles) { foreach ($packageBundles as $bundleClassName) { if (class_exists($bundleClassName)) { $bundles[] = new $bundleClassName(); } } } return $bundles; }
php
private function bundlesFromConfiguration(): array { $bundles = []; /** @var string[] $packageBundles */ foreach ($this->readBundleConfiguration() as $packageBundles) { foreach ($packageBundles as $bundleClassName) { if (class_exists($bundleClassName)) { $bundles[] = new $bundleClassName(); } } } return $bundles; }
[ "private", "function", "bundlesFromConfiguration", "(", ")", ":", "array", "{", "$", "bundles", "=", "[", "]", ";", "/** @var string[] $packageBundles */", "foreach", "(", "$", "this", "->", "readBundleConfiguration", "(", ")", "as", "$", "packageBundles", ")", ...
Reads the bundles from the bundle configuration file and instantiates them. @return Bundle[]
[ "Reads", "the", "bundles", "from", "the", "bundle", "configuration", "file", "and", "instantiates", "them", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Core/ApplicationKernel.php#L142-L156
train
phpList/core
src/Domain/Repository/Identity/AdministratorRepository.php
AdministratorRepository.findOneByLoginCredentials
public function findOneByLoginCredentials(string $loginName, string $plainTextPassword) { $passwordHash = $this->hashGenerator->createPasswordHash($plainTextPassword); return $this->findOneBy( [ 'loginName' => $loginName, 'passwordHash' => $passwordHash, 'superUser' => true, ] ); }
php
public function findOneByLoginCredentials(string $loginName, string $plainTextPassword) { $passwordHash = $this->hashGenerator->createPasswordHash($plainTextPassword); return $this->findOneBy( [ 'loginName' => $loginName, 'passwordHash' => $passwordHash, 'superUser' => true, ] ); }
[ "public", "function", "findOneByLoginCredentials", "(", "string", "$", "loginName", ",", "string", "$", "plainTextPassword", ")", "{", "$", "passwordHash", "=", "$", "this", "->", "hashGenerator", "->", "createPasswordHash", "(", "$", "plainTextPassword", ")", ";"...
Finds the Administrator with the given login credentials. Returns null if there is no match, i.e., if the login credentials are incorrect. This also checks that the administrator is a super user. @param string $loginName @param string $plainTextPassword @return Administrator|null
[ "Finds", "the", "Administrator", "with", "the", "given", "login", "credentials", ".", "Returns", "null", "if", "there", "is", "no", "match", "i", ".", "e", ".", "if", "the", "login", "credentials", "are", "incorrect", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Domain/Repository/Identity/AdministratorRepository.php#L44-L55
train
phpList/core
src/Core/ApplicationStructure.php
ApplicationStructure.getApplicationRoot
public function getApplicationRoot(): string { $corePackagePath = $this->getCorePackageRoot(); $corePackageIsRootPackage = interface_exists('PhpList\\Core\\Tests\\Support\\Interfaces\\TestMarker'); if ($corePackageIsRootPackage) { $applicationRoot = $corePackagePath; } else { // remove 3 more path segments, i.e., "vendor/phplist/core/" $corePackagePath = dirname($corePackagePath, 3); $applicationRoot = $corePackagePath; } if (!file_exists($applicationRoot . '/composer.json')) { throw new \RuntimeException( 'There is no composer.json in the supposed application root "' . $applicationRoot . '".', 1501169001 ); } return $applicationRoot; }
php
public function getApplicationRoot(): string { $corePackagePath = $this->getCorePackageRoot(); $corePackageIsRootPackage = interface_exists('PhpList\\Core\\Tests\\Support\\Interfaces\\TestMarker'); if ($corePackageIsRootPackage) { $applicationRoot = $corePackagePath; } else { // remove 3 more path segments, i.e., "vendor/phplist/core/" $corePackagePath = dirname($corePackagePath, 3); $applicationRoot = $corePackagePath; } if (!file_exists($applicationRoot . '/composer.json')) { throw new \RuntimeException( 'There is no composer.json in the supposed application root "' . $applicationRoot . '".', 1501169001 ); } return $applicationRoot; }
[ "public", "function", "getApplicationRoot", "(", ")", ":", "string", "{", "$", "corePackagePath", "=", "$", "this", "->", "getCorePackageRoot", "(", ")", ";", "$", "corePackageIsRootPackage", "=", "interface_exists", "(", "'PhpList\\\\Core\\\\Tests\\\\Support\\\\Interfa...
Returns the absolute path to the application root. When core is installed as a dependency (library) of an application, this method will return the application's package path. When phpList4-core is installed stand-alone (i.e., as an application - usually only for testing), this method will be the phpList4-core package path. @return string the absolute path without the trailing slash @throws \RuntimeException if there is no composer.json in the application root
[ "Returns", "the", "absolute", "path", "to", "the", "application", "root", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Core/ApplicationStructure.php#L38-L58
train
phpList/core
src/Composer/ScriptHandler.php
ScriptHandler.mirrorDirectoryFromCore
private static function mirrorDirectoryFromCore(string $directoryWithoutSlashes) { $directoryWithSlashes = '/' . $directoryWithoutSlashes . '/'; $fileSystem = new Filesystem(); $fileSystem->mirror( static::getCoreDirectory() . $directoryWithSlashes, static::getApplicationRoot() . $directoryWithSlashes, null, ['override' => true, 'delete' => false] ); }
php
private static function mirrorDirectoryFromCore(string $directoryWithoutSlashes) { $directoryWithSlashes = '/' . $directoryWithoutSlashes . '/'; $fileSystem = new Filesystem(); $fileSystem->mirror( static::getCoreDirectory() . $directoryWithSlashes, static::getApplicationRoot() . $directoryWithSlashes, null, ['override' => true, 'delete' => false] ); }
[ "private", "static", "function", "mirrorDirectoryFromCore", "(", "string", "$", "directoryWithoutSlashes", ")", "{", "$", "directoryWithSlashes", "=", "'/'", ".", "$", "directoryWithoutSlashes", ".", "'/'", ";", "$", "fileSystem", "=", "new", "Filesystem", "(", ")...
Copies a directory from the core package. This method overwrites existing files, but will not delete any files. This method must not be called for the core package itself. @param string $directoryWithoutSlashes directory name (without any slashes) relative to the core package @return void
[ "Copies", "a", "directory", "from", "the", "core", "package", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ScriptHandler.php#L132-L143
train
phpList/core
src/Composer/ScriptHandler.php
ScriptHandler.listModules
public static function listModules(Event $event) { $packageRepository = new PackageRepository(); $packageRepository->injectComposer($event->getComposer()); $modules = $packageRepository->findModules(); $maximumPackageNameLength = static::calculateMaximumPackageNameLength($modules); foreach ($modules as $module) { $paddedName = str_pad($module->getName(), $maximumPackageNameLength + 1); echo $paddedName . ' ' . $module->getPrettyVersion() . PHP_EOL; } }
php
public static function listModules(Event $event) { $packageRepository = new PackageRepository(); $packageRepository->injectComposer($event->getComposer()); $modules = $packageRepository->findModules(); $maximumPackageNameLength = static::calculateMaximumPackageNameLength($modules); foreach ($modules as $module) { $paddedName = str_pad($module->getName(), $maximumPackageNameLength + 1); echo $paddedName . ' ' . $module->getPrettyVersion() . PHP_EOL; } }
[ "public", "static", "function", "listModules", "(", "Event", "$", "event", ")", "{", "$", "packageRepository", "=", "new", "PackageRepository", "(", ")", ";", "$", "packageRepository", "->", "injectComposer", "(", "$", "event", "->", "getComposer", "(", ")", ...
Echos the names and version numbers of all installed phpList modules. @param Event $event @return void
[ "Echos", "the", "names", "and", "version", "numbers", "of", "all", "installed", "phpList", "modules", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ScriptHandler.php#L152-L164
train
phpList/core
src/Composer/ScriptHandler.php
ScriptHandler.warmProductionCache
public static function warmProductionCache(Event $event) { $consoleDir = static::getConsoleDir($event, 'warm the cache'); if ($consoleDir === null) { return; } static::executeCommand($event, $consoleDir, 'cache:warm -e prod'); }
php
public static function warmProductionCache(Event $event) { $consoleDir = static::getConsoleDir($event, 'warm the cache'); if ($consoleDir === null) { return; } static::executeCommand($event, $consoleDir, 'cache:warm -e prod'); }
[ "public", "static", "function", "warmProductionCache", "(", "Event", "$", "event", ")", "{", "$", "consoleDir", "=", "static", "::", "getConsoleDir", "(", "$", "event", ",", "'warm the cache'", ")", ";", "if", "(", "$", "consoleDir", "===", "null", ")", "{...
Warms the production cache. @param Event $event @return void
[ "Warms", "the", "production", "cache", "." ]
c07f6825d49460314f034b498cf1e341b9ebf7fe
https://github.com/phpList/core/blob/c07f6825d49460314f034b498cf1e341b9ebf7fe/src/Composer/ScriptHandler.php#L272-L280
train
arrilot/bitrix-migrations
src/Autocreate/Handlers/OnBeforeUserTypeDelete.php
OnBeforeUserTypeDelete.getReplace
public function getReplace() { return [ 'iblockId' => $this->fields['IBLOCK_ID'], 'code' => "'".$this->fields['FIELD_NAME']."'", 'entity' => "'".$this->fields['ENTITY_ID']."'", 'fields' => var_export($this->fields, true), ]; }
php
public function getReplace() { return [ 'iblockId' => $this->fields['IBLOCK_ID'], 'code' => "'".$this->fields['FIELD_NAME']."'", 'entity' => "'".$this->fields['ENTITY_ID']."'", 'fields' => var_export($this->fields, true), ]; }
[ "public", "function", "getReplace", "(", ")", "{", "return", "[", "'iblockId'", "=>", "$", "this", "->", "fields", "[", "'IBLOCK_ID'", "]", ",", "'code'", "=>", "\"'\"", ".", "$", "this", "->", "fields", "[", "'FIELD_NAME'", "]", ".", "\"'\"", ",", "'e...
Get array of placeholders to replace. @return array
[ "Get", "array", "of", "placeholders", "to", "replace", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Handlers/OnBeforeUserTypeDelete.php#L44-L52
train
arrilot/bitrix-migrations
src/Commands/TemplatesCommand.php
TemplatesCommand.collectRows
protected function collectRows() { $rows = collect($this->collection->all()) ->filter(function ($template) { return $template['is_alias'] == false; }) ->sortBy('name') ->map(function ($template) { $row = []; $names = array_merge([$template['name']], $template['aliases']); $row[] = implode("\n/ ", $names); $row[] = wordwrap($template['path'], 65, "\n", true); $row[] = wordwrap($template['description'], 25, "\n", true); return $row; }); return $this->separateRows($rows); }
php
protected function collectRows() { $rows = collect($this->collection->all()) ->filter(function ($template) { return $template['is_alias'] == false; }) ->sortBy('name') ->map(function ($template) { $row = []; $names = array_merge([$template['name']], $template['aliases']); $row[] = implode("\n/ ", $names); $row[] = wordwrap($template['path'], 65, "\n", true); $row[] = wordwrap($template['description'], 25, "\n", true); return $row; }); return $this->separateRows($rows); }
[ "protected", "function", "collectRows", "(", ")", "{", "$", "rows", "=", "collect", "(", "$", "this", "->", "collection", "->", "all", "(", ")", ")", "->", "filter", "(", "function", "(", "$", "template", ")", "{", "return", "$", "template", "[", "'i...
Collect and return templates from a Migrator. @return array
[ "Collect", "and", "return", "templates", "from", "a", "Migrator", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/TemplatesCommand.php#L56-L75
train
arrilot/bitrix-migrations
src/Commands/TemplatesCommand.php
TemplatesCommand.separateRows
protected function separateRows($templates) { $rows = []; foreach ($templates as $template) { $rows[] = $template; $rows[] = new TableSeparator(); } unset($rows[count($rows) - 1]); return $rows; }
php
protected function separateRows($templates) { $rows = []; foreach ($templates as $template) { $rows[] = $template; $rows[] = new TableSeparator(); } unset($rows[count($rows) - 1]); return $rows; }
[ "protected", "function", "separateRows", "(", "$", "templates", ")", "{", "$", "rows", "=", "[", "]", ";", "foreach", "(", "$", "templates", "as", "$", "template", ")", "{", "$", "rows", "[", "]", "=", "$", "template", ";", "$", "rows", "[", "]", ...
Separate rows with a separator. @param $templates @return array
[ "Separate", "rows", "with", "a", "separator", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/TemplatesCommand.php#L84-L94
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.createMigration
public function createMigration($name, $templateName, array $replace = [], $subDir = '') { $targetDir = $this->dir; $subDir = trim(str_replace('\\', '/', $subDir), '/'); if ($subDir) { $targetDir .= '/' . $subDir; } $this->files->createDirIfItDoesNotExist($targetDir); $fileName = $this->constructFileName($name); $className = $this->getMigrationClassNameByFileName($fileName); $templateName = $this->templates->selectTemplate($templateName); $template = $this->files->getContent($this->templates->getTemplatePath($templateName)); $template = $this->replacePlaceholdersInTemplate($template, array_merge($replace, ['className' => $className])); $this->files->putContent($targetDir.'/'.$fileName.'.php', $template); return $fileName; }
php
public function createMigration($name, $templateName, array $replace = [], $subDir = '') { $targetDir = $this->dir; $subDir = trim(str_replace('\\', '/', $subDir), '/'); if ($subDir) { $targetDir .= '/' . $subDir; } $this->files->createDirIfItDoesNotExist($targetDir); $fileName = $this->constructFileName($name); $className = $this->getMigrationClassNameByFileName($fileName); $templateName = $this->templates->selectTemplate($templateName); $template = $this->files->getContent($this->templates->getTemplatePath($templateName)); $template = $this->replacePlaceholdersInTemplate($template, array_merge($replace, ['className' => $className])); $this->files->putContent($targetDir.'/'.$fileName.'.php', $template); return $fileName; }
[ "public", "function", "createMigration", "(", "$", "name", ",", "$", "templateName", ",", "array", "$", "replace", "=", "[", "]", ",", "$", "subDir", "=", "''", ")", "{", "$", "targetDir", "=", "$", "this", "->", "dir", ";", "$", "subDir", "=", "tr...
Create migration file. @param string $name - migration name @param string $templateName @param array $replace - array of placeholders that should be replaced with a given values. @param string $subDir @return string
[ "Create", "migration", "file", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L103-L123
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.runMigrations
public function runMigrations() { $migrations = $this->getMigrationsToRun(); $ran = []; if (empty($migrations)) { return $ran; } foreach ($migrations as $migration) { $this->runMigration($migration); $ran[] = $migration; } return $ran; }
php
public function runMigrations() { $migrations = $this->getMigrationsToRun(); $ran = []; if (empty($migrations)) { return $ran; } foreach ($migrations as $migration) { $this->runMigration($migration); $ran[] = $migration; } return $ran; }
[ "public", "function", "runMigrations", "(", ")", "{", "$", "migrations", "=", "$", "this", "->", "getMigrationsToRun", "(", ")", ";", "$", "ran", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "migrations", ")", ")", "{", "return", "$", "ran", "...
Run all migrations that were not run before.
[ "Run", "all", "migrations", "that", "were", "not", "run", "before", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L128-L143
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.runMigration
public function runMigration($file) { $migration = $this->getMigrationObjectByFileName($file); $this->disableBitrixIblockHelperCache(); $this->checkTransactionAndRun($migration, function () use ($migration, $file) { if ($migration->up() === false) { throw new Exception("Migration up from {$file}.php returned false"); } }); $this->logSuccessfulMigration($file); }
php
public function runMigration($file) { $migration = $this->getMigrationObjectByFileName($file); $this->disableBitrixIblockHelperCache(); $this->checkTransactionAndRun($migration, function () use ($migration, $file) { if ($migration->up() === false) { throw new Exception("Migration up from {$file}.php returned false"); } }); $this->logSuccessfulMigration($file); }
[ "public", "function", "runMigration", "(", "$", "file", ")", "{", "$", "migration", "=", "$", "this", "->", "getMigrationObjectByFileName", "(", "$", "file", ")", ";", "$", "this", "->", "disableBitrixIblockHelperCache", "(", ")", ";", "$", "this", "->", "...
Run a given migration. @param string $file @throws Exception @return string
[ "Run", "a", "given", "migration", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L154-L167
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.rollbackMigration
public function rollbackMigration($file) { $migration = $this->getMigrationObjectByFileName($file); $this->checkTransactionAndRun($migration, function () use ($migration, $file) { if ($migration->down() === false) { throw new Exception("<error>Can't rollback migration:</error> {$file}.php"); } }); $this->removeSuccessfulMigrationFromLog($file); }
php
public function rollbackMigration($file) { $migration = $this->getMigrationObjectByFileName($file); $this->checkTransactionAndRun($migration, function () use ($migration, $file) { if ($migration->down() === false) { throw new Exception("<error>Can't rollback migration:</error> {$file}.php"); } }); $this->removeSuccessfulMigrationFromLog($file); }
[ "public", "function", "rollbackMigration", "(", "$", "file", ")", "{", "$", "migration", "=", "$", "this", "->", "getMigrationObjectByFileName", "(", "$", "file", ")", ";", "$", "this", "->", "checkTransactionAndRun", "(", "$", "migration", ",", "function", ...
Rollback a given migration. @param string $file @throws Exception @return mixed
[ "Rollback", "a", "given", "migration", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L222-L233
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.getMigrationsToRun
public function getMigrationsToRun() { $allMigrations = $this->getAllMigrations(); $ranMigrations = $this->getRanMigrations(); return array_diff($allMigrations, $ranMigrations); }
php
public function getMigrationsToRun() { $allMigrations = $this->getAllMigrations(); $ranMigrations = $this->getRanMigrations(); return array_diff($allMigrations, $ranMigrations); }
[ "public", "function", "getMigrationsToRun", "(", ")", "{", "$", "allMigrations", "=", "$", "this", "->", "getAllMigrations", "(", ")", ";", "$", "ranMigrations", "=", "$", "this", "->", "getRanMigrations", "(", ")", ";", "return", "array_diff", "(", "$", "...
Get array of migrations that should be ran. @return array
[ "Get", "array", "of", "migrations", "that", "should", "be", "ran", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L264-L271
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.constructFileName
protected function constructFileName($name) { list($usec, $sec) = explode(' ', microtime()); $usec = substr($usec, 2, 6); return date('Y_m_d_His', $sec).'_'.$usec.'_'.$name; }
php
protected function constructFileName($name) { list($usec, $sec) = explode(' ', microtime()); $usec = substr($usec, 2, 6); return date('Y_m_d_His', $sec).'_'.$usec.'_'.$name; }
[ "protected", "function", "constructFileName", "(", "$", "name", ")", "{", "list", "(", "$", "usec", ",", "$", "sec", ")", "=", "explode", "(", "' '", ",", "microtime", "(", ")", ")", ";", "$", "usec", "=", "substr", "(", "$", "usec", ",", "2", ",...
Construct migration file name from migration name and current time. @param string $name @return string
[ "Construct", "migration", "file", "name", "from", "migration", "name", "and", "current", "time", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L313-L320
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.getMigrationClassNameByFileName
protected function getMigrationClassNameByFileName($file) { $fileExploded = explode('_', $file); $datePart = implode('_', array_slice($fileExploded, 0, 5)); $namePart = implode('_', array_slice($fileExploded, 5)); return Helpers::studly($namePart.'_'.$datePart); }
php
protected function getMigrationClassNameByFileName($file) { $fileExploded = explode('_', $file); $datePart = implode('_', array_slice($fileExploded, 0, 5)); $namePart = implode('_', array_slice($fileExploded, 5)); return Helpers::studly($namePart.'_'.$datePart); }
[ "protected", "function", "getMigrationClassNameByFileName", "(", "$", "file", ")", "{", "$", "fileExploded", "=", "explode", "(", "'_'", ",", "$", "file", ")", ";", "$", "datePart", "=", "implode", "(", "'_'", ",", "array_slice", "(", "$", "fileExploded", ...
Get a migration class name by a migration file name. @param string $file @return string
[ "Get", "a", "migration", "class", "name", "by", "a", "migration", "file", "name", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L329-L337
train
arrilot/bitrix-migrations
src/Migrator.php
Migrator.replacePlaceholdersInTemplate
protected function replacePlaceholdersInTemplate($template, array $replace) { foreach ($replace as $placeholder => $value) { $template = str_replace("__{$placeholder}__", $value, $template); } return $template; }
php
protected function replacePlaceholdersInTemplate($template, array $replace) { foreach ($replace as $placeholder => $value) { $template = str_replace("__{$placeholder}__", $value, $template); } return $template; }
[ "protected", "function", "replacePlaceholdersInTemplate", "(", "$", "template", ",", "array", "$", "replace", ")", "{", "foreach", "(", "$", "replace", "as", "$", "placeholder", "=>", "$", "value", ")", "{", "$", "template", "=", "str_replace", "(", "\"__{$p...
Replace all placeholders in the stub. @param string $template @param array $replace @return string
[ "Replace", "all", "placeholders", "in", "the", "stub", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Migrator.php#L347-L354
train
arrilot/bitrix-migrations
src/Autocreate/Manager.php
Manager.init
public static function init($dir, $table = null) { $templates = new TemplatesCollection(); $templates->registerAutoTemplates(); $config = [ 'dir' => $dir, 'table' => is_null($table) ? 'migrations' : $table, ]; static::$migrator = new Migrator($config, $templates); static::addEventHandlers(); static::turnOn(); }
php
public static function init($dir, $table = null) { $templates = new TemplatesCollection(); $templates->registerAutoTemplates(); $config = [ 'dir' => $dir, 'table' => is_null($table) ? 'migrations' : $table, ]; static::$migrator = new Migrator($config, $templates); static::addEventHandlers(); static::turnOn(); }
[ "public", "static", "function", "init", "(", "$", "dir", ",", "$", "table", "=", "null", ")", "{", "$", "templates", "=", "new", "TemplatesCollection", "(", ")", ";", "$", "templates", "->", "registerAutoTemplates", "(", ")", ";", "$", "config", "=", "...
Initialize autocreation. @param string $dir @param string|null $table
[ "Initialize", "autocreation", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Manager.php#L61-L76
train
arrilot/bitrix-migrations
src/Autocreate/Manager.php
Manager.createMigration
protected static function createMigration(HandlerInterface $handler) { $migrator = static::$migrator; $notifier = new Notifier(); $migration = $migrator->createMigration( strtolower($handler->getName()), $handler->getTemplate(), $handler->getReplace() ); $migrator->logSuccessfulMigration($migration); $notifier->newMigration($migration); }
php
protected static function createMigration(HandlerInterface $handler) { $migrator = static::$migrator; $notifier = new Notifier(); $migration = $migrator->createMigration( strtolower($handler->getName()), $handler->getTemplate(), $handler->getReplace() ); $migrator->logSuccessfulMigration($migration); $notifier->newMigration($migration); }
[ "protected", "static", "function", "createMigration", "(", "HandlerInterface", "$", "handler", ")", "{", "$", "migrator", "=", "static", "::", "$", "migrator", ";", "$", "notifier", "=", "new", "Notifier", "(", ")", ";", "$", "migration", "=", "$", "migrat...
Create migration and apply it. @param HandlerInterface $handler
[ "Create", "migration", "and", "apply", "it", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Manager.php#L128-L141
train
arrilot/bitrix-migrations
src/Autocreate/Manager.php
Manager.addEventHandlers
protected static function addEventHandlers() { $eventManager = EventManager::getInstance(); foreach (static::$handlers as $module => $handlers) { foreach ($handlers as $event => $handler) { $eventManager->addEventHandler($module, $event, [__CLASS__, $handler], false, 5000); } } $eventManager->addEventHandler('main', 'OnAfterEpilog', function () { $notifier = new Notifier(); $notifier->deleteNotificationFromPreviousMigration(); return new EventResult(); }); }
php
protected static function addEventHandlers() { $eventManager = EventManager::getInstance(); foreach (static::$handlers as $module => $handlers) { foreach ($handlers as $event => $handler) { $eventManager->addEventHandler($module, $event, [__CLASS__, $handler], false, 5000); } } $eventManager->addEventHandler('main', 'OnAfterEpilog', function () { $notifier = new Notifier(); $notifier->deleteNotificationFromPreviousMigration(); return new EventResult(); }); }
[ "protected", "static", "function", "addEventHandlers", "(", ")", "{", "$", "eventManager", "=", "EventManager", "::", "getInstance", "(", ")", ";", "foreach", "(", "static", "::", "$", "handlers", "as", "$", "module", "=>", "$", "handlers", ")", "{", "fore...
Add event handlers.
[ "Add", "event", "handlers", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Manager.php#L146-L162
train
arrilot/bitrix-migrations
src/Commands/StatusCommand.php
StatusCommand.showOldMigrations
protected function showOldMigrations() { $old = collect($this->migrator->getRanMigrations()); $this->output->writeln("<fg=yellow>Old migrations:\r\n</>"); $max = 5; if ($old->count() > $max) { $this->output->writeln('<fg=yellow>...</>'); $old = $old->take(-$max); } foreach ($old as $migration) { $this->output->writeln("<fg=yellow>{$migration}.php</>"); } }
php
protected function showOldMigrations() { $old = collect($this->migrator->getRanMigrations()); $this->output->writeln("<fg=yellow>Old migrations:\r\n</>"); $max = 5; if ($old->count() > $max) { $this->output->writeln('<fg=yellow>...</>'); $old = $old->take(-$max); } foreach ($old as $migration) { $this->output->writeln("<fg=yellow>{$migration}.php</>"); } }
[ "protected", "function", "showOldMigrations", "(", ")", "{", "$", "old", "=", "collect", "(", "$", "this", "->", "migrator", "->", "getRanMigrations", "(", ")", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"<fg=yellow>Old migrations:\\r\\n</>...
Show old migrations. @return void
[ "Show", "old", "migrations", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/StatusCommand.php#L55-L71
train
arrilot/bitrix-migrations
src/Commands/StatusCommand.php
StatusCommand.showNewMigrations
protected function showNewMigrations() { $new = collect($this->migrator->getMigrationsToRun()); $this->output->writeln("<fg=green>New migrations:\r\n</>"); foreach ($new as $migration) { $this->output->writeln("<fg=green>{$migration}.php</>"); } }
php
protected function showNewMigrations() { $new = collect($this->migrator->getMigrationsToRun()); $this->output->writeln("<fg=green>New migrations:\r\n</>"); foreach ($new as $migration) { $this->output->writeln("<fg=green>{$migration}.php</>"); } }
[ "protected", "function", "showNewMigrations", "(", ")", "{", "$", "new", "=", "collect", "(", "$", "this", "->", "migrator", "->", "getMigrationsToRun", "(", ")", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"<fg=green>New migrations:\\r\\n</...
Show new migrations. @return void
[ "Show", "new", "migrations", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/StatusCommand.php#L78-L87
train
arrilot/bitrix-migrations
src/Autocreate/Handlers/OnBeforeIBlockPropertyUpdate.php
OnBeforeIBlockPropertyUpdate.collectPropertyFieldsFromDB
protected function collectPropertyFieldsFromDB() { $fields = CIBlockProperty::getByID($this->fields['ID'])->fetch(); $fields['VALUES'] = []; $filter = [ 'IBLOCK_ID' => $this->fields['IBLOCK_ID'], 'PROPERTY_ID' => $this->fields['ID'], ]; $sort = [ 'SORT' => 'ASC', 'VALUE' => 'ASC', ]; $propertyEnums = CIBlockPropertyEnum::GetList($sort, $filter); while ($v = $propertyEnums->GetNext()) { $fields['VALUES'][$v['ID']] = [ 'ID' => $v['ID'], 'VALUE' => $v['VALUE'], 'SORT' => $v['SORT'], 'XML_ID' => $v['XML_ID'], 'DEF' => $v['DEF'], ]; } return $fields; }
php
protected function collectPropertyFieldsFromDB() { $fields = CIBlockProperty::getByID($this->fields['ID'])->fetch(); $fields['VALUES'] = []; $filter = [ 'IBLOCK_ID' => $this->fields['IBLOCK_ID'], 'PROPERTY_ID' => $this->fields['ID'], ]; $sort = [ 'SORT' => 'ASC', 'VALUE' => 'ASC', ]; $propertyEnums = CIBlockPropertyEnum::GetList($sort, $filter); while ($v = $propertyEnums->GetNext()) { $fields['VALUES'][$v['ID']] = [ 'ID' => $v['ID'], 'VALUE' => $v['VALUE'], 'SORT' => $v['SORT'], 'XML_ID' => $v['XML_ID'], 'DEF' => $v['DEF'], ]; } return $fields; }
[ "protected", "function", "collectPropertyFieldsFromDB", "(", ")", "{", "$", "fields", "=", "CIBlockProperty", "::", "getByID", "(", "$", "this", "->", "fields", "[", "'ID'", "]", ")", "->", "fetch", "(", ")", ";", "$", "fields", "[", "'VALUES'", "]", "="...
Collect property fields from DB and convert them to format that can be compared from user input. @return array
[ "Collect", "property", "fields", "from", "DB", "and", "convert", "them", "to", "format", "that", "can", "be", "compared", "from", "user", "input", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Handlers/OnBeforeIBlockPropertyUpdate.php#L75-L101
train
arrilot/bitrix-migrations
src/Autocreate/Handlers/OnBeforeIBlockPropertyUpdate.php
OnBeforeIBlockPropertyUpdate.propertyHasChanged
protected function propertyHasChanged() { foreach ($this->dbFields as $field => $value) { if (isset($this->fields[$field]) && ($this->fields[$field] != $value)) { return true; } } return false; }
php
protected function propertyHasChanged() { foreach ($this->dbFields as $field => $value) { if (isset($this->fields[$field]) && ($this->fields[$field] != $value)) { return true; } } return false; }
[ "protected", "function", "propertyHasChanged", "(", ")", "{", "foreach", "(", "$", "this", "->", "dbFields", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "field", "]", ")", "&&", ...
Determine if property has been changed. @return bool
[ "Determine", "if", "property", "has", "been", "changed", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Handlers/OnBeforeIBlockPropertyUpdate.php#L108-L117
train
arrilot/bitrix-migrations
src/TemplatesCollection.php
TemplatesCollection.registerBasicTemplates
public function registerBasicTemplates() { $templates = [ [ 'name' => 'add_iblock', 'path' => $this->dir.'/add_iblock.template', 'description' => 'Add iblock', ], [ 'name' => 'add_iblock_type', 'path' => $this->dir.'/add_iblock_type.template', 'description' => 'Add iblock type', ], [ 'name' => 'add_iblock_element_property', 'path' => $this->dir.'/add_iblock_element_property.template', 'description' => 'Add iblock element property', 'aliases' => [ 'add_iblock_prop', 'add_iblock_element_prop', 'add_element_prop', 'add_element_property', ], ], [ 'name' => 'add_uf', 'path' => $this->dir.'/add_uf.template', 'description' => 'Add user field (for sections, users e.t.c)', ], [ 'name' => 'add_table', 'path' => $this->dir.'/add_table.template', 'description' => 'Create table', 'aliases' => [ 'create_table', ], ], [ 'name' => 'delete_table', 'path' => $this->dir.'/delete_table.template', 'description' => 'Drop table', 'aliases' => [ 'drop_table', ], ], [ 'name' => 'query', 'path' => $this->dir.'/query.template', 'description' => 'Simple database query', ], ]; foreach ($templates as $template) { $this->registerTemplate($template); } }
php
public function registerBasicTemplates() { $templates = [ [ 'name' => 'add_iblock', 'path' => $this->dir.'/add_iblock.template', 'description' => 'Add iblock', ], [ 'name' => 'add_iblock_type', 'path' => $this->dir.'/add_iblock_type.template', 'description' => 'Add iblock type', ], [ 'name' => 'add_iblock_element_property', 'path' => $this->dir.'/add_iblock_element_property.template', 'description' => 'Add iblock element property', 'aliases' => [ 'add_iblock_prop', 'add_iblock_element_prop', 'add_element_prop', 'add_element_property', ], ], [ 'name' => 'add_uf', 'path' => $this->dir.'/add_uf.template', 'description' => 'Add user field (for sections, users e.t.c)', ], [ 'name' => 'add_table', 'path' => $this->dir.'/add_table.template', 'description' => 'Create table', 'aliases' => [ 'create_table', ], ], [ 'name' => 'delete_table', 'path' => $this->dir.'/delete_table.template', 'description' => 'Drop table', 'aliases' => [ 'drop_table', ], ], [ 'name' => 'query', 'path' => $this->dir.'/query.template', 'description' => 'Simple database query', ], ]; foreach ($templates as $template) { $this->registerTemplate($template); } }
[ "public", "function", "registerBasicTemplates", "(", ")", "{", "$", "templates", "=", "[", "[", "'name'", "=>", "'add_iblock'", ",", "'path'", "=>", "$", "this", "->", "dir", ".", "'/add_iblock.template'", ",", "'description'", "=>", "'Add iblock'", ",", "]", ...
Register basic templates.
[ "Register", "basic", "templates", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/TemplatesCollection.php#L41-L96
train
arrilot/bitrix-migrations
src/TemplatesCollection.php
TemplatesCollection.registerAutoTemplates
public function registerAutoTemplates() { $templates = [ 'add_iblock', 'update_iblock', 'delete_iblock', 'add_iblock_element_property', 'update_iblock_element_property', 'delete_iblock_element_property', 'add_uf', 'update_uf', 'delete_uf', 'add_hlblock', 'update_hlblock', 'delete_hlblock', 'add_group', 'update_group', 'delete_group', ]; foreach ($templates as $template) { $this->registerTemplate([ 'name' => 'auto_'.$template, 'path' => $this->dir.'/auto/'.$template.'.template', ]); } }
php
public function registerAutoTemplates() { $templates = [ 'add_iblock', 'update_iblock', 'delete_iblock', 'add_iblock_element_property', 'update_iblock_element_property', 'delete_iblock_element_property', 'add_uf', 'update_uf', 'delete_uf', 'add_hlblock', 'update_hlblock', 'delete_hlblock', 'add_group', 'update_group', 'delete_group', ]; foreach ($templates as $template) { $this->registerTemplate([ 'name' => 'auto_'.$template, 'path' => $this->dir.'/auto/'.$template.'.template', ]); } }
[ "public", "function", "registerAutoTemplates", "(", ")", "{", "$", "templates", "=", "[", "'add_iblock'", ",", "'update_iblock'", ",", "'delete_iblock'", ",", "'add_iblock_element_property'", ",", "'update_iblock_element_property'", ",", "'delete_iblock_element_property'", ...
Register templates for automigrations.
[ "Register", "templates", "for", "automigrations", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/TemplatesCollection.php#L101-L127
train
arrilot/bitrix-migrations
src/TemplatesCollection.php
TemplatesCollection.registerTemplate
public function registerTemplate($template) { $template = $this->normalizeTemplateDuringRegistration($template); $this->templates[$template['name']] = $template; $this->registerTemplateAliases($template, $template['aliases']); }
php
public function registerTemplate($template) { $template = $this->normalizeTemplateDuringRegistration($template); $this->templates[$template['name']] = $template; $this->registerTemplateAliases($template, $template['aliases']); }
[ "public", "function", "registerTemplate", "(", "$", "template", ")", "{", "$", "template", "=", "$", "this", "->", "normalizeTemplateDuringRegistration", "(", "$", "template", ")", ";", "$", "this", "->", "templates", "[", "$", "template", "[", "'name'", "]"...
Dynamically register migration template. @param array $template @return void
[ "Dynamically", "register", "migration", "template", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/TemplatesCollection.php#L146-L153
train
arrilot/bitrix-migrations
src/TemplatesCollection.php
TemplatesCollection.selectTemplate
public function selectTemplate($template) { if (is_null($template)) { return 'default'; } if (!array_key_exists($template, $this->templates)) { throw new RuntimeException("Template \"{$template}\" is not registered"); } return $template; }
php
public function selectTemplate($template) { if (is_null($template)) { return 'default'; } if (!array_key_exists($template, $this->templates)) { throw new RuntimeException("Template \"{$template}\" is not registered"); } return $template; }
[ "public", "function", "selectTemplate", "(", "$", "template", ")", "{", "if", "(", "is_null", "(", "$", "template", ")", ")", "{", "return", "'default'", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "template", ",", "$", "this", "->", "templ...
Find out template name from user input. @param string|null $template @return string
[ "Find", "out", "template", "name", "from", "user", "input", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/TemplatesCollection.php#L174-L185
train
arrilot/bitrix-migrations
src/TemplatesCollection.php
TemplatesCollection.normalizeTemplateDuringRegistration
protected function normalizeTemplateDuringRegistration($template) { if (empty($template['name'])) { throw new InvalidArgumentException('Impossible to register a template without "name"'); } if (empty($template['path'])) { throw new InvalidArgumentException('Impossible to register a template without "path"'); } $template['description'] = isset($template['description']) ? $template['description'] : ''; $template['aliases'] = isset($template['aliases']) ? $template['aliases'] : []; $template['is_alias'] = false; return $template; }
php
protected function normalizeTemplateDuringRegistration($template) { if (empty($template['name'])) { throw new InvalidArgumentException('Impossible to register a template without "name"'); } if (empty($template['path'])) { throw new InvalidArgumentException('Impossible to register a template without "path"'); } $template['description'] = isset($template['description']) ? $template['description'] : ''; $template['aliases'] = isset($template['aliases']) ? $template['aliases'] : []; $template['is_alias'] = false; return $template; }
[ "protected", "function", "normalizeTemplateDuringRegistration", "(", "$", "template", ")", "{", "if", "(", "empty", "(", "$", "template", "[", "'name'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Impossible to register a template without \"...
Check template fields and normalize them. @param $template @return array
[ "Check", "template", "fields", "and", "normalize", "them", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/TemplatesCollection.php#L194-L209
train
arrilot/bitrix-migrations
src/TemplatesCollection.php
TemplatesCollection.registerTemplateAliases
protected function registerTemplateAliases($template, array $aliases = []) { foreach ($aliases as $alias) { $template['is_alias'] = true; $template['name'] = $alias; $template['aliases'] = []; $this->templates[$template['name']] = $template; } }
php
protected function registerTemplateAliases($template, array $aliases = []) { foreach ($aliases as $alias) { $template['is_alias'] = true; $template['name'] = $alias; $template['aliases'] = []; $this->templates[$template['name']] = $template; } }
[ "protected", "function", "registerTemplateAliases", "(", "$", "template", ",", "array", "$", "aliases", "=", "[", "]", ")", "{", "foreach", "(", "$", "aliases", "as", "$", "alias", ")", "{", "$", "template", "[", "'is_alias'", "]", "=", "true", ";", "$...
Register template aliases. @param array $template @param array $aliases @return void
[ "Register", "template", "aliases", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/TemplatesCollection.php#L219-L228
train
arrilot/bitrix-migrations
src/Autocreate/Handlers/OnBeforeHLBlockUpdate.php
OnBeforeHLBlockUpdate.fieldsHaveBeenChanged
protected function fieldsHaveBeenChanged() { $old = HighloadBlockTable::getById($this->id)->fetch(); $new = $this->fields + ['ID' => (string) $this->id]; return $new != $old; }
php
protected function fieldsHaveBeenChanged() { $old = HighloadBlockTable::getById($this->id)->fetch(); $new = $this->fields + ['ID' => (string) $this->id]; return $new != $old; }
[ "protected", "function", "fieldsHaveBeenChanged", "(", ")", "{", "$", "old", "=", "HighloadBlockTable", "::", "getById", "(", "$", "this", "->", "id", ")", "->", "fetch", "(", ")", ";", "$", "new", "=", "$", "this", "->", "fields", "+", "[", "'ID'", ...
Determine if fields have been changed. @return bool
[ "Determine", "if", "fields", "have", "been", "changed", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Autocreate/Handlers/OnBeforeHLBlockUpdate.php#L82-L88
train
arrilot/bitrix-migrations
src/Commands/RollbackCommand.php
RollbackCommand.rollbackMigration
protected function rollbackMigration($migration) { if ($this->migrator->doesMigrationFileExist($migration)) { $this->migrator->rollbackMigration($migration); } else { $this->markRolledBackWithConfirmation($migration); } $this->message("<info>Rolled back:</info> {$migration}.php"); }
php
protected function rollbackMigration($migration) { if ($this->migrator->doesMigrationFileExist($migration)) { $this->migrator->rollbackMigration($migration); } else { $this->markRolledBackWithConfirmation($migration); } $this->message("<info>Rolled back:</info> {$migration}.php"); }
[ "protected", "function", "rollbackMigration", "(", "$", "migration", ")", "{", "if", "(", "$", "this", "->", "migrator", "->", "doesMigrationFileExist", "(", "$", "migration", ")", ")", "{", "$", "this", "->", "migrator", "->", "rollbackMigration", "(", "$",...
Call rollback. @param $migration @return null
[ "Call", "rollback", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/RollbackCommand.php#L70-L79
train
arrilot/bitrix-migrations
src/Commands/RollbackCommand.php
RollbackCommand.markRolledBackWithConfirmation
protected function markRolledBackWithConfirmation($migration) { $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("<error>Migration $migration was not found.\r\nDo you want to mark it as rolled back? (y/n)</error>\r\n", false); if (!$helper->ask($this->input, $this->output, $question)) { $this->abort(); } $this->migrator->removeSuccessfulMigrationFromLog($migration); }
php
protected function markRolledBackWithConfirmation($migration) { $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("<error>Migration $migration was not found.\r\nDo you want to mark it as rolled back? (y/n)</error>\r\n", false); if (!$helper->ask($this->input, $this->output, $question)) { $this->abort(); } $this->migrator->removeSuccessfulMigrationFromLog($migration); }
[ "protected", "function", "markRolledBackWithConfirmation", "(", "$", "migration", ")", "{", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "'question'", ")", ";", "$", "question", "=", "new", "ConfirmationQuestion", "(", "\"<error>Migration $migration was ...
Ask a user to confirm rolling back non-existing migration and remove it from log. @param $migration @return void
[ "Ask", "a", "user", "to", "confirm", "rolling", "back", "non", "-", "existing", "migration", "and", "remove", "it", "from", "log", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/RollbackCommand.php#L102-L112
train
arrilot/bitrix-migrations
src/Commands/RollbackCommand.php
RollbackCommand.deleteIfNeeded
protected function deleteIfNeeded($migration) { if (!$this->input->getOption('delete')) { return; } if ($this->migrator->deleteMigrationFile($migration)) { $this->message("<info>Deleted:</info> {$migration}.php"); } }
php
protected function deleteIfNeeded($migration) { if (!$this->input->getOption('delete')) { return; } if ($this->migrator->deleteMigrationFile($migration)) { $this->message("<info>Deleted:</info> {$migration}.php"); } }
[ "protected", "function", "deleteIfNeeded", "(", "$", "migration", ")", "{", "if", "(", "!", "$", "this", "->", "input", "->", "getOption", "(", "'delete'", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "migrator", "->", "deleteMigrat...
Delete migration file if options is set @param string $migration @return null
[ "Delete", "migration", "file", "if", "options", "is", "set" ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Commands/RollbackCommand.php#L121-L130
train
arrilot/bitrix-migrations
src/Storages/BitrixDatabaseStorage.php
BitrixDatabaseStorage.getRanMigrations
public function getRanMigrations() { $migrations = []; $dbRes = $this->db->query("SELECT MIGRATION FROM {$this->table} ORDER BY ID ASC"); while ($result = $dbRes->fetch()) { $migrations[] = $result['MIGRATION']; } return $migrations; }
php
public function getRanMigrations() { $migrations = []; $dbRes = $this->db->query("SELECT MIGRATION FROM {$this->table} ORDER BY ID ASC"); while ($result = $dbRes->fetch()) { $migrations[] = $result['MIGRATION']; } return $migrations; }
[ "public", "function", "getRanMigrations", "(", ")", "{", "$", "migrations", "=", "[", "]", ";", "$", "dbRes", "=", "$", "this", "->", "db", "->", "query", "(", "\"SELECT MIGRATION FROM {$this->table} ORDER BY ID ASC\"", ")", ";", "while", "(", "$", "result", ...
Get an array of migrations the have been ran previously. Must be ordered by order asc. @return array
[ "Get", "an", "array", "of", "migrations", "the", "have", "been", "ran", "previously", ".", "Must", "be", "ordered", "by", "order", "asc", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Storages/BitrixDatabaseStorage.php#L64-L74
train
arrilot/bitrix-migrations
src/Storages/BitrixDatabaseStorage.php
BitrixDatabaseStorage.logSuccessfulMigration
public function logSuccessfulMigration($name) { $this->db->insert($this->table, [ 'MIGRATION' => "'".$this->db->forSql($name)."'", ]); }
php
public function logSuccessfulMigration($name) { $this->db->insert($this->table, [ 'MIGRATION' => "'".$this->db->forSql($name)."'", ]); }
[ "public", "function", "logSuccessfulMigration", "(", "$", "name", ")", "{", "$", "this", "->", "db", "->", "insert", "(", "$", "this", "->", "table", ",", "[", "'MIGRATION'", "=>", "\"'\"", ".", "$", "this", "->", "db", "->", "forSql", "(", "$", "nam...
Save migration name to the database to prevent it from running again. @param string $name @return void
[ "Save", "migration", "name", "to", "the", "database", "to", "prevent", "it", "from", "running", "again", "." ]
a081d5262497ed4127966955c36d5dae95c29e29
https://github.com/arrilot/bitrix-migrations/blob/a081d5262497ed4127966955c36d5dae95c29e29/src/Storages/BitrixDatabaseStorage.php#L83-L88
train
lsascha/registeraddress
Classes/Domain/Repository/AddressRepository.php
AddressRepository.findOneByEmailIgnoreHidden
public function findOneByEmailIgnoreHidden($email) { $query = $this->createQuery(); $query->getQuerySettings()->setIgnoreEnableFields(TRUE); $query->matching( $query->equals('email', $email ) ); return $query->execute()->getFirst(); }
php
public function findOneByEmailIgnoreHidden($email) { $query = $this->createQuery(); $query->getQuerySettings()->setIgnoreEnableFields(TRUE); $query->matching( $query->equals('email', $email ) ); return $query->execute()->getFirst(); }
[ "public", "function", "findOneByEmailIgnoreHidden", "(", "$", "email", ")", "{", "$", "query", "=", "$", "this", "->", "createQuery", "(", ")", ";", "$", "query", "->", "getQuerySettings", "(", ")", "->", "setIgnoreEnableFields", "(", "TRUE", ")", ";", "$"...
Returns an Object by email address and ignores hidden field. @param string $email @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array all objects, will be empty if no objects are found, will be an array if raw query results are enabled
[ "Returns", "an", "Object", "by", "email", "address", "and", "ignores", "hidden", "field", "." ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Domain/Repository/AddressRepository.php#L47-L57
train
lsascha/registeraddress
Classes/Domain/Repository/AddressRepository.php
AddressRepository.findAllByRegisteraddresshash
public function findAllByRegisteraddresshash($hash) { $query = $this->createQuery(); $query->matching( $query->equals('registeraddresshash', $hash ) ); return $query->execute(); }
php
public function findAllByRegisteraddresshash($hash) { $query = $this->createQuery(); $query->matching( $query->equals('registeraddresshash', $hash ) ); return $query->execute(); }
[ "public", "function", "findAllByRegisteraddresshash", "(", "$", "hash", ")", "{", "$", "query", "=", "$", "this", "->", "createQuery", "(", ")", ";", "$", "query", "->", "matching", "(", "$", "query", "->", "equals", "(", "'registeraddresshash'", ",", "$",...
Returns all Objects by hash. @param string $hash @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array all objects, will be empty if no objects are found, will be an array if raw query results are enabled
[ "Returns", "all", "Objects", "by", "hash", "." ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Domain/Repository/AddressRepository.php#L86-L95
train
lsascha/registeraddress
Classes/Hook/DataHandlerHook.php
DataHandlerHook.processDatamap_postProcessFieldArray
public function processDatamap_postProcessFieldArray($status, $table, $id, array &$fieldArray, DataHandler $pObj) { if ($table === 'tt_address' && $status === 'new') { if (empty($fieldArray['registeraddresshash'])) { $rnd = microtime(true) . random_int(10000, 90000); $regHash = sha1($fieldArray['email'] . $rnd); $fieldArray['registeraddresshash'] = $regHash; } } }
php
public function processDatamap_postProcessFieldArray($status, $table, $id, array &$fieldArray, DataHandler $pObj) { if ($table === 'tt_address' && $status === 'new') { if (empty($fieldArray['registeraddresshash'])) { $rnd = microtime(true) . random_int(10000, 90000); $regHash = sha1($fieldArray['email'] . $rnd); $fieldArray['registeraddresshash'] = $regHash; } } }
[ "public", "function", "processDatamap_postProcessFieldArray", "(", "$", "status", ",", "$", "table", ",", "$", "id", ",", "array", "&", "$", "fieldArray", ",", "DataHandler", "$", "pObj", ")", "{", "if", "(", "$", "table", "===", "'tt_address'", "&&", "$",...
Hook method for postProcessFieldArray @param $status @param $table @param $id @param array $fieldArray @param DataHandler $pObj @return void
[ "Hook", "method", "for", "postProcessFieldArray" ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Hook/DataHandlerHook.php#L41-L51
train
lsascha/registeraddress
Classes/Controller/AddressController.php
AddressController.getPlainRenderer
protected function getPlainRenderer($templateName = 'default', $format = 'txt') { $view = $this->objectManager->get(StandaloneView::class); $view->getRequest()->setControllerExtensionName('registeraddress'); $view->setFormat($format); // find plugin view configuration $frameworkConfiguration = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK ); // find partial paths from plugin configuration $partialPaths = $this->getViewProperty($frameworkConfiguration, 'partialRootPaths'); // set configured partialPaths so they can be overwritten $view->setPartialRootPaths($partialPaths); $templatePaths = $this->getViewProperty($frameworkConfiguration, 'templateRootPaths'); $view->setTemplateRootPaths($templatePaths); // set configured TemplateRootPaths from plugin $layoutPaths = $this->getViewProperty($frameworkConfiguration, 'layoutRootPaths'); $view->setLayoutRootPaths($layoutPaths); $view->setTemplate($templateName); $view->assign('settings', $this->settings); return $view; }
php
protected function getPlainRenderer($templateName = 'default', $format = 'txt') { $view = $this->objectManager->get(StandaloneView::class); $view->getRequest()->setControllerExtensionName('registeraddress'); $view->setFormat($format); // find plugin view configuration $frameworkConfiguration = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK ); // find partial paths from plugin configuration $partialPaths = $this->getViewProperty($frameworkConfiguration, 'partialRootPaths'); // set configured partialPaths so they can be overwritten $view->setPartialRootPaths($partialPaths); $templatePaths = $this->getViewProperty($frameworkConfiguration, 'templateRootPaths'); $view->setTemplateRootPaths($templatePaths); // set configured TemplateRootPaths from plugin $layoutPaths = $this->getViewProperty($frameworkConfiguration, 'layoutRootPaths'); $view->setLayoutRootPaths($layoutPaths); $view->setTemplate($templateName); $view->assign('settings', $this->settings); return $view; }
[ "protected", "function", "getPlainRenderer", "(", "$", "templateName", "=", "'default'", ",", "$", "format", "=", "'txt'", ")", "{", "$", "view", "=", "$", "this", "->", "objectManager", "->", "get", "(", "StandaloneView", "::", "class", ")", ";", "$", "...
This creates another stand-alone instance of the Fluid view to render a template @param string $templateName the name of the template to use @param string $format the format of the fluid template "html" or "txt" @return StandaloneView the Fluid instance @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
[ "This", "creates", "another", "stand", "-", "alone", "instance", "of", "the", "Fluid", "view", "to", "render", "a", "template" ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Controller/AddressController.php#L68-L96
train
lsascha/registeraddress
Classes/Controller/AddressController.php
AddressController.sendResponseMail
protected function sendResponseMail( $recipientmails = '', $templateName, array $data = NULL, $type = self::MAILFORMAT_TXT, $subjectSuffix = '' ) { $oldSpamProtectSetting = $GLOBALS['TSFE']->spamProtectEmailAddresses; // disable spamProtectEmailAddresses setting for e-mails $GLOBALS['TSFE']->spamProtectEmailAddresses = 0; $recipients = explode(',', $recipientmails); $from = [$this->settings['sendermail'] => $this->settings['sendername']]; $subject = $this->settings['responseSubject']; // add suffix to subject if set if ($subjectSuffix != '') { $subject .= ' - ' . $subjectSuffix; } $mailHtml = ''; $mailText = ''; switch ($type) { case self::MAILFORMAT_TXT: $mailTextView = $this->getPlainRenderer($templateName, 'txt'); break; case self::MAILFORMAT_HTML: $mailHtmlView = $this->getPlainRenderer($templateName, 'html'); break; /** @noinspection PhpMissingBreakStatementInspection */ case self::MAILFORMAT_TXTHTML: $mailHtmlView = $this->getPlainRenderer($templateName, 'html'); default: $mailTextView = $this->getPlainRenderer($templateName, 'txt'); break; } if (isset($mailTextView)) { $mailTextView->assignMultiple($data); $mailText = $mailTextView->render(); } if (isset($mailHtmlView)) { $mailHtmlView->assignMultiple($data); $mailHtml = $mailHtmlView->render(); } foreach ($recipients as $recipient) { $recipientMail = [trim($recipient)]; $this->sendEmail( $recipientMail, $from, $subject, $mailHtml, $mailText ); } // revert spamProtectSettings $GLOBALS['TSFE']->spamProtectEmailAddresses = $oldSpamProtectSetting; }
php
protected function sendResponseMail( $recipientmails = '', $templateName, array $data = NULL, $type = self::MAILFORMAT_TXT, $subjectSuffix = '' ) { $oldSpamProtectSetting = $GLOBALS['TSFE']->spamProtectEmailAddresses; // disable spamProtectEmailAddresses setting for e-mails $GLOBALS['TSFE']->spamProtectEmailAddresses = 0; $recipients = explode(',', $recipientmails); $from = [$this->settings['sendermail'] => $this->settings['sendername']]; $subject = $this->settings['responseSubject']; // add suffix to subject if set if ($subjectSuffix != '') { $subject .= ' - ' . $subjectSuffix; } $mailHtml = ''; $mailText = ''; switch ($type) { case self::MAILFORMAT_TXT: $mailTextView = $this->getPlainRenderer($templateName, 'txt'); break; case self::MAILFORMAT_HTML: $mailHtmlView = $this->getPlainRenderer($templateName, 'html'); break; /** @noinspection PhpMissingBreakStatementInspection */ case self::MAILFORMAT_TXTHTML: $mailHtmlView = $this->getPlainRenderer($templateName, 'html'); default: $mailTextView = $this->getPlainRenderer($templateName, 'txt'); break; } if (isset($mailTextView)) { $mailTextView->assignMultiple($data); $mailText = $mailTextView->render(); } if (isset($mailHtmlView)) { $mailHtmlView->assignMultiple($data); $mailHtml = $mailHtmlView->render(); } foreach ($recipients as $recipient) { $recipientMail = [trim($recipient)]; $this->sendEmail( $recipientMail, $from, $subject, $mailHtml, $mailText ); } // revert spamProtectSettings $GLOBALS['TSFE']->spamProtectEmailAddresses = $oldSpamProtectSetting; }
[ "protected", "function", "sendResponseMail", "(", "$", "recipientmails", "=", "''", ",", "$", "templateName", ",", "array", "$", "data", "=", "NULL", ",", "$", "type", "=", "self", "::", "MAILFORMAT_TXT", ",", "$", "subjectSuffix", "=", "''", ")", "{", "...
sends an e-mail to users @param string $recipientmails @param string $templateName @param array $data @param string $type @param string $subjectSuffix @return void @throws \InvalidArgumentException @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
[ "sends", "an", "e", "-", "mail", "to", "users" ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Controller/AddressController.php#L146-L203
train
lsascha/registeraddress
Classes/Controller/AddressController.php
AddressController.checkIfAddressExists
private function checkIfAddressExists($address) { $oldAddress = $this->addressRepository->findOneByEmailIgnoreHidden( $address ); return isset($oldAddress) && $oldAddress ? $oldAddress : null; }
php
private function checkIfAddressExists($address) { $oldAddress = $this->addressRepository->findOneByEmailIgnoreHidden( $address ); return isset($oldAddress) && $oldAddress ? $oldAddress : null; }
[ "private", "function", "checkIfAddressExists", "(", "$", "address", ")", "{", "$", "oldAddress", "=", "$", "this", "->", "addressRepository", "->", "findOneByEmailIgnoreHidden", "(", "$", "address", ")", ";", "return", "isset", "(", "$", "oldAddress", ")", "&&...
checks if address already exists @param string $address address to check @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array returns the already existing address or NULL if it is new
[ "checks", "if", "address", "already", "exists" ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Controller/AddressController.php#L211-L216
train
lsascha/registeraddress
Classes/Controller/AddressController.php
AddressController.informationAction
public function informationAction($email, $uid) { $address = $this->addressRepository->findOneByEmailIgnoreHidden($email); if ($address && $address->getUid() == $uid) { $data = [ 'address' => $address, 'hash' => $address->getRegisteraddresshash() ]; if ($address->getHidden()) { // if e-mail still unapproved, send complete registration mail again $mailTemplate = 'Address/MailNewsletterRegistration'; } else { // if e-mail already approved, just send information mail to edit or delete $mailTemplate = 'Address/MailNewsletterInformation'; } $this->sendResponseMail( $address->getEmail(), $mailTemplate, $data, $this->settings['mailformat'], LocalizationUtility::translate('mail.info.subjectsuffix', 'registeraddress') ); $this->view->assign('address', $address); } }
php
public function informationAction($email, $uid) { $address = $this->addressRepository->findOneByEmailIgnoreHidden($email); if ($address && $address->getUid() == $uid) { $data = [ 'address' => $address, 'hash' => $address->getRegisteraddresshash() ]; if ($address->getHidden()) { // if e-mail still unapproved, send complete registration mail again $mailTemplate = 'Address/MailNewsletterRegistration'; } else { // if e-mail already approved, just send information mail to edit or delete $mailTemplate = 'Address/MailNewsletterInformation'; } $this->sendResponseMail( $address->getEmail(), $mailTemplate, $data, $this->settings['mailformat'], LocalizationUtility::translate('mail.info.subjectsuffix', 'registeraddress') ); $this->view->assign('address', $address); } }
[ "public", "function", "informationAction", "(", "$", "email", ",", "$", "uid", ")", "{", "$", "address", "=", "$", "this", "->", "addressRepository", "->", "findOneByEmailIgnoreHidden", "(", "$", "email", ")", ";", "if", "(", "$", "address", "&&", "$", "...
action inormation mail anforderung @param \string $email @param integer $uid @return void @throws \InvalidArgumentException @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
[ "action", "inormation", "mail", "anforderung" ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Controller/AddressController.php#L316-L343
train
lsascha/registeraddress
Classes/Controller/AddressController.php
AddressController.unsubscribeFormAction
public function unsubscribeFormAction( $email = NULL ) { $address = $this->addressRepository->findOneByEmail($email); if ($email != NULL) { $this->view->assign('email', $email); } if ($address) { $data = [ 'address' => $address, 'hash' => $address->getRegisteraddresshash() ]; $mailTemplate = 'Address/MailNewsletterUnsubscribe'; $this->sendResponseMail( $address->getEmail(), $mailTemplate, $data, $this->settings['mailformat'], LocalizationUtility::translate('mail.unsubscribe.subjectsuffix', 'registeraddress') ); $this->view->assign('address', $address); } }
php
public function unsubscribeFormAction( $email = NULL ) { $address = $this->addressRepository->findOneByEmail($email); if ($email != NULL) { $this->view->assign('email', $email); } if ($address) { $data = [ 'address' => $address, 'hash' => $address->getRegisteraddresshash() ]; $mailTemplate = 'Address/MailNewsletterUnsubscribe'; $this->sendResponseMail( $address->getEmail(), $mailTemplate, $data, $this->settings['mailformat'], LocalizationUtility::translate('mail.unsubscribe.subjectsuffix', 'registeraddress') ); $this->view->assign('address', $address); } }
[ "public", "function", "unsubscribeFormAction", "(", "$", "email", "=", "NULL", ")", "{", "$", "address", "=", "$", "this", "->", "addressRepository", "->", "findOneByEmail", "(", "$", "email", ")", ";", "if", "(", "$", "email", "!=", "NULL", ")", "{", ...
action send unsubscribe link to e-mail address @param \string $email @return void @throws \InvalidArgumentException @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
[ "action", "send", "unsubscribe", "link", "to", "e", "-", "mail", "address" ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/Classes/Controller/AddressController.php#L354-L378
train
lsascha/registeraddress
class.ext_update.php
ext_update.access
public function access() { $typo3Version = VersionNumberUtility::getNumericTypo3Version(); if (VersionNumberUtility::convertVersionNumberToInteger($typo3Version) >= 8000000) { // If TYPO3 version is version 8 or higher $count = $this->queryBuilder->count('uid') ->from('tt_address') ->where( $this->queryBuilder->expr()->eq( 'registeraddresshash', $this->queryBuilder->createNamedParameter('') ) ) ->execute() ->fetchColumn(0); } else { // For TYPO3 Version 7 or lower $count = $this->databaseConnection->exec_SELECTcountRows( 'uid', 'tt_address', 'registeraddresshash=""' ); } return ($count > 0); }
php
public function access() { $typo3Version = VersionNumberUtility::getNumericTypo3Version(); if (VersionNumberUtility::convertVersionNumberToInteger($typo3Version) >= 8000000) { // If TYPO3 version is version 8 or higher $count = $this->queryBuilder->count('uid') ->from('tt_address') ->where( $this->queryBuilder->expr()->eq( 'registeraddresshash', $this->queryBuilder->createNamedParameter('') ) ) ->execute() ->fetchColumn(0); } else { // For TYPO3 Version 7 or lower $count = $this->databaseConnection->exec_SELECTcountRows( 'uid', 'tt_address', 'registeraddresshash=""' ); } return ($count > 0); }
[ "public", "function", "access", "(", ")", "{", "$", "typo3Version", "=", "VersionNumberUtility", "::", "getNumericTypo3Version", "(", ")", ";", "if", "(", "VersionNumberUtility", "::", "convertVersionNumberToInteger", "(", "$", "typo3Version", ")", ">=", "8000000", ...
Called by the extension manager to determine if the update menu entry should by showed. @return bool
[ "Called", "by", "the", "extension", "manager", "to", "determine", "if", "the", "update", "menu", "entry", "should", "by", "showed", "." ]
2e3284e3b2f3751239db53574f7fff10e7afc0e8
https://github.com/lsascha/registeraddress/blob/2e3284e3b2f3751239db53574f7fff10e7afc0e8/class.ext_update.php#L50-L75
train
antonioribeiro/version
src/package/Support/Git.php
Git.extractVersion
public function extractVersion($string) { preg_match_all( $this->config->get('git.version.matcher'), $string, $matches ); if (empty($matches[0])) { throw new GitTagNotFound('No git tags found in this repository'); } return $matches; }
php
public function extractVersion($string) { preg_match_all( $this->config->get('git.version.matcher'), $string, $matches ); if (empty($matches[0])) { throw new GitTagNotFound('No git tags found in this repository'); } return $matches; }
[ "public", "function", "extractVersion", "(", "$", "string", ")", "{", "preg_match_all", "(", "$", "this", "->", "config", "->", "get", "(", "'git.version.matcher'", ")", ",", "$", "string", ",", "$", "matches", ")", ";", "if", "(", "empty", "(", "$", "...
Break and extract version from string. @param $string @throws GitTagNotFound @return array
[ "Break", "and", "extract", "version", "from", "string", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L42-L55
train
antonioribeiro/version
src/package/Support/Git.php
Git.makeGitVersionRetrieverCommand
public function makeGitVersionRetrieverCommand($mode = null) { $mode = is_null($mode) ? $this->config->get('version_source') : $mode; return $this->searchAndReplaceRepository( $this->config->get('git.version.'.$mode) ); }
php
public function makeGitVersionRetrieverCommand($mode = null) { $mode = is_null($mode) ? $this->config->get('version_source') : $mode; return $this->searchAndReplaceRepository( $this->config->get('git.version.'.$mode) ); }
[ "public", "function", "makeGitVersionRetrieverCommand", "(", "$", "mode", "=", "null", ")", "{", "$", "mode", "=", "is_null", "(", "$", "mode", ")", "?", "$", "this", "->", "config", "->", "get", "(", "'version_source'", ")", ":", "$", "mode", ";", "re...
Make a git version command. @param string|null $mode @return string
[ "Make", "a", "git", "version", "command", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L74-L81
train
antonioribeiro/version
src/package/Support/Git.php
Git.getCommit
public function getCommit($mode = null) { return $this->getFromGit( $this->makeGitHashRetrieverCommand($mode), Constants::VERSION_CACHE_KEY, $this->config->get('build.length', 6) ); }
php
public function getCommit($mode = null) { return $this->getFromGit( $this->makeGitHashRetrieverCommand($mode), Constants::VERSION_CACHE_KEY, $this->config->get('build.length', 6) ); }
[ "public", "function", "getCommit", "(", "$", "mode", "=", "null", ")", "{", "return", "$", "this", "->", "getFromGit", "(", "$", "this", "->", "makeGitHashRetrieverCommand", "(", "$", "mode", ")", ",", "Constants", "::", "VERSION_CACHE_KEY", ",", "$", "thi...
Get the current git commit number, to be used as build number. @param string|null $mode @return string
[ "Get", "the", "current", "git", "commit", "number", "to", "be", "used", "as", "build", "number", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L90-L97
train
antonioribeiro/version
src/package/Support/Git.php
Git.getGitHashRetrieverCommand
public function getGitHashRetrieverCommand($mode = null) { $mode = is_null($mode) ? $this->config->get('build.mode') : $mode; return $this->config->get('git.'.$mode); }
php
public function getGitHashRetrieverCommand($mode = null) { $mode = is_null($mode) ? $this->config->get('build.mode') : $mode; return $this->config->get('git.'.$mode); }
[ "public", "function", "getGitHashRetrieverCommand", "(", "$", "mode", "=", "null", ")", "{", "$", "mode", "=", "is_null", "(", "$", "mode", ")", "?", "$", "this", "->", "config", "->", "get", "(", "'build.mode'", ")", ":", "$", "mode", ";", "return", ...
Get the git hash retriever command. @param string|null $mode @return \Illuminate\Config\Repository|mixed
[ "Get", "the", "git", "hash", "retriever", "command", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L106-L111
train
antonioribeiro/version
src/package/Support/Git.php
Git.getFromGit
protected function getFromGit($command, $keySuffix, $length = 256) { if ($value = $this->cache->get($key = $this->cache->key($keySuffix))) { return $value; } $value = substr($this->shell($command), 0, $length); $this->cache->put($key, $value); return $value; }
php
protected function getFromGit($command, $keySuffix, $length = 256) { if ($value = $this->cache->get($key = $this->cache->key($keySuffix))) { return $value; } $value = substr($this->shell($command), 0, $length); $this->cache->put($key, $value); return $value; }
[ "protected", "function", "getFromGit", "(", "$", "command", ",", "$", "keySuffix", ",", "$", "length", "=", "256", ")", "{", "if", "(", "$", "value", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "key", "=", "$", "this", "->", "cache", ...
Get a cached value or execute a shell command to retrieve it. @param $command @param $keySuffix @param int $length @return bool|mixed|null|string
[ "Get", "a", "cached", "value", "or", "execute", "a", "shell", "command", "to", "retrieve", "it", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L122-L133
train
antonioribeiro/version
src/package/Support/Git.php
Git.getVersionFromGit
public function getVersionFromGit($mode = null) { return $this->getFromGit( $this->makeGitVersionRetrieverCommand($mode), Constants::BUILD_CACHE_KEY ); }
php
public function getVersionFromGit($mode = null) { return $this->getFromGit( $this->makeGitVersionRetrieverCommand($mode), Constants::BUILD_CACHE_KEY ); }
[ "public", "function", "getVersionFromGit", "(", "$", "mode", "=", "null", ")", "{", "return", "$", "this", "->", "getFromGit", "(", "$", "this", "->", "makeGitVersionRetrieverCommand", "(", "$", "mode", ")", ",", "Constants", "::", "BUILD_CACHE_KEY", ")", ";...
Get the current app version from Git. @param null $mode @return bool|mixed|null|string
[ "Get", "the", "current", "app", "version", "from", "Git", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L142-L148
train
antonioribeiro/version
src/package/Support/Git.php
Git.version
public function version($type) { $version = $this->extractVersion($this->getVersionFromGit()); return [ 'major' => $this->getMatchedVersionItem($version, 1), 'minor' => $this->getMatchedVersionItem($version, 2), 'patch' => $this->getMatchedVersionItem($version, 3), 'build' => $this->getMatchedVersionItem($version, 4), ][$type]; }
php
public function version($type) { $version = $this->extractVersion($this->getVersionFromGit()); return [ 'major' => $this->getMatchedVersionItem($version, 1), 'minor' => $this->getMatchedVersionItem($version, 2), 'patch' => $this->getMatchedVersionItem($version, 3), 'build' => $this->getMatchedVersionItem($version, 4), ][$type]; }
[ "public", "function", "version", "(", "$", "type", ")", "{", "$", "version", "=", "$", "this", "->", "extractVersion", "(", "$", "this", "->", "getVersionFromGit", "(", ")", ")", ";", "return", "[", "'major'", "=>", "$", "this", "->", "getMatchedVersionI...
Get version from the git repository. @param $type @throws GitTagNotFound @return string
[ "Get", "version", "from", "the", "git", "repository", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L169-L182
train
antonioribeiro/version
src/package/Support/Git.php
Git.shell
protected function shell($command) { $process = new Process($command, $this->getBasePath()); $process->run(); if (!$process->isSuccessful()) { return ''; } return $this->cleanOutput($process->getOutput()); }
php
protected function shell($command) { $process = new Process($command, $this->getBasePath()); $process->run(); if (!$process->isSuccessful()) { return ''; } return $this->cleanOutput($process->getOutput()); }
[ "protected", "function", "shell", "(", "$", "command", ")", "{", "$", "process", "=", "new", "Process", "(", "$", "command", ",", "$", "this", "->", "getBasePath", "(", ")", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$...
Execute an shell command. @param $command @throws Exception @return string
[ "Execute", "an", "shell", "command", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Git.php#L230-L241
train
antonioribeiro/version
src/package/Support/Absorb.php
Absorb.absorbVersion
private function absorbVersion() { if (($type = $this->config->get('current.git_absorb')) === false) { return; } $version = $this->git->extractVersion( $this->git->getVersionFromGit($type) ); $config = $this->config->getRoot(); $config['current']['major'] = (int) $version[1][0]; $config['current']['minor'] = (int) $version[2][0]; $config['current']['patch'] = (int) $version[3][0]; $this->config->update($config); }
php
private function absorbVersion() { if (($type = $this->config->get('current.git_absorb')) === false) { return; } $version = $this->git->extractVersion( $this->git->getVersionFromGit($type) ); $config = $this->config->getRoot(); $config['current']['major'] = (int) $version[1][0]; $config['current']['minor'] = (int) $version[2][0]; $config['current']['patch'] = (int) $version[3][0]; $this->config->update($config); }
[ "private", "function", "absorbVersion", "(", ")", "{", "if", "(", "(", "$", "type", "=", "$", "this", "->", "config", "->", "get", "(", "'current.git_absorb'", ")", ")", "===", "false", ")", "{", "return", ";", "}", "$", "version", "=", "$", "this", ...
Absorb the version number from git.
[ "Absorb", "the", "version", "number", "from", "git", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Absorb.php#L54-L73
train
antonioribeiro/version
src/package/Support/Absorb.php
Absorb.absorbBuild
private function absorbBuild() { if (($type = $this->config->get('build.git_absorb')) === false) { return; } $config = $this->config->getRoot(); $config['build']['number'] = $this->git->getCommit($type); $this->config->update($config); }
php
private function absorbBuild() { if (($type = $this->config->get('build.git_absorb')) === false) { return; } $config = $this->config->getRoot(); $config['build']['number'] = $this->git->getCommit($type); $this->config->update($config); }
[ "private", "function", "absorbBuild", "(", ")", "{", "if", "(", "(", "$", "type", "=", "$", "this", "->", "config", "->", "get", "(", "'build.git_absorb'", ")", ")", "===", "false", ")", "{", "return", ";", "}", "$", "config", "=", "$", "this", "->...
Absorb the build from git.
[ "Absorb", "the", "build", "from", "git", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Absorb.php#L78-L89
train
antonioribeiro/version
src/package/Support/Config.php
Config.loadConfig
public function loadConfig($config = null) { $config = !is_null($config) || !file_exists($this->configFile) ? $this->setConfigFile($this->getConfigFile($config)) : $this->configFile; return $this->loadToLaravelConfig($config); }
php
public function loadConfig($config = null) { $config = !is_null($config) || !file_exists($this->configFile) ? $this->setConfigFile($this->getConfigFile($config)) : $this->configFile; return $this->loadToLaravelConfig($config); }
[ "public", "function", "loadConfig", "(", "$", "config", "=", "null", ")", "{", "$", "config", "=", "!", "is_null", "(", "$", "config", ")", "||", "!", "file_exists", "(", "$", "this", "->", "configFile", ")", "?", "$", "this", "->", "setConfigFile", ...
Load package YAML configuration. @param null $config @return Collection
[ "Load", "package", "YAML", "configuration", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Config.php#L105-L113
train
antonioribeiro/version
src/package/Support/Config.php
Config.getConfigFile
public function getConfigFile($file = null) { $file = $file ?: $this->configFile; return file_exists($file) ? $file : $this->getConfigFileStub(); }
php
public function getConfigFile($file = null) { $file = $file ?: $this->configFile; return file_exists($file) ? $file : $this->getConfigFileStub(); }
[ "public", "function", "getConfigFile", "(", "$", "file", "=", "null", ")", "{", "$", "file", "=", "$", "file", "?", ":", "$", "this", "->", "configFile", ";", "return", "file_exists", "(", "$", "file", ")", "?", "$", "file", ":", "$", "this", "->",...
Get the config file path. @param string|null $file @return string
[ "Get", "the", "config", "file", "path", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Config.php#L122-L127
train
antonioribeiro/version
src/package/Support/Config.php
Config.update
public function update($config) { config(['version' => $config]); $this->yaml->saveAsYaml($config, $this->configFile); }
php
public function update($config) { config(['version' => $config]); $this->yaml->saveAsYaml($config, $this->configFile); }
[ "public", "function", "update", "(", "$", "config", ")", "{", "config", "(", "[", "'version'", "=>", "$", "config", "]", ")", ";", "$", "this", "->", "yaml", "->", "saveAsYaml", "(", "$", "config", ",", "$", "this", "->", "configFile", ")", ";", "}...
Update the config file. @param $config
[ "Update", "the", "config", "file", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Config.php#L134-L139
train
antonioribeiro/version
src/package/ServiceProvider.php
ServiceProvider.registerService
protected function registerService() { $this->app->singleton('pragmarx.version', function () { $version = new Version($this->config); $version->setConfigFileStub($this->getConfigFileStub()); return $version; }); }
php
protected function registerService() { $this->app->singleton('pragmarx.version', function () { $version = new Version($this->config); $version->setConfigFileStub($this->getConfigFileStub()); return $version; }); }
[ "protected", "function", "registerService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'pragmarx.version'", ",", "function", "(", ")", "{", "$", "version", "=", "new", "Version", "(", "$", "this", "->", "config", ")", ";", "$", "...
Register service service.
[ "Register", "service", "service", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/ServiceProvider.php#L165-L174
train
antonioribeiro/version
src/package/Support/Cache.php
Cache.put
public function put($key, $value, $minutes = 10) { IlluminateCache::put( $key, $value, $this->config->get('cache.time', $minutes) ); }
php
public function put($key, $value, $minutes = 10) { IlluminateCache::put( $key, $value, $this->config->get('cache.time', $minutes) ); }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", "=", "10", ")", "{", "IlluminateCache", "::", "put", "(", "$", "key", ",", "$", "value", ",", "$", "this", "->", "config", "->", "get", "(", "'cache.time'", ",", ...
Add something to the cache. @param $key @param $value @param int $minutes
[ "Add", "something", "to", "the", "cache", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Cache.php#L28-L35
train
antonioribeiro/version
src/package/Support/Cache.php
Cache.flush
public function flush() { IlluminateCache::forget($this->key(Constants::BUILD_CACHE_KEY)); IlluminateCache::forget($this->key(Constants::VERSION_CACHE_KEY)); }
php
public function flush() { IlluminateCache::forget($this->key(Constants::BUILD_CACHE_KEY)); IlluminateCache::forget($this->key(Constants::VERSION_CACHE_KEY)); }
[ "public", "function", "flush", "(", ")", "{", "IlluminateCache", "::", "forget", "(", "$", "this", "->", "key", "(", "Constants", "::", "BUILD_CACHE_KEY", ")", ")", ";", "IlluminateCache", "::", "forget", "(", "$", "this", "->", "key", "(", "Constants", ...
Get the current object instance.
[ "Get", "the", "current", "object", "instance", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Cache.php#L66-L71
train
antonioribeiro/version
src/package/Support/Increment.php
Increment.incrementBuild
public function incrementBuild($by = null) { return $this->increment(function ($config) use ($by) { $increment_by = $by ?: $config['build']['increment_by']; $config['build']['number'] = $config['build']['number'] + $increment_by; return $config; }, 'build.number'); }
php
public function incrementBuild($by = null) { return $this->increment(function ($config) use ($by) { $increment_by = $by ?: $config['build']['increment_by']; $config['build']['number'] = $config['build']['number'] + $increment_by; return $config; }, 'build.number'); }
[ "public", "function", "incrementBuild", "(", "$", "by", "=", "null", ")", "{", "return", "$", "this", "->", "increment", "(", "function", "(", "$", "config", ")", "use", "(", "$", "by", ")", "{", "$", "increment_by", "=", "$", "by", "?", ":", "$", ...
Increment the build number. @param null $by @return int @internal param null $increment
[ "Increment", "the", "build", "number", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Support/Increment.php#L45-L55
train
antonioribeiro/version
src/package/Version.php
Version.getVersion
protected function getVersion($type) { return $this->git->isVersionComingFromGit() ? $this->git->version($type) : $this->config->get("current.{$type}"); }
php
protected function getVersion($type) { return $this->git->isVersionComingFromGit() ? $this->git->version($type) : $this->config->get("current.{$type}"); }
[ "protected", "function", "getVersion", "(", "$", "type", ")", "{", "return", "$", "this", "->", "git", "->", "isVersionComingFromGit", "(", ")", "?", "$", "this", "->", "git", "->", "version", "(", "$", "type", ")", ":", "$", "this", "->", "config", ...
Get a version. @param $type @return string
[ "Get", "a", "version", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Version.php#L103-L108
train
antonioribeiro/version
src/package/Version.php
Version.instantiateClass
protected function instantiateClass( $instance, $property, $class = null, $arguments = [] ) { return $this->{$property} = is_null($instance) ? ($instance = new $class(...$arguments)) : $instance; }
php
protected function instantiateClass( $instance, $property, $class = null, $arguments = [] ) { return $this->{$property} = is_null($instance) ? ($instance = new $class(...$arguments)) : $instance; }
[ "protected", "function", "instantiateClass", "(", "$", "instance", ",", "$", "property", ",", "$", "class", "=", "null", ",", "$", "arguments", "=", "[", "]", ")", "{", "return", "$", "this", "->", "{", "$", "property", "}", "=", "is_null", "(", "$",...
Instantiate a class. @param $instance object @param $property string @param $class string @return Yaml|object
[ "Instantiate", "a", "class", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Version.php#L162-L171
train
antonioribeiro/version
src/package/Version.php
Version.replaceVariables
protected function replaceVariables($string) { do { $original = $string; $string = $this->searchAndReplaceVariables($string); } while ($original !== $string); return $string; }
php
protected function replaceVariables($string) { do { $original = $string; $string = $this->searchAndReplaceVariables($string); } while ($original !== $string); return $string; }
[ "protected", "function", "replaceVariables", "(", "$", "string", ")", "{", "do", "{", "$", "original", "=", "$", "string", ";", "$", "string", "=", "$", "this", "->", "searchAndReplaceVariables", "(", "$", "string", ")", ";", "}", "while", "(", "$", "o...
Replace text variables with their values. @param $string @return mixed
[ "Replace", "text", "variables", "with", "their", "values", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Version.php#L180-L189
train
antonioribeiro/version
src/package/Version.php
Version.getBuild
public function getBuild() { if ( $this->git->isVersionComingFromGit() && ($value = $this->git->version('build')) ) { return $value; } if ($this->config->get('build.mode') === Constants::BUILD_MODE_NUMBER) { return $this->config->get('build.number'); } return $this->git->getCommit(); }
php
public function getBuild() { if ( $this->git->isVersionComingFromGit() && ($value = $this->git->version('build')) ) { return $value; } if ($this->config->get('build.mode') === Constants::BUILD_MODE_NUMBER) { return $this->config->get('build.number'); } return $this->git->getCommit(); }
[ "public", "function", "getBuild", "(", ")", "{", "if", "(", "$", "this", "->", "git", "->", "isVersionComingFromGit", "(", ")", "&&", "(", "$", "value", "=", "$", "this", "->", "git", "->", "version", "(", "'build'", ")", ")", ")", "{", "return", "...
Get the current build. @return mixed
[ "Get", "the", "current", "build", "." ]
e3558bb329a326253bb146de200572d6d0df4b71
https://github.com/antonioribeiro/version/blob/e3558bb329a326253bb146de200572d6d0df4b71/src/package/Version.php#L228-L242
train
jolicode/JoliTypo
src/JoliTypo/Fixer/Hyphen.php
Hyphen.fixLocale
protected function fixLocale($locale) { if (in_array($locale, $this->supportedLocales)) { return $locale; } if (($short = Fixer::getLanguageFromLocale($locale)) !== $locale) { if (in_array($short, $this->supportedLocales)) { return $short; } } // If no better locale found... return $locale; }
php
protected function fixLocale($locale) { if (in_array($locale, $this->supportedLocales)) { return $locale; } if (($short = Fixer::getLanguageFromLocale($locale)) !== $locale) { if (in_array($short, $this->supportedLocales)) { return $short; } } // If no better locale found... return $locale; }
[ "protected", "function", "fixLocale", "(", "$", "locale", ")", "{", "if", "(", "in_array", "(", "$", "locale", ",", "$", "this", "->", "supportedLocales", ")", ")", "{", "return", "$", "locale", ";", "}", "if", "(", "(", "$", "short", "=", "Fixer", ...
Transform fr_FR to fr to fit the list of supported locales. @param $locale @return mixed
[ "Transform", "fr_FR", "to", "fr", "to", "fit", "the", "list", "of", "supported", "locales", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer/Hyphen.php#L89-L103
train
jolicode/JoliTypo
src/JoliTypo/StateBag.php
StateBag.fixSiblingNode
public function fixSiblingNode($key, $new_content) { $storedSibling = $this->getSiblingNode($key); if ($storedSibling) { $storedSibling->getParent()->replaceChild($storedSibling->getDocument()->createTextNode($new_content), $storedSibling->getNode()); unset($this->siblingNode[$key][$this->currentDepth]); } }
php
public function fixSiblingNode($key, $new_content) { $storedSibling = $this->getSiblingNode($key); if ($storedSibling) { $storedSibling->getParent()->replaceChild($storedSibling->getDocument()->createTextNode($new_content), $storedSibling->getNode()); unset($this->siblingNode[$key][$this->currentDepth]); } }
[ "public", "function", "fixSiblingNode", "(", "$", "key", ",", "$", "new_content", ")", "{", "$", "storedSibling", "=", "$", "this", "->", "getSiblingNode", "(", "$", "key", ")", ";", "if", "(", "$", "storedSibling", ")", "{", "$", "storedSibling", "->", ...
Replace and destroy the content of a stored Node. @param string $key @param string $new_content
[ "Replace", "and", "destroy", "the", "content", "of", "a", "stored", "Node", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/StateBag.php#L55-L63
train
jolicode/JoliTypo
src/JoliTypo/Fixer.php
Fixer.compileRules
private function compileRules($rules) { if (!is_array($rules) || empty($rules)) { throw new BadRuleSetException('Rules must be an array of Fixer'); } $this->_rules = []; foreach ($rules as $rule) { if (is_object($rule)) { $fixer = $rule; $className = get_class($rule); } else { $className = class_exists($rule) ? $rule : (class_exists( 'JoliTypo\\Fixer\\'.$rule ) ? 'JoliTypo\\Fixer\\'.$rule : false); if (!$className) { throw new BadRuleSetException(sprintf('Fixer %s not found', $rule)); } $fixer = new $className($this->getLocale()); } if (!$fixer instanceof FixerInterface) { throw new BadRuleSetException(sprintf('%s must implement FixerInterface', $className)); } $this->_rules[$className] = $fixer; } if (empty($this->_rules)) { throw new BadRuleSetException("No rules configured, can't fix the content!"); } }
php
private function compileRules($rules) { if (!is_array($rules) || empty($rules)) { throw new BadRuleSetException('Rules must be an array of Fixer'); } $this->_rules = []; foreach ($rules as $rule) { if (is_object($rule)) { $fixer = $rule; $className = get_class($rule); } else { $className = class_exists($rule) ? $rule : (class_exists( 'JoliTypo\\Fixer\\'.$rule ) ? 'JoliTypo\\Fixer\\'.$rule : false); if (!$className) { throw new BadRuleSetException(sprintf('Fixer %s not found', $rule)); } $fixer = new $className($this->getLocale()); } if (!$fixer instanceof FixerInterface) { throw new BadRuleSetException(sprintf('%s must implement FixerInterface', $className)); } $this->_rules[$className] = $fixer; } if (empty($this->_rules)) { throw new BadRuleSetException("No rules configured, can't fix the content!"); } }
[ "private", "function", "compileRules", "(", "$", "rules", ")", "{", "if", "(", "!", "is_array", "(", "$", "rules", ")", "||", "empty", "(", "$", "rules", ")", ")", "{", "throw", "new", "BadRuleSetException", "(", "'Rules must be an array of Fixer'", ")", "...
Build the _rules array of Fixer. @param $rules @throws Exception\BadRuleSetException
[ "Build", "the", "_rules", "array", "of", "Fixer", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer.php#L126-L158
train
jolicode/JoliTypo
src/JoliTypo/Fixer.php
Fixer.processDOM
private function processDOM(\DOMNode $node, \DOMDocument $dom) { if ($node->hasChildNodes()) { $nodes = []; foreach ($node->childNodes as $childNode) { if ($childNode instanceof \DOMElement && $childNode->tagName) { if (in_array($childNode->tagName, $this->protectedTags)) { continue; } } $nodes[] = $childNode; } $depth = $this->stateBag->getCurrentDepth(); foreach ($nodes as $childNode) { if ($childNode instanceof \DOMText && !$childNode->isWhitespaceInElementContent()) { $this->stateBag->setCurrentDepth($depth); $this->doFix($childNode, $node, $dom); } else { $this->stateBag->setCurrentDepth($this->stateBag->getCurrentDepth() + 1); $this->processDOM($childNode, $dom); } } } }
php
private function processDOM(\DOMNode $node, \DOMDocument $dom) { if ($node->hasChildNodes()) { $nodes = []; foreach ($node->childNodes as $childNode) { if ($childNode instanceof \DOMElement && $childNode->tagName) { if (in_array($childNode->tagName, $this->protectedTags)) { continue; } } $nodes[] = $childNode; } $depth = $this->stateBag->getCurrentDepth(); foreach ($nodes as $childNode) { if ($childNode instanceof \DOMText && !$childNode->isWhitespaceInElementContent()) { $this->stateBag->setCurrentDepth($depth); $this->doFix($childNode, $node, $dom); } else { $this->stateBag->setCurrentDepth($this->stateBag->getCurrentDepth() + 1); $this->processDOM($childNode, $dom); } } } }
[ "private", "function", "processDOM", "(", "\\", "DOMNode", "$", "node", ",", "\\", "DOMDocument", "$", "dom", ")", "{", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "$", "nodes", "=", "[", "]", ";", "foreach", "(", "$", "node"...
Loop over all the DOMNode recursively. @param \DOMNode $node @param \DOMDocument $dom
[ "Loop", "over", "all", "the", "DOMNode", "recursively", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer.php#L166-L192
train
jolicode/JoliTypo
src/JoliTypo/Fixer.php
Fixer.doFix
private function doFix(\DOMText $childNode, \DOMNode $node, \DOMDocument $dom) { $content = $childNode->wholeText; $current_node = new StateNode($childNode, $node, $dom); $this->stateBag->setCurrentNode($current_node); // run the string on all the fixers foreach ($this->_rules as $fixer) { $content = $fixer->fix($content, $this->stateBag); } // update the DOM only if the node has changed if ($childNode->wholeText !== $content) { $new_node = $dom->createTextNode($content); $node->replaceChild($new_node, $childNode); // As the node is replaced, we also update it in the StateNode $current_node->replaceNode($new_node); } }
php
private function doFix(\DOMText $childNode, \DOMNode $node, \DOMDocument $dom) { $content = $childNode->wholeText; $current_node = new StateNode($childNode, $node, $dom); $this->stateBag->setCurrentNode($current_node); // run the string on all the fixers foreach ($this->_rules as $fixer) { $content = $fixer->fix($content, $this->stateBag); } // update the DOM only if the node has changed if ($childNode->wholeText !== $content) { $new_node = $dom->createTextNode($content); $node->replaceChild($new_node, $childNode); // As the node is replaced, we also update it in the StateNode $current_node->replaceNode($new_node); } }
[ "private", "function", "doFix", "(", "\\", "DOMText", "$", "childNode", ",", "\\", "DOMNode", "$", "node", ",", "\\", "DOMDocument", "$", "dom", ")", "{", "$", "content", "=", "$", "childNode", "->", "wholeText", ";", "$", "current_node", "=", "new", "...
Run the Fixers on a DOMText content. @param \DOMText $childNode The node to fix @param \DOMNode $node The parent node where to replace the current one @param \DOMDocument $dom The Document
[ "Run", "the", "Fixers", "on", "a", "DOMText", "content", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer.php#L201-L221
train
jolicode/JoliTypo
src/JoliTypo/Fixer.php
Fixer.fixContentEncoding
private function fixContentEncoding($content) { if (!empty($content)) { // Little hack to force UTF-8 if (false === strpos($content, '<?xml encoding')) { $hack = false === strpos( $content, '<body' ) ? '<?xml encoding="UTF-8"><body>' : '<?xml encoding="UTF-8">'; $content = $hack.$content; } $encoding = mb_detect_encoding($content); $headPos = mb_strpos($content, '<head>'); // Add a meta to the <head> section if (false !== $headPos) { $headPos += 6; $content = mb_substr($content, 0, $headPos). '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'">'. mb_substr($content, $headPos); } $content = mb_convert_encoding($content, 'HTML-ENTITIES', $encoding); } return $content; }
php
private function fixContentEncoding($content) { if (!empty($content)) { // Little hack to force UTF-8 if (false === strpos($content, '<?xml encoding')) { $hack = false === strpos( $content, '<body' ) ? '<?xml encoding="UTF-8"><body>' : '<?xml encoding="UTF-8">'; $content = $hack.$content; } $encoding = mb_detect_encoding($content); $headPos = mb_strpos($content, '<head>'); // Add a meta to the <head> section if (false !== $headPos) { $headPos += 6; $content = mb_substr($content, 0, $headPos). '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'">'. mb_substr($content, $headPos); } $content = mb_convert_encoding($content, 'HTML-ENTITIES', $encoding); } return $content; }
[ "private", "function", "fixContentEncoding", "(", "$", "content", ")", "{", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "// Little hack to force UTF-8", "if", "(", "false", "===", "strpos", "(", "$", "content", ",", "'<?xml encoding'", ")", ...
Convert the content encoding properly and add Content-Type meta if HTML document. @see http://php.net/manual/en/domdocument.loadhtml.php#91513 @see https://github.com/jolicode/JoliTypo/issues/7 @param $content @return string
[ "Convert", "the", "content", "encoding", "properly", "and", "add", "Content", "-", "Type", "meta", "if", "HTML", "document", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer.php#L267-L294
train
jolicode/JoliTypo
src/JoliTypo/Fixer.php
Fixer.setLocale
public function setLocale($locale) { if (!is_string($locale) || empty($locale)) { throw new \InvalidArgumentException('Locale must be an IETF language tag.'); } // Set the Locale on Fixer that needs it foreach ($this->_rules as $rule) { if ($rule instanceof LocaleAwareFixerInterface) { $rule->setLocale($locale); } } $this->locale = $locale; }
php
public function setLocale($locale) { if (!is_string($locale) || empty($locale)) { throw new \InvalidArgumentException('Locale must be an IETF language tag.'); } // Set the Locale on Fixer that needs it foreach ($this->_rules as $rule) { if ($rule instanceof LocaleAwareFixerInterface) { $rule->setLocale($locale); } } $this->locale = $locale; }
[ "public", "function", "setLocale", "(", "$", "locale", ")", "{", "if", "(", "!", "is_string", "(", "$", "locale", ")", "||", "empty", "(", "$", "locale", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Locale must be an IETF language ...
Change the locale of the Fixer. @param string $locale An IETF language tag @throws \InvalidArgumentException
[ "Change", "the", "locale", "of", "the", "Fixer", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer.php#L349-L363
train
jolicode/JoliTypo
src/JoliTypo/Fixer/SmartQuotes.php
SmartQuotes.setLocale
public function setLocale($locale) { // Handle from locale + country switch (strtolower($locale)) { // “…” case 'pt-br': $this->opening = Fixer::LDQUO; $this->openingSuffix = ''; $this->closing = Fixer::RDQUO; $this->closingPrefix = ''; return; } // Handle from locale only $short = Fixer::getLanguageFromLocale($locale); switch ($short) { // « … » case 'fr': $this->opening = Fixer::LAQUO; $this->openingSuffix = Fixer::NO_BREAK_SPACE; $this->closing = Fixer::RAQUO; $this->closingPrefix = Fixer::NO_BREAK_SPACE; break; // «…» case 'hy': case 'az': case 'hz': case 'eu': case 'be': case 'ca': case 'el': case 'it': case 'no': case 'fa': case 'lv': case 'pt': case 'ru': case 'es': case 'uk': $this->opening = Fixer::LAQUO; $this->openingSuffix = ''; $this->closing = Fixer::RAQUO; $this->closingPrefix = ''; break; // „…“ case 'de': case 'ka': case 'cs': case 'et': case 'is': case 'lt': case 'mk': case 'ro': case 'sk': case 'sl': case 'wen': $this->opening = Fixer::BDQUO; $this->openingSuffix = ''; $this->closing = Fixer::LDQUO; $this->closingPrefix = ''; break; // “…” case 'en': case 'us': case 'gb': case 'af': case 'ar': case 'eo': case 'id': case 'ga': case 'ko': case 'br': case 'th': case 'tr': case 'vi': $this->opening = Fixer::LDQUO; $this->openingSuffix = ''; $this->closing = Fixer::RDQUO; $this->closingPrefix = ''; break; // ”…” case 'fi': case 'sv': case 'bs': $this->opening = Fixer::RDQUO; $this->openingSuffix = ''; $this->closing = Fixer::RDQUO; $this->closingPrefix = ''; break; } }
php
public function setLocale($locale) { // Handle from locale + country switch (strtolower($locale)) { // “…” case 'pt-br': $this->opening = Fixer::LDQUO; $this->openingSuffix = ''; $this->closing = Fixer::RDQUO; $this->closingPrefix = ''; return; } // Handle from locale only $short = Fixer::getLanguageFromLocale($locale); switch ($short) { // « … » case 'fr': $this->opening = Fixer::LAQUO; $this->openingSuffix = Fixer::NO_BREAK_SPACE; $this->closing = Fixer::RAQUO; $this->closingPrefix = Fixer::NO_BREAK_SPACE; break; // «…» case 'hy': case 'az': case 'hz': case 'eu': case 'be': case 'ca': case 'el': case 'it': case 'no': case 'fa': case 'lv': case 'pt': case 'ru': case 'es': case 'uk': $this->opening = Fixer::LAQUO; $this->openingSuffix = ''; $this->closing = Fixer::RAQUO; $this->closingPrefix = ''; break; // „…“ case 'de': case 'ka': case 'cs': case 'et': case 'is': case 'lt': case 'mk': case 'ro': case 'sk': case 'sl': case 'wen': $this->opening = Fixer::BDQUO; $this->openingSuffix = ''; $this->closing = Fixer::LDQUO; $this->closingPrefix = ''; break; // “…” case 'en': case 'us': case 'gb': case 'af': case 'ar': case 'eo': case 'id': case 'ga': case 'ko': case 'br': case 'th': case 'tr': case 'vi': $this->opening = Fixer::LDQUO; $this->openingSuffix = ''; $this->closing = Fixer::RDQUO; $this->closingPrefix = ''; break; // ”…” case 'fi': case 'sv': case 'bs': $this->opening = Fixer::RDQUO; $this->openingSuffix = ''; $this->closing = Fixer::RDQUO; $this->closingPrefix = ''; break; } }
[ "public", "function", "setLocale", "(", "$", "locale", ")", "{", "// Handle from locale + country", "switch", "(", "strtolower", "(", "$", "locale", ")", ")", "{", "// “…”", "case", "'pt-br'", ":", "$", "this", "->", "opening", "=", "Fixer", "::", "LDQUO", ...
Default configuration for supported lang. @param string $locale
[ "Default", "configuration", "for", "supported", "lang", "." ]
772fcde584ed14bd4feeeb06549402efc135d8ab
https://github.com/jolicode/JoliTypo/blob/772fcde584ed14bd4feeeb06549402efc135d8ab/src/JoliTypo/Fixer/SmartQuotes.php#L56-L148
train
u01jmg3/ics-parser
src/ICal/Event.php
Event.prepareData
protected function prepareData($value) { if (is_string($value)) { return stripslashes(trim(str_replace('\n', "\n", $value))); } elseif (is_array($value)) { return array_map('self::prepareData', $value); } return $value; }
php
protected function prepareData($value) { if (is_string($value)) { return stripslashes(trim(str_replace('\n', "\n", $value))); } elseif (is_array($value)) { return array_map('self::prepareData', $value); } return $value; }
[ "protected", "function", "prepareData", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "stripslashes", "(", "trim", "(", "str_replace", "(", "'\\n'", ",", "\"\\n\"", ",", "$", "value", ")", ")", ")", ...
Prepares the data for output @param mixed $value @return mixed
[ "Prepares", "the", "data", "for", "output" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/Event.php#L138-L147
train
u01jmg3/ics-parser
src/ICal/Event.php
Event.printData
public function printData($html = self::HTML_TEMPLATE) { $data = array( 'SUMMARY' => $this->summary, 'DTSTART' => $this->dtstart, 'DTEND' => $this->dtend, 'DTSTART_TZ' => $this->dtstart_tz, 'DTEND_TZ' => $this->dtend_tz, 'DURATION' => $this->duration, 'DTSTAMP' => $this->dtstamp, 'UID' => $this->uid, 'CREATED' => $this->created, 'LAST-MODIFIED' => $this->lastmodified, 'DESCRIPTION' => $this->description, 'LOCATION' => $this->location, 'SEQUENCE' => $this->sequence, 'STATUS' => $this->status, 'TRANSP' => $this->transp, 'ORGANISER' => $this->organizer, 'ATTENDEE(S)' => $this->attendee, ); $data = array_filter($data); // Remove any blank values $output = ''; foreach ($data as $key => $value) { $output .= sprintf($html, $key, $value); } return $output; }
php
public function printData($html = self::HTML_TEMPLATE) { $data = array( 'SUMMARY' => $this->summary, 'DTSTART' => $this->dtstart, 'DTEND' => $this->dtend, 'DTSTART_TZ' => $this->dtstart_tz, 'DTEND_TZ' => $this->dtend_tz, 'DURATION' => $this->duration, 'DTSTAMP' => $this->dtstamp, 'UID' => $this->uid, 'CREATED' => $this->created, 'LAST-MODIFIED' => $this->lastmodified, 'DESCRIPTION' => $this->description, 'LOCATION' => $this->location, 'SEQUENCE' => $this->sequence, 'STATUS' => $this->status, 'TRANSP' => $this->transp, 'ORGANISER' => $this->organizer, 'ATTENDEE(S)' => $this->attendee, ); $data = array_filter($data); // Remove any blank values $output = ''; foreach ($data as $key => $value) { $output .= sprintf($html, $key, $value); } return $output; }
[ "public", "function", "printData", "(", "$", "html", "=", "self", "::", "HTML_TEMPLATE", ")", "{", "$", "data", "=", "array", "(", "'SUMMARY'", "=>", "$", "this", "->", "summary", ",", "'DTSTART'", "=>", "$", "this", "->", "dtstart", ",", "'DTEND'", "=...
Returns Event data excluding anything blank within an HTML template @param string $html HTML template to use @return string
[ "Returns", "Event", "data", "excluding", "anything", "blank", "within", "an", "HTML", "template" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/Event.php#L156-L186
train
u01jmg3/ics-parser
src/ICal/Event.php
Event.snakeCase
protected static function snakeCase($input, $glue = '_', $separator = '-') { $input = preg_split('/(?<=[a-z])(?=[A-Z])/x', $input); $input = join($input, $glue); $input = str_replace($separator, $glue, $input); return strtolower($input); }
php
protected static function snakeCase($input, $glue = '_', $separator = '-') { $input = preg_split('/(?<=[a-z])(?=[A-Z])/x', $input); $input = join($input, $glue); $input = str_replace($separator, $glue, $input); return strtolower($input); }
[ "protected", "static", "function", "snakeCase", "(", "$", "input", ",", "$", "glue", "=", "'_'", ",", "$", "separator", "=", "'-'", ")", "{", "$", "input", "=", "preg_split", "(", "'/(?<=[a-z])(?=[A-Z])/x'", ",", "$", "input", ")", ";", "$", "input", "...
Converts the given input to snake_case @param string $input @param string $glue @param string $separator @return string
[ "Converts", "the", "given", "input", "to", "snake_case" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/Event.php#L196-L203
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.initString
public function initString($string) { if (empty($this->cal)) { $lines = explode(PHP_EOL, $string); $this->initLines($lines); } else { trigger_error('ICal::initString: Calendar already initialised in constructor', E_USER_NOTICE); } return $this; }
php
public function initString($string) { if (empty($this->cal)) { $lines = explode(PHP_EOL, $string); $this->initLines($lines); } else { trigger_error('ICal::initString: Calendar already initialised in constructor', E_USER_NOTICE); } return $this; }
[ "public", "function", "initString", "(", "$", "string", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "cal", ")", ")", "{", "$", "lines", "=", "explode", "(", "PHP_EOL", ",", "$", "string", ")", ";", "$", "this", "->", "initLines", "(", "...
Initialises lines from a string @param string $string @return ICal
[ "Initialises", "lines", "from", "a", "string" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L497-L508
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.initFile
public function initFile($file) { if (empty($this->cal)) { $lines = $this->fileOrUrl($file); $this->initLines($lines); } else { trigger_error('ICal::initFile: Calendar already initialised in constructor', E_USER_NOTICE); } return $this; }
php
public function initFile($file) { if (empty($this->cal)) { $lines = $this->fileOrUrl($file); $this->initLines($lines); } else { trigger_error('ICal::initFile: Calendar already initialised in constructor', E_USER_NOTICE); } return $this; }
[ "public", "function", "initFile", "(", "$", "file", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "cal", ")", ")", "{", "$", "lines", "=", "$", "this", "->", "fileOrUrl", "(", "$", "file", ")", ";", "$", "this", "->", "initLines", "(", ...
Initialises lines from a file @param string $file @return ICal
[ "Initialises", "lines", "from", "a", "file" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L516-L527
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.initUrl
public function initUrl($url, $username = null, $password = null, $userAgent = null) { if (!is_null($username) && !is_null($password)) { $this->httpBasicAuth['username'] = $username; $this->httpBasicAuth['password'] = $password; } if (!is_null($userAgent)) { $this->httpUserAgent = $userAgent; } $this->initFile($url); return $this; }
php
public function initUrl($url, $username = null, $password = null, $userAgent = null) { if (!is_null($username) && !is_null($password)) { $this->httpBasicAuth['username'] = $username; $this->httpBasicAuth['password'] = $password; } if (!is_null($userAgent)) { $this->httpUserAgent = $userAgent; } $this->initFile($url); return $this; }
[ "public", "function", "initUrl", "(", "$", "url", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ",", "$", "userAgent", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "username", ")", "&&", "!", "is_null", "(", ...
Initialises lines from a URL @param string $url @param string $username @param string $password @param string $userAgent @return ICal
[ "Initialises", "lines", "from", "a", "URL" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L538-L552
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.reduceEventsToMinMaxRange
protected function reduceEventsToMinMaxRange() { $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array(); if (!empty($events)) { foreach ($events as $key => $anEvent) { if ($this->doesEventStartOutsideWindow($anEvent)) { $this->eventCount--; unset($events[$key]); continue; } } $this->cal['VEVENT'] = $events; } }
php
protected function reduceEventsToMinMaxRange() { $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array(); if (!empty($events)) { foreach ($events as $key => $anEvent) { if ($this->doesEventStartOutsideWindow($anEvent)) { $this->eventCount--; unset($events[$key]); continue; } } $this->cal['VEVENT'] = $events; } }
[ "protected", "function", "reduceEventsToMinMaxRange", "(", ")", "{", "$", "events", "=", "(", "isset", "(", "$", "this", "->", "cal", "[", "'VEVENT'", "]", ")", ")", "?", "$", "this", "->", "cal", "[", "'VEVENT'", "]", ":", "array", "(", ")", ";", ...
Reduces the number of events to the defined minimum and maximum range @return void
[ "Reduces", "the", "number", "of", "events", "to", "the", "defined", "minimum", "and", "maximum", "range" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L729-L746
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.isOutOfRange
protected function isOutOfRange($calendarDate, $minTimestamp, $maxTimestamp) { $timestamp = strtotime(explode('T', $calendarDate)[0]); return $timestamp < $minTimestamp || $timestamp > $maxTimestamp; }
php
protected function isOutOfRange($calendarDate, $minTimestamp, $maxTimestamp) { $timestamp = strtotime(explode('T', $calendarDate)[0]); return $timestamp < $minTimestamp || $timestamp > $maxTimestamp; }
[ "protected", "function", "isOutOfRange", "(", "$", "calendarDate", ",", "$", "minTimestamp", ",", "$", "maxTimestamp", ")", "{", "$", "timestamp", "=", "strtotime", "(", "explode", "(", "'T'", ",", "$", "calendarDate", ")", "[", "0", "]", ")", ";", "retu...
Determines whether a valid iCalendar date is within a given range @param string $calendarDate @param integer $minTimestamp @param integer $maxTimestamp @return boolean
[ "Determines", "whether", "a", "valid", "iCalendar", "date", "is", "within", "a", "given", "range" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L768-L773
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.iCalDateToUnixTimestamp
public function iCalDateToUnixTimestamp($icalDate, $forceTimeZone = false, $forceUtc = false) { $dateTime = $this->iCalDateToDateTime($icalDate, $forceTimeZone, $forceUtc); return $dateTime->getTimestamp(); }
php
public function iCalDateToUnixTimestamp($icalDate, $forceTimeZone = false, $forceUtc = false) { $dateTime = $this->iCalDateToDateTime($icalDate, $forceTimeZone, $forceUtc); return $dateTime->getTimestamp(); }
[ "public", "function", "iCalDateToUnixTimestamp", "(", "$", "icalDate", ",", "$", "forceTimeZone", "=", "false", ",", "$", "forceUtc", "=", "false", ")", "{", "$", "dateTime", "=", "$", "this", "->", "iCalDateToDateTime", "(", "$", "icalDate", ",", "$", "fo...
Returns a Unix timestamp from an iCal date time format @param string $icalDate @param boolean $forceTimeZone @param boolean $forceUtc @return integer
[ "Returns", "a", "Unix", "timestamp", "from", "an", "iCal", "date", "time", "format" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L1095-L1099
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.iCalDateWithTimeZone
public function iCalDateWithTimeZone(array $event, $key, $format = self::DATE_TIME_FORMAT) { if (!isset($event[$key . '_array']) || !isset($event[$key])) { return false; } $dateArray = $event[$key . '_array']; if ($key === 'DURATION') { $duration = end($dateArray); $dateTime = $this->parseDuration($event['DTSTART'], $duration, null); } else { $dateTime = new \DateTime($dateArray[1], new \DateTimeZone(self::TIME_ZONE_UTC)); $dateTime->setTimezone(new \DateTimeZone($this->calendarTimeZone())); } // Force time zone if (isset($dateArray[0]['TZID'])) { if ($this->isValidIanaTimeZoneId($dateArray[0]['TZID'])) { $dateTime->setTimezone(new \DateTimeZone($dateArray[0]['TZID'])); } elseif ($this->isValidCldrTimeZoneId($dateArray[0]['TZID'])) { $dateTime->setTimezone(new \DateTimeZone($this->isValidCldrTimeZoneId($dateArray[0]['TZID'], true))); } else { $dateTime->setTimezone(new \DateTimeZone($this->defaultTimeZone)); } } if (is_null($format)) { $output = $dateTime; } else { if ($format === self::UNIX_FORMAT) { $output = $dateTime->getTimestamp(); } else { $output = $dateTime->format($format); } } return $output; }
php
public function iCalDateWithTimeZone(array $event, $key, $format = self::DATE_TIME_FORMAT) { if (!isset($event[$key . '_array']) || !isset($event[$key])) { return false; } $dateArray = $event[$key . '_array']; if ($key === 'DURATION') { $duration = end($dateArray); $dateTime = $this->parseDuration($event['DTSTART'], $duration, null); } else { $dateTime = new \DateTime($dateArray[1], new \DateTimeZone(self::TIME_ZONE_UTC)); $dateTime->setTimezone(new \DateTimeZone($this->calendarTimeZone())); } // Force time zone if (isset($dateArray[0]['TZID'])) { if ($this->isValidIanaTimeZoneId($dateArray[0]['TZID'])) { $dateTime->setTimezone(new \DateTimeZone($dateArray[0]['TZID'])); } elseif ($this->isValidCldrTimeZoneId($dateArray[0]['TZID'])) { $dateTime->setTimezone(new \DateTimeZone($this->isValidCldrTimeZoneId($dateArray[0]['TZID'], true))); } else { $dateTime->setTimezone(new \DateTimeZone($this->defaultTimeZone)); } } if (is_null($format)) { $output = $dateTime; } else { if ($format === self::UNIX_FORMAT) { $output = $dateTime->getTimestamp(); } else { $output = $dateTime->format($format); } } return $output; }
[ "public", "function", "iCalDateWithTimeZone", "(", "array", "$", "event", ",", "$", "key", ",", "$", "format", "=", "self", "::", "DATE_TIME_FORMAT", ")", "{", "if", "(", "!", "isset", "(", "$", "event", "[", "$", "key", ".", "'_array'", "]", ")", "|...
Returns a date adapted to the calendar time zone depending on the event `TZID` @param array $event @param string $key @param string $format @return string|boolean
[ "Returns", "a", "date", "adapted", "to", "the", "calendar", "time", "zone", "depending", "on", "the", "event", "TZID" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L1109-L1147
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.processDateConversions
protected function processDateConversions() { $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array(); if (!empty($events)) { foreach ($events as $key => $anEvent) { if (!$this->isValidDate($anEvent['DTSTART'])) { unset($events[$key]); $this->eventCount--; continue; } if ($this->useTimeZoneWithRRules && isset($anEvent['RRULE_array'][2]) && $anEvent['RRULE_array'][2] === self::RECURRENCE_EVENT) { $events[$key]['DTSTART_tz'] = $anEvent['DTSTART']; $events[$key]['DTEND_tz'] = isset($anEvent['DTEND']) ? $anEvent['DTEND'] : $anEvent['DTSTART']; } else { $events[$key]['DTSTART_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTSTART'); if ($this->iCalDateWithTimeZone($anEvent, 'DTEND')) { $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTEND'); } elseif ($this->iCalDateWithTimeZone($anEvent, 'DURATION')) { $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DURATION'); } elseif ($this->iCalDateWithTimeZone($anEvent, 'DTSTART')) { $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTSTART'); } } } $this->cal['VEVENT'] = $events; } }
php
protected function processDateConversions() { $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array(); if (!empty($events)) { foreach ($events as $key => $anEvent) { if (!$this->isValidDate($anEvent['DTSTART'])) { unset($events[$key]); $this->eventCount--; continue; } if ($this->useTimeZoneWithRRules && isset($anEvent['RRULE_array'][2]) && $anEvent['RRULE_array'][2] === self::RECURRENCE_EVENT) { $events[$key]['DTSTART_tz'] = $anEvent['DTSTART']; $events[$key]['DTEND_tz'] = isset($anEvent['DTEND']) ? $anEvent['DTEND'] : $anEvent['DTSTART']; } else { $events[$key]['DTSTART_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTSTART'); if ($this->iCalDateWithTimeZone($anEvent, 'DTEND')) { $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTEND'); } elseif ($this->iCalDateWithTimeZone($anEvent, 'DURATION')) { $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DURATION'); } elseif ($this->iCalDateWithTimeZone($anEvent, 'DTSTART')) { $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTSTART'); } } } $this->cal['VEVENT'] = $events; } }
[ "protected", "function", "processDateConversions", "(", ")", "{", "$", "events", "=", "(", "isset", "(", "$", "this", "->", "cal", "[", "'VEVENT'", "]", ")", ")", "?", "$", "this", "->", "cal", "[", "'VEVENT'", "]", ":", "array", "(", ")", ";", "if...
Processes date conversions using the time zone Add keys `DTSTART_tz` and `DTEND_tz` to each Event These keys contain dates adapted to the calendar time zone depending on the event `TZID`. @return void
[ "Processes", "date", "conversions", "using", "the", "time", "zone" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L1949-L1980
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.events
public function events() { $array = $this->cal; $array = isset($array['VEVENT']) ? $array['VEVENT'] : array(); $events = array(); if (!empty($array)) { foreach ($array as $event) { $events[] = new Event($event); } } return $events; }
php
public function events() { $array = $this->cal; $array = isset($array['VEVENT']) ? $array['VEVENT'] : array(); $events = array(); if (!empty($array)) { foreach ($array as $event) { $events[] = new Event($event); } } return $events; }
[ "public", "function", "events", "(", ")", "{", "$", "array", "=", "$", "this", "->", "cal", ";", "$", "array", "=", "isset", "(", "$", "array", "[", "'VEVENT'", "]", ")", "?", "$", "array", "[", "'VEVENT'", "]", ":", "array", "(", ")", ";", "$"...
Returns an array of Events. Every event is a class with the event details being properties within it. @return array
[ "Returns", "an", "array", "of", "Events", ".", "Every", "event", "is", "a", "class", "with", "the", "event", "details", "being", "properties", "within", "it", "." ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2013-L2026
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.calendarTimeZone
public function calendarTimeZone($ignoreUtc = false) { if (isset($this->cal['VCALENDAR']['X-WR-TIMEZONE'])) { $timeZone = $this->cal['VCALENDAR']['X-WR-TIMEZONE']; } elseif (isset($this->cal['VTIMEZONE']['TZID'])) { $timeZone = $this->cal['VTIMEZONE']['TZID']; } else { $timeZone = $this->defaultTimeZone; } // Use default time zone if the calendar's is invalid if ($this->isValidIanaTimeZoneId($timeZone) === false) { // phpcs:ignore CustomPHPCS.ControlStructures.AssignmentInCondition.Warning if (($timeZone = $this->isValidCldrTimeZoneId($timeZone, true)) === false) { $timeZone = $this->defaultTimeZone; } } if ($ignoreUtc && strtoupper($timeZone) === self::TIME_ZONE_UTC) { return null; } return $timeZone; }
php
public function calendarTimeZone($ignoreUtc = false) { if (isset($this->cal['VCALENDAR']['X-WR-TIMEZONE'])) { $timeZone = $this->cal['VCALENDAR']['X-WR-TIMEZONE']; } elseif (isset($this->cal['VTIMEZONE']['TZID'])) { $timeZone = $this->cal['VTIMEZONE']['TZID']; } else { $timeZone = $this->defaultTimeZone; } // Use default time zone if the calendar's is invalid if ($this->isValidIanaTimeZoneId($timeZone) === false) { // phpcs:ignore CustomPHPCS.ControlStructures.AssignmentInCondition.Warning if (($timeZone = $this->isValidCldrTimeZoneId($timeZone, true)) === false) { $timeZone = $this->defaultTimeZone; } } if ($ignoreUtc && strtoupper($timeZone) === self::TIME_ZONE_UTC) { return null; } return $timeZone; }
[ "public", "function", "calendarTimeZone", "(", "$", "ignoreUtc", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cal", "[", "'VCALENDAR'", "]", "[", "'X-WR-TIMEZONE'", "]", ")", ")", "{", "$", "timeZone", "=", "$", "this", "->", ...
Returns the calendar time zone @param boolean $ignoreUtc @return string
[ "Returns", "the", "calendar", "time", "zone" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2054-L2077
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.eventsFromRange
public function eventsFromRange($rangeStart = null, $rangeEnd = null) { // Sort events before processing range $events = $this->sortEventsWithOrder($this->events(), SORT_ASC); if (empty($events)) { return array(); } $extendedEvents = array(); if (!is_null($rangeStart)) { try { $rangeStart = new \DateTime($rangeStart, new \DateTimeZone($this->defaultTimeZone)); } catch (\Exception $e) { error_log("ICal::eventsFromRange: Invalid date passed ({$rangeStart})"); $rangeStart = false; } } else { $rangeStart = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); } if (!is_null($rangeEnd)) { try { $rangeEnd = new \DateTime($rangeEnd, new \DateTimeZone($this->defaultTimeZone)); } catch (\Exception $e) { error_log("ICal::eventsFromRange: Invalid date passed ({$rangeEnd})"); $rangeEnd = false; } } else { $rangeEnd = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); $rangeEnd->modify('+20 years'); } // If start and end are identical and are dates with no times... if ($rangeEnd->format('His') == 0 && $rangeStart->getTimestamp() == $rangeEnd->getTimestamp()) { $rangeEnd->modify('+1 day'); } $rangeStart = $rangeStart->getTimestamp(); $rangeEnd = $rangeEnd->getTimestamp(); foreach ($events as $anEvent) { $eventStart = $anEvent->dtstart_array[2]; $eventEnd = (isset($anEvent->dtend_array[2])) ? $anEvent->dtend_array[2] : null; if (($eventStart >= $rangeStart && $eventStart < $rangeEnd) // Event start date contained in the range || ($eventEnd !== null && ( ($eventEnd > $rangeStart && $eventEnd <= $rangeEnd) // Event end date contained in the range || ($eventStart < $rangeStart && $eventEnd > $rangeEnd) // Event starts before and finishes after range ) ) ) { $extendedEvents[] = $anEvent; } } if (empty($extendedEvents)) { return array(); } return $extendedEvents; }
php
public function eventsFromRange($rangeStart = null, $rangeEnd = null) { // Sort events before processing range $events = $this->sortEventsWithOrder($this->events(), SORT_ASC); if (empty($events)) { return array(); } $extendedEvents = array(); if (!is_null($rangeStart)) { try { $rangeStart = new \DateTime($rangeStart, new \DateTimeZone($this->defaultTimeZone)); } catch (\Exception $e) { error_log("ICal::eventsFromRange: Invalid date passed ({$rangeStart})"); $rangeStart = false; } } else { $rangeStart = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); } if (!is_null($rangeEnd)) { try { $rangeEnd = new \DateTime($rangeEnd, new \DateTimeZone($this->defaultTimeZone)); } catch (\Exception $e) { error_log("ICal::eventsFromRange: Invalid date passed ({$rangeEnd})"); $rangeEnd = false; } } else { $rangeEnd = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); $rangeEnd->modify('+20 years'); } // If start and end are identical and are dates with no times... if ($rangeEnd->format('His') == 0 && $rangeStart->getTimestamp() == $rangeEnd->getTimestamp()) { $rangeEnd->modify('+1 day'); } $rangeStart = $rangeStart->getTimestamp(); $rangeEnd = $rangeEnd->getTimestamp(); foreach ($events as $anEvent) { $eventStart = $anEvent->dtstart_array[2]; $eventEnd = (isset($anEvent->dtend_array[2])) ? $anEvent->dtend_array[2] : null; if (($eventStart >= $rangeStart && $eventStart < $rangeEnd) // Event start date contained in the range || ($eventEnd !== null && ( ($eventEnd > $rangeStart && $eventEnd <= $rangeEnd) // Event end date contained in the range || ($eventStart < $rangeStart && $eventEnd > $rangeEnd) // Event starts before and finishes after range ) ) ) { $extendedEvents[] = $anEvent; } } if (empty($extendedEvents)) { return array(); } return $extendedEvents; }
[ "public", "function", "eventsFromRange", "(", "$", "rangeStart", "=", "null", ",", "$", "rangeEnd", "=", "null", ")", "{", "// Sort events before processing range", "$", "events", "=", "$", "this", "->", "sortEventsWithOrder", "(", "$", "this", "->", "events", ...
Returns a sorted array of the events in a given range, or an empty array if no events exist in the range. Events will be returned if the start or end date is contained within the range (inclusive), or if the event starts before and end after the range. If a start date is not specified or of a valid format, then the start of the range will default to the current time and date of the server. If an end date is not specified or of a valid format, then the end of the range will default to the current time and date of the server, plus 20 years. Note that this function makes use of Unix timestamps. This might be a problem for events on, during, or after 29 Jan 2038. See https://en.wikipedia.org/wiki/Unix_time#Representing_the_number @param string|null $rangeStart @param string|null $rangeEnd @return array @throws \Exception
[ "Returns", "a", "sorted", "array", "of", "the", "events", "in", "a", "given", "range", "or", "an", "empty", "array", "if", "no", "events", "exist", "in", "the", "range", "." ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2127-L2190
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.eventsFromInterval
public function eventsFromInterval($interval) { $rangeStart = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); $rangeEnd = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); $dateInterval = \DateInterval::createFromDateString($interval); $rangeEnd->add($dateInterval); return $this->eventsFromRange($rangeStart->format('Y-m-d'), $rangeEnd->format('Y-m-d')); }
php
public function eventsFromInterval($interval) { $rangeStart = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); $rangeEnd = new \DateTime('now', new \DateTimeZone($this->defaultTimeZone)); $dateInterval = \DateInterval::createFromDateString($interval); $rangeEnd->add($dateInterval); return $this->eventsFromRange($rangeStart->format('Y-m-d'), $rangeEnd->format('Y-m-d')); }
[ "public", "function", "eventsFromInterval", "(", "$", "interval", ")", "{", "$", "rangeStart", "=", "new", "\\", "DateTime", "(", "'now'", ",", "new", "\\", "DateTimeZone", "(", "$", "this", "->", "defaultTimeZone", ")", ")", ";", "$", "rangeEnd", "=", "...
Returns a sorted array of the events following a given string, or `false` if no events exist in the range. @param string $interval @return array
[ "Returns", "a", "sorted", "array", "of", "the", "events", "following", "a", "given", "string", "or", "false", "if", "no", "events", "exist", "in", "the", "range", "." ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2199-L2208
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.sortEventsWithOrder
public function sortEventsWithOrder(array $events, $sortOrder = SORT_ASC) { $extendedEvents = array(); $timestamp = array(); foreach ($events as $key => $anEvent) { $extendedEvents[] = $anEvent; $timestamp[$key] = $anEvent->dtstart_array[2]; } array_multisort($timestamp, $sortOrder, $extendedEvents); return $extendedEvents; }
php
public function sortEventsWithOrder(array $events, $sortOrder = SORT_ASC) { $extendedEvents = array(); $timestamp = array(); foreach ($events as $key => $anEvent) { $extendedEvents[] = $anEvent; $timestamp[$key] = $anEvent->dtstart_array[2]; } array_multisort($timestamp, $sortOrder, $extendedEvents); return $extendedEvents; }
[ "public", "function", "sortEventsWithOrder", "(", "array", "$", "events", ",", "$", "sortOrder", "=", "SORT_ASC", ")", "{", "$", "extendedEvents", "=", "array", "(", ")", ";", "$", "timestamp", "=", "array", "(", ")", ";", "foreach", "(", "$", "events", ...
Sorts events based on a given sort order @param array $events @param integer $sortOrder Either SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING @return array
[ "Sorts", "events", "based", "on", "a", "given", "sort", "order" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2217-L2230
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.isValidIanaTimeZoneId
protected function isValidIanaTimeZoneId($timeZone) { if (in_array($timeZone, $this->validTimeZones)) { return true; } $valid = array(); $tza = timezone_abbreviations_list(); foreach ($tza as $zone) { foreach ($zone as $item) { $valid[$item['timezone_id']] = true; } } unset($valid['']); if (isset($valid[$timeZone]) || in_array($timeZone, timezone_identifiers_list(\DateTimeZone::ALL_WITH_BC))) { $this->validTimeZones[] = $timeZone; return true; } return false; }
php
protected function isValidIanaTimeZoneId($timeZone) { if (in_array($timeZone, $this->validTimeZones)) { return true; } $valid = array(); $tza = timezone_abbreviations_list(); foreach ($tza as $zone) { foreach ($zone as $item) { $valid[$item['timezone_id']] = true; } } unset($valid['']); if (isset($valid[$timeZone]) || in_array($timeZone, timezone_identifiers_list(\DateTimeZone::ALL_WITH_BC))) { $this->validTimeZones[] = $timeZone; return true; } return false; }
[ "protected", "function", "isValidIanaTimeZoneId", "(", "$", "timeZone", ")", "{", "if", "(", "in_array", "(", "$", "timeZone", ",", "$", "this", "->", "validTimeZones", ")", ")", "{", "return", "true", ";", "}", "$", "valid", "=", "array", "(", ")", ";...
Checks if a time zone is a valid IANA time zone @param string $timeZone @return boolean
[ "Checks", "if", "a", "time", "zone", "is", "a", "valid", "IANA", "time", "zone" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2249-L2273
train
u01jmg3/ics-parser
src/ICal/ICal.php
ICal.parseDuration
protected function parseDuration($date, $duration, $format = self::UNIX_FORMAT) { $dateTime = date_create($date); $dateTime->modify($duration->y . ' year'); $dateTime->modify($duration->m . ' month'); $dateTime->modify($duration->d . ' day'); $dateTime->modify($duration->h . ' hour'); $dateTime->modify($duration->i . ' minute'); $dateTime->modify($duration->s . ' second'); if (is_null($format)) { $output = $dateTime; } else { if ($format === self::UNIX_FORMAT) { $output = $dateTime->getTimestamp(); } else { $output = $dateTime->format($format); } } return $output; }
php
protected function parseDuration($date, $duration, $format = self::UNIX_FORMAT) { $dateTime = date_create($date); $dateTime->modify($duration->y . ' year'); $dateTime->modify($duration->m . ' month'); $dateTime->modify($duration->d . ' day'); $dateTime->modify($duration->h . ' hour'); $dateTime->modify($duration->i . ' minute'); $dateTime->modify($duration->s . ' second'); if (is_null($format)) { $output = $dateTime; } else { if ($format === self::UNIX_FORMAT) { $output = $dateTime->getTimestamp(); } else { $output = $dateTime->format($format); } } return $output; }
[ "protected", "function", "parseDuration", "(", "$", "date", ",", "$", "duration", ",", "$", "format", "=", "self", "::", "UNIX_FORMAT", ")", "{", "$", "dateTime", "=", "date_create", "(", "$", "date", ")", ";", "$", "dateTime", "->", "modify", "(", "$"...
Parses a duration and applies it to a date @param string $date @param string $duration @param string $format @return integer|\DateTime
[ "Parses", "a", "duration", "and", "applies", "it", "to", "a", "date" ]
cb0f8b674b381f9d99ab0c246e9f5a4e01693606
https://github.com/u01jmg3/ics-parser/blob/cb0f8b674b381f9d99ab0c246e9f5a4e01693606/src/ICal/ICal.php#L2414-L2435
train