idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
59,300
protected function buildCodeFromSql ( Configuration $ configuration , array $ sql ) : string { $ currentPlatform = $ configuration -> getConnection ( ) -> getDatabasePlatform ( ) -> getName ( ) ; $ code = [ ] ; foreach ( $ sql as $ query ) { if ( stripos ( $ query , $ configuration -> getMigrationsTableName ( ) ) !== f...
Returns PHP code for a migration file that executes the given array of SQL statements .
59,301
protected function matchesFilterGroup ( $ element , array $ parsedFilter ) { foreach ( $ parsedFilter [ 'Filters' ] as $ filter ) { if ( $ this -> matchesFilter ( $ element , $ filter ) ) { return true ; } } return false ; }
Evaluate Filter Group . An element matches the filter group if it matches at least one part of the filter group .
59,302
protected function matchesAttributeFilter ( $ element , array $ attributeFilter ) { if ( $ attributeFilter [ 'PropertyPath' ] !== null ) { $ value = $ this -> getPropertyPath ( $ element , $ attributeFilter [ 'PropertyPath' ] ) ; } else { $ value = $ element ; } $ operand = null ; if ( isset ( $ attributeFilter [ 'Oper...
Match a single attribute filter
59,303
protected function evaluateOperator ( $ value , $ operator , $ operand ) { switch ( $ operator ) { case '=' : return $ value === $ operand ; case '!=' : return $ value !== $ operand ; case '<' : return $ value < $ operand ; case '<=' : return $ value <= $ operand ; case '>' : return $ value > $ operand ; case '>=' : re...
Evaluate an operator
59,304
public function resolveRequestPatternClass ( $ name ) { $ resolvedClassName = $ this -> objectManager -> getClassNameByObjectName ( $ name ) ; if ( $ resolvedClassName !== false ) { return $ resolvedClassName ; } $ resolvedClassName = $ this -> objectManager -> getClassNameByObjectName ( 'Neos\Flow\Security\RequestPatt...
Resolves the class name of a request pattern . If a valid request pattern class name is given it is just returned .
59,305
public function showCommand ( string $ type = 'Settings' , string $ path = null ) { $ availableConfigurationTypes = $ this -> configurationManager -> getAvailableConfigurationTypes ( ) ; if ( in_array ( $ type , $ availableConfigurationTypes ) ) { $ configuration = $ this -> configurationManager -> getConfiguration ( $...
Show the active configuration settings
59,306
public function listTypesCommand ( ) { $ this -> outputLine ( 'The following configuration types are registered:' ) ; $ this -> outputLine ( ) ; foreach ( $ this -> configurationManager -> getAvailableConfigurationTypes ( ) as $ type ) { $ this -> outputFormatted ( '- %s' , [ $ type ] ) ; } }
List registered configuration types
59,307
public function validateCommand ( string $ type = null , string $ path = null , bool $ verbose = false ) { if ( $ type === null ) { $ this -> outputLine ( 'Validating <b>all</b> configuration' ) ; } else { $ this -> outputLine ( 'Validating <b>' . $ type . '</b> configuration' . ( $ path !== null ? ' on path <b>' . $ p...
Validate the given configuration
59,308
public function generateSchemaCommand ( string $ type = null , string $ path = null , string $ yaml = null ) { $ data = null ; if ( $ yaml !== null && is_file ( $ yaml ) && is_readable ( $ yaml ) ) { $ data = Yaml :: parseFile ( $ yaml ) ; } elseif ( $ type !== null ) { $ data = $ this -> configurationManager -> getCon...
Generate a schema for the given configuration or YAML file .
59,309
public function initializeObject ( ) { foreach ( $ this -> options as $ key => $ value ) { $ isOptionSet = $ this -> setOption ( $ key , $ value ) ; if ( ! $ isOptionSet ) { throw new TargetException ( sprintf ( 'An unknown option "%s" was specified in the configuration of a resource FileSystemTarget. Please check your...
Initializes this resource publishing target
59,310
protected function checkAndRemovePackageSymlinks ( StorageInterface $ storage ) { if ( ! $ storage instanceof PackageStorage ) { return ; } foreach ( $ storage -> getPublicResourcePaths ( ) as $ packageKey => $ path ) { $ targetPathAndFilename = $ this -> path . $ packageKey ; if ( Files :: is_link ( $ targetPathAndFil...
Checks if the PackageStorage has been previously initialized with symlinks and clears them . Otherwise the original sources would be overwritten .
59,311
protected function handleMissingData ( ResourceMetaDataInterface $ resource , CollectionInterface $ collection ) { $ message = sprintf ( 'Could not publish resource %s with SHA1 hash %s of collection %s because there seems to be no corresponding data in the storage.' , $ resource -> getFilename ( ) , $ resource -> getS...
Handle missing data notification
59,312
protected function getResourcesBaseUri ( ) { if ( $ this -> absoluteBaseUri === null ) { $ this -> absoluteBaseUri = $ this -> detectResourcesBaseUri ( ) ; } return $ this -> absoluteBaseUri ; }
Returns the resolved absolute base URI for resources of this target .
59,313
protected function detectResourcesBaseUri ( ) { if ( $ this -> baseUri !== '' && ( $ this -> baseUri [ 0 ] === '/' || strpos ( $ this -> baseUri , '://' ) !== false ) ) { return $ this -> baseUri ; } $ requestHandler = $ this -> bootstrap -> getActiveRequestHandler ( ) ; if ( $ requestHandler instanceof HttpRequestHand...
Detects and returns the website s absolute base URI
59,314
public function persistEntities ( ) { foreach ( $ this -> entityManager -> getUnitOfWork ( ) -> getIdentityMap ( ) as $ className => $ entities ) { if ( $ className === $ this -> entityClassName ) { $ this -> entityManager -> flush ( $ entities ) ; return ; } } }
Persists all entities managed by the repository and all cascading dependencies
59,315
public function hashPassword ( $ password , $ staticSalt = null ) { $ dynamicSalt = UtilityAlgorithms :: generateRandomBytes ( $ this -> dynamicSaltLength ) ; $ result = CryptographyAlgorithms :: pbkdf2 ( $ password , $ dynamicSalt . $ staticSalt , $ this -> iterationCount , $ this -> derivedKeyLength , $ this -> algor...
Hash a password for storage using PBKDF2 and the configured parameters . Will use a combination of a random dynamic salt and the given static salt .
59,316
public function getProxyClass ( $ fullClassName ) { if ( interface_exists ( $ fullClassName ) || in_array ( BaseTestCase :: class , class_parents ( $ fullClassName ) ) ) { return false ; } if ( class_exists ( $ fullClassName ) === false ) { return false ; } $ classReflection = new \ ReflectionClass ( $ fullClassName ) ...
Returns a proxy class object for the specified original class .
59,317
public function hasCacheEntryForClass ( $ fullClassName ) { if ( isset ( $ this -> proxyClasses [ $ fullClassName ] ) ) { return false ; } return $ this -> classesCache -> has ( str_replace ( '\\' , '_' , $ fullClassName ) ) ; }
Checks if the specified class still exists in the code cache . If that is the case it means that obviously the proxy class doesn t have to be rebuilt because otherwise the cache would have been flushed by the file monitor or some other mechanism .
59,318
public function compile ( ) { $ classCount = 0 ; foreach ( $ this -> objectManager -> getRegisteredClassNames ( ) as $ fullOriginalClassNames ) { foreach ( $ fullOriginalClassNames as $ fullOriginalClassName ) { if ( isset ( $ this -> proxyClasses [ $ fullOriginalClassName ] ) ) { $ proxyClassCode = $ this -> proxyClas...
Compiles the configured proxy classes and methods as static PHP code and stores it in the proxy class code cache . Also builds the static object container which acts as a registry for non - prototype objects during runtime .
59,319
protected function cacheOriginalClassFileAndProxyCode ( $ className , $ pathAndFilename , $ proxyClassCode ) { $ classCode = file_get_contents ( $ pathAndFilename ) ; $ classCode = $ this -> stripOpeningPhpTag ( $ classCode ) ; $ classNameSuffix = self :: ORIGINAL_CLASSNAME_SUFFIX ; $ classCode = preg_replace_callback ...
Reads the specified class file appends ORIGINAL_CLASSNAME_SUFFIX to its class name and stores the result in the proxy classes cache .
59,320
protected static function renderOptionArrayValueAsString ( array $ optionValue ) { $ values = [ ] ; foreach ( $ optionValue as $ k => $ v ) { $ value = '' ; if ( is_string ( $ k ) ) { $ value .= '"' . $ k . '"=' ; } if ( is_object ( $ v ) ) { $ value .= self :: renderAnnotation ( $ v ) ; } elseif ( is_array ( $ v ) ) {...
Render an array value as string for an annotation .
59,321
public function flushCommand ( bool $ force = false ) { $ this -> cacheManager -> flushCaches ( ) ; $ this -> outputLine ( 'Flushed all caches for "' . $ this -> bootstrap -> getContext ( ) . '" context.' ) ; if ( $ this -> lockManager -> isSiteLocked ( ) ) { $ this -> lockManager -> unlockSite ( ) ; } $ frozenPackages...
Flush all caches
59,322
public function flushOneCommand ( string $ identifier ) { if ( ! $ this -> cacheManager -> hasCache ( $ identifier ) ) { $ this -> outputLine ( 'The cache "%s" does not exist.' , [ $ identifier ] ) ; $ cacheConfigurations = $ this -> cacheManager -> getCacheConfigurations ( ) ; $ shortestDistance = - 1 ; foreach ( arra...
Flushes a particular cache by its identifier
59,323
public function listCommand ( bool $ quiet = false ) { $ cacheConfigurations = $ this -> cacheManager -> getCacheConfigurations ( ) ; $ defaultConfiguration = $ cacheConfigurations [ 'Default' ] ; unset ( $ cacheConfigurations [ 'Default' ] ) ; ksort ( $ cacheConfigurations ) ; $ headers = [ 'Cache' , 'Backend' , 'Stat...
List all configured caches and their status if available
59,324
public function showCommand ( string $ cacheIdentifier ) { try { $ cache = $ this -> cacheManager -> getCache ( $ cacheIdentifier ) ; } catch ( NoSuchCacheException $ exception ) { $ this -> outputLine ( '<error>A Cache with id "%s" is not configured.</error>' , [ $ cacheIdentifier ] ) ; $ this -> outputLine ( 'Use the...
Display details of a cache including a detailed status if available
59,325
public function setupCommand ( string $ cacheIdentifier ) { try { $ cache = $ this -> cacheManager -> getCache ( $ cacheIdentifier ) ; } catch ( NoSuchCacheException $ exception ) { $ this -> outputLine ( '<error>A Cache with id "%s" is not configured.</error>' , [ $ cacheIdentifier ] ) ; $ this -> outputLine ( 'Use th...
Setup the given Cache if possible
59,326
public function setupAllCommand ( bool $ quiet = false ) { $ cacheConfigurations = $ this -> cacheManager -> getCacheConfigurations ( ) ; unset ( $ cacheConfigurations [ 'Default' ] ) ; $ hasErrorsOrWarnings = false ; foreach ( array_keys ( $ cacheConfigurations ) as $ cacheIdentifier ) { $ cache = $ this -> cacheManag...
Setup all Caches
59,327
public function sysCommand ( int $ address ) { if ( $ address === 64738 ) { $ this -> cacheManager -> flushCaches ( ) ; $ content = 'G1syShtbMkobWzE7MzdtG1sxOzQ0bSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtICAgICAgKioqKiBDT01NT0RPUkUgNjQgQkFTSUMgVjIgKioqKiAgICAgIBtbMG0KG1sxOzM3bRt...
Call system function
59,328
private function renderResult ( Result $ result ) { if ( $ result -> hasNotices ( ) ) { foreach ( $ result -> getNotices ( ) as $ notice ) { if ( ! empty ( $ notice -> getTitle ( ) ) ) { $ this -> outputLine ( '<b>%s</b>: %s' , [ $ notice -> getTitle ( ) , $ notice -> render ( ) ] ) ; } else { $ this -> outputLine ( $ ...
Outputs the given Result object in a human - readable way
59,329
protected function resolveView ( ) { $ view = new SimpleTemplateView ( [ 'templateSource' => file_get_contents ( FLOW_PATH_FLOW . 'Resources/Private/Mvc/StandardView_Template.html' ) ] ) ; $ view -> setControllerContext ( $ this -> controllerContext ) ; return $ view ; }
Overrides the standard resolveView method
59,330
public function parse ( string $ pointcutExpression , string $ sourceHint ) : PointcutFilterComposite { $ this -> sourceHint = $ sourceHint ; if ( ! is_string ( $ pointcutExpression ) || strlen ( $ pointcutExpression ) === 0 ) { throw new InvalidPointcutExpressionException ( sprintf ( 'Pointcut expression must be a val...
Parses a string pointcut expression and returns the pointcut objects accordingly
59,331
protected function parseDesignatorClassAnnotatedWith ( string $ operator , string $ annotationPattern , PointcutFilterComposite $ pointcutFilterComposite ) : void { $ annotationPropertyConstraints = [ ] ; $ this -> parseAnnotationPattern ( $ annotationPattern , $ annotationPropertyConstraints ) ; $ filter = new Pointcu...
Takes a class annotation filter pattern and adds a so configured class annotation filter to the filter composite object .
59,332
protected function parseDesignatorClass ( string $ operator , string $ classPattern , PointcutFilterComposite $ pointcutFilterComposite ) : void { $ filter = new PointcutClassNameFilter ( $ classPattern ) ; $ filter -> injectReflectionService ( $ this -> reflectionService ) ; $ pointcutFilterComposite -> addFilter ( $ ...
Takes a class filter pattern and adds a so configured class filter to the filter composite object .
59,333
protected function parseDesignatorMethod ( string $ operator , string $ signaturePattern , PointcutFilterComposite $ pointcutFilterComposite ) : void { if ( strpos ( $ signaturePattern , '->' ) === false ) { throw new InvalidPointcutExpressionException ( 'Syntax error: "->" expected in "' . $ signaturePattern . '", def...
Splits the parameters of the pointcut designator method into a class and a method part and adds the appropriately configured filters to the filter composite object .
59,334
protected function parseDesignatorWithin ( string $ operator , string $ signaturePattern , PointcutFilterComposite $ pointcutFilterComposite ) : void { $ filter = new PointcutClassTypeFilter ( $ signaturePattern ) ; $ filter -> injectReflectionService ( $ this -> reflectionService ) ; $ pointcutFilterComposite -> addFi...
Adds a class type filter to the pointcut filter composite
59,335
protected function parseDesignatorPointcut ( string $ operator , string $ pointcutExpression , PointcutFilterComposite $ pointcutFilterComposite ) : void { if ( strpos ( $ pointcutExpression , '->' ) === false ) { throw new InvalidPointcutExpressionException ( 'Syntax error: "->" expected in "' . $ pointcutExpression ....
Splits the value of the pointcut designator pointcut into an aspect class - and a pointcut method part and adds the appropriately configured filter to the composite object .
59,336
protected function parseDesignatorFilter ( string $ operator , string $ filterObjectName , PointcutFilterComposite $ pointcutFilterComposite ) : void { $ customFilter = $ this -> objectManager -> get ( $ filterObjectName ) ; if ( ! $ customFilter instanceof PointcutFilterInterface ) { throw new InvalidPointcutExpressio...
Adds a custom filter to the pointcut filter composite
59,337
protected function parseDesignatorSetting ( string $ operator , string $ configurationPath , PointcutFilterComposite $ pointcutFilterComposite ) : void { $ filter = new PointcutSettingFilter ( $ configurationPath ) ; $ configurationManager = $ this -> objectManager -> get ( ConfigurationManager :: class ) ; $ filter ->...
Adds a setting filter to the pointcut filter composite
59,338
protected function parseRuntimeEvaluations ( string $ operator , string $ runtimeEvaluations , PointcutFilterComposite $ pointcutFilterComposite ) : void { $ runtimeEvaluationsDefinition = [ $ operator => [ 'evaluateConditions' => $ this -> getRuntimeEvaluationConditionsFromEvaluateString ( $ runtimeEvaluations ) ] ] ;...
Adds runtime evaluations to the pointcut filter composite
59,339
protected function getArgumentConstraintsFromMethodArgumentsPattern ( string $ methodArgumentsPattern ) : array { $ matches = [ ] ; $ argumentConstraints = [ ] ; preg_match_all ( self :: PATTERN_MATCHRUNTIMEEVALUATIONSDEFINITION , $ methodArgumentsPattern , $ matches ) ; $ matchesCount = count ( $ matches [ 0 ] ) ; for...
Parses the method arguments pattern and returns the corresponding constraints array
59,340
protected function getRuntimeEvaluationConditionsFromEvaluateString ( string $ evaluateString ) : array { $ matches = [ ] ; $ runtimeEvaluationConditions = [ ] ; preg_match_all ( self :: PATTERN_MATCHRUNTIMEEVALUATIONSDEFINITION , $ evaluateString , $ matches ) ; $ matchesCount = count ( $ matches [ 0 ] ) ; for ( $ i =...
Parses the evaluate string for runtime evaluations and returns the corresponding conditions array
59,341
public function getSession ( $ sessionIdentifier ) { if ( $ this -> currentSession !== null && $ this -> currentSession -> isStarted ( ) && $ this -> currentSession -> getId ( ) === $ sessionIdentifier ) { return $ this -> currentSession ; } if ( isset ( $ this -> remoteSessions [ $ sessionIdentifier ] ) ) { return $ t...
Returns the specified session . If no session with the given identifier exists NULL is returned .
59,342
public function getActiveSessions ( ) { $ activeSessions = [ ] ; foreach ( $ this -> metaDataCache -> getByTag ( 'session' ) as $ sessionIdentifier => $ sessionInfo ) { $ session = new Session ( $ sessionIdentifier , $ sessionInfo [ 'storageIdentifier' ] , $ sessionInfo [ 'lastActivityTimestamp' ] , $ sessionInfo [ 'ta...
Returns all active sessions even remote ones .
59,343
public function getSessionsByTag ( $ tag ) { $ taggedSessions = [ ] ; foreach ( $ this -> metaDataCache -> getByTag ( Session :: TAG_PREFIX . $ tag ) as $ sessionIdentifier => $ sessionInfo ) { $ session = new Session ( $ sessionIdentifier , $ sessionInfo [ 'storageIdentifier' ] , $ sessionInfo [ 'lastActivityTimestamp...
Returns all sessions which are tagged by the specified tag .
59,344
public function destroySessionsByTag ( $ tag , $ reason = '' ) { $ sessions = $ this -> getSessionsByTag ( $ tag ) ; foreach ( $ sessions as $ session ) { $ session -> destroy ( $ reason ) ; } return count ( $ sessions ) ; }
Destroys all sessions which are tagged with the specified tag .
59,345
public function getMethodArgument ( $ argumentName ) { if ( ! array_key_exists ( $ argumentName , $ this -> methodArguments ) ) { throw new InvalidArgumentException ( 'The argument "' . $ argumentName . '" does not exist in method ' . $ this -> className . '->' . $ this -> methodName , 1172750905 ) ; } return $ this ->...
Returns the value of the specified method argument
59,346
public function setMethodArgument ( $ argumentName , $ argumentValue ) : void { if ( ! array_key_exists ( $ argumentName , $ this -> methodArguments ) ) { throw new InvalidArgumentException ( 'The argument "' . $ argumentName . '" does not exist in method ' . $ this -> className . '->' . $ this -> methodName , 13092602...
Sets the value of the specified method argument
59,347
public function detectLocaleFromHttpHeader ( $ acceptLanguageHeader ) { $ acceptableLanguages = I18n \ Utility :: parseAcceptLanguageHeader ( $ acceptLanguageHeader ) ; if ( $ acceptableLanguages === false ) { return $ this -> localizationService -> getConfiguration ( ) -> getDefaultLocale ( ) ; } foreach ( $ acceptabl...
Returns best - matching Locale object based on the Accept - Language header provided as parameter . System default locale will be returned if no successful matches were done .
59,348
public function detectLocaleFromLocaleTag ( $ localeIdentifier ) { try { return $ this -> detectLocaleFromTemplateLocale ( new Locale ( $ localeIdentifier ) ) ; } catch ( Exception \ InvalidLocaleIdentifierException $ exception ) { return $ this -> localizationService -> getConfiguration ( ) -> getDefaultLocale ( ) ; }...
Returns best - matching Locale object based on the locale identifier provided as parameter . System default locale will be returned if no successful matches were done .
59,349
public function detectLocaleFromTemplateLocale ( Locale $ locale ) { $ bestMatchingLocale = $ this -> localeCollection -> findBestMatchingLocale ( $ locale ) ; if ( $ bestMatchingLocale !== null ) { return $ bestMatchingLocale ; } return $ this -> localizationService -> getConfiguration ( ) -> getDefaultLocale ( ) ; }
Returns best - matching Locale object based on the template Locale object provided as parameter . System default locale will be returned if no successful matches were done .
59,350
public function getCachedMatchResults ( RouteContext $ routeContext ) { $ cachedResult = $ this -> routeCache -> get ( $ routeContext -> getCacheEntryIdentifier ( ) ) ; if ( $ cachedResult !== false ) { $ this -> logger -> debug ( sprintf ( 'Router route(): A cached Route with the cache identifier "%s" matched the requ...
Checks the cache for the given RouteContext and returns the result or false if no matching ache entry was found
59,351
public function getCachedResolvedUriConstraints ( ResolveContext $ resolveContext ) { $ routeValues = $ this -> convertObjectsToHashes ( $ resolveContext -> getRouteValues ( ) ) ; if ( $ routeValues === null ) { return false ; } return $ this -> resolveCache -> get ( $ this -> buildResolveCacheIdentifier ( $ resolveCon...
Checks the cache for the given ResolveContext and returns the cached UriConstraints if a cache entry is found
59,352
protected function convertObjectsToHashes ( array $ routeValues ) { foreach ( $ routeValues as & $ value ) { if ( is_object ( $ value ) ) { if ( $ value instanceof CacheAwareInterface ) { $ identifier = $ value -> getCacheEntryIdentifier ( ) ; } else { $ identifier = $ this -> persistenceManager -> getIdentifierByObjec...
Recursively converts objects in an array to their identifiers
59,353
protected function buildResolveCacheIdentifier ( ResolveContext $ resolveContext , array $ routeValues ) { Arrays :: sortKeysRecursively ( $ routeValues ) ; return md5 ( sprintf ( 'abs:%s|prefix:%s|routeValues:%s' , $ resolveContext -> isForceAbsoluteUri ( ) ? 1 : 0 , $ resolveContext -> getUriPathPrefix ( ) , trim ( h...
Generates the Resolve cache identifier for the given Request
59,354
public function withParameter ( string $ parameterName , $ parameterValue ) : self { if ( ! TypeHandling :: isLiteral ( gettype ( $ parameterValue ) ) && ( ! $ parameterValue instanceof CacheAwareInterface ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Parameter values must be literal types or implement the Ca...
Create a new instance adding the given parameter
59,355
public static function generateSaltedMd5 ( $ clearString ) { $ salt = substr ( md5 ( rand ( ) . Utility \ Algorithms :: generateRandomString ( 23 ) ) , 0 , rand ( 6 , 10 ) ) ; return ( md5 ( md5 ( $ clearString ) . $ salt ) . ',' . $ salt ) ; }
Generates a salted md5 hash over the given string .
59,356
public function outputLine ( string $ text = '' , array $ arguments = [ ] ) : void { $ this -> output ( $ text . PHP_EOL , $ arguments ) ; }
Outputs specified text to the console window and appends a line break
59,357
public function outputFormatted ( string $ text = '' , array $ arguments = [ ] , int $ leftPadding = 0 ) : void { $ lines = explode ( PHP_EOL , $ text ) ; foreach ( $ lines as $ line ) { $ formattedText = str_repeat ( ' ' , $ leftPadding ) . wordwrap ( $ line , $ this -> getMaximumLineLength ( ) - $ leftPadding , PHP_E...
Formats the given text to fit into the maximum line length and outputs it to the console window
59,358
public function select ( $ question , array $ choices , $ default = null , bool $ multiSelect = false , int $ attempts = null ) { $ question = new ChoiceQuestion ( $ this -> combineQuestion ( $ question ) , $ choices , $ default ) ; $ question -> setMaxAttempts ( $ attempts ) -> setMultiselect ( $ multiSelect ) -> setE...
Asks the user to select a value
59,359
public function ask ( $ question , string $ default = null ) { $ question = new Question ( $ this -> combineQuestion ( $ question ) , $ default ) ; return $ this -> getQuestionHelper ( ) -> ask ( $ this -> input , $ this -> output , $ question ) ; }
Asks a question to the user
59,360
public function askConfirmation ( $ question , bool $ default = true ) : bool { $ question = new ConfirmationQuestion ( $ this -> combineQuestion ( $ question ) , $ default ) ; return $ this -> getQuestionHelper ( ) -> ask ( $ this -> input , $ this -> output , $ question ) ; }
Asks a confirmation to the user .
59,361
public function askHiddenResponse ( $ question , bool $ fallback = true ) { $ question = new Question ( $ this -> combineQuestion ( $ question ) ) ; $ question -> setHidden ( true ) -> setHiddenFallback ( $ fallback ) ; return $ this -> getQuestionHelper ( ) -> ask ( $ this -> input , $ this -> output , $ question ) ; ...
Asks a question to the user the response is hidden
59,362
public function askAndValidate ( $ question , callable $ validator , int $ attempts = null , string $ default = null ) { $ question = new Question ( $ this -> combineQuestion ( $ question ) , $ default ) ; $ question -> setValidator ( $ validator ) -> setMaxAttempts ( $ attempts ) ; return $ this -> getQuestionHelper (...
Asks for a value and validates the response
59,363
public function askHiddenResponseAndValidate ( $ question , callable $ validator , int $ attempts = null , bool $ fallback = true ) { $ question = new Question ( $ this -> combineQuestion ( $ question ) ) ; $ question -> setHidden ( true ) -> setHiddenFallback ( $ fallback ) -> setValidator ( $ validator ) -> setMaxAtt...
Asks for a value hide and validates the response
59,364
public static function createFileMonitorAtBoot ( $ identifier , Bootstrap $ bootstrap ) { $ fileMonitorCache = $ bootstrap -> getEarlyInstance ( CacheManager :: class ) -> getCache ( 'Flow_Monitor' ) ; $ fileChangeDetector = new ChangeDetectionStrategy \ ModificationTimeStrategy ( ) ; $ fileChangeDetector -> injectCach...
Helper method to create a FileMonitor instance during boot sequence as injections have to be done manually .
59,365
public function injectChangeDetectionStrategy ( ChangeDetectionStrategyInterface $ changeDetectionStrategy ) { $ this -> changeDetectionStrategy = $ changeDetectionStrategy ; $ this -> changeDetectionStrategy -> setFileMonitor ( $ this ) ; }
Injects the Change Detection Strategy
59,366
public function monitorFile ( $ pathAndFilename ) { if ( ! is_string ( $ pathAndFilename ) ) { throw new \ InvalidArgumentException ( 'String expected, ' . gettype ( $ pathAndFilename ) , ' given.' , 1231171809 ) ; } $ pathAndFilename = Files :: getUnixStylePath ( $ pathAndFilename ) ; if ( array_search ( $ pathAndFile...
Adds the specified file to the list of files to be monitored . The file in question does not necessarily have to exist .
59,367
public function monitorDirectory ( $ path , $ filenamePattern = null ) { if ( ! is_string ( $ path ) ) { throw new \ InvalidArgumentException ( 'String expected, ' . gettype ( $ path ) , ' given.' , 1231171810 ) ; } $ path = Files :: getNormalizedPath ( Files :: getUnixStylePath ( $ path ) ) ; if ( ! array_key_exists (...
Adds the specified directory to the list of directories to be monitored . All files in these directories will be monitored too .
59,368
public function detectChanges ( ) { if ( $ this -> changedFiles === null || $ this -> changedPaths === null ) { $ this -> loadDetectedDirectoriesAndFiles ( ) ; $ changesDetected = false ; $ this -> changedPaths = $ this -> changedFiles = [ ] ; $ this -> changedFiles = $ this -> detectChangedFiles ( $ this -> monitoredF...
Detects changes of the files and directories to be monitored and emits signals accordingly .
59,369
protected function detectChangesOnPath ( $ path , $ filenamePattern ) { $ currentDirectoryChanged = false ; try { $ currentSubDirectoriesAndFiles = $ this -> readMonitoredDirectoryRecursively ( $ path , $ filenamePattern ) ; } catch ( \ Exception $ exception ) { $ currentSubDirectoriesAndFiles = [ ] ; $ this -> changed...
Detect changes for one of the monitored paths .
59,370
protected function readMonitoredDirectoryRecursively ( $ path , $ filenamePattern ) { $ directories = [ Files :: getNormalizedPath ( $ path ) ] ; while ( $ directories !== [ ] ) { $ currentDirectory = array_pop ( $ directories ) ; if ( is_file ( $ currentDirectory . '.flowFileMonitorIgnore' ) ) { continue ; } if ( $ ha...
Read a monitored directory recursively taking into account filename patterns
59,371
protected function loadDetectedDirectoriesAndFiles ( ) { if ( $ this -> directoriesAndFiles === null ) { $ this -> directoriesAndFiles = json_decode ( $ this -> cache -> get ( $ this -> identifier . '_directoriesAndFiles' ) , true ) ; if ( ! is_array ( $ this -> directoriesAndFiles ) ) { $ this -> directoriesAndFiles =...
Loads the last detected files for this monitor .
59,372
protected function detectChangedFiles ( array $ pathAndFilenames ) { $ changedFiles = [ ] ; foreach ( $ pathAndFilenames as $ pathAndFilename ) { $ status = $ this -> changeDetectionStrategy -> getFileStatus ( $ pathAndFilename ) ; if ( $ status !== ChangeDetectionStrategyInterface :: STATUS_UNCHANGED ) { $ changedFile...
Detects changes in the given list of files and emits signals if necessary .
59,373
public function setColorizeArray ( array $ colorScheme ) { $ allowedLogLevels = array_values ( \ Monolog \ Logger :: getLevels ( ) ) ; $ colorScheme = array_intersect_key ( $ colorScheme , array_flip ( $ allowedLogLevels ) ) ; $ this -> colorScheme = $ colorScheme ; }
Set the Color Scheme Array
59,374
protected function getModifiedSince ( ) : \ DateTime { if ( is_null ( $ this -> since ) ) { $ this -> since = new \ DateTime ( '@0' ) ; } return $ this -> since ; }
Extract the If - Modified - Since value from the headers .
59,375
public function drop ( $ _ , $ assoc_args ) { WP_CLI :: confirm ( "Are you sure you want to drop the '" . DB_NAME . "' database?" , $ assoc_args ) ; self :: run_query ( sprintf ( 'DROP DATABASE `%s`' , DB_NAME ) , self :: get_dbuser_dbpass_args ( $ assoc_args ) ) ; WP_CLI :: success ( 'Database dropped.' ) ; }
Deletes the existing database .
59,376
public function reset ( $ _ , $ assoc_args ) { WP_CLI :: confirm ( "Are you sure you want to reset the '" . DB_NAME . "' database?" , $ assoc_args ) ; $ mysql_args = self :: get_dbuser_dbpass_args ( $ assoc_args ) ; self :: run_query ( sprintf ( 'DROP DATABASE IF EXISTS `%s`' , DB_NAME ) , $ mysql_args ) ; self :: run_...
Removes all tables from the database .
59,377
public function check ( $ _ , $ assoc_args ) { $ assoc_args [ 'check' ] = true ; self :: run ( Utils \ esc_cmd ( '/usr/bin/env mysqlcheck --no-defaults %s' , DB_NAME ) , $ assoc_args ) ; WP_CLI :: success ( 'Database checked.' ) ; }
Checks the current status of the database .
59,378
public function cli ( $ args , $ assoc_args ) { if ( ! isset ( $ assoc_args [ 'database' ] ) ) { $ assoc_args [ 'database' ] = DB_NAME ; } self :: run ( '/usr/bin/env mysql --no-defaults --no-auto-rehash' , $ assoc_args ) ; }
Opens a MySQL console using credentials from wp - config . php
59,379
public function query ( $ args , $ assoc_args ) { $ assoc_args [ 'database' ] = DB_NAME ; if ( ! empty ( $ args ) ) { $ assoc_args [ 'execute' ] = $ args [ 0 ] ; } self :: run ( '/usr/bin/env mysql --no-defaults --no-auto-rehash' , $ assoc_args ) ; }
Executes a SQL query against the database .
59,380
public function export ( $ args , $ assoc_args ) { if ( ! empty ( $ args [ 0 ] ) ) { $ result_file = $ args [ 0 ] ; } else { $ hash = substr ( md5 ( mt_rand ( ) ) , 0 , 7 ) ; $ result_file = sprintf ( '%s-%s-%s.sql' , DB_NAME , date ( 'Y-m-d' ) , $ hash ) ; } $ stdout = ( '-' === $ result_file ) ; $ porcelain = Utils \...
Exports the database to a file or to STDOUT .
59,381
public function import ( $ args , $ assoc_args ) { if ( ! empty ( $ args [ 0 ] ) ) { $ result_file = $ args [ 0 ] ; } else { $ result_file = sprintf ( '%s.sql' , DB_NAME ) ; } $ mysql_args = array ( 'database' => DB_NAME , ) ; $ mysql_args = array_merge ( self :: get_dbuser_dbpass_args ( $ assoc_args ) , $ mysql_args )...
Imports a database from a file or from STDIN .
59,382
public function tables ( $ args , $ assoc_args ) { $ format = Utils \ get_flag_value ( $ assoc_args , 'format' ) ; unset ( $ assoc_args [ 'format' ] ) ; if ( empty ( $ args ) && empty ( $ assoc_args ) ) { $ assoc_args [ 'scope' ] = 'all' ; } $ tables = Utils \ wp_get_table_names ( $ args , $ assoc_args ) ; if ( 'csv' =...
Lists the database tables .
59,383
public function columns ( $ args , $ assoc_args ) { global $ wpdb ; $ format = Utils \ get_flag_value ( $ assoc_args , 'format' ) ; Utils \ wp_get_table_names ( array ( $ args [ 0 ] ) , array ( ) ) ; $ columns = $ wpdb -> get_results ( 'SHOW COLUMNS FROM ' . $ args [ 0 ] ) ; $ formatter_fields = array ( 'Field' , 'Type...
Displays information about a given table .
59,384
private static function get_dbuser_dbpass_args ( $ assoc_args ) { $ mysql_args = array ( ) ; $ dbuser = Utils \ get_flag_value ( $ assoc_args , 'dbuser' ) ; if ( null !== $ dbuser ) { $ mysql_args [ 'dbuser' ] = $ dbuser ; } $ dbpass = Utils \ get_flag_value ( $ assoc_args , 'dbpass' ) ; if ( null !== $ dbpass ) { $ my...
Helper to pluck dbuser and dbpass from associative args array .
59,385
private static function get_columns ( $ table ) { global $ wpdb ; $ table_sql = self :: esc_sql_ident ( $ table ) ; $ primary_keys = array ( ) ; $ text_columns = array ( ) ; $ all_columns = array ( ) ; $ suppress_errors = $ wpdb -> suppress_errors ( ) ; $ results = $ wpdb -> get_results ( "DESCRIBE $table_sql" ) ; if (...
Gets the column names of a db table differentiated into key columns and text columns and all columns .
59,386
private static function get_mysql_args ( $ assoc_args ) { $ allowed_mysql_options = [ 'auto-rehash' , 'auto-vertical-output' , 'batch' , 'binary-as-hex' , 'binary-mode' , 'bind-address' , 'character-sets-dir' , 'column-names' , 'column-type-info' , 'comments' , 'compress' , 'connect-expired-password' , 'connect_timeout...
Helper to pluck mysql options from associative args array .
59,387
public function createSharedLinkWithSettings ( string $ path , array $ settings = [ ] ) { $ parameters = [ 'path' => $ this -> normalizePath ( $ path ) , ] ; if ( count ( $ settings ) ) { $ parameters = array_merge ( compact ( 'settings' ) , $ parameters ) ; } return $ this -> rpcEndpointRequest ( 'sharing/create_share...
Create a shared link with custom settings .
59,388
public function listSharedLinks ( string $ path = null , bool $ direct_only = false , string $ cursor = null ) : array { $ parameters = [ 'path' => $ path ? $ this -> normalizePath ( $ path ) : null , 'cursor' => $ cursor , 'direct_only' => $ direct_only , ] ; $ body = $ this -> rpcEndpointRequest ( 'sharing/list_share...
List shared links .
59,389
public function regenerate ( $ args , $ assoc_args = array ( ) ) { $ assoc_args = wp_parse_args ( $ assoc_args , [ 'image_size' => '' ] ) ; $ image_size = $ assoc_args [ 'image_size' ] ; if ( $ image_size && ! in_array ( $ image_size , get_intermediate_image_sizes ( ) , true ) ) { WP_CLI :: error ( sprintf ( 'Unknown i...
Regenerates thumbnails for one or more attachments .
59,390
public function image_size ( $ args , $ assoc_args ) { $ assoc_args = array_merge ( array ( 'fields' => 'name,width,height,crop,ratio' , ) , $ assoc_args ) ; $ sizes = $ this -> get_registered_image_sizes ( ) ; usort ( $ sizes , function ( $ a , $ b ) { if ( $ a [ 'width' ] === $ b [ 'width' ] ) { return 0 ; } return (...
Lists image sizes registered with WordPress .
59,391
private function remove_image_size_filters ( $ image_size_filters ) { foreach ( $ image_size_filters as $ name => $ filter ) { remove_filter ( $ name , $ filter , PHP_INT_MAX ) ; } }
Remove above intermediate image size filters .
59,392
private function update_attachment_metadata_for_image_size ( $ id , $ new_metadata , $ image_size ) { $ metadata = wp_get_attachment_metadata ( $ id ) ; if ( ! is_array ( $ metadata ) ) { return false ; } if ( ! empty ( $ new_metadata [ 'sizes' ] [ $ image_size ] ) ) { $ metadata [ 'sizes' ] [ $ image_size ] = $ new_me...
Update attachment sizes metadata just for a particular intermediate image size .
59,393
private function get_images ( $ args = array ( ) , $ additional_mime_types = array ( ) ) { $ mime_types = array_merge ( array ( 'image' ) , $ additional_mime_types ) ; $ query_args = array ( 'post_type' => 'attachment' , 'post__in' => $ args , 'post_mime_type' => $ mime_types , 'post_status' => 'any' , 'posts_per_page'...
Get images from the installation .
59,394
private function get_intermediate_size_metadata ( $ size ) { $ width = intval ( get_option ( "{$size}_size_w" ) ) ; $ height = intval ( get_option ( "{$size}_size_h" ) ) ; $ crop = get_option ( "{$size}_crop" ) ; return array ( 'name' => $ size , 'width' => $ width , 'height' => $ height , 'crop' => false !== $ crop ? ...
Get the metadata for the passed intermediate image size .
59,395
private function get_registered_image_sizes ( ) { global $ _wp_additional_image_sizes ; $ image_sizes = array ( ) ; $ default_image_sizes = get_intermediate_image_sizes ( ) ; foreach ( $ default_image_sizes as $ size ) { $ image_sizes [ ] = $ this -> get_intermediate_size_metadata ( $ size ) ; } if ( is_array ( $ _wp_a...
Get all the registered image sizes along with their dimensions .
59,396
public function clear ( ) { $ this -> groups = array ( ) ; $ this -> users = array ( ) ; $ this -> percentage = 0 ; $ this -> requestParam = '' ; $ this -> data = array ( ) ; }
Clear the feature of all configuration
59,397
public function isActive ( Rollout $ rollout , RolloutUserInterface $ user = null , array $ requestParameters = array ( ) ) { if ( null == $ user ) { return $ this -> isParamInRequestParams ( $ requestParameters ) || $ this -> percentage == 100 || $ this -> isInActiveGroup ( $ rollout ) ; } return $ this -> isParamInRe...
Is the feature active?
59,398
public function remove ( $ feature ) { $ this -> storage -> remove ( $ this -> key ( $ feature ) ) ; $ features = $ this -> features ( ) ; if ( in_array ( $ feature , $ features ) ) { $ features = array_diff ( $ features , array ( $ feature ) ) ; } $ this -> storage -> set ( $ this -> featuresKey ( ) , implode ( ',' , ...
Remove a feature definition from rollout
59,399
public function setFeatureData ( $ feature , array $ data ) { $ feature = $ this -> get ( $ feature ) ; if ( $ feature ) { $ feature -> setData ( array_merge ( $ feature -> getData ( ) , $ data ) ) ; $ this -> save ( $ feature ) ; } }
Update feature specific data