idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
57,200 | public static function replaceSpecialRange ( SemverConverter $ converter , $ match ) { $ newMatch = $ converter -> convertVersion ( $ match ) ; $ newMatch = '>=' . static :: standardizeVersion ( SemverUtil :: replaceAlias ( $ newMatch , '>' ) ) . ',<' ; $ exp = static :: getSplittedVersion ( $ match ) ; $ increase = fa... | Replaces the special range ^ . |
57,201 | protected static function analyzeSubVersion ( $ i , array & $ exp , & $ increase ) { $ analyzed = false ; if ( $ increase ) { $ exp [ $ i ] = 0 ; $ analyzed = true ; } if ( 0 === $ i && ( int ) $ exp [ $ i ] > 0 ) { $ increase = true ; $ exp [ $ i ] = ( int ) $ exp [ $ i ] + 1 ; $ analyzed = true ; } return $ analyzed ... | Analyze the sub version of splitted version . |
57,202 | protected static function increaseSubVersion ( $ i , array & $ exp , & $ increase ) { $ iNext = min ( min ( $ i + 1 , 3 ) , \ count ( $ exp ) - 1 ) ; if ( ( $ iNext !== $ i && ( $ exp [ $ i ] > 0 || ( int ) $ exp [ $ iNext ] > 9999998 ) ) || $ iNext === $ i ) { $ exp [ $ i ] = ( int ) $ exp [ $ i ] + 1 ; $ increase = t... | Increase the sub version of splitted version . |
57,203 | protected static function standardizeVersion ( $ version ) { if ( \ is_string ( $ version ) ) { $ version = explode ( '.' , $ version ) ; } while ( \ count ( $ version ) < 3 ) { $ version [ ] = '0' ; } return implode ( '.' , $ version ) ; } | Standardize the version . |
57,204 | protected static function getSplittedVersion ( $ version ) { $ version = static :: cleanExtraVersion ( $ version ) ; $ version = str_replace ( array ( '*' , 'x' , 'X' ) , '9999999' , $ version ) ; $ exp = explode ( '.' , $ version ) ; return $ exp ; } | Split the version . |
57,205 | public static function createType ( $ type ) { if ( ! isset ( static :: $ typeClasses [ $ type ] ) ) { throw new InvalidArgumentException ( 'The asset type "' . $ type . '" does not exist, only "' . implode ( '", "' , static :: getTypes ( ) ) . '" are accepted' ) ; } $ class = static :: $ typeClasses [ $ type ] ; retur... | Creates asset type . |
57,206 | public function setIO ( IOInterface $ io ) { $ this -> io = $ io ; $ this -> verbose = $ io -> isVerbose ( ) ; } | Sets the IO . |
57,207 | protected function loadRealPackage ( LazyPackageInterface $ package ) { $ realPackage = false ; try { $ data = $ this -> driver -> getComposerInformation ( $ this -> identifier ) ; $ valid = \ is_array ( $ data ) ; $ data = $ this -> preProcess ( $ this -> driver , $ this -> validateData ( $ data ) , $ this -> identifi... | Loads the real package . |
57,208 | public static function convertDateVersion ( $ version ) { if ( preg_match ( '/^\d{7,}\./' , $ version ) ) { $ pos = strpos ( $ version , '.' ) ; $ version = substr ( $ version , 0 , $ pos ) . self :: convertDateMinorVersion ( substr ( $ version , $ pos + 1 ) ) ; } return $ version ; } | Converts the date or datetime version . |
57,209 | public static function convertVersionMetadata ( $ version ) { $ version = str_replace ( self :: $ cleanPatterns , '' , $ version ) ; if ( preg_match_all ( self :: createPattern ( '([a-zA-Z]+|(\-|\+)[a-zA-Z]+|(\-|\+)[0-9]+)' ) , $ version , $ matches , PREG_OFFSET_CAPTURE ) ) { list ( $ type , $ version , $ end ) = self... | Converts the version metadata . |
57,210 | public static function createPattern ( $ pattern ) { $ numVer = '([0-9]+|x|\*)' ; $ numVer2 = '(' . $ numVer . '\.' . $ numVer . ')' ; $ numVer3 = '(' . $ numVer . '\.' . $ numVer . '\.' . $ numVer . ')' ; return '/^' . '(' . $ numVer . '|' . $ numVer2 . '|' . $ numVer3 . ')' . $ pattern . '/' ; } | Creates a pattern with the version prefix pattern . |
57,211 | protected static function cleanVersion ( $ version , array $ matches ) { $ end = substr ( $ version , \ strlen ( $ matches [ 1 ] [ 0 ] [ 0 ] ) ) ; $ version = $ matches [ 1 ] [ 0 ] [ 0 ] . '-' ; $ matches = array ( ) ; if ( preg_match ( '/^(\-|\+)/' , $ end , $ matches ) ) { $ end = substr ( $ end , 1 ) ; } $ matches =... | Clean the raw version . |
57,212 | protected static function matchVersion ( $ version , $ type ) { $ patchVersion = true ; if ( \ in_array ( $ type , array ( 'dev' , 'snapshot' ) , true ) ) { $ type = 'dev' ; $ patchVersion = false ; } elseif ( 'a' === $ type ) { $ type = 'alpha' ; } elseif ( \ in_array ( $ type , array ( 'b' , 'pre' ) , true ) ) { $ ty... | Match the version . |
57,213 | protected static function convertDateMinorVersion ( $ minor ) { $ split = explode ( '.' , $ minor ) ; $ minor = ( int ) $ split [ 0 ] ; $ revision = isset ( $ split [ 1 ] ) ? ( int ) $ split [ 1 ] : 0 ; return '.' . sprintf ( '%03d' , $ minor ) . sprintf ( '%03d' , $ revision ) ; } | Convert the minor version of date . |
57,214 | public function setPool ( Pool $ pool ) { $ this -> pool = $ pool ; foreach ( $ this -> poolRepositories as $ repo ) { $ pool -> addRepository ( $ repo ) ; } $ this -> poolRepositories = array ( ) ; return $ this ; } | Set the pool . |
57,215 | public function addRepositories ( array $ repositories ) { foreach ( $ repositories as $ index => $ repo ) { $ this -> validateRepositories ( $ index , $ repo ) ; if ( 'package' === $ repo [ 'type' ] ) { $ name = $ repo [ 'package' ] [ 'name' ] ; } else { $ name = \ is_int ( $ index ) ? preg_replace ( '{^https?://}i' ,... | Adds asset vcs repositories . |
57,216 | protected function validateRepositories ( $ index , $ repo ) { if ( ! \ is_array ( $ repo ) ) { throw new \ UnexpectedValueException ( 'Repository ' . $ index . ' (' . json_encode ( $ repo ) . ') should be an array, ' . \ gettype ( $ repo ) . ' given' ) ; } if ( ! isset ( $ repo [ 'type' ] ) ) { throw new \ UnexpectedV... | Validates the config of repositories . |
57,217 | protected function validatePackageRepositories ( $ index , $ repo ) { if ( 'package' !== $ repo [ 'type' ] ) { return ; } if ( ! isset ( $ repo [ 'package' ] ) ) { throw new \ UnexpectedValueException ( 'Repository ' . $ index . ' (' . json_encode ( $ repo ) . ') must have a package definition"' ) ; } foreach ( array (... | Validates the config of package repositories . |
57,218 | protected function validateVcsRepositories ( $ index , $ repo ) { if ( 'package' === $ repo [ 'type' ] ) { return ; } if ( false === strpos ( $ repo [ 'type' ] , '-' ) ) { throw new \ UnexpectedValueException ( 'Repository ' . $ index . ' (' . json_encode ( $ repo ) . ') must have a type defined in this way: "%asset-ty... | Validates the config of vcs repositories . |
57,219 | protected function getNoApiOption ( ) { $ packageName = $ this -> repoConfig [ 'package-name' ] ; $ opts = RepoUtil :: getArrayValue ( $ this -> repoConfig , 'vcs-driver-options' , array ( ) ) ; $ noApiOpt = RepoUtil :: getArrayValue ( $ opts , 'github-no-api' , array ( ) ) ; $ defaultValue = false ; if ( \ is_bool ( $... | Get the no - api repository option . |
57,220 | protected function getContents ( $ url , $ fetchingRepoData = false ) { $ url = $ this -> getValidContentUrl ( $ url ) ; if ( null !== $ this -> redirectApi ) { return parent :: getContents ( $ url , $ fetchingRepoData ) ; } try { $ contents = $ this -> getRemoteContents ( $ url ) ; $ this -> redirectApi = false ; retu... | Get the remote content . |
57,221 | protected function hasRedirectUrl ( $ url ) { if ( null === $ this -> redirectApi && 0 === strpos ( $ url , $ this -> getRepositoryApiUrl ( ) ) ) { $ this -> redirectApi = $ this -> getNewRepositoryUrl ( ) ; if ( \ is_string ( $ this -> redirectApi ) ) { $ this -> cache -> write ( 'redirect-api' , $ this -> redirectApi... | Check if the driver must find the new url . |
57,222 | protected function getNewRepositoryUrl ( ) { try { $ this -> getRemoteContents ( $ this -> getRepositoryUrl ( ) ) ; $ headers = $ this -> remoteFilesystem -> getLastHeaders ( ) ; if ( ! empty ( $ headers [ 0 ] ) && preg_match ( '{^HTTP/\S+ (30[1278])}i' , $ headers [ 0 ] , $ match ) ) { array_shift ( $ headers ) ; retu... | Get the new url of repository . |
57,223 | protected function findNewLocationInHeader ( array $ headers ) { $ url = false ; foreach ( $ headers as $ header ) { if ( 0 === strpos ( $ header , 'Location:' ) ) { $ newUrl = trim ( substr ( $ header , 9 ) ) ; preg_match ( '#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#' , $ newUrl , $ match ... | Find the new url api in the header . |
57,224 | protected function getRepositoryApiUrl ( $ owner = null , $ repository = null ) { $ owner = null !== $ owner ? $ owner : $ this -> owner ; $ repository = null !== $ repository ? $ repository : $ this -> repository ; return $ this -> getApiUrl ( ) . '/repos/' . $ owner . '/' . $ repository ; } | Get the url API of the repository . |
57,225 | protected function doAddBranches ( $ resource , array $ branchBlacklist ) { do { $ branchData = JsonFile :: parseJson ( ( string ) $ this -> getContents ( $ resource ) , $ resource ) ; foreach ( $ branchData as $ branch ) { $ name = substr ( $ branch [ 'ref' ] , 11 ) ; if ( ! \ in_array ( $ name , $ branchBlacklist , t... | Push the list of all branch . |
57,226 | protected function cleanRange ( $ range ) { foreach ( array ( '<' , '>' , '=' , '~' , '^' , '||' , '&&' ) as $ character ) { $ range = str_replace ( $ character . ' ' , $ character , $ range ) ; } $ range = preg_replace ( '/(?:[vV])(\d+)/' , '${1}' , $ range ) ; $ range = str_replace ( ' ||' , '||' , $ range ) ; return... | Clean the raw range . |
57,227 | protected function matchRange ( $ range ) { $ pattern = '/(\ -\ )|(<)|(>)|(=)|(\|\|)|(\ )|(,)|(\~)|(\^)/' ; $ matches = preg_split ( $ pattern , $ range , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ special = null ; $ replace = null ; $ first = true ; foreach ( $ matches as $ i => $ match ) { if ( $ first && '' !== $ match ) ... | Match the range . |
57,228 | protected function matchRangeToken ( $ i , $ match , array & $ matches , & $ special , & $ replace ) { if ( ' - ' === $ match ) { $ matches [ $ i - 1 ] = '>=' . str_replace ( array ( '*' , 'x' , 'X' ) , '0' , $ matches [ $ i - 1 ] ) ; if ( false !== strpos ( $ matches [ $ i + 1 ] , '.' ) && false === strpos ( $ matches... | Converts the token of the matched range . |
57,229 | public static function convertName ( $ name ) { if ( 0 === strpos ( $ name , '@' ) && false !== strpos ( $ name , '/' ) ) { $ name = ltrim ( str_replace ( '/' , '--' , $ name ) , '@' ) ; } return $ name ; } | Convert the npm package name . |
57,230 | public static function convertLicenses ( $ licenses ) { if ( ! \ is_array ( $ licenses ) ) { return $ licenses ; } $ result = array ( ) ; foreach ( $ licenses as $ license ) { if ( \ is_array ( $ license ) ) { if ( ! empty ( $ license [ 'type' ] ) ) { $ result [ ] = $ license [ 'type' ] ; } elseif ( ! empty ( $ license... | Convert the npm licenses list . |
57,231 | public static function convertContributors ( $ value , $ prevValue ) { $ mergeValue = \ is_array ( $ prevValue ) ? $ prevValue : array ( ) ; $ mergeValue = array_merge ( $ mergeValue , \ is_array ( $ value ) ? $ value : array ( ) ) ; if ( \ count ( $ mergeValue ) > 0 ) { $ value = $ mergeValue ; } return $ value ; } | Convert the contributors section . |
57,232 | public static function convertDist ( $ value ) { if ( \ is_array ( $ value ) ) { $ data = ( array ) $ value ; $ value = array ( ) ; foreach ( $ data as $ type => $ url ) { if ( \ is_string ( $ url ) ) { self :: convertDistEntry ( $ value , $ type , $ url ) ; } } } return $ value ; } | Convert the dist section . |
57,233 | private static function convertDistEntry ( array & $ value , $ type , $ url ) { $ httpPrefix = 'http://' ; if ( 0 === strpos ( $ url , $ httpPrefix ) ) { $ url = 'https://' . substr ( $ url , \ strlen ( $ httpPrefix ) ) ; } if ( 'shasum' === $ type ) { $ value [ $ type ] = $ url ; } elseif ( 'tarball' === $ type ) { $ ... | Convert the each entry of dist section . |
57,234 | public static function create ( Config $ config , Composer $ composer , PackageInterface $ package , $ installDir = null , $ section = 'ignore-files' ) { $ installDir = static :: getInstallDir ( $ composer , $ package , $ installDir ) ; $ manager = new IgnoreManager ( $ installDir ) ; $ config = $ config -> getArray ( ... | Create a ignore manager . |
57,235 | protected static function getInstallDir ( Composer $ composer , PackageInterface $ package , $ installDir = null ) { if ( null === $ installDir ) { $ installDir = rtrim ( $ composer -> getConfig ( ) -> get ( 'vendor-dir' ) , '/' ) . '/' . $ package -> getName ( ) ; } return rtrim ( $ installDir , '/' ) ; } | Get the installation directory of the package . |
57,236 | protected static function addPatterns ( IgnoreManager $ manager , $ patterns ) { $ enabled = false === $ patterns ? false : true ; $ manager -> setEnabled ( $ enabled ) ; if ( \ is_array ( $ patterns ) ) { foreach ( $ patterns as $ pattern ) { $ manager -> addPattern ( $ pattern ) ; } } } | Add ignore file patterns in the ignore manager . |
57,237 | protected function deleteIgnoredFiles ( PackageInterface $ package ) { $ manager = IgnoreFactory :: create ( $ this -> config , $ this -> composer , $ package , $ this -> getInstallPath ( $ package ) ) ; if ( $ manager -> isEnabled ( ) && ! $ manager -> hasPattern ( ) ) { $ this -> addIgnorePatterns ( $ manager , $ pac... | Deletes files defined in bower . json in section ignore . |
57,238 | protected function putArrayRepositoryConfig ( array $ packageConfigs , $ name , Pool $ pool ) { $ packages = $ this -> createArrayRepositoryConfig ( $ packageConfigs ) ; $ repo = new ArrayRepository ( $ packages ) ; Util :: addRepositoryInstance ( $ this -> io , $ this -> repositoryManager , $ this -> repos , $ name , ... | Create and put the array repository with the asset configs . |
57,239 | protected function createArrayRepositoryConfig ( array $ packageConfigs ) { $ packages = array ( ) ; $ loader = new ArrayLoader ( ) ; foreach ( $ packageConfigs as $ version => $ config ) { try { $ config [ 'version' ] = $ version ; $ config = $ this -> assetType -> getPackageConverter ( ) -> convert ( $ config ) ; $ c... | Create the array repository with the asset configs . |
57,240 | public static function create ( $ repoConfig , $ port , $ path , ProcessExecutor $ process , IOInterface $ io ) { $ isWindows = \ defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ; return new self ( $ repoConfig , $ port , $ path , $ process , $ isWindows , $ io ) ; } | Create perforce helper . |
57,241 | protected function findWhatProvides ( $ name ) { $ assetPrefix = $ this -> assetType -> getComposerVendorName ( ) . '/' ; if ( false === strpos ( $ name , $ assetPrefix ) ) { return array ( ) ; } if ( isset ( $ this -> providers [ $ name ] ) ) { return $ this -> providers [ $ name ] ; } $ data = null ; if ( $ this -> h... | Finds what provides in cache or return empty array if the name is not a asset package . |
57,242 | protected function hasVcsRepository ( $ name ) { foreach ( $ this -> repositoryManager -> getRepositories ( ) as $ mRepo ) { if ( $ mRepo instanceof AssetVcsRepository && $ name === $ mRepo -> getComposerPackageName ( ) ) { return true ; } } return false ; } | Checks if the package vcs repository is already include in repository manager . |
57,243 | protected function whatProvidesManageException ( Pool $ pool , $ name , \ Exception $ exception ) { if ( $ exception instanceof TransportException ) { $ this -> fallbackWathProvides ( $ pool , $ name , $ exception ) ; return ; } throw $ exception ; } | Manage exception for whatProvides method . |
57,244 | protected function fallbackWathProvides ( Pool $ pool , $ name , TransportException $ ex ) { $ providers = array ( ) ; if ( 404 === $ ex -> getCode ( ) && ! $ this -> fallbackProviders ) { $ this -> fallbackProviders = true ; $ repoName = Util :: convertAliasName ( $ name ) ; $ results = $ this -> search ( $ repoName )... | Searchs if the registry has a package with the same name exists with a different camelcase . |
57,245 | public function addPattern ( $ pattern ) { $ this -> doAddPattern ( $ this -> convertPattern ( $ pattern ) ) ; $ this -> hasPattern = true ; } | Adds an ignore pattern . |
57,246 | public function cleanup ( ) { if ( $ this -> isEnabled ( ) && $ this -> hasPattern ( ) && realpath ( $ this -> installDir ) ) { $ paths = iterator_to_array ( $ this -> finder -> in ( $ this -> installDir ) ) ; foreach ( $ paths as $ path ) { $ this -> filesystem -> remove ( $ path ) ; } } } | Deletes all files and directories that matches patterns . |
57,247 | public function doAddPattern ( $ pattern ) { if ( 0 === strpos ( $ pattern , '!' ) ) { $ searchPattern = substr ( $ pattern , 1 ) ; $ this -> finder -> notPath ( Glob :: toRegex ( $ searchPattern , true , true ) ) ; $ pathComponents = explode ( '/' , $ searchPattern ) ; if ( 1 < \ count ( $ pathComponents ) ) { $ paren... | Action for Add an ignore pattern . |
57,248 | protected function convertPattern ( $ pattern ) { $ prefix = 0 === strpos ( $ pattern , '!' ) ? '!' : '' ; $ searchPattern = trim ( ltrim ( $ pattern , '!' ) , '/' ) ; $ pattern = $ prefix . $ searchPattern ; if ( \ in_array ( $ searchPattern , array ( '*' , '*.*' ) , true ) ) { $ this -> doAddPattern ( $ prefix . '.*'... | Converter pattern to glob . |
57,249 | protected function convertExtraKey ( array $ asset , $ assetKey , array & $ composer , $ composerKey , $ extraKey = 'extra' ) { $ extra = isset ( $ composer [ $ extraKey ] ) ? $ composer [ $ extraKey ] : array ( ) ; $ this -> convertKey ( $ asset , $ assetKey , $ extra , $ composerKey ) ; if ( \ count ( $ extra ) > 0 )... | Converts the extra key of package . |
57,250 | protected function convertDependencies ( array $ asset , $ assetKey , array & $ composer , $ composerKey , array & $ vcsRepos = array ( ) ) { if ( isset ( $ asset [ $ assetKey ] ) && \ is_array ( $ asset [ $ assetKey ] ) ) { $ newDependencies = array ( ) ; foreach ( $ asset [ $ assetKey ] as $ dependency => $ version )... | Converts simple key of package . |
57,251 | protected function convertDependency ( $ dependency , $ version , array & $ vcsRepos , array $ composer ) { list ( $ dependency , $ version ) = PackageUtil :: checkUrlVersion ( $ this -> assetType , $ dependency , $ version , $ vcsRepos , $ composer ) ; list ( $ dependency , $ version ) = PackageUtil :: checkAliasVersi... | Convert the . |
57,252 | protected function getPathRev ( $ identifier ) { $ path = $ identifier ; $ rev = '' ; preg_match ( '{^(.+?)(@\d+)?/$}' , $ identifier , $ match ) ; if ( ! empty ( $ match [ 2 ] ) ) { $ path = $ match [ 1 ] ; $ rev = $ match [ 2 ] ; } return array ( $ path , $ rev ) ; } | Get path and rev . |
57,253 | protected function getComposerContent ( $ resource , $ rev ) { $ output = null ; try { $ output = $ this -> execute ( $ this -> getSvnCredetials ( 'svn cat' ) , $ this -> baseUrl . $ resource . $ rev ) ; } catch ( \ RuntimeException $ e ) { throw new TransportException ( $ e -> getMessage ( ) ) ; } return $ output ; } | Get the composer content . |
57,254 | protected function parseComposerContent ( $ output , $ resource , $ path , $ rev ) { if ( ! trim ( $ output ) ) { return array ( '_nonexistent_package' => true ) ; } $ composer = ( array ) JsonFile :: parseJson ( $ output , $ this -> baseUrl . $ resource . $ rev ) ; return $ this -> addComposerTime ( $ composer , $ pat... | Parse the content of composer . |
57,255 | protected function getSvnCredetials ( $ command ) { $ httpBasic = $ this -> config -> get ( 'http-basic' ) ; $ parsedUrl = parse_url ( $ this -> baseUrl ) ; $ svnCommand = $ command ; if ( $ parsedUrl && isset ( $ httpBasic [ $ parsedUrl [ 'host' ] ] ) ) { if ( $ httpBasic [ $ parsedUrl [ 'host' ] ] [ 'username' ] && $... | Get the credentials of SVN . |
57,256 | public static function a ( string $ rdata ) : string { if ( ! filter_var ( $ rdata , FILTER_VALIDATE_IP ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The IP address "%s" is invalid.' , $ rdata ) ) ; } return inet_pton ( $ rdata ) ; } | Used for A and AAAA records . |
57,257 | private function IANA2PHP ( int $ type ) : int { $ constantName = 'DNS_' . RecordTypeEnum :: getName ( $ type ) ; if ( ! defined ( $ constantName ) ) { throw new UnsupportedTypeException ( sprintf ( 'Record type "%d" is not a supported type.' , $ type ) ) ; } $ phpType = constant ( $ constantName ) ; if ( ! is_int ( $ ... | Maps an IANA Rdata type to the built - in PHP DNS constant . |
57,258 | public function onMessage ( string $ message , string $ address , SocketInterface $ socket ) { try { $ this -> dispatch ( Events :: MESSAGE , new MessageEvent ( $ socket , $ address , $ message ) ) ; $ socket -> send ( $ this -> handleQueryFromStream ( $ message ) , $ address ) ; } catch ( \ Exception $ exception ) { $... | This methods gets called each time a query is received . |
57,259 | public function handleQueryFromStream ( string $ buffer ) : string { $ message = Decoder :: decodeMessage ( $ buffer ) ; $ this -> dispatch ( Events :: QUERY_RECEIVE , new QueryReceiveEvent ( $ message ) ) ; $ responseMessage = clone $ message ; $ responseMessage -> getHeader ( ) -> setResponse ( true ) -> setRecursion... | Decode a message and return an encoded response . |
57,260 | private function needsAdditionalRecords ( Message $ message ) : void { foreach ( $ message -> getAnswers ( ) as $ answer ) { $ name = null ; switch ( $ answer -> getType ( ) ) { case RecordTypeEnum :: TYPE_NS : $ name = $ answer -> getRdata ( ) ; break ; case RecordTypeEnum :: TYPE_MX : $ name = $ answer -> getRdata ( ... | Populate the additional records of a message if required . |
57,261 | public function isWildcardDomain ( string $ domain ) : bool { $ domain = rtrim ( $ domain , '.' ) . '.' ; $ pattern = '/^\*\.(?:[a-zA-Z0-9\-\_]+\.)*$/' ; return ( bool ) preg_match ( $ pattern , $ domain ) ; } | Determine if a domain is a wildcard domain . |
57,262 | protected function addWildcardRecord ( ResourceRecord $ resourceRecord ) : void { $ labels = explode ( '.' , rtrim ( $ resourceRecord -> getName ( ) , '.' ) ) ; $ labels = array_reverse ( $ labels ) ; $ array = & $ this -> wildcardRecords ; foreach ( $ labels as $ label ) { if ( '*' === $ label ) { $ array [ $ label ] ... | Add a wildcard ResourceRecord . |
57,263 | protected function handleName ( string $ name , string $ parent ) { if ( '@' === $ name || '' === $ name ) { return $ parent ; } if ( '.' !== substr ( $ name , - 1 , 1 ) ) { return $ name . '.' . $ parent ; } return $ name ; } | Add the parent domain to names that are not fully qualified . |
57,264 | private function simpleXmlToArray ( \ SimpleXMLElement $ xmlObject ) : array { $ array = [ ] ; foreach ( $ xmlObject -> children ( ) as $ node ) { $ array [ $ node -> getName ( ) ] = is_array ( $ node ) ? $ this -> simpleXmlToArray ( $ node ) : ( string ) $ node ; } return $ array ; } | Convert a SimpleXML object to an associative array . |
57,265 | public function allowsRecursion ( ) : bool { foreach ( $ this -> resolvers as $ resolver ) { if ( $ resolver -> allowsRecursion ( ) ) { return true ; } } return false ; } | Check if any of the resolvers supports recursion . |
57,266 | public static function encodeDomainName ( $ domain ) : string { if ( '.' === $ domain ) { return chr ( 0 ) ; } $ domain = rtrim ( $ domain , '.' ) . '.' ; $ res = '' ; foreach ( explode ( '.' , $ domain ) as $ label ) { $ res .= chr ( strlen ( $ label ) ) . $ label ; } return $ res ; } | Encode a domain name as a sequence of labels . |
57,267 | private static function encodeFlags ( Header $ header ) : int { return 0x0 | ( $ header -> isResponse ( ) & 0x1 ) << 15 | ( $ header -> getOpcode ( ) & 0xf ) << 11 | ( $ header -> isAuthoritative ( ) & 0x1 ) << 10 | ( $ header -> isTruncated ( ) & 0x1 ) << 9 | ( $ header -> isRecursionDesired ( ) & 0x1 ) << 8 | ( $ hea... | Encode the bit field of the Header between ID and QDCOUNT . |
57,268 | public static function init ( $ lifeTime = 0 ) { if ( self :: $ sessionStarted == false ) { session_set_cookie_params ( $ lifeTime ) ; session_start ( ) ; return self :: $ sessionStarted = true ; } return false ; } | If session has not started start sessions . |
57,269 | public static function set ( $ key , $ value = false ) { if ( is_array ( $ key ) && $ value == false ) { foreach ( $ key as $ name => $ value ) { $ _SESSION [ self :: $ prefix . $ name ] = $ value ; } } else { $ _SESSION [ self :: $ prefix . $ key ] = $ value ; } return true ; } | Add value to a session . |
57,270 | public static function pull ( $ key ) { if ( isset ( $ _SESSION [ self :: $ prefix . $ key ] ) ) { $ value = $ _SESSION [ self :: $ prefix . $ key ] ; unset ( $ _SESSION [ self :: $ prefix . $ key ] ) ; return $ value ; } return null ; } | Extract session item delete session item and finally return the item . |
57,271 | public static function get ( $ key = '' , $ secondkey = false ) { $ name = self :: $ prefix . $ key ; if ( empty ( $ key ) ) { return isset ( $ _SESSION ) ? $ _SESSION : null ; } elseif ( $ secondkey == true ) { if ( isset ( $ _SESSION [ $ name ] [ $ secondkey ] ) ) { return $ _SESSION [ $ name ] [ $ secondkey ] ; } } ... | Get item from session . |
57,272 | public static function destroy ( $ key = '' , $ prefix = false ) { if ( self :: $ sessionStarted == true ) { if ( $ key == '' && $ prefix == false ) { session_unset ( ) ; session_destroy ( ) ; } elseif ( $ prefix == true ) { foreach ( $ _SESSION as $ index => $ value ) { if ( strpos ( $ index , self :: $ prefix ) === 0... | Empties and destroys the session . |
57,273 | public function setColor ( $ color ) { if ( null === $ color ) { return $ this ; } $ this -> color = $ this -> convertColor ( $ color ) ; return $ this ; } | Set the image color . |
57,274 | private function convertHashToArrayOfBoolean ( ) { preg_match_all ( '/(\w)(\w)/' , $ this -> hash , $ chars ) ; foreach ( $ chars [ 1 ] as $ i => $ char ) { $ index = ( int ) ( $ i / 3 ) ; $ data = $ this -> convertHexaToBoolean ( $ char ) ; $ items = [ 0 => [ 0 , 4 ] , 1 => [ 1 , 3 ] , 2 => [ 2 ] , ] ; foreach ( $ ite... | Convert the hash into an multidimensional array of boolean . |
57,275 | public function setString ( $ string ) { if ( null === $ string ) { throw new Exception ( 'The string cannot be null.' ) ; } $ this -> hash = md5 ( $ string ) ; $ this -> convertHashToArrayOfBoolean ( ) ; return $ this ; } | Generate a hash from the original string . |
57,276 | public function setSize ( $ size ) { if ( null === $ size ) { return $ this ; } $ this -> size = $ size ; $ this -> pixelRatio = ( int ) round ( $ size / 5 ) ; return $ this ; } | Set the image size . |
57,277 | public function displayImage ( $ string , $ size = 64 , $ color = null , $ backgroundColor = null ) { header ( 'Content-Type: ' . $ this -> generator -> getMimeType ( ) ) ; echo $ this -> getImageData ( $ string , $ size , $ color , $ backgroundColor ) ; } | Display an Identicon image . |
57,278 | public function getImageResource ( $ string , $ size = 64 , $ color = null , $ backgroundColor = null ) { return $ this -> generator -> getImageResource ( $ string , $ size , $ color , $ backgroundColor ) ; } | Get an Identicon PNG image resource . |
57,279 | public function getImageDataUri ( $ string , $ size = 64 , $ color = null , $ backgroundColor = null ) { return sprintf ( 'data:%s;base64,%s' , $ this -> generator -> getMimeType ( ) , base64_encode ( $ this -> getImageData ( $ string , $ size , $ color , $ backgroundColor ) ) ) ; } | Get an Identicon PNG image data as base 64 encoded . |
57,280 | public function getRelatedElements ( $ params = null ) { $ fieldParams = explode ( '.' , $ params [ 'relatedTo' ] [ 'field' ] ) ; if ( ! isset ( $ fieldParams [ 0 ] ) || ! isset ( $ fieldParams [ 1 ] ) ) { return false ; } $ superTableFieldHandle = $ fieldParams [ 0 ] ; $ superTableBlockFieldHandle = $ fieldParams [ 1 ... | Expands the defualt relationship behaviour to include Super Table fields so that the user can filter by those too . |
57,281 | public function getBlockTypes ( ) : array { if ( $ this -> _blockTypes !== null ) { return $ this -> _blockTypes ; } if ( $ this -> getIsNew ( ) ) { return [ ] ; } return $ this -> _blockTypes = SuperTable :: $ plugin -> getService ( ) -> getBlockTypesByFieldId ( $ this -> id ) ; } | Returns the block types . |
57,282 | public function getBlockTypeFields ( ) : array { if ( $ this -> _blockTypeFields !== null ) { return $ this -> _blockTypeFields ; } if ( empty ( $ blockTypes = $ this -> getBlockTypes ( ) ) ) { return $ this -> _blockTypeFields = [ ] ; } $ contexts = [ ] ; $ layoutIds = [ ] ; foreach ( $ blockTypes as $ blockType ) { $... | Returns all of the block types fields . |
57,283 | public function setBlockTypes ( $ blockTypes ) { $ this -> _blockTypes = [ ] ; $ defaultFieldConfig = [ 'type' => null , 'instructions' => null , 'required' => false , 'translationMethod' => Field :: TRANSLATION_METHOD_NONE , 'translationKeyFormat' => null , 'typesettings' => null , ] ; foreach ( $ blockTypes as $ key ... | Sets the block types . |
57,284 | private function _getBlockTypeInfoForInput ( ElementInterface $ element = null ) : array { $ settings = $ this -> getSettings ( ) ; $ blockTypes = [ ] ; $ originalNamespace = Craft :: $ app -> getView ( ) -> getNamespace ( ) ; $ namespace = Craft :: $ app -> getView ( ) -> namespaceInputName ( $ this -> handle . '[__BL... | Returns info about each block type and their field types for the Super Table field input . |
57,285 | public function getBlockTypesByFieldId ( int $ fieldId ) : array { if ( ! empty ( $ this -> _fetchedAllBlockTypesForFieldId [ $ fieldId ] ) ) { return $ this -> _blockTypesByFieldId [ $ fieldId ] ; } $ this -> _blockTypesByFieldId [ $ fieldId ] = [ ] ; $ results = $ this -> _createBlockTypeQuery ( ) -> where ( [ 'field... | Returns the block types for a given Super Table field . |
57,286 | public function getBlockTypeById ( int $ blockTypeId ) { if ( $ this -> _blockTypesById !== null && array_key_exists ( $ blockTypeId , $ this -> _blockTypesById ) ) { return $ this -> _blockTypesById [ $ blockTypeId ] ; } $ result = $ this -> _createBlockTypeQuery ( ) -> where ( [ 'id' => $ blockTypeId ] ) -> one ( ) ;... | Returns a block type by its ID . |
57,287 | public function validateBlockType ( SuperTableBlockTypeModel $ blockType , bool $ validateUniques = true ) : bool { $ validates = true ; $ reservedHandles = [ 'type' ] ; $ blockTypeRecord = $ this -> _getBlockTypeRecord ( $ blockType ) ; $ blockTypeRecord -> fieldId = $ blockType -> fieldId ; if ( ! $ blockTypeRecord -... | Validates a block type . |
57,288 | public function saveBlockType ( SuperTableBlockTypeModel $ blockType , bool $ runValidation = true ) : bool { if ( $ runValidation && ! $ blockType -> validate ( ) ) { return false ; } $ fieldsService = Craft :: $ app -> getFields ( ) ; $ parentField = $ fieldsService -> getFieldById ( $ blockType -> fieldId ) ; $ isNe... | Saves a block type . |
57,289 | public function deleteBlockType ( SuperTableBlockTypeModel $ blockType ) : bool { Craft :: $ app -> getProjectConfig ( ) -> remove ( self :: CONFIG_BLOCKTYPE_KEY . '.' . $ blockType -> uid ) ; return true ; } | Deletes a block type . |
57,290 | public function validateFieldSettings ( SuperTableField $ supertableField ) : bool { $ validates = true ; foreach ( $ supertableField -> getBlockTypes ( ) as $ blockType ) { if ( ! $ this -> validateBlockType ( $ blockType , false ) ) { $ validates = false ; $ blockTypeErrors = $ blockType -> getErrors ( ) ; if ( ! $ b... | Validates a Super Table field s settings . |
57,291 | public function deleteSuperTableField ( SuperTableField $ supertableField ) : bool { $ db = Craft :: $ app -> getDb ( ) ; $ db -> getSchema ( ) -> refresh ( ) ; $ transaction = $ db -> beginTransaction ( ) ; try { $ originalContentTable = Craft :: $ app -> getContent ( ) -> contentTable ; Craft :: $ app -> getContent (... | Deletes a Super Table field . |
57,292 | public function defineContentTableName ( SuperTableField $ field ) : string { $ baseName = 'stc_' . strtolower ( $ field -> handle ) ; $ db = Craft :: $ app -> getDb ( ) ; $ i = - 1 ; do { $ i ++ ; $ parentFieldId = '' ; if ( $ field -> context != 'global' ) { $ parentFieldContext = explode ( ':' , $ field -> context )... | Defines a new Super Table content table name . |
57,293 | public function getBlockById ( int $ blockId , int $ siteId = null ) { $ block = Craft :: $ app -> getElements ( ) -> getElementById ( $ blockId , SuperTableBlockElement :: class , $ siteId ) ; return $ block ; } | Returns a block by its ID . |
57,294 | public function saveField ( SuperTableField $ field , ElementInterface $ owner ) { if ( $ owner -> duplicateOf !== null ) { $ query = $ owner -> duplicateOf -> getFieldValue ( $ field -> handle ) ; $ duplicateBlocks = ! $ owner -> propagating || $ field -> localizeBlocks ; } else { $ query = $ owner -> getFieldValue ( ... | Saves a Super Table field . |
57,295 | private function _getBlockTypeRecord ( $ blockType ) : SuperTableBlockTypeRecord { if ( is_string ( $ blockType ) ) { $ blockTypeRecord = SuperTableBlockTypeRecord :: findOne ( [ 'uid' => $ blockType ] ) ?? new SuperTableBlockTypeRecord ( ) ; if ( ! $ blockTypeRecord -> getIsNewRecord ( ) ) { $ this -> _blockTypeRecord... | Returns a block type record by its ID or creates a new one . |
57,296 | private function _createContentTable ( string $ tableName ) { $ migration = new CreateSuperTableContentTable ( [ 'tableName' => $ tableName ] ) ; ob_start ( ) ; $ migration -> up ( ) ; ob_end_clean ( ) ; } | Creates the content table for a Super Table field . |
57,297 | private function _applyFieldTranslationSetting ( ElementInterface $ owner , SuperTableField $ field ) { if ( $ field -> localizeBlocks ) { $ blockQuery = SuperTableBlockElement :: find ( ) -> fieldId ( $ field -> id ) -> ownerId ( $ owner -> id ) -> anyStatus ( ) -> siteId ( $ owner -> siteId ) -> ownerSiteId ( ':empty... | Applies the field s translation setting to a set of blocks . |
57,298 | public function getHandle ( ) { if ( ! isset ( $ this -> handle ) && $ this -> fieldId ) { $ field = Craft :: $ app -> fields -> getFieldById ( $ this -> fieldId ) ; foreach ( $ field -> getBlockTypes ( ) as $ index => $ blockType ) { if ( $ blockType -> id == $ this -> id ) { $ this -> handle = $ field -> handle . '-'... | Fake handle for easier integrations . |
57,299 | public function execute ( $ i , $ maxProcesses , $ suite , $ currentProcessCounter , $ isFirstOnItsThread = false ) { return array_change_key_case ( static :: cleanEnvVariables ( $ _SERVER ) + $ _ENV + [ self :: ENV_TEST_CHANNEL => ( int ) $ i , self :: ENV_TEST_CHANNEL_READABLE => 'test_' . $ i , self :: ENV_TEST_CHAN... | create an array of env |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.