idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
12,400 | public function hasSort ( string $ field ) : bool { foreach ( $ this -> sorts as $ sort ) { if ( $ field === $ sort -> getField ( ) ) { return true ; } } return false ; } | Tell if this Jory contains a sorting on the given field . |
12,401 | public function hasFilter ( string $ field ) : bool { if ( $ this -> filter === null ) { return false ; } return $ this -> filter -> hasFilter ( $ field ) ; } | Tell if this Jory contains a filter on the given field . |
12,402 | private static function ensureKeyPair ( ) { $ publicKeyLocation = DIR_DATA . 'xentriq/security/xentriq.security.website.pub' ; $ privateKeyLocation = DIR_DATA . 'xentriq/security/xentriq.security.website.priv' ; if ( ! file_exists ( $ publicKeyLocation ) || ! file_exists ( $ privateKeyLocation ) ) { $ privateKey = open... | Ensures that the keypair essential to the security functions used in Xentriq have are available . |
12,403 | public function getTimeZone ( ) { try { return new \ DateTimeZone ( $ this -> timezone ) ; } catch ( \ Exception $ e ) { return new \ DateTimeZone ( Yii :: $ app -> timeZone ) ; } } | Get the user s time zone . Defaults to the application timezone if not specified by the user . |
12,404 | public function process ( ) { $ reader = new AnnotationReader ( ) ; $ paths = array ( ) ; foreach ( $ this -> routeCollection -> getIterator ( ) as $ route ) { $ routeMethod = $ this -> getReflectionMethodForRoute ( $ route ) ; if ( $ routeMethod === null ) continue ; $ swaggerAnnotation = $ reader -> getMethodAnnotati... | Processes all the routes in the application to build the swagger json . Generates an array containing all the paths . |
12,405 | private function createResponsesForRoute ( $ annotations ) { $ responses = array ( ) ; foreach ( $ annotations as $ annotation ) { if ( $ annotation instanceof SwaggerResult ) { $ response = array ( "description" => $ annotation -> description ) ; if ( $ annotation -> schema !== null ) { $ schema = $ this -> processSch... | Creates a responses array for the route which has those annotations passes into this function |
12,406 | private function getReflectionMethodForRoute ( Route $ route ) { $ class = $ this -> extractClassFromRoute ( $ route ) ; $ method = $ this -> extractFunctionFromRoute ( $ route ) ; if ( $ class !== null && $ method !== null ) { return new \ ReflectionMethod ( $ class , $ method ) ; } return null ; } | Returns the ReflectionMethod class for a route . |
12,407 | public static function convert ( array $ json ) { $ loader = new ArrayLoader ; $ package = $ loader -> load ( $ json ) ; if ( $ package instanceof CompletePackage ) { return $ package ; } throw new InvalidPackageException ( 'Expected instance of CompletePackage, got ' . get_class ( $ package ) ) ; } | Convert json to Package . |
12,408 | protected function _compress ( ) { $ start = microtime ( true ) ; $ this -> info ( ' Trying to compress files' ) ; $ config = $ this -> config ; $ exclude = $ config [ 'files' ] [ 'exclude' ] ; $ archiver = $ config [ 'archiver' ] ; if ( ! empty ( $ config [ 'files' ] [ 'archiver' ] ) ) { $ archiver = $ config [ 'file... | Create database backup |
12,409 | public function __named ( string $ class , string $ method , array $ args = array ( ) ) { FEnv :: set ( "app.activity_called" , array ( "class" => $ class , "method" => $ method ) ) ; $ container = FrameworkContainer :: getInstance ( ) ; $ call = $ container -> get ( $ class ) ; $ rs = $ container -> call ( $ class . "... | Pass method arguments by name |
12,410 | public function getCurrentBranch ( $ projectRoot ) { $ result = Shell :: execute ( '(cd {projectRoot}; {binPath} branch)' , [ '{binPath}' => $ this -> binPath , '{projectRoot}' => $ projectRoot , ] ) ; return $ result -> outputLines [ 0 ] ; } | Returns currently active Mercurial branch name for the project . |
12,411 | private function createTreeArray ( ) { $ tree = [ ] ; foreach ( $ this -> models as $ model ) { $ tree [ ] = [ 'id' => $ model -> { $ this -> id } , 'parent_id' => $ model -> { $ this -> parent_id } , 'model' => $ model , ] ; } return $ tree ; } | Create tree array from models . |
12,412 | private function hasChild ( $ rows , $ id ) { foreach ( $ rows as $ row ) { if ( $ row [ 'parent_id' ] == $ id ) { return true ; } } return false ; } | Check node for child . |
12,413 | private function buildTree ( $ rows , $ parent_id = 0 ) { $ containerAttributes = '' ; if ( ! $ this -> containerOptionsIsSet ) { $ containerAttributes = Html :: renderTagAttributes ( $ this -> containerOptions ) ; $ this -> containerOptionsIsSet = true ; } $ result = "<ul$containerAttributes>" ; foreach ( $ rows as $ ... | Create tree . |
12,414 | public function export ( ) { openlog ( $ this -> identity , LOG_ODELAY | LOG_PID , $ this -> facility ) ; foreach ( $ this -> messages as $ message ) { syslog ( $ this -> _syslogLevels [ $ message [ 1 ] ] , $ this -> formatMessage ( $ message ) ) ; } closelog ( ) ; } | Writes log messages to syslog |
12,415 | public static function is_running ( ) { if ( ! file_exists ( Config :: $ pid_file ) ) { return false ; } $ pid = file_get_contents ( Config :: $ pid_file ) ; if ( posix_getpgid ( $ pid ) === false ) { unlink ( Config :: $ pid_file ) ; return false ; } return true ; } | public static function running |
12,416 | private function get_first_transaction ( & $ transactions , $ parallel ) { foreach ( $ transactions as $ key => $ transaction ) { if ( $ transaction -> parallel == $ parallel ) { unset ( $ transactions [ $ key ] ) ; $ transaction -> lock_transaction ( ) ; return $ transaction ; } } return null ; } | Check the status of a given slot |
12,417 | public function compressFile ( string $ filePath ) : bool { $ compressor = $ this -> getCompressor ( ) ; if ( null === $ compressor ) { return false ; } $ process = new Process ( \ array_merge ( $ compressor , [ $ filePath ] ) ) ; $ process -> run ( ) ; return $ process -> isSuccessful ( ) ; } | Tries to compress the given file and writes the output to the same path with added . gz . |
12,418 | public function actionConfirm ( $ search ) { $ user = User :: findByEmailOrMobile ( $ search ) ; if ( $ user === null ) { $ this -> stdout ( Yii :: t ( 'user' , 'User is not found' ) . "\n" , Console :: FG_RED ) ; } else { if ( $ user -> setEmailConfirm ( ) ) { $ this -> stdout ( Yii :: t ( 'user' , 'User has been conf... | Confirms a user by setting confirmed_at field to current time . |
12,419 | public function addOptions ( array $ options ) { foreach ( $ options as $ name => $ value ) { $ this -> addOption ( $ name , $ value ) ; } return $ this ; } | Add specifically curl option list to current request |
12,420 | public function addOption ( $ name , $ value ) { if ( strpos ( $ name , '.' ) !== false ) { $ method = explode ( '.' , $ name ) ; $ method = array_shift ( $ method ) . implode ( '' , array_map ( 'ucfirst' , $ method ) ) ; $ this -> configuration -> $ method ( $ value ) ; } elseif ( $ name === 'user_agent' ) { $ this ->... | Add an option for current request |
12,421 | public function send ( ) { if ( ! $ this -> client ) { throw new RuntimeException ( 'A client must be set on the request' ) ; } if ( null === $ this -> configuration -> url ) { $ this -> configuration -> url = $ this -> getUrl ( ) -> toString ( ) ; } $ this -> prepare ( ) ; return $ this -> client -> send ( $ this ) ; ... | Send method . To send a request a client must be linked |
12,422 | public function setUserAgent ( $ ua ) { $ this -> configuration -> user_agent = $ ua ; $ this -> addHeader ( 'User-Agent' , $ ua ) ; return $ this ; } | Set the client UA for current request |
12,423 | public function compare ( SchemaVersion $ version ) { return version_compare ( str_replace ( '-' , '.' , $ this -> toString ( ) ) , str_replace ( '-' , '.' , $ version -> toString ( ) ) ) ; } | Returns - 1 if the current version is lower than the second 0 if they are equal and 1 if the second is lower . |
12,424 | protected function buildLengthAware ( $ numberOfPages ) { $ pages = $ this -> newPages ( ) ; if ( $ this -> totalCount < 1 ) { return $ pages ; } return $ this -> addPages ( $ pages , 1 , $ numberOfPages ) ; } | Buid pages if total count is known . |
12,425 | protected function buildLengthUnaware ( ) { $ pages = $ this -> newPages ( ) ; $ itemCount = count ( $ this -> items ) ; if ( $ itemCount < 1 ) { return $ pages ; } $ perhapsMorePages = $ itemCount >= $ this -> perPage ; $ pageParameter = $ this -> getPageParameterName ( ) ; $ currentPage = $ this -> currentPageNumber ... | Build pages when no total count is available . |
12,426 | protected function buildStartEmphasized ( $ squeezeTo , $ numberOfPages ) { $ pages = $ this -> newPages ( $ numberOfPages ) ; $ this -> addPages ( $ pages , 1 , $ squeezeTo - static :: $ defaultSqueezeSpace ) ; $ this -> addPlaceHolder ( $ pages ) ; $ this -> addPages ( $ pages , $ numberOfPages - ( static :: $ defaul... | Build pages for one of the first pages . Many pages at the start will be visible less at the end . |
12,427 | protected function buildEndEmphasized ( $ squeezeTo , $ numberOfPages ) { $ pages = $ this -> newPages ( $ numberOfPages ) ; $ this -> addPages ( $ pages , 1 , static :: $ defaultSqueezeSpace ) ; $ this -> addPlaceHolder ( $ pages ) ; $ leftOffset = $ squeezeTo - ( static :: $ defaultSqueezeSpace + 1 ) ; $ this -> addP... | Build pages for the last pages . Many pages at the end will be visible less at the start . |
12,428 | protected function buildCentered ( $ squeezeTo , $ numberOfPages ) { $ pages = $ this -> newPages ( $ numberOfPages ) ; $ midLength = $ squeezeTo - 2 ; $ midOffset = $ this -> currentPageNumber - $ midLength / 2 ; $ this -> addPages ( $ pages , 1 , 1 ) ; $ this -> addPlaceHolder ( $ pages ) ; $ this -> addPages ( $ pag... | Build a paginator squeezed to the center . Many pages in the center will be visible and just 1 at the start and one at the end . |
12,429 | public function buildSwagger ( ) { $ swagger = $ this -> swaggerConfig ; $ swagger [ 'swagger' ] = '2.0' ; $ paths = $ this -> routingProcessor -> process ( ) ; if ( count ( $ paths ) > 0 ) $ swagger [ 'paths' ] = $ paths ; $ schemes = $ this -> schemaProcessor -> process ( ) ; if ( count ( $ schemes ) > 0 ) $ swagger ... | Combines the loose parts to a complete whole then encodes it in json and returns it |
12,430 | public function event ( $ title , $ text = null , $ type = Event :: INFO , array $ tags = array ( ) , $ timestamp = null ) { return new Event ( $ title , $ text , $ this -> host , $ type , array_merge ( $ this -> defaultTags , $ tags ) , $ timestamp ) ; } | Method to build a single event |
12,431 | protected function loadKeysIfNotLoaded ( ) { if ( ! $ this -> keyProvider || $ this -> keysLoaded ) { return ; } $ this -> keysLoaded = true ; foreach ( call_user_func ( $ this -> keyProvider ) as $ key => $ xType ) { $ this -> namedTypes [ $ key ] = $ xType ; } } | Loads the keys if not done before |
12,432 | private function addUsedIndex ( string $ index ) { $ this -> listUsedIndex [ $ index ] = ( isset ( $ this -> dictionary [ $ index ] ) && $ this -> dictionary [ $ index ] != $ index ) ; } | Add used index . |
12,433 | public function setSearchPath ( array $ searchMask = [ ] , array $ searchPath = [ ] , array $ excludePath = [ ] ) { $ this -> searchContent = new SearchContent ( $ searchMask , $ searchPath , $ excludePath ) ; } | Set path search . |
12,434 | protected function searchDefaultTranslate ( ) { if ( $ this -> searchContent ) { $ this -> listAllDefaultTranslate = $ this -> searchContent -> getList ( ) ; if ( $ this -> dictionary && $ this -> listAllDefaultTranslate ) { foreach ( $ this -> listAllDefaultTranslate as $ identification => $ item ) { if ( $ item [ 'ty... | Search default translate . |
12,435 | public function createTranslate ( string $ identification , string $ message , $ idLocale = null ) : string { if ( isset ( $ this -> dictionary ) && $ this -> dictionary ) { if ( ! isset ( $ this -> dictionary [ $ identification ] ) || $ this -> dictionary [ $ identification ] != $ message ) { $ this -> saveTranslate (... | Create translate . |
12,436 | public function callErrorTrait ( $ message , int $ code , ? Exception $ previous , $ thrower ) : void { $ message = $ this -> createMessage ( $ message , $ code ) ; parent :: __construct ( $ message , $ code , $ previous ) ; $ this -> truncateTrace ( $ thrower ) ; } | Performs common actions |
12,437 | public function rewind ( ) { $ this -> failOnWriteOnly ( ) ; $ this -> onRewind ( ) ; $ this -> currentValue = $ this -> readNext ( $ this -> initHandle ( ) , $ this -> chunkSize ) ; $ this -> position = $ this -> currentValue === null ? - 1 : 0 ; } | Reset the internal pointer to the beginning . |
12,438 | public function toString ( ) { $ this -> failOnWriteOnly ( ) ; if ( $ this -> shouldLock === false ) { return $ this -> readAll ( ) ; } $ path = ( string ) $ this -> url ( ) ; if ( ! $ this -> lockApplied && $ this -> pathIsLocked ( $ path ) ) { throw new ResourceLockedException ( "$path is locked" ) ; } return $ this ... | Renders this object . Without any exception problems you can render the content here . |
12,439 | protected function addGetterSetter ( $ property ) { $ properyName = $ this -> parseMethodName ( $ property , '' ) ; $ getter = "get{$properyName}" ; $ setter = "set{$properyName}" ; $ type = null ; extract ( $ this -> getNames ( ) -> properties [ $ property ] ) ; $ cast = '' ; if ( $ type == 'int' ) $ cast = '(int)' ; ... | Create getter & setter methods for properties |
12,440 | protected function addRelationParent ( $ columnName ) { $ table = substr ( $ columnName , 3 ) ; $ parent = new NameManager ( $ this -> getNames ( ) -> namespace , $ table ) ; $ method = $ this -> buildMethod ( "fetch{$parent->entityName}" ) ; $ body = <<<MBODY\${$parent->tableName} = new \\{$parent->namespace_model}\\... | Create method to return related Parent entity linked to foreign key stored in this coloumn |
12,441 | protected function addRelationChild ( $ tableName ) { $ parameter = new ParameterGenerator ( ) ; $ parameter -> setName ( 'whereArray' ) ; $ parameter -> setDefaultValue ( [ ] ) ; $ child = new NameManager ( $ this -> getNames ( ) -> namespace , $ tableName ) ; $ functionName = ucwords ( $ tableName ) ; $ method = $ th... | Create method to return related children entities this primary key found in table |
12,442 | public static function loadBundle ( & $ bundle ) { if ( sizeof ( $ bundle -> content ) == 0 ) { return ; } $ bundleCache = Cache :: getInstance ( 'MEMCACHE' , 'APC' , 'FILE_ENCODED' ) ; $ bundleCachePath = "xqbundle/{$bundle->bundleId}" ; if ( ! DEBUG && ( $ bundleCache -> available ( ) && $ bundleCache -> hasCached ( ... | Preload a bundle . This function preloads information about the files in the bundle and their content . |
12,443 | public static function getBundleFileDetails ( & $ bundle , string & $ file ) { $ filePath = $ bundle -> directory . $ file ; $ fileModified = filemtime ( $ bundle -> directory . $ file ) ; if ( ! $ bundle -> lastModified || $ fileModified > $ bundle -> lastModified ) { $ bundle -> lastModified = $ fileModified ; } $ pr... | Get additional details about a file from a bundle . |
12,444 | private static function getBundleContentType ( \ stdClass $ bundle ) : string { $ mimeType = null ; switch ( $ bundle -> type ) { case 'sass' : case 'scss' : case 'css' : case 'stylesheet' : $ mimeType = 'text/css' ; break ; case 'javascript' : case 'js' : $ mimeType = 'application/javascript' ; break ; default : if ( ... | Get the content - type of a bundle . There are default content - types for the type specified for a bundle . If no type is recognized this function will lookup the mime - content - type of the first file in the bundle s list . |
12,445 | private static function getBundleContent ( \ stdClass $ bundle ) : string { $ bundleContent = '' ; switch ( $ bundle -> type ) { case 'sass' : case 'scss' : $ bundleContent = self :: getSassBundleContent ( $ bundle ) ; break ; case 'css' : case 'stylesheet' : case 'javascript' : case 'js' : $ bundleContent = self :: ge... | Get the full content of a bundle while detecting the appropriate actions to take to prepare the content for the type of the bundle . |
12,446 | private static function getSassBundleContent ( \ stdClass $ bundle ) : string { $ bundleContent = '' ; if ( sizeof ( $ bundle -> files ) == 0 ) { return $ bundleContent ; } foreach ( $ bundle -> files as $ preloaded ) { if ( DEBUG ) { $ bundleContent .= "/* {$preloaded->name} */" . CHAR_CRLF ; } $ content = File :: get... | Get the full content of a bundle and compile the content of each file using a Sass compiler before appending . |
12,447 | private static function getPlainBundleContent ( \ stdClass $ bundle , bool $ includeNameComment = false ) : string { $ bundleContent = '' ; if ( sizeof ( $ bundle -> files ) == 0 ) { return $ bundleContent ; } $ bundleContent = '' ; foreach ( $ bundle -> files as $ preloaded ) { if ( $ includeNameComment ) { $ bundleCo... | Get the full content of a bundle as is . |
12,448 | public function clearRecipientHeaders ( ) { $ headers = $ this -> swiftMessage -> getHeaders ( ) ; foreach ( $ headers -> getAll ( ) as $ header ) { if ( ! $ header instanceof Swift_Mime_Headers_MailboxHeader ) { continue ; } if ( in_array ( strtolower ( $ header -> getFieldName ( ) ) , $ this -> recipientHeaderNames )... | Remove all to cc and bcc headers to that the target can be overwritten . |
12,449 | public function set ( string $ str ) : self { $ this -> str = $ this -> inputConv ( $ str ) ; return $ this ; } | The string setter . |
12,450 | protected function outputConv ( string $ str ) : string { if ( $ str === '' ) { return '' ; } return \ iconv ( 'UTF-32' , $ this -> encoding , static :: $ utf32Header . $ str ) ; } | convert the output string to its original encoding |
12,451 | protected function inputConv ( string $ str ) : string { if ( $ str === '' ) { return '' ; } return \ substr ( \ iconv ( $ this -> encoding , 'UTF-32' , $ str ) , 4 ) ; } | convert the input string to UTF - 32 without header |
12,452 | public static function messageFromHttpStatusCode ( $ httpStatusCode ) { $ message = sprintf ( 'HTTP %s' , $ httpStatusCode ) ; switch ( $ httpStatusCode ) { case 400 : $ message .= ' Bad Request (invalid parameters for the API endpoint)' ; break ; case 401 : $ message .= ' Unauthorized (check that your API key is corre... | Maps HTTP status codes to more useful error descriptions |
12,453 | public function rewriteNamespacedImports ( string $ fileContent ) : string { $ importParser = new CssUrlImportParser ( ) ; return $ importParser -> replaceValidImports ( $ fileContent , function ( string $ path ) { try { $ asset = Asset :: createFromAssetPath ( $ path ) ; return $ this -> assetUrl -> generateUrl ( $ as... | Rewrites the path to namespaced assets |
12,454 | public function rewriteRelativeImports ( Asset $ asset , string $ fileContent ) : string { $ importParser = new CssUrlImportParser ( ) ; return $ importParser -> replaceValidImports ( $ fileContent , function ( string $ path ) use ( $ asset ) { return $ this -> rewritePathInStaticImport ( $ asset , $ path ) ; } ) ; } | Rewrites all imports to use the names from the cache |
12,455 | private function rewritePathInStaticImport ( Asset $ asset , string $ path ) : string { if ( 1 === \ preg_match ( '~^(//|[a-z]+:)~' , $ path ) ) { return $ path ; } $ assetAtPath = $ asset -> getRelativeAsset ( $ path ) ; $ assetAtPath = $ this -> cache -> get ( $ assetAtPath ) ; if ( null !== $ assetAtPath ) { $ baseN... | Rewrites the path to fix the local path to an update one |
12,456 | public function run ( ) { $ this -> directory_list = $ this -> list_directory ( $ this -> language_files_dir ) ; $ this -> translations = $ this -> process_directory ( $ this -> directory_list ) ; $ this -> packages = $ this -> create_packages ( ) ; $ this -> create_language_packs ( ) ; $ this -> create_json ( ) ; } | Start making stuff . |
12,457 | private function list_directory ( $ dir ) { $ dir_list = array ( ) ; foreach ( glob ( $ dir . '/*.{mo,po,zip}' , GLOB_BRACE ) as $ file ) { $ dir_list [ ] = basename ( $ file ) ; } return $ dir_list ; } | Create an array of the directory contents . |
12,458 | private function process_directory ( $ dir_list ) { $ translation_list = array_map ( function ( $ e ) { return pathinfo ( $ e , PATHINFO_FILENAME ) ; } , $ dir_list ) ; $ translation_list = array_unique ( $ translation_list ) ; return $ translation_list ; } | Returns an array of translations with stripped file extension . |
12,459 | private function create_packages ( ) { $ packages = array ( ) ; foreach ( $ this -> translations as $ translation ) { $ package = array ( ) ; foreach ( $ this -> directory_list as $ file ) { if ( false !== stripos ( $ file , $ translation ) ) { $ package [ ] = $ this -> language_files_dir . '/' . $ file ; } } $ package... | Creates an associative array of translations from directory listing . |
12,460 | private function create_language_packs ( ) { foreach ( $ this -> packages as $ translation => $ files ) { $ this -> create_zip ( $ files , $ this -> packages_dir . '/' . $ translation . '.zip' , true ) ; } } | Create language pack zipfiles . |
12,461 | private function create_zip ( $ files = array ( ) , $ destination = '' , $ overwrite = true ) { if ( file_exists ( $ destination ) && ! $ overwrite ) { return false ; } $ zip = new \ ZipArchive ( ) ; if ( $ zip -> open ( $ destination , \ ZIPARCHIVE :: OVERWRITE | \ ZIPARCHIVE :: CREATE ) !== true ) { return false ; } ... | Create individual zipfile . |
12,462 | private function create_json ( ) { $ packages = $ this -> list_directory ( $ this -> packages_dir ) ; $ arr = array ( ) ; foreach ( $ packages as $ package ) { foreach ( $ this -> translations as $ translation ) { if ( false !== stripos ( $ package , $ translation ) ) { $ locale = ltrim ( strrchr ( $ translation , '-' ... | Create JSON file of translations for export and use by GitHub Updater . |
12,463 | private function get_po_revision ( $ file ) { $ file = $ this -> language_files_dir . '/' . $ file ; $ headers = array ( 'PO-Revision-Date' => '"PO-Revision-Date' ) ; $ all_headers = array ( ) ; $ fp = fopen ( $ file , 'r' ) ; $ contents = fread ( $ fp , 1024 ) ; fclose ( $ fp ) ; foreach ( $ headers as $ field => $ re... | Returns PO - Revision - Date from . po file . |
12,464 | protected function filterPaths ( array $ paths , $ pattern , array $ extensions = [ ] ) { if ( ! $ this -> isFilterPattern ( $ pattern ) && ! $ extensions ) { return $ paths ; } return array_filter ( $ paths , function ( $ path ) use ( $ pattern , $ extensions ) { return $ this -> filterPath ( $ path , $ pattern , $ ex... | Filter out file names by pattern and extensions . |
12,465 | protected function filterPath ( $ path , $ pattern , array $ extensions = [ ] ) { $ usePattern = $ this -> isFilterPattern ( $ pattern ) ; if ( ! $ usePattern && ! $ extensions ) { return true ; } if ( $ usePattern && ! fnmatch ( $ pattern , $ this -> basename ( $ path ) ) ) { return false ; } if ( $ extensions && ! in... | Apply the filter on a single path . |
12,466 | public function loadFromArray ( array $ items ) { foreach ( $ items as $ item ) { if ( is_array ( $ item ) && ! empty ( $ item ) ) { $ this -> add ( $ item ) ; } } return $ this ; } | Load the sidebar items from config files . |
12,467 | public function parse ( $ callbacks , LocatorInterface $ locator ) { $ data = null ; while ( $ this -> read ( ) ) { if ( $ this -> nodeType == \ XMLReader :: ELEMENT ) { $ child = $ this -> parseElement ( $ this -> name , $ callbacks , $ locator ) ; $ data = $ child ; break ; } } return $ data ; } | Parse the entity XML . |
12,468 | protected function parseElement ( $ name , $ callbacks , LocatorInterface $ locator ) { $ hasChildren = ! $ this -> isEmptyElement ; $ attributes = $ this -> hasAttributes ? $ this -> getAttributes ( ) : [ ] ; $ children = [ ] ; $ callback = 'onBefore' . ucfirst ( $ name ) ; if ( isset ( $ callbacks [ $ callback ] ) ) ... | Recursively parse the element tree . |
12,469 | protected function getAttributes ( ) { $ attributes = [ ] ; $ this -> moveToFirstAttribute ( ) ; do { $ attributes [ $ this -> name ] = $ this -> value ; } while ( $ this -> moveToNextAttribute ( ) ) ; return $ attributes ; } | Get element attributes |
12,470 | public function hasModule ( $ id ) { if ( ( $ pos = strpos ( $ id , '/' ) ) !== false ) { $ module = $ this -> getModule ( substr ( $ id , 0 , $ pos ) ) ; return $ module === null ? false : $ module -> hasModule ( substr ( $ id , $ pos + 1 ) ) ; } else { return isset ( $ this -> _modules [ $ id ] ) ; } } | Checks whether the child module of the specified ID exists . This method supports checking the existence of both child and grand child modules . |
12,471 | public static function extract ( $ src , $ dst ) { $ result = false ; $ archive = \ ezcArchive :: open ( $ src ) ; $ archive -> extract ( $ dst ) ; $ result = true ; return $ result ; } | Extract a ZIP or TAR archive |
12,472 | private function buildReplacements ( ) { if ( $ this -> csvFormat -> getEscape ( ) ) { $ this -> escapeChars = [ $ this -> csvFormat -> getEscape ( ) , $ this -> csvFormat -> getDelimiter ( ) , "\n" , "\r" , "\t" , ] ; if ( $ this -> csvFormat -> hasQuote ( ) && ! $ this -> csvFormat -> useDoubleQuotes ( ) ) { $ this -... | Build replacements to perform for each entry |
12,473 | private function getHeaderPrefix ( array $ data ) { if ( $ this -> first && $ this -> csvFormat -> hasHeaderRow ( ) ) { $ this -> first = false ; $ postHeaderPad = $ this -> csvFormat -> getDataStart ( ) - $ this -> csvFormat -> getHeaderRow ( ) ; return $ this -> format ( array_keys ( $ data ) ) . str_repeat ( $ this ... | Gets a prefix for headers if required |
12,474 | public function getInitialBlock ( ) { $ linePad = $ this -> csvFormat -> hasHeaderRow ( ) ? $ this -> csvFormat -> getHeaderRow ( ) - 1 : $ this -> csvFormat -> getDataStart ( ) - 1 ; return $ this -> initial . str_repeat ( $ this -> getRowSeparator ( ) , $ linePad ) ; } | Return an initial block if required |
12,475 | public static function make ( $ key , $ resource , $ version = 'v2' ) { $ client = new Client ( $ key , $ version ) ; $ namespace = 'Rule\\ApiWrapper\\Api\\' . strtoupper ( $ version ) . '\\' . ucfirst ( $ resource ) . '\\' ; $ classname = $ namespace . ucfirst ( $ resource ) ; if ( ! class_exists ( $ classname ) ) { t... | Creates api resource |
12,476 | public static function isStringable ( $ value ) { return static :: isStringLike ( $ value ) || is_numeric ( $ value ) || is_bool ( $ value ) || is_null ( $ value ) ; } | Return true if a value can be casted to string . |
12,477 | public static function toBool ( $ value ) { if ( $ value instanceof Countable ) { return ( bool ) count ( $ value ) ; } if ( ! static :: isStringLike ( $ value ) ) { return ( bool ) $ value ; } $ string = "$value" ; if ( trim ( $ string ) == '' ) { return false ; } if ( in_array ( strtolower ( $ value ) , [ '0' , 'fals... | Cast a value to boolean . |
12,478 | public static function toArray ( $ value ) { if ( ! is_array ( $ value ) && ! $ value instanceof Traversable ) { $ name = static :: of ( $ value ) ; throw new TypeException ( "Can only cast Traversable and arrays to array, not $name" ) ; } return is_array ( $ value ) ? $ value : iterator_to_array ( $ value ) ; } | Make something an array . |
12,479 | public function sendConfirmationEmail ( FormEvent $ event ) { $ user = $ event -> getForm ( ) -> getData ( ) ; $ user -> setEnabled ( false ) ; if ( null === $ user -> getConfirmationToken ( ) ) { $ user -> setConfirmationToken ( $ this -> generateToken ( ) ) ; } $ this -> mailer -> sendConfirmationEmailMessage ( $ use... | Sends an email to the user to activate his account . |
12,480 | private function updateBodyFor ( self $ toUpdate ) : JsonResponse { $ json = $ this -> jsonEncode ( $ toUpdate -> payload , $ toUpdate -> encodingOptions ) ; $ body = $ this -> createBodyFromJson ( $ json ) ; return $ toUpdate -> withBody ( $ body ) ; } | Update the response body for the given instance . |
12,481 | public function generateMarkup ( string $ attribute , string $ content ) : string { return preg_replace_callback ( '/{(\w+)}/' , function ( $ matches ) use ( $ attribute , $ content ) { switch ( $ matches [ 1 ] ) { case 'name' : return $ this -> tagName ; case 'attribute' : return $ attribute ; case 'content' : return ... | Generates markup string for specified tag attribute and inner text . |
12,482 | protected function createConnection ( ) { $ config = $ this -> config ; $ db = new \ mysqli ; $ db -> connect ( $ config [ 'host' ] , $ config [ 'user' ] , $ config [ 'password' ] , $ config [ 'database' ] , $ config [ 'port' ] ) ; if ( ! empty ( $ config [ 'charset' ] ) ) { $ db -> set_charset ( $ config [ 'charset' ]... | create mysql connection |
12,483 | protected function removeConnection ( $ db_sock ) { swoole_event_del ( $ db_sock ) ; $ this -> idle_pool [ $ db_sock ] [ 'object' ] -> close ( ) ; unset ( $ this -> idle_pool [ $ db_sock ] ) ; $ this -> connection_num -- ; } | remove mysql connection |
12,484 | protected function createGeocoder ( ) { if ( $ this -> apiKey === null ) { throw new Exception ( 'API key must be set before geocoding.' ) ; } if ( $ this -> geocoder === null ) { $ this -> geocoder = new GoogleMaps ( new CurlHttpAdapter , $ this -> lang , null , true , $ this -> apiKey ) ; } return $ this -> geocoder ... | Create a geocoder object if one doesn t already exist . |
12,485 | protected function param ( $ paramName ) { $ fallbacks = $ this -> getDefaultParamsNonPersistentCached ( ) ; if ( $ paramName == 'content' ) { return $ this -> content ? $ this -> content : $ fallbacks [ 'content' ] ; } if ( isset ( $ this -> params [ $ paramName ] ) ) { return $ this -> params [ $ paramName ] ; } else... | return param value if existing |
12,486 | public function isScalar ( ) { return in_array ( $ this -> group ( ) , [ self :: NUMBER , self :: STRING , self :: BOOL ] ) ; } | Return if this type is scalar . |
12,487 | public function toArray ( ) { $ array = [ 'name' => $ this -> getName ( ) ] ; foreach ( static :: $ propertyMap [ static :: class ] as $ name => $ property ) { $ value = $ this -> { $ name } ; $ array [ $ name ] = $ value instanceof XType ? $ value -> toArray ( ) : $ value ; } if ( ! count ( $ this -> constraints ) ) {... | Return the xtype properties as an array . |
12,488 | protected function buildPropertyMap ( ) { $ map = [ ] ; $ properties = ( new ReflectionObject ( $ this ) ) -> getProperties ( ReflectionProperty :: IS_PUBLIC ) ; foreach ( $ properties as $ property ) { $ map [ $ property -> getName ( ) ] = $ property ; } return $ map ; } | Returns a lookup array of all public properties as keys . |
12,489 | protected function buildMethodMaps ( ) { $ getterMap = [ ] ; $ setterMap = [ ] ; $ methods = ( new ReflectionObject ( $ this ) ) -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; foreach ( $ methods as $ method ) { if ( $ this -> isGetter ( $ method ) ) { $ getterMap [ $ this -> toPropertyName ( $ method -> getName ( )... | Returns two lookup arrays of all public getters and setters . |
12,490 | protected function toPropertyName ( $ methodName ) { if ( strpos ( $ methodName , 'get' ) === 0 || strpos ( $ methodName , 'set' ) === 0 ) { return lcfirst ( substr ( $ methodName , 3 ) ) ; } if ( strpos ( $ methodName , 'is' ) === 0 ) { return lcfirst ( substr ( $ methodName , 2 ) ) ; } return $ methodName ; } | Return the property name of a method name . |
12,491 | public function onInit ( BaseEvent $ event ) { $ this -> state -> loadSettings ( ) ; $ this -> state -> setDevMode ( false ) ; $ this -> mergeFiles ( $ this -> state -> getIncludes ( ) , false ) ; $ this -> mergeFiles ( $ this -> state -> getRequires ( ) , true ) ; } | Handle an event callback for initialization . |
12,492 | private function installRequires ( Request $ request , array $ links , $ dev = false ) { foreach ( $ links as $ link ) { $ this -> logger -> info ( $ dev ? "Adding dev dependency <comment>{$link}</comment>" : "Adding dependency <comment>{$link}</comment>" ) ; $ request -> install ( $ link -> getTarget ( ) , $ link -> g... | Install requirements . |
12,493 | private function runFirstInstall ( ScriptEvent $ event ) { $ installer = Installer :: create ( $ event -> getIO ( ) , Factory :: create ( $ event -> getIO ( ) , null , false ) ) ; $ installer -> setPreferSource ( $ this -> isPreferredInstall ( 'source' ) ) ; $ installer -> setPreferDist ( $ this -> isPreferredInstall (... | Run first install . |
12,494 | public function preRender ( Event $ event ) { $ markdown = $ event -> getParam ( 'markdown' ) ; $ markdownHash = md5 ( $ markdown ) ; $ success = false ; $ renderedMarkdown = $ this -> cache -> getItem ( $ markdownHash , $ success ) ; if ( $ success ) { $ event -> stopPropagation ( true ) ; return $ renderedMarkdown ; ... | Searches the cache for rendered markdown . |
12,495 | public function postRender ( Event $ event ) { $ markdown = $ event -> getParam ( 'markdown' ) ; $ renderedMarkdown = $ event -> getParam ( 'renderedMarkdown' ) ; $ markdownHash = md5 ( $ markdown ) ; return $ this -> cache -> setItem ( $ markdownHash , $ renderedMarkdown ) ; } | Saves the rendered markdown within the cache . |
12,496 | private function parseIterator ( Iterator $ iterator ) { $ iterator = $ this -> parseHeaderRow ( $ iterator ) ; if ( $ this -> csvFormat -> getDataStart ( ) > 1 || $ this -> csvFormat -> getLimit ( ) !== - 1 ) { $ iterator = new LimitIterator ( $ iterator , max ( 0 , $ this -> csvFormat -> getDataStart ( ) - 1 ) , $ th... | Parse a supplied iterator |
12,497 | public function handleHeaderRow ( array $ current , $ key ) { if ( $ key == $ this -> csvFormat -> getHeaderRow ( ) - 1 ) { if ( count ( $ current ) > 1 || strlen ( $ current [ 0 ] ) > 0 ) { $ this -> headerRow = $ current ; } } return true ; } | Parse the rows looking for the header row and storing it locally |
12,498 | public function mapHeaders ( array $ current ) { if ( count ( $ this -> headerRow ) > 0 ) { if ( count ( $ this -> headerRow ) !== count ( $ current ) ) { throw new RuntimeException ( "The number of entries in: " . implode ( ',' , $ current ) . " does not match the header: " . implode ( ',' , $ this -> headerRow ) ) ; ... | Map any headers found onto each element in the data |
12,499 | public function delete ( $ key , $ section = null ) { if ( is_null ( $ section ) ) { $ pieces = explode ( '.' , $ key ) ; $ section = $ pieces [ 0 ] ; $ key = $ pieces [ 1 ] ; } return $ this -> model -> deleteSetting ( $ section , $ key ) ; } | Deletes a setting |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.