idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
56,500
private static function checkSeqType ( $ seqTp ) { $ seqTp = strtoupper ( $ seqTp ) ; if ( in_array ( $ seqTp , [ self :: SEQUENCE_TYPE_FIRST , self :: SEQUENCE_TYPE_RECURRING , self :: SEQUENCE_TYPE_ONCE , self :: SEQUENCE_TYPE_FINAL ] ) ) return $ seqTp ; return false ; }
Checks if the sequence type is valid .
56,501
public static function version2string ( $ version ) { switch ( $ version ) { case self :: SEPA_PAIN_001_001_03_GBIC : case self :: SEPA_PAIN_001_001_03 : return 'pain.001.001.03' ; case self :: SEPA_PAIN_001_002_03 : return 'pain.001.002.03' ; case self :: SEPA_PAIN_001_003_03 : return 'pain.001.003.03' ; case self :: SEPA_PAIN_008_001_02_GBIC : case self :: SEPA_PAIN_008_001_02_AUSTRIAN_003 : case self :: SEPA_PAIN_008_001_02 : return 'pain.008.001.02' ; case self :: SEPA_PAIN_008_002_02 : return 'pain.008.002.02' ; case self :: SEPA_PAIN_008_003_02 : return 'pain.008.003.02' ; default : return false ; } }
Returns the SEPA file version as a string .
56,502
public function createBridge ( IOInterface $ io ) : NpmBridge { return new NpmBridge ( $ io , $ this -> vendorFinder , $ this -> client ) ; }
Construct a new Composer NPM bridge plugin .
56,503
public function getEscapedString ( ) { if ( $ this -> escapedString === null ) { $ this -> escapedString = str_replace ( '-' , ' ' , $ this -> escape ( $ this -> getRawString ( ) ) ) ; $ this -> escapedString = preg_replace ( [ '/\s+([0-9])/' , '/\s+/' ] , [ '$1' , ' ' ] , $ this -> escapedString ) ; } return $ this -> escapedString ; }
Remove spaces before numbers in order to avoid search errors Remove all dashes
56,504
public static function parse ( $ url ) { $ scheme = substr ( $ url , 0 , strpos ( $ url , ':' ) ) ; if ( strpos ( $ scheme , '+' ) ) { $ scheme = substr ( $ scheme , 0 , strpos ( $ scheme , '+' ) ) ; } if ( ! $ scheme ) { throw new \ Exception ( sprintf ( 'The url \'%s\' could not be parsed' , $ url ) ) ; } if ( isset ( static :: $ schemeMap [ $ scheme ] ) ) { $ className = static :: $ schemeMap [ $ scheme ] ; } else { $ className = static :: currentNamespace ( ) . '\\' . ucfirst ( $ scheme ) . 'Dsn' ; if ( ! class_exists ( $ className ) ) { $ className = static :: currentClass ( ) ; } } return new $ className ( $ url ) ; }
parse a dsn string into a dsn instance
56,505
public static function map ( $ scheme = null , $ class = null ) { if ( is_array ( $ scheme ) ) { foreach ( $ scheme as $ s => $ class ) { static :: map ( $ s , $ class ) ; } return static :: $ schemeMap ; } if ( $ scheme === null ) { return static :: $ schemeMap ; } if ( $ class === null ) { return isset ( static :: $ schemeMap [ $ scheme ] ) ? static :: $ schemeMap [ $ scheme ] : null ; } if ( $ class === false ) { unset ( $ schemeMap [ $ scheme ] ) ; return ; } return static :: $ schemeMap [ $ scheme ] = $ class ; }
Read or change the scheme map
56,506
public function defaultPort ( $ port = null ) { if ( ! is_null ( $ port ) ) { $ this -> defaultPort = ( int ) $ port ; if ( $ this -> url [ 'port' ] === null ) { $ this -> url [ 'port' ] = $ this -> defaultPort ; } } return $ this -> defaultPort ; }
Get or set the default port
56,507
protected function parseUrlArray ( $ url ) { if ( strpos ( $ url [ 'scheme' ] , '+' ) ) { list ( $ url [ 'scheme' ] , $ url [ 'adapter' ] ) = explode ( '+' , $ url [ 'scheme' ] ) ; } $ defaultPort = $ this -> defaultPort ( ) ; if ( $ defaultPort && empty ( $ url [ 'port' ] ) ) { $ url [ 'port' ] = $ defaultPort ; } if ( isset ( $ url [ 'query' ] ) ) { $ extra = [ ] ; parse_str ( $ url [ 'query' ] , $ extra ) ; unset ( $ url [ 'query' ] ) ; $ url += $ extra ; } $ url = array_merge ( $ this -> uriKeys , $ url ) ; foreach ( [ 'host' , 'user' , 'pass' ] as $ key ) { if ( ! isset ( $ url [ $ key ] ) ) { continue ; } $ url [ $ key ] = urldecode ( $ url [ $ key ] ) ; } foreach ( $ url as $ key => $ val ) { $ setter = 'set' . ucfirst ( $ key ) ; $ this -> $ setter ( $ val ) ; } }
Worker function for parseUrl
56,508
protected function toUrlArray ( $ data ) { $ url = array_intersect_key ( $ data , $ this -> uriKeys ) ; foreach ( [ 'host' , 'user' , 'pass' ] as $ key ) { if ( ! isset ( $ url [ $ key ] ) ) { continue ; } $ url [ $ key ] = urlencode ( $ url [ $ key ] ) ; } if ( $ url [ 'adapter' ] ) { $ return = $ url [ 'scheme' ] . '+' . $ url [ 'adapter' ] . '://' ; } else { $ return = $ url [ 'scheme' ] . '://' ; } if ( ! empty ( $ url [ 'user' ] ) ) { $ return .= $ url [ 'user' ] ; if ( ! empty ( $ url [ 'pass' ] ) ) { $ return .= ':' . $ url [ 'pass' ] ; } $ return .= '@' ; } $ return .= $ url [ 'host' ] ; $ defaultPort = $ this -> defaultPort ( ) ; if ( ! empty ( $ url [ 'port' ] ) && $ url [ 'port' ] != $ defaultPort ) { $ return .= ':' . $ url [ 'port' ] ; } $ return .= $ url [ 'path' ] ; $ query = array_diff_key ( $ data , $ this -> uriKeys ) ; if ( $ query ) { foreach ( $ query as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ intermediate = [ ] ; foreach ( $ value as $ k => $ v ) { $ v = urlencode ( $ v ) ; $ intermediate [ ] = "{$key}[$k]=$v" ; } $ value = implode ( $ intermediate , '&' ) ; continue ; } $ value = "$key=$value" ; } $ return .= '?' . implode ( $ query , '&' ) ; } return $ return ; }
Worker function for toUrl - does not rely on instance state
56,509
protected function _addFilter ( $ facetName , $ value ) { if ( isset ( $ this -> filters [ $ facetName ] ) ) { $ currentValue = $ this -> filters [ $ facetName ] ; if ( ! is_array ( $ currentValue ) ) { $ currentValue = array ( $ currentValue ) ; } $ currentValue [ ] = $ value ; $ value = $ currentValue ; } $ this -> filters [ $ facetName ] = $ value ; }
Add new filter without overwriting existing filters
56,510
private function isValidAttributeFilterValue ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ subValue ) { if ( ! $ this -> isValidAttributeFilterValue ( $ subValue ) ) { return false ; } } return true ; } return ctype_digit ( $ value ) ; }
Value must be an option ID or an array of option IDs
56,511
public static function studlyCase ( $ string ) { $ string = Strings :: capitalize ( Strings :: replace ( $ string , [ '/-/' , '/_/' ] , ' ' ) ) ; return Strings :: replace ( $ string , '/ /' ) ; }
Converts the given string to StudlyCase
56,512
public static function spinalCase ( $ string ) { preg_match_all ( '/([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)/' , $ string , $ matches ) ; $ matches = $ matches [ 0 ] ; foreach ( $ matches as & $ match ) { $ match = ( $ match == Strings :: upper ( $ match ) ) ? Strings :: lower ( $ match ) : Strings :: firstLower ( $ match ) ; } return implode ( '-' , $ matches ) ; }
Converts the given string to spinal - case
56,513
public function appendService ( ServiceBase $ successor ) { if ( $ this -> successor !== null ) { $ this -> successor -> appendService ( $ successor ) ; } else { $ this -> successor = $ successor ; } }
Append service to chain of responsibility
56,514
protected function _constructBaseUrl ( $ servlet , $ params = array ( ) ) { if ( count ( $ params ) ) { $ escapedParams = array ( ) ; foreach ( $ params as $ key => $ value ) { $ escapedParams [ ] = urlencode ( $ key ) . '=' . urlencode ( $ value ) ; } $ queryString = $ this -> _queryDelimiter . implode ( $ this -> _queryStringDelimiter , $ escapedParams ) ; } else { $ queryString = '' ; } if ( ! $ this -> _basePath ) { throw new Exception ( 'Please provide a base path' ) ; } $ protocol = 'http://' ; if ( $ this -> _useHttps ) { $ protocol = 'https://' ; } return $ protocol . $ this -> _host . ':' . $ this -> _port . $ this -> _basePath . $ servlet . $ queryString ; }
Return a valid http URL given this server s host port and path and a provided servlet name Exclude core name from
56,515
public function swapCores ( $ core , $ otherCore , $ method = self :: METHOD_GET ) { if ( ! $ this -> _coresUrl ) { throw new Exception ( 'Please call "setBasePath" before.' ) ; } $ params = array ( ) ; $ params [ 'action' ] = 'SWAP' ; $ params [ 'core' ] = $ core ; $ params [ 'other' ] = $ otherCore ; $ queryString = $ this -> _generateQueryString ( $ params ) ; if ( $ method == self :: METHOD_GET ) { return $ this -> _sendRawGet ( $ this -> _coresUrl . $ this -> _queryDelimiter . $ queryString ) ; } else if ( $ method == self :: METHOD_POST ) { return $ this -> _sendRawPost ( $ this -> _coresUrl , $ queryString , FALSE , 'application/x-www-form-urlencoded; charset=UTF-8' ) ; } else { throw new Apache_Solr_InvalidArgumentException ( "Unsupported method '$method', please use the Service::METHOD_* constants" ) ; } }
core swap interface
56,516
public function info ( $ method = self :: METHOD_GET ) { if ( ! $ this -> _infoUrl ) { throw new Exception ( 'Please call "setBasePath" before.' ) ; } $ params = array ( ) ; $ params [ 'wt' ] = 'json' ; $ queryString = $ this -> _generateQueryString ( $ params ) ; if ( $ method == self :: METHOD_GET ) { return $ this -> _sendRawGet ( $ this -> _infoUrl . $ this -> _queryDelimiter . $ queryString ) ; } else if ( $ method == self :: METHOD_POST ) { return $ this -> _sendRawPost ( $ this -> _infoUrl , $ queryString , FALSE , 'application/x-www-form-urlencoded; charset=UTF-8' ) ; } else { throw new Apache_Solr_InvalidArgumentException ( "Unsupported method '$method', please use the Service::METHOD_* constants" ) ; } }
admin info interface
56,517
public function exclude ( array $ names ) { $ filtered = clone $ this ; foreach ( $ names as $ name ) { unset ( $ filtered [ $ name ] ) ; } return $ filtered ; }
Returns new collection without the given field names
56,518
public function install ( Composer $ composer , bool $ isDevMode = true ) { $ this -> io -> write ( '<info>Installing NPM dependencies for root project</info>' ) ; $ package = $ composer -> getPackage ( ) ; if ( $ this -> isDependantPackage ( $ package , $ isDevMode ) ) { $ isNpmAvailable = $ this -> client -> isAvailable ( ) ; $ extra = $ package -> getExtra ( ) ; if ( ! $ isNpmAvailable && $ this -> isPackageOptional ( $ extra ) ) { $ this -> io -> write ( 'Skipping as NPM is unavailable' ) ; } else { $ this -> client -> install ( null , $ isDevMode , $ this -> packageTimeout ( $ extra ) ) ; } } else { $ this -> io -> write ( 'Nothing to install' ) ; } $ this -> installForVendors ( $ composer ) ; }
Install NPM dependencies for a Composer project and its dependencies .
56,519
public function update ( Composer $ composer ) { $ this -> io -> write ( '<info>Updating NPM dependencies for root project</info>' ) ; $ package = $ composer -> getPackage ( ) ; if ( $ this -> isDependantPackage ( $ package , true ) ) { $ timeout = $ this -> packageTimeout ( $ package -> getExtra ( ) ) ; $ this -> client -> update ( null , $ timeout ) ; $ this -> client -> install ( null , true , $ timeout ) ; } else { $ this -> io -> write ( 'Nothing to update' ) ; } $ this -> installForVendors ( $ composer ) ; }
Update NPM dependencies for a Composer project and its dependencies .
56,520
public function toUrl ( ) { $ url = $ this -> url ; unset ( $ url [ 'engine' ] , $ url [ 'database' ] ) ; $ url [ 'scheme' ] = $ this -> getScheme ( ) ; $ url [ 'path' ] = $ this -> getPath ( ) ; return $ this -> toUrlArray ( $ url ) ; }
return this instance as a dsn url string
56,521
public static function containsCaseless ( $ haystack , $ needles ) { foreach ( ( array ) $ needles as $ needle ) { $ needle = preg_quote ( $ needle ) ; if ( $ needle != '' && preg_match ( "/$needle/iu" , $ haystack ) ) { return true ; } } return false ; }
Taken from Illuminate \ Support \ Str Determine if a given string contains a given word with case insensitive match .
56,522
public function getServerInfo ( ) { return sprintf ( '%s:%s%s%s' , $ this -> host , $ this -> port , $ this -> path , $ this -> core ) ; }
Return unique resource identifier for solr core
56,523
public function __isset ( $ key ) { if ( ! $ this -> _isParsed ) { $ this -> _parseData ( ) ; $ this -> _isParsed = true ; } return isset ( $ this -> _parsedData -> $ key ) ; }
Magic function for isset function on parsed data
56,524
protected function _parseData ( ) { $ data = json_decode ( $ this -> _response -> getBody ( ) ) ; if ( $ data === null ) { throw new Apache_Solr_ParserException ( 'Solr response does not appear to be valid JSON, please examine the raw response with getRawResponse() method' ) ; } if ( ( $ this -> _createDocuments || $ this -> _collapseSingleValueArrays ) && isset ( $ data -> response ) && is_array ( $ data -> response -> docs ) ) { $ documents = array ( ) ; foreach ( $ data -> response -> docs as $ originalDocument ) { if ( $ this -> _createDocuments ) { $ document = new Apache_Solr_Document ( ) ; } else { $ document = $ originalDocument ; } foreach ( $ originalDocument as $ key => $ value ) { if ( $ this -> _collapseSingleValueArrays && is_array ( $ value ) && count ( $ value ) <= 1 ) { $ value = array_shift ( $ value ) ; } $ document -> $ key = $ value ; } $ documents [ ] = $ document ; } $ data -> response -> docs = $ documents ; } $ this -> _parsedData = $ data ; }
Parse the raw response into the parsed_data array for access
56,525
public function tokenize ( $ code ) { $ code = trim ( ( string ) $ code ) ; if ( empty ( $ code ) ) { throw new \ InvalidArgumentException ( 'Cannot tokenize empty string.' ) ; } $ this -> code = $ code ; $ this -> tokens = array ( ) ; $ tokenArray = explode ( ' ' , $ this -> code ) ; if ( ! is_array ( $ tokenArray ) || empty ( $ tokenArray ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot tokenize string: %s, please use " "(empty space for delimeter betwwen tokens)' , $ this -> code ) ) ; } foreach ( $ tokenArray as $ t ) { if ( array_key_exists ( $ t , static :: $ operatorsMap ) ) { $ token = new Operator ( $ t , static :: $ operatorsMap [ $ t ] [ 'priority' ] , static :: $ operatorsMap [ $ t ] [ 'associativity' ] ) ; } elseif ( is_numeric ( $ t ) ) { $ token = new Token ( ( float ) $ t , Token :: T_OPERAND ) ; } elseif ( '(' === $ t ) { $ token = new Token ( $ t , Token :: T_LEFT_BRACKET ) ; } elseif ( ')' === $ t ) { $ token = new Token ( $ t , Token :: T_RIGHT_BRACKET ) ; } elseif ( '' === $ t ) { continue ; } else { throw new \ InvalidArgumentException ( sprintf ( 'Syntax error: unknown token "%s"' , $ t ) ) ; } $ this -> tokens [ ] = $ token ; } return $ this -> tokens ; }
Tokenize matematical expression .
56,526
public function flush ( ) { if ( ! empty ( $ this -> documents ) ) { $ this -> resource -> addDocuments ( $ this -> storeId , $ this -> documents ) ; $ this -> clearDocuments ( ) ; } }
Commit previously added documents to Solr and clear queue
56,527
public static function getDefaultStatusMessage ( $ statusCode ) { $ statusCode = ( int ) $ statusCode ; if ( isset ( self :: $ _defaultStatusMessages [ $ statusCode ] ) ) { return self :: $ _defaultStatusMessages [ $ statusCode ] ; } return "Unknown Status" ; }
Get the HTTP status message based on status code
56,528
public function publish ( Message $ message ) { if ( ! $ message -> getShortMessage ( ) || ! $ message -> getHost ( ) ) { throw new \ UnexpectedValueException ( 'Missing required data parameter: "version", "short_message" and "host" are required.' ) ; } $ message -> setVersion ( self :: GRAYLOG2_PROTOCOL_VERSION ) ; $ preparedMessage = $ this -> getPreparedMessage ( $ message ) ; $ socket = $ this -> getSocketConnection ( ) ; if ( $ this -> isMessageSizeGreaterChunkSize ( $ preparedMessage ) ) { $ messageId = $ this -> getMessageId ( ) ; $ messageChunks = $ this -> getMessageChunks ( $ preparedMessage ) ; $ messageChunksCount = count ( $ messageChunks ) ; foreach ( array_values ( $ messageChunks ) as $ messageChunkIndex => $ messageChunk ) { $ bytesWritten = $ this -> writeMessageChunkToSocket ( $ socket , $ messageId , $ messageChunk , $ messageChunkIndex , $ messageChunksCount ) ; if ( false === $ bytesWritten ) { return false ; } } } else { if ( false === $ this -> writeMessageToSocket ( $ socket , $ preparedMessage ) ) { return false ; } } usleep ( 20 ) ; return true ; }
Publishes a Message returns false if an error occured during write
56,529
protected function _initUrls ( ) { $ this -> _extractUrl = $ this -> _constructUrl ( self :: EXTRACT_SERVLET ) ; $ this -> _pingUrl = $ this -> _constructUrl ( self :: PING_SERVLET ) ; $ this -> _searchUrl = $ this -> _constructUrl ( self :: SEARCH_SERVLET ) ; $ this -> _systemUrl = $ this -> _constructUrl ( self :: SYSTEM_SERVLET , array ( 'wt' => self :: SOLR_WRITER ) ) ; $ this -> _threadsUrl = $ this -> _constructUrl ( self :: THREADS_SERVLET , array ( 'wt' => self :: SOLR_WRITER ) ) ; $ this -> _updateUrl = $ this -> _constructUrl ( self :: UPDATE_SERVLET , array ( 'wt' => self :: SOLR_WRITER ) ) ; $ this -> _urlsInited = true ; }
Construct the Full URLs for the three servlets we reference
56,530
protected function _sendRawGet ( $ url , $ timeout = FALSE ) { $ httpTransport = $ this -> getHttpTransport ( ) ; $ httpResponse = $ httpTransport -> performGetRequest ( $ url , $ timeout ) ; $ solrResponse = new Apache_Solr_Response ( $ httpResponse , $ this -> _createDocuments , $ this -> _collapseSingleValueArrays ) ; if ( $ solrResponse -> getHttpStatus ( ) != 200 ) { throw new Apache_Solr_HttpTransportException ( $ solrResponse ) ; } return $ solrResponse ; }
Central method for making a get operation against this Solr Server
56,531
public function setHost ( $ host ) { if ( empty ( $ host ) ) { throw new Apache_Solr_InvalidArgumentException ( 'Host parameter is empty' ) ; } else { $ this -> _host = $ host ; } if ( $ this -> _urlsInited ) { $ this -> _initUrls ( ) ; } }
Set the host used . If empty will fallback to constants
56,532
public function setPort ( $ port ) { $ port = ( int ) $ port ; if ( $ port <= 0 ) { throw new Apache_Solr_InvalidArgumentException ( 'Port is not a valid port number' ) ; } else { $ this -> _port = $ port ; } if ( $ this -> _urlsInited ) { $ this -> _initUrls ( ) ; } }
Set the port used . If empty will fallback to constants
56,533
public function setPath ( $ path ) { $ path = trim ( $ path , '/' ) ; if ( strlen ( $ path ) > 0 ) { $ this -> _path = '/' . $ path . '/' ; } else { $ this -> _path = '/' ; } if ( $ this -> _urlsInited ) { $ this -> _initUrls ( ) ; } }
Set the path used . If empty will fallback to constants
56,534
public function setNamedListTreatment ( $ namedListTreatment ) { switch ( ( string ) $ namedListTreatment ) { case Apache_Solr_Service :: NAMED_LIST_FLAT : $ this -> _namedListTreatment = Apache_Solr_Service :: NAMED_LIST_FLAT ; break ; case Apache_Solr_Service :: NAMED_LIST_MAP : $ this -> _namedListTreatment = Apache_Solr_Service :: NAMED_LIST_MAP ; break ; default : throw new Apache_Solr_InvalidArgumentException ( 'Not a valid named list treatement option' ) ; } }
Set how NamedLists should be formatted in the response data . This mainly effects the facet counts format .
56,535
public function softCommit ( $ expungeDeletes = false , $ waitFlush = true , $ waitSearcher = true , $ timeout = 3600 ) { return $ this -> commit ( $ expungeDeletes , $ waitFlush , $ waitSearcher , $ timeout , true ) ; }
Send a soft commit command . Will be synchronous unless both wait parameters are set to false .
56,536
private static function getHttpTransportAdapter ( $ serverConfig ) { switch ( $ serverConfig -> getHttpTransportMethod ( ) ) { case HttpTransportMethod :: HTTP_TRANSPORT_METHOD_CURL : $ adapter = new Apache_Solr_HttpTransport_Curl ( ) ; break ; default : $ adapter = new Apache_Solr_HttpTransport_FileGetContents ( ) ; } if ( $ serverConfig -> isUseHttpBasicAuth ( ) ) { $ adapter -> setAuthenticationCredentials ( $ serverConfig -> getHttpBasicAuthUsername ( ) , $ serverConfig -> getHttpBasicAuthPassword ( ) ) ; } return $ adapter ; }
Create HttpTransportAdapter based on configuration
56,537
public function getTitle ( ) { if ( $ this -> pageState -> hasCurrent ( ) ) { return $ this -> pageState -> getCurrentLeaf ( ) -> getTitle ( ) ; } return $ this -> view -> lookup ( GeneralConfig :: class ) -> getPageName ( ) ; }
Returns the title of the current page or the page name specified in app . ini if there is no current page .
56,538
public function escapeLikePattern ( string $ pattern ) : string { $ esc = $ this -> getLikeEscapeCharacter ( ) ; return str_replace ( array ( $ esc , QueryComparator :: LIKE_WILDCARD_MANY_CHARS , QueryComparator :: LIKE_WILDCARD_ONE_CHAR ) , array ( $ esc . $ esc , $ esc . QueryComparator :: LIKE_WILDCARD_MANY_CHARS , $ esc . QueryComparator :: LIKE_WILDCARD_ONE_CHAR ) , $ pattern ) ; }
Quotes the like wildcard chars
56,539
private function parseViewCreateStatement ( $ createStatement ) { $ matches = preg_split ( '/AS/i' , $ createStatement ) ; if ( isset ( $ matches [ 1 ] ) ) { return trim ( $ matches [ 1 ] ) ; } return $ createStatement ; }
Parse the given create statement and extract the query
56,540
public static function hook ( string ... $ hookKeys ) : NavComposer { return new NavComposer ( NavBranchCriteria :: create ( null , null , $ hookKeys ) ) ; }
Uses page as base which is marked with passed hooks .
56,541
public function createRecord ( $ tableName , array $ recordData = [ ] ) { if ( ! $ this -> isNoneSystemTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The table name "' . $ tableName . '" is not allowed.' , 1334438817 ) ; } if ( isset ( $ recordData [ 'uid' ] ) ) { throw new \ InvalidArgumentException ( 'The column "uid" must not be set in $recordData.' , 1334438963 ) ; } return $ this -> createRecordWithoutTableNameChecks ( $ tableName , $ recordData ) ; }
Creates a new dummy record for unit tests .
56,542
protected function createRecordWithoutTableNameChecks ( $ tableName , array $ recordData ) { $ dummyColumnName = $ this -> getDummyColumnName ( $ tableName ) ; $ recordData [ $ dummyColumnName ] = 1 ; $ uid = \ Tx_Phpunit_Service_Database :: insert ( $ tableName , $ recordData ) ; $ this -> markTableAsDirty ( $ tableName ) ; return $ uid ; }
Creates a new dummy record for unit tests without checks for the table name .
56,543
public function createFrontEndUser ( $ frontEndUserGroups = '' , array $ recordData = [ ] ) { $ frontEndUserGroupsWithoutSpaces = str_replace ( ' ' , '' , $ frontEndUserGroups ) ; if ( $ frontEndUserGroupsWithoutSpaces === '' ) { $ frontEndUserGroupsWithoutSpaces = $ this -> createFrontEndUserGroup ( ) ; } if ( ! preg_match ( '/^(?:[1-9]+\\d*,?)+$/' , $ frontEndUserGroupsWithoutSpaces ) ) { throw new \ InvalidArgumentException ( '$frontEndUserGroups must contain a comma-separated list of UIDs. Each UID must be > 0.' , 1334439059 ) ; } if ( isset ( $ recordData [ 'uid' ] ) ) { throw new \ InvalidArgumentException ( 'The column "uid" must not be set in $recordData.' , 1334439065 ) ; } if ( isset ( $ recordData [ 'usergroup' ] ) ) { throw new \ InvalidArgumentException ( 'The column "usergroup" must not be set in $recordData.' , 1334439071 ) ; } $ completeRecordData = $ recordData ; $ completeRecordData [ 'usergroup' ] = $ frontEndUserGroupsWithoutSpaces ; return $ this -> createRecordWithoutTableNameChecks ( 'fe_users' , $ completeRecordData ) ; }
Creates a FE user record .
56,544
public function createAndLoginFrontEndUser ( $ frontEndUserGroups = '' , array $ recordData = [ ] ) { $ frontEndUserUid = $ this -> createFrontEndUser ( $ frontEndUserGroups , $ recordData ) ; $ this -> loginFrontEndUser ( $ frontEndUserUid ) ; return $ frontEndUserUid ; }
Creates and logs in an FE user .
56,545
public function deleteRecord ( $ tableName , $ uid ) { if ( ! $ this -> isNoneSystemTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The table name "' . $ tableName . '" is not allowed.' , 1334439187 ) ; } \ Tx_Phpunit_Service_Database :: delete ( $ tableName , 'uid = ' . $ uid . ' AND ' . $ this -> getDummyColumnName ( $ tableName ) . ' = 1' ) ; }
Deletes a dummy record from the database .
56,546
public function createRelationAndUpdateCounter ( $ tableName , $ uidLocal , $ uidForeign , $ columnName ) { if ( ! $ this -> isTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The table name "' . $ tableName . '" is not allowed.' ) ; } if ( $ uidLocal <= 0 ) { throw new \ InvalidArgumentException ( '$uidLocal must be > 0, but actually is "' . $ uidLocal . '"' , 1334439220 ) ; } if ( $ uidForeign <= 0 ) { throw new \ InvalidArgumentException ( '$uidForeign must be > 0, but actually is "' . $ uidForeign . '"' , 1334439233 ) ; } $ tca = \ Tx_Phpunit_Service_Database :: getTcaForTable ( $ tableName ) ; $ relationConfiguration = $ tca [ 'columns' ] [ $ columnName ] ; if ( ! isset ( $ relationConfiguration [ 'config' ] [ 'MM' ] ) || ( $ relationConfiguration [ 'config' ] [ 'MM' ] === '' ) ) { throw new Exception ( 'The column ' . $ columnName . ' in the table ' . $ tableName . ' is not configured to contain m:n relations using a m:n table.' , 1334439257 ) ; } if ( isset ( $ relationConfiguration [ 'config' ] [ 'MM_opposite_field' ] ) ) { $ this -> createRelationAndUpdateCounter ( $ relationConfiguration [ 'config' ] [ 'foreign_table' ] , $ uidForeign , $ uidLocal , $ relationConfiguration [ 'config' ] [ 'MM_opposite_field' ] ) ; } else { $ this -> createRelation ( $ relationConfiguration [ 'config' ] [ 'MM' ] , $ uidLocal , $ uidForeign ) ; } $ this -> increaseRelationCounter ( $ tableName , $ uidLocal , $ columnName ) ; }
Creates a relation between two records based on the rules defined in TCA regarding the relation .
56,547
public function cleanUp ( $ performDeepCleanUp = false ) { $ this -> cleanUpTableSet ( false , $ performDeepCleanUp ) ; $ this -> cleanUpTableSet ( true , $ performDeepCleanUp ) ; $ this -> deleteAllDummyFoldersAndFiles ( ) ; $ this -> discardFakeFrontEnd ( ) ; foreach ( $ this -> getHooks ( ) as $ hook ) { if ( ! ( $ hook instanceof \ Tx_Phpunit_Interface_FrameworkCleanupHook ) ) { throw new Exception ( 'The class ' . get_class ( $ hook ) . ' must implement \\Tx_Phpunit_Interface_FrameworkCleanupHook.' , 1299257923 ) ; } $ hook -> cleanUp ( ) ; } RootlineUtility :: purgeCaches ( ) ; }
Deletes all dummy records that have been added through this framework . For this all records with the is_dummy_record flag set to 1 will be deleted from all tables that have been used within this instance of the testing framework .
56,548
protected function deleteAllDummyFoldersAndFiles ( ) { if ( isset ( $ this -> dummyFolders [ 'uploadFolder' ] ) ) { GeneralUtility :: rmdir ( $ this -> getUploadFolderPath ( ) , true ) ; $ this -> dummyFolders = [ ] ; $ this -> dummyFiles = [ ] ; } else { foreach ( $ this -> dummyFiles as $ dummyFile ) { $ this -> deleteDummyFile ( $ dummyFile ) ; } foreach ( $ this -> dummyFolders as $ dummyFolder ) { $ this -> deleteDummyFolder ( $ dummyFolder ) ; } } }
Deletes all dummy files and folders .
56,549
public function createDummyFile ( $ fileName = 'test.txt' , $ content = '' ) { $ this -> createDummyUploadFolder ( ) ; $ uniqueFileName = $ this -> getUniqueFileOrFolderPath ( $ fileName ) ; if ( ! GeneralUtility :: writeFile ( $ uniqueFileName , $ content ) ) { throw new Exception ( 'The file ' . $ uniqueFileName . ' could not be created.' , 1334439291 ) ; } $ this -> addToDummyFileList ( $ uniqueFileName ) ; return $ uniqueFileName ; }
Creates an empty dummy file with a unique file name in the calling extension s upload directory .
56,550
public function createDummyZipArchive ( $ fileName = 'test.zip' , array $ filesToAddToArchive = [ ] ) { $ this -> checkForZipArchive ( ) ; $ this -> createDummyUploadFolder ( ) ; $ uniqueFileName = $ this -> getUniqueFileOrFolderPath ( $ fileName ) ; $ zip = new ZipArchive ( ) ; if ( $ zip -> open ( $ uniqueFileName , ZipArchive :: CREATE ) !== true ) { throw new Exception ( 'The new ZIP archive "' . $ fileName . '" could not be created.' , 1334439299 ) ; } $ contents = ! empty ( $ filesToAddToArchive ) ? $ filesToAddToArchive : [ $ this -> createDummyFile ( ) ] ; foreach ( $ contents as $ pathToFile ) { if ( ! file_exists ( $ pathToFile ) ) { throw new Exception ( 'The provided path "' . $ pathToFile . '" does not point to an existing file.' , 1334439306 ) ; } $ zip -> addFile ( $ pathToFile , $ this -> getPathRelativeToUploadDirectory ( $ pathToFile ) ) ; } $ zip -> close ( ) ; $ this -> addToDummyFileList ( $ uniqueFileName ) ; return $ uniqueFileName ; }
Creates a dummy ZIP archive with a unique file name in the calling extension s upload directory .
56,551
public function createDummyFolder ( $ folderName ) { $ this -> createDummyUploadFolder ( ) ; $ uniqueFolderName = $ this -> getUniqueFileOrFolderPath ( $ folderName ) ; if ( ! GeneralUtility :: mkdir ( $ uniqueFolderName ) ) { throw new Exception ( 'The folder ' . $ uniqueFolderName . ' could not be created.' , 1334439333 ) ; } $ relativeUniqueFolderName = $ this -> getPathRelativeToUploadDirectory ( $ uniqueFolderName ) ; $ this -> dummyFolders = [ $ relativeUniqueFolderName => $ relativeUniqueFolderName ] + $ this -> dummyFolders ; return $ uniqueFolderName ; }
Creates a dummy folder with a unique folder name in the calling extension s upload directory .
56,552
protected function createDummyUploadFolder ( ) { $ uploadFolderPath = $ this -> getUploadFolderPath ( ) ; if ( is_dir ( $ uploadFolderPath ) ) { return ; } $ creationSuccessful = GeneralUtility :: mkdir ( $ uploadFolderPath ) ; if ( ! $ creationSuccessful ) { throw new \ RuntimeException ( 'The upload folder ' . $ uploadFolderPath . ' could not be created.' , 1334439408 ) ; } $ this -> dummyFolders [ 'uploadFolder' ] = $ uploadFolderPath ; }
Creates the upload folder if it does not exist yet .
56,553
public function setUploadFolderPath ( $ absolutePath ) { if ( ! empty ( $ this -> dummyFiles ) || ! empty ( $ this -> dummyFolders ) ) { throw new Exception ( 'The upload folder path must not be changed if there are already dummy files or folders.' , 1334439424 ) ; } $ this -> uploadFolderPath = $ absolutePath ; }
Sets the upload folder path .
56,554
public function getUniqueFileOrFolderPath ( $ path ) { if ( $ path === '' ) { throw new \ InvalidArgumentException ( 'The first parameter $path must not be empty.' , 1476054696353 ) ; } $ pathInformation = pathinfo ( $ path ) ; $ fileNameWithoutExtension = $ pathInformation [ 'filename' ] ; if ( $ pathInformation [ 'dirname' ] !== '.' ) { $ absoluteDirectoryWithTrailingSlash = $ this -> getUploadFolderPath ( ) . $ pathInformation [ 'dirname' ] . '/' ; } else { $ absoluteDirectoryWithTrailingSlash = $ this -> getUploadFolderPath ( ) ; } $ extension = isset ( $ pathInformation [ 'extension' ] ) ? ( '.' . $ pathInformation [ 'extension' ] ) : '' ; $ suffixCounter = 0 ; do { $ suffix = ( $ suffixCounter > 0 ) ? ( '-' . $ suffixCounter ) : '' ; $ newPath = $ absoluteDirectoryWithTrailingSlash . $ fileNameWithoutExtension . $ suffix . $ extension ; $ suffixCounter ++ ; } while ( is_file ( $ newPath ) ) ; return $ newPath ; }
Returns a unique absolute path of a file or folder .
56,555
public function discardFakeFrontEnd ( ) { if ( ! $ this -> hasFakeFrontEnd ( ) ) { return ; } $ this -> logoutFrontEndUser ( ) ; $ GLOBALS [ 'TSFE' ] = null ; $ GLOBALS [ 'TT' ] = null ; unset ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'FE' ] [ 'dontSetCookie' ] , $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 'Objects' ] [ FrontendUserAuthentication :: class ] ) ; $ this -> hasFakeFrontEnd = false ; }
Discards the fake front end .
56,556
public function loginFrontEndUser ( $ userId ) { if ( ( int ) $ userId === 0 ) { throw new \ InvalidArgumentException ( 'The user ID must be > 0.' , 1334439475 ) ; } if ( ! $ this -> hasFakeFrontEnd ( ) ) { throw new Exception ( 'Please create a front end before calling loginFrontEndUser.' , 1334439483 ) ; } if ( $ this -> isLoggedIn ( ) ) { $ this -> logoutFrontEndUser ( ) ; } $ this -> suppressFrontEndCookies ( ) ; $ tempUser = [ $ GLOBALS [ 'TSFE' ] -> fe_user -> userid_column => $ userId , ] ; $ GLOBALS [ 'TSFE' ] -> fe_user -> createUserSession ( $ tempUser ) ; $ GLOBALS [ 'TSFE' ] -> fe_user -> user = $ GLOBALS [ 'TSFE' ] -> fe_user -> getRawUserByUid ( $ userId ) ; $ GLOBALS [ 'TSFE' ] -> fe_user -> fetchGroupData ( ) ; $ GLOBALS [ 'TSFE' ] -> loginUser = 1 ; }
Fakes that a front - end user has logged in .
56,557
public function logoutFrontEndUser ( ) { if ( ! $ this -> hasFakeFrontEnd ( ) ) { throw new Exception ( 'Please create a front end before calling logoutFrontEndUser.' , 1334439488 ) ; } if ( ! $ this -> isLoggedIn ( ) ) { return ; } $ this -> suppressFrontEndCookies ( ) ; $ GLOBALS [ 'TSFE' ] -> fe_user -> logoff ( ) ; $ GLOBALS [ 'TSFE' ] -> loginUser = 0 ; }
Logs out the current front - end user .
56,558
public function isLoggedIn ( ) { if ( ! $ this -> hasFakeFrontEnd ( ) ) { throw new Exception ( 'Please create a front end before calling isLoggedIn.' , 1334439494 ) ; } return isset ( $ GLOBALS [ 'TSFE' ] ) && is_object ( $ GLOBALS [ 'TSFE' ] ) && is_array ( $ GLOBALS [ 'TSFE' ] -> fe_user -> user ) ; }
Checks whether a FE user is logged in .
56,559
public function getDummyColumnName ( $ tableName ) { $ result = 'is_dummy_record' ; if ( $ this -> isSystemTableNameAllowed ( $ tableName ) ) { $ result = 'tx_phpunit_' . $ result ; } elseif ( $ this -> isAdditionalTableNameAllowed ( $ tableName ) ) { $ result = $ this -> tablePrefix . '_' . $ result ; } return $ result ; }
Returns the name of the column that marks a record as a dummy record .
56,560
public function resetAutoIncrement ( $ tableName ) { if ( ! $ this -> isTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The given table name is invalid. This means it is either empty or not in the list of allowed tables.' , 1334439521 ) ; } if ( ! Tx_Phpunit_Service_Database :: tableHasColumnUid ( $ tableName ) ) { return ; } $ newAutoIncrementValue = $ this -> getMaximumUidFromTable ( $ tableName ) + 1 ; \ Tx_Phpunit_Service_Database :: enableQueryLogging ( ) ; $ dbResult = \ Tx_Phpunit_Service_Database :: getDatabaseConnection ( ) -> sql_query ( 'ALTER TABLE ' . $ tableName . ' AUTO_INCREMENT=' . $ newAutoIncrementValue . ';' ) ; if ( $ dbResult === false ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439540 ) ; } }
Eagerly resets the auto increment value for a given table to the highest existing UID + 1 .
56,561
public function resetAutoIncrementLazily ( $ tableName ) { if ( ! $ this -> isTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The given table name is invalid. This means it is either empty or not in the list of allowed tables.' , 1334439548 ) ; } if ( ! Tx_Phpunit_Service_Database :: tableHasColumnUid ( $ tableName ) ) { return ; } if ( $ this -> getAutoIncrement ( $ tableName ) > ( $ this -> getMaximumUidFromTable ( $ tableName ) + $ this -> resetAutoIncrementThreshold ) ) { $ this -> resetAutoIncrement ( $ tableName ) ; } }
Resets the auto increment value for a given table to the highest existing UID + 1 if the current auto increment value is higher than a certain threshold over the current maximum UID .
56,562
public function getAutoIncrement ( $ tableName ) { if ( ! $ this -> isTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The given table name is invalid. This means it is either empty or not in the list of allowed tables.' , 1334439567 ) ; } \ Tx_Phpunit_Service_Database :: enableQueryLogging ( ) ; $ dbResult = \ Tx_Phpunit_Service_Database :: getDatabaseConnection ( ) -> sql_query ( 'SHOW TABLE STATUS WHERE Name = \'' . $ tableName . '\';' ) ; if ( ! $ dbResult ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439578 ) ; } $ row = \ Tx_Phpunit_Service_Database :: getDatabaseConnection ( ) -> sql_fetch_assoc ( $ dbResult ) ; \ Tx_Phpunit_Service_Database :: getDatabaseConnection ( ) -> sql_free_result ( $ dbResult ) ; $ autoIncrement = $ row [ 'Auto_increment' ] ; if ( $ autoIncrement === null ) { throw new \ InvalidArgumentException ( 'The given table name is invalid. This means it is either empty or not in the list of allowed tables.' , 1334439584 ) ; } return ( int ) $ autoIncrement ; }
Reads the current auto increment value for a given table .
56,563
public function getRelationSorting ( $ tableName , $ uidLocal ) { if ( ! $ this -> relationSorting [ $ tableName ] [ $ uidLocal ] ) { $ this -> relationSorting [ $ tableName ] [ $ uidLocal ] = 0 ; } $ this -> relationSorting [ $ tableName ] [ $ uidLocal ] ++ ; return $ this -> relationSorting [ $ tableName ] [ $ uidLocal ] ; }
Returns the next sorting value of the relation table which should be used .
56,564
public function increaseRelationCounter ( $ tableName , $ uid , $ fieldName ) { if ( ! $ this -> isTableNameAllowed ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'The table name "' . $ tableName . '" is invalid. This means it is either empty or not in the list of allowed tables.' , 1334439601 ) ; } if ( ! \ Tx_Phpunit_Service_Database :: tableHasColumn ( $ tableName , $ fieldName ) ) { throw new \ InvalidArgumentException ( 'The table ' . $ tableName . ' has no column ' . $ fieldName . '.' , 1334439616 ) ; } \ Tx_Phpunit_Service_Database :: enableQueryLogging ( ) ; $ dbResult = \ Tx_Phpunit_Service_Database :: getDatabaseConnection ( ) -> sql_query ( 'UPDATE ' . $ tableName . ' SET ' . $ fieldName . '=' . $ fieldName . '+1 WHERE uid=' . $ uid ) ; if ( ! $ dbResult ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439623 ) ; } if ( \ Tx_Phpunit_Service_Database :: getDatabaseConnection ( ) -> sql_affected_rows ( ) === 0 ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439632 ) ; } $ this -> markTableAsDirty ( $ tableName ) ; }
Updates an int field of a database table by one . This is mainly needed for counting up the relation counter when creating a database relation .
56,565
protected function getHooks ( ) { if ( ! self :: $ hooksHaveBeenRetrieved ) { $ hookClasses = $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXTCONF' ] [ 'phpunit' ] [ 'FrameworkCleanUp' ] ; if ( is_array ( $ hookClasses ) ) { foreach ( $ hookClasses as $ hookClass ) { self :: $ hooks [ ] = GeneralUtility :: getUserObj ( $ hookClass ) ; } } self :: $ hooksHaveBeenRetrieved = true ; } return self :: $ hooks ; }
Gets all hooks for this class .
56,566
public static function delete ( $ tableName , $ whereClause ) { if ( $ tableName === '' ) { throw new \ InvalidArgumentException ( 'The table name must not be empty.' , 1331315508 ) ; } self :: enableQueryLogging ( ) ; $ dbResult = self :: getDatabaseConnection ( ) -> exec_DELETEquery ( $ tableName , $ whereClause ) ; if ( ! $ dbResult ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439746 ) ; } return self :: getDatabaseConnection ( ) -> sql_affected_rows ( ) ; }
Executes a DELETE query .
56,567
public static function update ( $ tableName , $ whereClause , array $ fields ) { if ( $ tableName === '' ) { throw new \ InvalidArgumentException ( 'The table name must not be empty.' , 1331315523 ) ; } self :: enableQueryLogging ( ) ; $ dbResult = self :: getDatabaseConnection ( ) -> exec_UPDATEquery ( $ tableName , $ whereClause , $ fields ) ; if ( ! $ dbResult ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439755 ) ; } return self :: getDatabaseConnection ( ) -> sql_affected_rows ( ) ; }
Executes an UPDATE query .
56,568
public static function insert ( $ tableName , array $ recordData ) { if ( $ tableName === '' ) { throw new \ InvalidArgumentException ( 'The table name must not be empty.' , 1331315544 ) ; } if ( empty ( $ recordData ) ) { throw new \ InvalidArgumentException ( '$recordData must not be empty.' , 1331315553 ) ; } self :: enableQueryLogging ( ) ; $ dbResult = self :: getDatabaseConnection ( ) -> exec_INSERTquery ( $ tableName , $ recordData ) ; if ( ! $ dbResult ) { throw new \ Tx_Phpunit_Exception_Database ( 1334439765 ) ; } return self :: getDatabaseConnection ( ) -> sql_insert_id ( ) ; }
Executes an INSERT query .
56,569
public static function selectColumnForMultiple ( $ fieldName , $ tableNames , $ whereClause = '' , $ groupBy = '' , $ orderBy = '' , $ limit = '' ) { $ rows = self :: selectMultiple ( $ fieldName , $ tableNames , $ whereClause , $ groupBy , $ orderBy , $ limit ) ; $ result = [ ] ; foreach ( $ rows as $ row ) { $ result [ ] = $ row [ $ fieldName ] ; } return $ result ; }
Executes a SELECT query and returns one column from the result rows as a one - dimensional numeric array .
56,570
public static function count ( $ tableNames , $ whereClause = '' ) { $ isOnlyOneTable = ( ( strpos ( $ tableNames , ',' ) === false ) && ( stripos ( trim ( $ tableNames ) , ' JOIN ' ) === false ) ) ; if ( $ isOnlyOneTable && self :: tableHasColumnUid ( $ tableNames ) ) { $ columns = 'uid' ; } else { $ columns = '*' ; } $ result = self :: selectSingle ( 'COUNT(' . $ columns . ') AS phpunit_counter' , $ tableNames , $ whereClause ) ; return ( int ) $ result [ 'phpunit_counter' ] ; }
Counts the number of matching records in the database for a particular WHERE clause .
56,571
public static function existsTable ( $ tableName ) { if ( $ tableName === '' ) { throw new \ InvalidArgumentException ( 'The table name must not be empty.' , 1331315636 ) ; } self :: retrieveTableNames ( ) ; return isset ( self :: $ tableNameCache [ $ tableName ] ) ; }
Checks whether a database table exists .
56,572
public static function getTcaForTable ( $ tableName ) { if ( isset ( self :: $ tcaCache [ $ tableName ] ) ) { return self :: $ tcaCache [ $ tableName ] ; } if ( ! self :: existsTable ( $ tableName ) ) { throw new \ BadMethodCallException ( 'The table "' . $ tableName . '" does not exist.' , 1331315679 ) ; } if ( ! isset ( $ GLOBALS [ 'TCA' ] [ $ tableName ] ) ) { throw new \ BadMethodCallException ( 'The table "' . $ tableName . '" has no TCA.' , 1331315694 ) ; } self :: $ tcaCache [ $ tableName ] = $ GLOBALS [ 'TCA' ] [ $ tableName ] ; return self :: $ tcaCache [ $ tableName ] ; }
Returns the TCA for a certain table .
56,573
public function getGroupMembers ( $ groupId , array $ filters = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'groups/%d/members' , $ groupId ) , [ 'query' => $ filters ] ) ) ; }
getGroupMembers - Gets members associated for a specific group
56,574
public function getGroupMember ( $ groupId , $ memberId ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'groups/%d/members/%d' , $ groupId , $ memberId ) ) ) ; }
getGroupMembers - Gets a specific member information for a specific group
56,575
public function render ( ) { $ content = $ this -> renderForm ( $ this -> renderSelect ( ) ) ; $ this -> outputService -> output ( $ content ) ; }
Renders the content of the view helper and pushes it to the output service .
56,576
protected function renderForm ( $ formContent ) { $ formContentWithAdditionalElements = $ formContent . $ this -> renderHiddenFields ( ) . $ this -> renderSubmitButton ( $ this -> translate ( 'run_all_tests' ) ) ; $ formContentWithinParagraph = $ this -> renderTag ( 'p' , [ ] , $ formContentWithAdditionalElements ) ; return $ this -> renderTag ( 'form' , [ 'action' => $ this -> action , 'method' => 'post' , ] , $ formContentWithinParagraph ) ; }
Renders the form with submit button around some content .
56,577
protected function renderSelect ( ) { $ options = $ this -> getOptions ( ) ; $ selectedExtensionStyle = '' ; $ renderedOptionTags = [ ] ; foreach ( $ options as $ option ) { if ( isset ( $ option [ 'selected' ] ) && $ option [ 'selected' ] === 'selected' ) { $ selectedExtensionStyle = $ option [ 'style' ] ; } if ( $ option [ 'value' ] === \ Tx_Phpunit_Testable :: ALL_EXTENSIONS ) { $ optionValue = $ this -> translate ( 'all_extensions' ) ; } else { $ optionValue = $ option [ 'value' ] ; } $ renderedOptionTags [ ] = $ this -> renderTag ( 'option' , $ option , $ optionValue ) ; } return $ this -> renderTag ( 'select' , [ 'name' => \ Tx_Phpunit_Interface_Request :: PARAMETER_NAMESPACE . '[' . \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_TESTABLE . ']' , 'onchange' => 'document.location = \'' . $ this -> action . '&' . \ Tx_Phpunit_Interface_Request :: PARAMETER_NAMESPACE . '[' . \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_TESTABLE . ']=' . '\'+this.options[this.selectedIndex].value;' , 'style' => $ selectedExtensionStyle , ] , implode ( LF , $ renderedOptionTags ) ) ; }
Renders the select box as HTML .
56,578
protected function getOptions ( ) { $ options = [ ] ; $ allExtensionOption = [ 'class' => 'alltests' , 'value' => \ Tx_Phpunit_Testable :: ALL_EXTENSIONS , ] ; if ( $ this -> isOptionSelected ( \ Tx_Phpunit_Testable :: ALL_EXTENSIONS ) ) { $ allExtensionOption [ 'selected' ] = 'selected' ; } $ options [ ] = $ allExtensionOption ; foreach ( $ this -> testFinder -> getTestablesForEverything ( ) as $ testable ) { $ extensionOption = [ 'style' => $ this -> createIconStyle ( $ testable -> getKey ( ) ) , 'value' => $ testable -> getKey ( ) , ] ; if ( $ this -> isOptionSelected ( $ testable -> getKey ( ) ) ) { $ extensionOption [ 'selected' ] = 'selected' ; } $ options [ ] = $ extensionOption ; } return $ options ; }
Gets all options rendered as an array
56,579
protected function getField ( $ key ) { return ! empty ( $ this -> response [ $ key ] ) ? $ this -> response [ $ key ] : null ; }
Helper for getting user data
56,580
public function render ( ) { $ attributes = array_merge ( $ this -> additionalAttributes , [ 'type' => $ this -> type , 'value' => $ this -> value , ] ) ; return $ this -> renderTag ( $ this -> tagName , $ attributes ) ; }
Renders the input field with the set attributes and value
56,581
public function main ( ) { LibraryLoader :: includeAll ( ) ; $ this -> doc = GeneralUtility :: makeInstance ( DocumentTemplate :: class ) ; $ this -> doc -> backPath = $ GLOBALS [ 'BACK_PATH' ] ; if ( $ GLOBALS [ 'BE_USER' ] -> user [ 'admin' ] ) { $ this -> doc -> bodyTagAdditions = 'id="doc3"' ; $ this -> addAdditionalHeaderData ( ) ; $ this -> cleanOutputBuffers ( ) ; $ this -> outputService -> output ( $ this -> doc -> startPage ( $ this -> translate ( 'title' ) ) . $ this -> doc -> header ( \ PHPUnit_Runner_Version :: getVersionString ( ) ) ) ; $ this -> renderRunTests ( ) ; $ this -> outputService -> output ( $ this -> doc -> section ( $ this -> translate ( 'shortcuts.title' ) , '<p>' . $ this -> translate ( 'shortcuts.text' ) . '</p> <p>' . $ this -> translate ( 'shortcuts.browser_dependency' ) . '</p> <ul> <li>' . $ this -> translate ( 'shortcuts.browser_safari_ie' ) . '</li> <li>' . $ this -> translate ( 'shortcuts.browser_firefox' ) . '</li> </ul>' ) ) ; } else { $ this -> outputService -> output ( $ this -> doc -> startPage ( $ this -> translate ( 'title' ) ) . $ this -> doc -> header ( $ this -> translate ( 'title' ) ) . $ this -> translate ( 'admin_rights_needed' ) ) ; } $ this -> outputService -> output ( $ this -> doc -> endPage ( ) ) ; }
Main function of the module . Outputs all content directly instead of collecting it and doing the output later .
56,582
protected function addAdditionalHeaderData ( ) { $ pageRenderer = GeneralUtility :: makeInstance ( PageRenderer :: class ) ; $ pageRenderer -> loadJquery ( ) ; $ publicResourcesPath = $ this -> extensionPath . 'Resources/Public/' ; $ pageRenderer -> addJsFile ( $ publicResourcesPath . 'JavaScript/BackEnd.js' , 'text/javascript' , false ) ; $ pageRenderer -> addCssFile ( $ publicResourcesPath . 'CSS/BackEnd.css' , 'stylesheet' , 'all' , '' , false ) ; }
Adds some JavaScript and CSS stuff to header data .
56,583
protected function createExtensionSelector ( ) { $ this -> getAndSaveSelectedTestableKey ( ) ; $ extensionSelectorViewHelper = GeneralUtility :: makeInstance ( \ Tx_Phpunit_ViewHelpers_ExtensionSelectorViewHelper :: class ) ; $ extensionSelectorViewHelper -> injectOutputService ( $ this -> outputService ) ; $ extensionSelectorViewHelper -> injectUserSettingService ( $ this -> userSettingsService ) ; $ extensionSelectorViewHelper -> injectTestFinder ( $ this -> testFinder ) ; $ extensionSelectorViewHelper -> setAction ( BackendUtility :: getModuleUrl ( 'tools_txphpunitbeM1' ) ) ; $ extensionSelectorViewHelper -> render ( ) ; }
Creates the extension drop - down .
56,584
protected function createCheckboxes ( ) { $ output = '<form action="' . htmlspecialchars ( BackendUtility :: getModuleUrl ( 'tools_txphpunitbeM1' ) ) . '" method="post">' ; $ output .= '<div class="phpunit-controls">' ; $ failureState = $ this -> userSettingsService -> getAsBoolean ( 'failure' ) ? 'checked="checked"' : '' ; $ errorState = $ this -> userSettingsService -> getAsBoolean ( 'error' ) ? 'checked="checked"' : '' ; $ skippedState = $ this -> userSettingsService -> getAsBoolean ( 'skipped' ) ? 'checked="checked"' : '' ; $ successState = $ this -> userSettingsService -> getAsBoolean ( 'success' ) ? 'checked="checked"' : '' ; $ incompleteState = $ this -> userSettingsService -> getAsBoolean ( 'incomplete' ) ? 'checked="checked"' : '' ; $ showTime = $ this -> userSettingsService -> getAsBoolean ( 'showTime' ) ? 'checked="checked"' : '' ; $ testdoxState = $ this -> userSettingsService -> getAsBoolean ( 'testdox' ) ? 'checked="checked"' : '' ; $ output .= '<input type="checkbox" id="SET_success" ' . $ successState . ' /><label for="SET_success">' . $ this -> translate ( 'success' ) . '</label>' ; $ output .= ' <input type="checkbox" id="SET_failure" ' . $ failureState . ' /><label for="SET_failure">' . $ this -> translate ( 'failure' ) . '</label>' ; $ output .= ' <input type="checkbox" id="SET_skipped" ' . $ skippedState . ' /><label for="SET_skipped">' . $ this -> translate ( 'skipped' ) . '</label>' ; $ output .= ' <input type="checkbox" id="SET_error" ' . $ errorState . ' /><label for="SET_error">' . $ this -> translate ( 'error' ) . '</label>' ; $ output .= ' <input type="checkbox" id="SET_testdox" ' . $ testdoxState . ' /><label for="SET_testdox">' . $ this -> translate ( 'show_as_human_readable' ) . '</label>' ; $ output .= ' <input type="checkbox" id="SET_incomplete" ' . $ incompleteState . ' /><label for="SET_incomplete">' . $ this -> translate ( 'incomplete' ) . '</label>' ; $ output .= ' <input type="checkbox" id="SET_showTime" ' . $ showTime . '/><label for="SET_showTime">' . $ this -> translate ( 'show_time' ) . '</label>' ; $ codecoverageDisable = '' ; $ codecoverageForLabelWhenDisabled = '' ; if ( ! extension_loaded ( 'xdebug' ) ) { $ codecoverageDisable = ' disabled="disabled"' ; $ codecoverageForLabelWhenDisabled = ' title="' . $ this -> translate ( 'code_coverage_requires_xdebug' ) . '"' ; } $ codeCoverageState = $ this -> userSettingsService -> getAsBoolean ( 'codeCoverage' ) ? 'checked="checked"' : '' ; $ output .= ' <input type="checkbox" id="SET_codeCoverage" ' . $ codecoverageDisable . ' ' . $ codeCoverageState . ' /><label for="SET_codeCoverage"' . $ codecoverageForLabelWhenDisabled . '>' . $ this -> translate ( 'collect_code_coverage_data' ) . '</label>' ; $ runSeleniumTests = $ this -> userSettingsService -> getAsBoolean ( 'runSeleniumTests' ) ? 'checked="checked"' : '' ; $ output .= ' <input type="checkbox" id="SET_runSeleniumTests" ' . $ runSeleniumTests . '/><label for="SET_runSeleniumTests">' . $ this -> translate ( 'run_selenium_tests' ) . '</label>' ; $ output .= '</div>' ; $ output .= '</form>' ; return $ output ; }
Renders the checkboxes for hiding or showing various test results .
56,585
protected function renderReRunButton ( ) { $ this -> outputService -> output ( '<form action="' . htmlspecialchars ( BackendUtility :: getModuleUrl ( 'tools_txphpunitbeM1' ) ) . '" method="post"> <p> <button type="submit" name="' . \ Tx_Phpunit_Interface_Request :: PARAMETER_NAMESPACE . ' [' . \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_EXECUTE . ']" value="run" accesskey="r">' . $ this -> translate ( 'run_again' ) . '</button> <input name="' . \ Tx_Phpunit_Interface_Request :: PARAMETER_NAMESPACE . '[' . \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_COMMAND . ']" type="hidden" value="' . htmlspecialchars ( $ this -> request -> getAsString ( \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_COMMAND ) ) . '" /> <input name="' . \ Tx_Phpunit_Interface_Request :: PARAMETER_NAMESPACE . '[' . \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_TEST . ']" type="hidden" value="' . htmlspecialchars ( $ this -> request -> getAsString ( \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_TEST ) ) . '" /> <input name="' . \ Tx_Phpunit_Interface_Request :: PARAMETER_NAMESPACE . '[' . \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_TESTCASE . ']" type="hidden" value="' . htmlspecialchars ( $ this -> request -> getAsString ( \ Tx_Phpunit_Interface_Request :: PARAMETER_KEY_TESTCASE ) ) . '" /> </p> </form>' ) ; }
Renders and output the re - run button .
56,586
protected function renderCodeCoverage ( ) { $ this -> coverage -> stop ( ) ; $ codeCoverageDirectory = PATH_site . 'typo3temp/codecoverage/' ; if ( ! is_readable ( $ codeCoverageDirectory ) && ! is_dir ( $ codeCoverageDirectory ) ) { GeneralUtility :: mkdir ( $ codeCoverageDirectory ) ; } $ coverageReport = new PHP_CodeCoverage_Report_HTML ( ) ; $ coverageReport -> process ( $ this -> coverage , $ codeCoverageDirectory ) ; $ this -> outputService -> output ( '<p><a target="_blank" href="../typo3temp/codecoverage/index.html">' . 'Click here to access the Code Coverage report</a></p>' . '<p>Memory peak usage: ' . GeneralUtility :: formatSize ( memory_get_peak_usage ( ) ) . 'B</p>' ) ; }
Renders and outputs the code coverage report .
56,587
protected function renderProgressbar ( ) { $ progressBarViewHelper = GeneralUtility :: makeInstance ( \ Tx_Phpunit_ViewHelpers_ProgressBarViewHelper :: class ) ; $ progressBarViewHelper -> injectOutputService ( $ this -> outputService ) ; $ progressBarViewHelper -> render ( ) ; }
Renders DIVs which contain information and a progressbar to visualize the running tests .
56,588
protected function getHolidays ( $ year ) { $ christmas = new DateTime ( $ year . '-12-25' , $ this -> timezone ) ; $ thanksgiving = new DateTime ( 'fourth Thursday of November ' . $ year , $ this -> timezone ) ; $ holidays = array ( new Holiday ( clone $ christmas , 'Christmas' , $ this -> timezone ) , new Holiday ( clone $ thanksgiving , 'Thanksgiving Day' , $ this -> timezone ) , new Holiday ( new DateTime ( $ year . '-1-1' , $ this -> timezone ) , "New Year's Day" , $ this -> timezone ) , new Holiday ( new DateTime ( $ year . '-7-4' , $ this -> timezone ) , 'Independence Day' , $ this -> timezone ) , new Holiday ( new DateTime ( $ year . '-11-11' , $ this -> timezone ) , 'Veterans Day' , $ this -> timezone ) , new Holiday ( new DateTime ( 'second Monday of October ' . $ year , $ this -> timezone ) , 'Columbus Day' , $ this -> timezone ) , new Holiday ( new DateTime ( 'first Monday of September ' . $ year , $ this -> timezone ) , 'Labor Day' , $ this -> timezone ) , new Holiday ( new DateTime ( 'last Monday of May ' . $ year , $ this -> timezone ) , 'Memorial Day' , $ this -> timezone ) , new Holiday ( new DateTime ( 'third Monday of February ' . $ year , $ this -> timezone ) , "President's Day" , $ this -> timezone ) , new Holiday ( new DateTime ( 'third Monday of January ' . $ year , $ this -> timezone ) , 'Martin Luther King, Jr. Day' , $ this -> timezone ) , ) ; $ holidays [ ] = new Holiday ( $ christmas -> modify ( '-1 day' ) , 'Christmas Eve' , $ this -> timezone ) ; $ holidays [ ] = new Holiday ( $ thanksgiving -> modify ( '+1 day' ) , 'Thanksgiving Adam' , $ this -> timezone ) ; return $ holidays ; }
The template method to be used in the between calculation .
56,589
public function addAlternateUrl ( string $ locale , string $ url ) : void { $ this -> alternateUrl [ $ locale ] = $ url ; }
Add an alternate url to the current one .
56,590
public function getMetadataFor ( $ value ) { $ metaData = new ClassMetadata ( get_class ( $ value ) ) ; $ fullClass = $ this -> getClassValidator ( $ value ) ; if ( empty ( $ fullClass ) ) { return $ metaData ; } $ loader = new $ fullClass ( ) ; $ loader -> load ( $ metaData ) ; if ( $ this -> listener ) { $ this -> listener -> onLoaded ( $ value , $ metaData ) ; } return $ metaData ; }
Returns the metadata for the given value .
56,591
protected function renderTag ( $ tagName , array $ attributes = [ ] , $ content = '' ) { if ( empty ( $ tagName ) ) { throw new \ InvalidArgumentException ( '$tagName must not be NULL or empty.' , 1343763729 ) ; } $ output = '<' . htmlspecialchars ( $ tagName ) ; foreach ( $ attributes as $ key => $ value ) { if ( ! is_string ( $ key ) || $ key === '' ) { throw new \ InvalidArgumentException ( 'Attribute key must not be empty.' , 1448657422 ) ; } $ output .= ' ' . htmlspecialchars ( $ key ) . '="' . htmlspecialchars ( $ value ) . '"' ; } if ( $ content !== '' ) { $ output .= '>' . $ content . '</' . htmlspecialchars ( $ tagName ) . '>' ; } else { $ output .= ' />' ; } return $ output ; }
Renders any HTML tag with its own parameter either around some content .
56,592
private function getClass ( BuilderFactory $ factory , string $ newClassName , \ ReflectionClass $ class ) : Builder { $ parentClass = $ class -> name ; $ builder = $ factory -> class ( $ newClassName ) -> extend ( $ parentClass ) -> implement ( 'Ray\Aop\WeavedInterface' ) ; $ builder = $ this -> addInterceptorProp ( $ builder ) ; return $ this -> addSerialisedAnnotationProp ( $ builder , $ class ) ; }
Return class statement
56,593
private function addClassDocComment ( Class_ $ node , \ ReflectionClass $ class ) : Class_ { $ docComment = $ class -> getDocComment ( ) ; if ( $ docComment ) { $ node -> setDocComment ( new Doc ( $ docComment ) ) ; } return $ node ; }
Add class doc comment
56,594
public function isSeleniumServerRunning ( ) { $ seleniumServerIsRunning = false ; $ errorLevel = 0 ; $ errorMessage = '' ; $ timeout = 1 ; $ socket = @ fsockopen ( $ this -> getSeleniumHost ( ) , $ this -> getSeleniumPort ( ) , $ errorLevel , $ errorMessage , $ timeout ) ; if ( $ socket !== false ) { $ seleniumServerIsRunning = true ; fclose ( $ socket ) ; } return $ seleniumServerIsRunning ; }
Tests if the Selenium RC server is running .
56,595
public function getSeleniumBrowserUrl ( ) { return $ this -> extensionSettingsService -> hasString ( 'selenium_browserurl' ) ? $ this -> extensionSettingsService -> getAsString ( 'selenium_browserurl' ) : rtrim ( GeneralUtility :: getIndpEnv ( 'TYPO3_SITE_URL' ) , '/' ) ; }
Returns the configured Selenium RC browser starting URL .
56,596
public function getGraceTtl ( ) { if ( ! isset ( $ this -> graceTtl ) ) { $ this -> graceTtl = self :: DEFAULT_GRACE_TTL ; } return $ this -> graceTtl ; }
Gets grace period
56,597
private function getMethod ( \ ReflectionMethod $ method ) { $ methodStmt = $ this -> factory -> method ( $ method -> name ) ; $ params = $ method -> getParameters ( ) ; foreach ( $ params as $ param ) { $ methodStmt = $ this -> getMethodStatement ( $ param , $ methodStmt ) ; } $ returnType = $ method -> getReturnType ( ) ; if ( $ returnType instanceof \ ReflectionType ) { $ this -> setReturnType ( $ returnType , $ methodStmt ) ; } $ methodInsideStatements = $ this -> getMethodInsideStatement ( $ method ) ; $ methodStmt -> addStmts ( $ methodInsideStatements ) ; return $ this -> addMethodDocComment ( $ methodStmt , $ method ) ; }
Return method statement
56,598
private function getMethodStatement ( \ ReflectionParameter $ param , Method $ methodStmt ) : Method { $ paramStmt = $ this -> factory -> param ( $ param -> name ) ; $ this -> setParameterType ( $ param , $ paramStmt ) ; $ this -> setDefault ( $ param , $ paramStmt ) ; $ methodStmt -> addParam ( $ paramStmt ) ; return $ methodStmt ; }
Return parameter reflection
56,599
public function createSurveyFromTemplate ( $ templateId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'POST' , 'surveys' , [ ] , array_merge ( $ data , [ 'from_template_id' => $ templateId ] ) ) ) ; }
createSurveyFromTemplate - Create a new survey from an existing template