idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
10,100 | protected function configurePermalinkForNewLanguage ( $ content ) { if ( null === $ this -> languageManager || null === $ this -> container ) { return $ content ; } $ urlManager = $ this -> container -> get ( 'red_kite_cms.url_manager' ) ; $ languageName = $ this -> languageManager -> get ( ) -> getLanguageName ( ) ; r... | Configures the permalink for the new language . |
10,101 | public function getPlayableGames ( $ entry = null ) { $ sortedPlayableGames = array ( ) ; foreach ( $ this -> missionGames as $ missionGame ) { $ g = $ missionGame -> getGame ( ) ; if ( $ g -> isStarted ( ) && $ g -> getActive ( ) ) { if ( ! $ missionGame -> getConditions ( ) || $ missionGame -> fulfillConditions ( $ e... | Get the playables game if any |
10,102 | public function getPreviousGame ( $ entry = null ) { $ currentGame = $ this -> getNextPlayableGame ( $ entry ) ; $ previousMissionGame = null ; foreach ( $ this -> missionGames as $ missionGame ) { if ( $ missionGame -> getGame ( ) -> getId ( ) === $ currentGame -> getId ( ) ) { return $ previousMissionGame ; } $ previ... | Get the previous playable game if any |
10,103 | public function getNextPlayableGame ( $ entry = null ) { $ sortedPlayableGames = $ this -> getPlayableGames ( $ entry ) ; return ( count ( $ sortedPlayableGames ) >= 1 ) ? current ( $ sortedPlayableGames ) -> getGame ( ) : null ; } | Get the next playable game if any |
10,104 | public function isPlayable ( $ subGame , $ entry = null ) { if ( ! $ subGame ) { return false ; } $ sortedPlayableGames = $ this -> getPlayableGames ( $ entry ) ; foreach ( $ sortedPlayableGames as $ pgame ) { if ( $ subGame -> getIdentifier ( ) === $ pgame -> getGame ( ) -> getIdentifier ( ) ) { return true ; } } retu... | is this game playable ? |
10,105 | public static function fromBase ( $ number , $ base ) { $ number = trim ( $ number , ' =-' ) ; if ( $ number === '' || strpos ( $ number , '.' ) !== false ) { throw new \ InvalidArgumentException ( 'Argument number is not an integer' ) ; } $ baseChar = static :: getBaseChar ( $ base ) ; if ( trim ( $ number , $ baseCha... | convert any based value bellow or equals to 64 to its decimal value |
10,106 | public function toBase ( $ base ) { if ( $ this -> normalize ( ) -> hasDecimals ( ) ) { throw new \ InvalidArgumentException ( 'Argument number is not an integer' ) ; } $ number = ltrim ( ( string ) $ this , '-' ) ; if ( static :: $ gmpSupport && $ base <= 62 ) { return static :: baseConvert ( $ number , 10 , $ base ) ... | convert decimal value to any other base bellow or equals to 64 |
10,107 | public function addArgument ( string $ name , $ value ) : Service { $ this -> arguments [ $ name ] = $ value ; return $ this ; } | Add argument . |
10,108 | public function addArguments ( array $ arguments ) : Service { $ this -> arguments = array_replace ( $ this -> arguments ?? [ ] , $ arguments ) ; return $ this ; } | Add arguments . |
10,109 | public function addCall ( string $ method , array $ arguments = [ ] ) : Service { $ this -> calls [ $ method ] = $ arguments ; return $ this ; } | Add call . |
10,110 | public function receiveRequest ( Request $ request ) : Response { $ curie = $ request :: schema ( ) -> getCurie ( ) ; $ curieStr = $ curie -> toString ( ) ; if ( isset ( $ this -> handlers [ $ curieStr ] ) ) { $ handler = $ this -> handlers [ $ curieStr ] ; } else { try { $ handler = $ this -> locator -> getRequestHand... | Invokes the handler that services the given request . If an exception occurs it will be caught and a RequestFailedResponse will be created with the reason . |
10,111 | public function add ( $ file , $ force = false ) { if ( ! file_exists ( $ file ) ) { throw new \ InvalidArgumentException ( sprintf ( 'File "%s" does not exist.' , $ file ) ) ; } if ( false === $ force && null !== $ path = $ this -> getCache ( $ file ) ) { return null === $ this -> target ? $ path : $ this -> target . ... | Copy a file to the directory . |
10,112 | private function getCache ( $ file ) { if ( null === $ this -> cache ) { return null ; } $ key = md5 ( $ file ) ; if ( $ this -> cache -> has ( $ key ) ) { list ( $ mtime , $ path ) = unserialize ( $ this -> cache -> get ( $ key ) ) ; if ( $ mtime === filemtime ( $ file ) ) { return $ path ; } $ delete = $ this -> dire... | Searches a fresh cached file for the given file . |
10,113 | protected function createResponse ( $ pid , $ alias , $ timeout = 0.0 , $ timeoutIncrease = 1.0 ) { return new ResponseRecord ( $ pid , $ alias , $ timeout , $ timeoutIncrease ) ; } | Create ResponseRecord . |
10,114 | protected function existsResponse ( $ pid ) { return isset ( $ this -> reps [ $ pid ] ) || isset ( $ this -> handledReps [ $ pid ] ) ; } | Check if ResponseRecord with given protocol ID exists . |
10,115 | protected function unfinishedResponses ( ) { $ now = TimeSupport :: now ( ) ; $ unfinishedReps = [ ] ; foreach ( $ this -> reps as $ pid => $ response ) { if ( $ now >= $ response -> timeout ) { $ unfinishedReps [ ] = $ response ; $ response -> timeout = $ now + $ response -> timeoutIncrease ; } } return $ unfinishedRe... | Return all unhandled ResponseRecords in array form . |
10,116 | protected function expireResponses ( ) { $ now = TimeSupport :: now ( ) ; $ expiredReps = [ ] ; foreach ( $ this -> handledReps as $ pid => $ response ) { if ( $ now >= $ response -> timeout ) { $ expiredReps [ ] = $ pid ; } } foreach ( $ expiredReps as $ pid ) { unset ( $ this -> handledReps [ $ pid ] ) ; } } | Expire unhandled ResponseRecords . |
10,117 | public function change ( ThemeInterface $ previousTheme , ThemeInterface $ theme , $ path , array $ templatesMap ) { $ this -> saveThemeStructure ( $ previousTheme , $ path ) ; $ this -> changeTemplate ( $ theme , $ templatesMap ) ; } | Changes the current theme |
10,118 | protected function saveThemeStructure ( ThemeInterface $ theme , $ themeStructureFile ) { $ templates = array ( ) ; foreach ( $ this -> languagesRepository -> activeLanguages ( ) as $ language ) { foreach ( $ this -> pagesRepository -> activePages ( ) as $ page ) { $ key = $ language -> getId ( ) . '-' . $ page -> getI... | Saves the current theme structure into a file |
10,119 | public function render ( array $ data , ContextInterface $ context ) { $ data = optionsParser ( $ data , [ 'name' => '' , 'val' => null , 'type' => 'text' , 'escape' => true , 'templateVars' => [ ] , ] ) ; $ data -> add ( 'value' , $ data -> consume ( 'val' ) ) ; return $ this -> _templates -> format ( 'hidden' , [ 'na... | Render a hidden widget |
10,120 | public function initialize ( ) : void { $ connection = config ( 'database.default' ) ; Accessor :: $ appRoot = config ( 'app.dir' ) ; UpstartConfig :: $ database = config ( "database.connections.{$connection}" ) ; if ( ! DB :: start ( ) ) { $ this -> exception ( 'Could not establish a database connection.' ) ; } $ this... | Initialize Database connection and Environment variables |
10,121 | private function convertQuestion ( Question $ question ) { $ buttons = $ question -> getButtons ( ) ; if ( $ buttons ) { return [ [ 'type' => 'suggested' , 'responses' => Collection :: make ( $ buttons ) -> transform ( function ( $ button ) { $ buttonData = [ 'type' => 'text' , 'metadata' => [ 'value' => $ button [ 'va... | Convert a Question object into a valid Kik keyboard object . |
10,122 | public function get ( $ key ) { $ key = sanitize_key ( $ key ) ; return isset ( $ _SESSION [ $ key ] ) ? json_decode ( $ _SESSION [ $ key ] ) : false ; } | Retrieve a session variable |
10,123 | public function set ( $ key , $ value ) { $ key = sanitize_key ( $ key ) ; $ _SESSION [ $ key ] = wp_json_encode ( $ value ) ; return $ _SESSION [ $ key ] ; } | Set a session variable |
10,124 | public function should_start_session ( ) { $ start_session = true ; if ( ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ blacklist = $ this -> get_blacklist ( ) ; $ uri = ltrim ( $ _SERVER [ 'REQUEST_URI' ] , '/' ) ; $ uri = untrailingslashit ( $ uri ) ; if ( in_array ( $ uri , $ blacklist ) ) { $ start_session = false ;... | Determines if we should start sessions |
10,125 | public function get_blacklist ( ) { $ blacklist = apply_filters ( 'geot/sessions/session_start_uri_blacklist' , array ( 'feed' , 'feed/rss' , 'feed/rss2' , 'feed/rdf' , 'feed/atom' , 'comments/feed' , ) ) ; $ folder = str_replace ( network_home_url ( ) , '' , get_site_url ( ) ) ; if ( ! empty ( $ folder ) ) { foreach (... | Retrieve the URI blacklist |
10,126 | public function set ( string $ key , $ value ) : void { if ( isset ( $ this -> data [ $ key ] ) ) { unset ( $ this -> data [ $ key ] ) ; } else { if ( $ this -> size >= $ this -> maxSize ) { \ reset ( $ this -> data ) ; unset ( $ this -> data [ \ key ( $ this -> data ) ] ) ; } else { $ this -> size ++ ; } } $ this -> d... | Put an item into the cache . |
10,127 | public function remove ( string $ key ) : void { if ( isset ( $ this -> data [ $ key ] ) ) { unset ( $ this -> data [ $ key ] ) ; $ this -> size -- ; } } | Remove an item from the cache if it exists . |
10,128 | private static function commit ( ) { $ transaction = env ( 'SIMPLES_TRANSACTION_CLASS' , '\\Simples\\Persistence\\Transaction' ) ; if ( ! class_exists ( $ transaction ) ) { return ; } if ( ! method_exists ( $ transaction , 'commit' ) ) { throw new ErrorException ( "The transaction commit method was not found" ) ; } if ... | Make a global commit of all changes made into request |
10,129 | public static function request ( ) { $ container = Container :: instance ( ) ; if ( ! $ container -> has ( 'request' ) ) { $ request = new Request ( Kernel :: options ( 'strict' ) ) ; $ container -> register ( 'request' , $ request -> fromServer ( ) ) ; } return $ container -> get ( 'request' ) ; } | Singleton to Request to keep only one instance for each request |
10,130 | public static function response ( ) { $ container = Container :: instance ( ) ; if ( ! $ container -> has ( 'response' ) ) { $ container -> register ( 'response' , new Response ( ) ) ; } return $ container -> get ( 'response' ) ; } | Singleton to Response to keep only one instance for each request |
10,131 | public function getConfigTreeBuilder ( ) { $ treeBuilder = new TreeBuilder ( ) ; $ rootNode = $ treeBuilder -> root ( $ this -> alias ) ; $ rootNode -> validate ( ) -> ifTrue ( function ( $ v ) { return ! empty ( $ v [ 'enabled' ] ) && empty ( $ v [ 'pools' ] ) ; } ) -> thenInvalid ( 'The child node "pools" at path "' ... | Get configuration tree builder instance . |
10,132 | public function create ( $ handlerType , $ level ) { if ( false === array_key_exists ( 'handler' , $ this -> _config ) ) { throw new MonologCreator \ Exception ( 'no handler configuration found' ) ; } if ( false === array_key_exists ( $ handlerType , $ this -> _config [ 'handler' ] ) ) { throw new MonologCreator \ Exce... | creates specific monolog handlers |
10,133 | public function allowBonus ( $ game , $ user ) { if ( ! $ game -> getPlayBonus ( ) || $ game -> getPlayBonus ( ) == 'none' ) { return false ; } elseif ( $ game -> getPlayBonus ( ) == 'one' ) { if ( $ this -> getEntryMapper ( ) -> findOneBy ( array ( 'game' => $ game , 'user' => $ user , 'bonus' => 1 ) ) ) { return fals... | Is it possible to trigger a bonus entry ? |
10,134 | public function addAnotherChance ( $ game , $ user , $ winner = 0 ) { if ( $ this -> allowBonus ( $ game , $ user ) ) { $ this -> addAnotherEntry ( $ game , $ user , $ winner ) ; return true ; } return false ; } | This bonus entry doesn t give points nor badges It s just there to increase the chances during the Draw Old Name playBonus |
10,135 | public function playAgain ( $ game , $ user , $ winner = 0 ) { if ( $ this -> allowBonus ( $ game , $ user ) ) { $ entry = $ this -> addAnotherEntry ( $ game , $ user , $ winner ) ; $ entry -> setActive ( 1 ) ; $ entry = $ this -> getEntryMapper ( ) -> update ( $ entry ) ; if ( $ entry -> getActive ( ) == 1 ) { return ... | This bonus entry doesn t give points nor badges but can play again |
10,136 | private function errorHandling ( ? bool $ isConsole = false ) { $ this -> internalErrors ( ) ; $ whoopsRun = new WhoopsRun ; $ development = new PrettyPageHandler ; $ errors = new Error ; $ production = new CallbackHandler ( $ this -> uiRegister ( ) ) ; $ cliErrors = new CallbackHandler ( $ this -> cliRegister ( ) ) ; ... | Handle application errors |
10,137 | public function uiRegister ( ) : Closure { return function ( $ exception , $ inspector , $ run ) { $ appHandler = new \ App \ Exceptions \ Handler ( ) ; if ( $ exception instanceof Exception ) { return $ appHandler -> render ( $ this -> getRequest ( ) ?? new Request ( array_merge ( $ _POST , $ _FILES ) ) , $ exception ... | Register production errors |
10,138 | public function cliRegister ( ) : Closure { return function ( $ exception , $ inspector , $ run ) { Output :: error ( $ exception ) ; die ( $ exception . PHP_EOL ) ; exit ; } ; } | Register cli errors |
10,139 | public static function buildBorder ( $ string , Border $ border ) { switch ( $ border -> getType ( ) ) { case Border :: TYPE_UNDERLINE : $ result = self :: buildUnderline ( $ string , $ border ) ; break ; case Border :: TYPE_FRAME : $ result = self :: buildFrame ( $ string , $ border ) ; break ; default : throw new Exc... | Render bordered string |
10,140 | private static function buildUnderline ( $ string , Border $ border ) { $ stringLength = Util :: getVisibleStringLength ( $ string ) ; $ underline = Util :: buildPatternLine ( $ border -> getLineCharacter ( ) , $ stringLength ) ; $ result = $ string . PHP_EOL . $ underline . PHP_EOL ; return $ result ; } | Underline with the given Border the given string |
10,141 | private static function buildFrame ( $ string , Border $ border ) { $ stringLength = Util :: getVisibleStringLength ( $ string ) ; $ line = Util :: buildPatternLine ( $ border -> getLineCharacter ( ) , $ stringLength + 2 ) ; $ firstLine = $ border -> getCrossCharacter ( ) . $ line . $ border -> getCrossCharacter ( ) ; ... | Frame with the given Border the given string |
10,142 | private static function __underlineBorder ( $ string ) { $ border = new Border ( Border :: TYPE_UNDERLINE ) ; $ borderedElement = new BorderedElement ( $ string , $ border ) ; return $ borderedElement -> render ( ) ; } | Underline a string with - |
10,143 | private static function __doubleUnderlineBorder ( $ string ) { $ border = new Border ( Border :: TYPE_UNDERLINE , '=' ) ; $ borderedElement = new BorderedElement ( $ string , $ border ) ; return $ borderedElement -> render ( ) ; } | Underline a string with = |
10,144 | private static function __border ( $ string ) { $ border = new Border ( Border :: TYPE_FRAME ) ; $ borderedElement = new BorderedElement ( $ string , $ border ) ; return $ borderedElement -> render ( ) ; } | Draw a border around a string |
10,145 | private static function __doubleBorder ( $ string ) { $ border = new Border ( Border :: TYPE_FRAME , '=' , '#' , '*' ) ; $ borderedElement = new BorderedElement ( $ string , $ border ) ; return $ borderedElement -> render ( ) ; } | Draw a double border around a string |
10,146 | public static function failure ( $ code , $ err = 'Unknown' , $ uri = '' , $ method = '' , $ extra = '' ) { switch ( $ code ) { case '403' : throw new \ HPCloud \ Transport \ ForbiddenException ( $ err ) ; case '401' : throw new \ HPCloud \ Transport \ UnauthorizedException ( $ err ) ; case '404' : throw new \ HPCloud ... | Handle error response . |
10,147 | public function content ( ) { $ out = '' ; $ max = $ this -> header ( 'Content-Length' , NULL ) ; if ( isset ( $ this -> metadata [ 'unread_bytes' ] ) && isset ( $ max ) ) { while ( ! feof ( $ this -> handle ) && strlen ( $ out ) < $ max ) { $ out .= fread ( $ this -> handle , 8192 ) ; } } else { $ out = stream_get_con... | Get the contents of this response as a string . |
10,148 | public function header ( $ name , $ default = NULL ) { if ( isset ( $ this -> headers [ $ name ] ) ) { return $ this -> headers [ $ name ] ; } return $ default ; } | Convenience function to retrieve a single header . |
10,149 | protected function parseHeaders ( $ headerArray ) { $ ret = array_shift ( $ headerArray ) ; $ responseLine = preg_split ( '/\s/' , $ ret ) ; $ count = count ( $ headerArray ) ; $ this -> protocol = $ responseLine [ 0 ] ; $ this -> code = ( int ) $ responseLine [ 1 ] ; $ this -> message = $ responseLine [ 2 ] ; if ( $ t... | Parse the HTTP headers . |
10,150 | public function getInfo ( $ name ) { $ keys = explode ( '.' , $ name ) ; if ( is_array ( $ keys ) ) { $ file = array_shift ( $ keys ) ; $ key = implode ( '.' , $ keys ) ; } else { $ file = $ name ; $ key = null ; } return [ 'file' => $ file , 'key' => $ key ] ; } | Get the filename and key of the config name |
10,151 | public function addElement ( $ blockType , array $ element ) { $ this -> blockType = $ blockType ; $ this -> label = $ element [ "description" ] ; $ this -> filter = $ element [ "filter" ] ; $ this -> type = 'element' ; } | Adds a menu element |
10,152 | protected function execCurl ( $ handle ) { if ( empty ( $ this -> multi ) ) { $ multi = curl_multi_init ( ) ; $ this -> multi = $ multi ; } else { $ multi = $ this -> multi ; } curl_multi_add_handle ( $ multi , $ handle ) ; $ active = NULL ; do { while ( ( $ mrc = curl_multi_exec ( $ multi , $ active ) ) == CURLM_CALL_... | Poor man s connection pooling . |
10,153 | protected function fetchHeaders ( $ file ) { $ buffer = array ( ) ; while ( $ header = fgets ( $ file ) ) { $ header = trim ( $ header ) ; if ( $ header == 'HTTP/1.1 100 Continue' ) { continue ; } if ( ! empty ( $ header ) ) { $ buffer [ ] = $ header ; } } return $ buffer ; } | This function reads the header file into an array . |
10,154 | protected function determineMethod ( $ curl , $ method ) { $ method = strtoupper ( $ method ) ; switch ( $ method ) { case 'GET' : curl_setopt ( $ curl , CURLOPT_HTTPGET , TRUE ) ; break ; case 'HEAD' : curl_setopt ( $ curl , CURLOPT_NOBODY , TRUE ) ; break ; case 'PUT' : curl_setopt ( $ curl , CURLOPT_PUT , TRUE ) ; b... | Set the appropriate constant on the CURL object . |
10,155 | protected function getFileName ( ) { $ fileName = parent :: getFileName ( ) ; if ( $ this -> maxCount !== false ) { $ fileName = strtr ( $ fileName , [ $ this -> countPlaceHolder => $ this -> currentFileCount ] ) ; } return $ fileName ; } | Base file name with replaced count placeholder . |
10,156 | public function build ( array $ config ) { $ router = new Router ( ) ; foreach ( $ config as $ name => $ route ) { if ( $ route instanceof RouteInterface ) { $ router -> register ( $ name , $ route ) ; continue ; } $ route = $ this -> applyDefaults ( $ route ) ; $ router -> register ( $ name , $ this -> createDefinitio... | Builds router and routes |
10,157 | public static function definition ( ) { return array ( 'fields' => array ( 'block_id' => array ( 'name' => 'BlockID' , 'datatype' => 'string' , 'default' => '' , 'required' => true , 'foreign_class' => 'eZFlowBlock' , 'foreign_attribute' => 'id' , 'multiplicity' => '1..*' ) , 'object_id' => array ( 'name' => 'ObjectID'... | Return the definition for the object |
10,158 | static function fetchListByContentObjectId ( $ objectId ) { $ conds = array ( 'object_id' => $ objectId ) ; $ objectList = eZPersistentObject :: fetchObjectList ( self :: definition ( ) , null , $ conds ) ; return $ objectList ; } | Fetch pool items by content object ID |
10,159 | protected function add ( array $ values ) { $ values = $ this -> dispatchBeforeOperationEvent ( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\BeforeLanguageAddingEvent' , LanguageEvents :: BEFORE_ADD_LANGUAGE , $ values , array ( 'message' => 'exception_language_adding_aborted' , 'domain' => 'ex... | Adds a new Language object from the given params |
10,160 | protected function edit ( array $ values ) { $ values = $ this -> dispatchBeforeOperationEvent ( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\BeforeLanguageEditingEvent' , LanguageEvents :: BEFORE_EDIT_LANGUAGE , $ values , array ( 'message' => 'exception_language_editing_aborted' , 'domain' =>... | Edits the managed language object |
10,161 | protected function resetMain ( ) { try { $ language = $ this -> languageRepository -> mainLanguage ( ) ; if ( null !== $ language ) { $ result = $ this -> languageRepository -> setRepositoryObject ( $ language ) -> save ( array ( 'MainLanguage' => 0 ) ) ; return $ result ; } return true ; } catch ( \ Exception $ e ) { ... | Degrades the main language to normal language |
10,162 | public static function decode ( $ value , $ assoc = false ) { $ data = json_decode ( ( string ) $ value , $ assoc ) ; switch ( json_last_error ( ) ) { case JSON_ERROR_NONE : return $ data ; break ; case JSON_ERROR_DEPTH : throw new \ RuntimeException ( 'Invalid JSON structure' ) ; break ; case JSON_ERROR_STATE_MISMATCH... | Returns a php variable from the json decoded value . Throws an exception if decoding the data is not possible |
10,163 | final public function normalize ( ) : void { foreach ( $ this -> props [ 'items' ] as & $ item ) { $ item = array_replace ( $ this -> defaultItem , $ item ) ; } unset ( $ item ) ; } | Normalizes the trace items |
10,164 | final public function truncateByLimit ( int $ limit ) : bool { if ( count ( $ this -> props [ 'items' ] ) <= $ limit ) { return false ; } $ this -> props [ 'items' ] = array_slice ( $ this -> props [ 'items' ] , 0 , $ limit ) ; return true ; } | Truncates the trace by a limit |
10,165 | public function trimFilename ( string $ prefix ) : bool { $ affected = false ; $ len = strlen ( $ prefix ) ; foreach ( $ this -> props [ 'items' ] as & $ item ) { if ( ( ! empty ( $ item [ 'file' ] ) ) && ( strpos ( $ item [ 'file' ] , $ prefix ) === 0 ) ) { $ item [ 'file' ] = substr ( $ item [ 'file' ] , $ len ) ; $ ... | Trims a filename by a basic directory name |
10,166 | public function truncate ( array $ options ) : bool { $ options = array_replace ( $ this -> defaultOptions , $ options ) ; $ nItems = [ ] ; foreach ( array_reverse ( $ this -> props [ 'items' ] ) as $ item ) { $ f = $ this -> filterItem ( $ item , $ options ) ; if ( $ f ) { if ( $ f !== self :: FILTER_LEFT ) { $ nItems... | Truncates the trace by a options |
10,167 | protected function filterItem ( array $ item , array $ options ) { if ( $ options [ 'filter' ] ) { $ f = call_user_func ( $ options [ 'filter' ] , $ item ) ; if ( $ f ) { return $ f ; } } if ( ! empty ( $ item [ 'class' ] ) ) { $ result = $ this -> filterByClass ( $ item , $ options ) ; if ( $ result !== false ) { retu... | Check a backtrace item for truncate |
10,168 | private function hashRaw ( $ password , $ salt , $ function = '' , $ storedHash = null ) { if ( $ function == '' ) { $ function = $ this -> hashFunction ; } if ( $ function !== 'crypt' ) { $ calcHash = hash ( $ function , hash ( $ function , $ password ) . $ salt ) ; } else if ( ! is_null ( $ storedHash ) ) { $ calcHas... | Hashes a password with a given salt . |
10,169 | protected function prefixParentKeys ( $ key , array $ parent ) : string { return ! empty ( $ parent ) ? $ this -> flattenKeys ( $ parent ) . ".$key" : $ key ; } | Helper function to prefix all of the parent keys . |
10,170 | public function tokenize ( array $ credentials ) { if ( empty ( $ credentials ) ) { throw new AuthenticationException ( 'Unable to create token, no or empty credentials' ) ; } foreach ( $ this -> providers as $ provider ) { if ( ! $ provider -> supportsCredentials ( $ credentials ) ) { continue ; } if ( ! $ token = $ p... | Creates token from credentials via user providers |
10,171 | public function authenticate ( RequestInterface $ request ) { $ token = $ this -> token ( ) ; if ( ! $ token && ! $ this -> findMatchingArea ( $ request ) ) { return $ this ; } if ( ! $ token ) { throw new AuthenticationException ( 'Unable to authenticate, token is missing' ) ; } foreach ( $ this -> providers as $ prov... | Authenticates token in user providers for requested area |
10,172 | public function authorize ( RequestInterface $ request ) { if ( ! $ area = $ this -> findMatchingArea ( $ request ) ) { return $ this ; } if ( ! $ this -> user ) { throw new AuthorizationException ( sprintf ( 'Access denied to area "%s". No authenticated user' , $ area -> pattern ( ) ) ) ; } if ( ! $ area -> authorize ... | Checks if authenticated user has access to requested area |
10,173 | protected function findMatchingArea ( RequestInterface $ request ) { foreach ( $ this -> areas as $ area ) { if ( ! $ area -> match ( $ request ) ) { continue ; } return $ area ; } return null ; } | Returns matching area or null if not found |
10,174 | private function loadView ( bool $ try = false ) : void { Accessor :: $ viewsExtension = config ( 'view.extension' ) ; Accessor :: $ viewsEngine = config ( 'view.engine' ) ; Accessor :: $ viewsCache = config ( 'app.dir' ) . config ( 'view.compiled' ) ; Accessor :: $ viewsDirectory = config ( 'app.dir' ) . config ( 'vie... | Load the view component |
10,175 | public static function check ( Plugin $ plugin , ReflectionClass $ info ) : bool { if ( array_key_exists ( 'PACKAGE' , $ info -> getConstants ( ) ) && array_key_exists ( 'VERSION' , $ info -> getConstants ( ) ) && ( array_key_exists ( 'AUTHORS' , $ info -> getConstants ( ) ) && is_array ( $ info -> getConstants ( ) [ '... | Check if plugin is usable |
10,176 | private static function isCompatable ( Plugin $ plugin ) : bool { $ frameworkVersion = substr ( self :: getVersion ( ) , 0 , strrpos ( self :: getVersion ( ) , '*' ) ) ; $ pluginVersions = explode ( '|' , $ plugin :: FRAMEWORK ) ; foreach ( $ pluginVersions as $ version ) { $ version = substr ( $ version , 0 , strrpos ... | Check if plugin supports the current version of the framework |
10,177 | function setServices ( iContainer $ container ) { $ this -> sc = $ container ; $ container -> nest ( $ this , uniqid ( ) ) ; } | Set Service Container |
10,178 | public function getDeliveryFields ( ) { $ contact = $ this -> getContact ( ) ; $ fields = FieldList :: create ( CompositeField :: create ( CompositeField :: create ( TextField :: create ( 'DeliveryCompany' , _t ( 'SilverCommerce\Checkout.Company' , 'Company' ) ) -> setRightTitle ( _t ( "SilverCommerce\Checkout.Optional... | Generate a FieldList of delivery address fields |
10,179 | public function getDeliveryDropdownFields ( ) { $ contact = $ this -> getContact ( ) ; return FieldList :: create ( CompositeField :: create ( DropdownField :: create ( 'ShippingAddress' , _t ( 'SilverCommerce\Checkout.DeliveryAddress' , 'Delivery Address' ) , $ contact -> Locations ( ) ) , FormAction :: create ( 'doAd... | Generate a FieldList containing fields for if the user has existing locations |
10,180 | public function move ( $ path , $ file = null , $ overwrite = false ) { if ( ! $ this -> isValid ( ) ) { throw new UploadedFileException ( 'Upload was not successful - ' . $ this -> getErrorMessage ( ) ) ; } $ target = $ this -> getTarget ( $ path , $ file ) ; if ( ! $ overwrite && is_file ( $ target ) ) { throw new Up... | Moves uploaded file to set path and file name |
10,181 | protected function getTarget ( $ path , $ file = null ) { if ( $ file === null ) { $ nArr = explode ( '.' , $ this -> raw [ 'name' ] ) ; $ file = md5 ( microtime ( true ) . implode ( '.' , $ nArr ) ) . '.' . array_pop ( $ nArr ) ; } return rtrim ( $ path , '\\/' ) . '/' . $ file ; } | Builds file name with path |
10,182 | public function getErrorMessage ( ) { switch ( $ this -> raw [ 'error' ] ) { case UPLOAD_ERR_OK : return null ; case UPLOAD_ERR_INI_SIZE : return 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' ; case UPLOAD_ERR_FORM_SIZE : return 'The uploaded file exceeds the MAX_FILE_SIZE directive specifie... | Returns error message |
10,183 | private static function matchType ( \ ReflectionParameter $ parameter , $ value ) : bool { if ( $ class = $ parameter -> getClass ( ) ) { return \ is_object ( $ value ) && $ class -> isInstance ( $ value ) ; } if ( $ parameter -> isArray ( ) ) { return \ is_array ( $ value ) ; } if ( $ parameter -> isCallable ( ) ) { r... | Checks if the value matches the parameter type . |
10,184 | private static function compareParameters ( \ ReflectionParameter $ a , \ ReflectionParameter $ b ) : int { if ( 0 !== $ result = self :: compareParameterClasses ( $ a , $ b ) ) { return $ result ; } if ( $ a -> isArray ( ) ^ $ b -> isArray ( ) ) { return $ b -> isArray ( ) << 1 - 1 ; } if ( $ a -> isCallable ( ) ^ $ b... | Compares reflection parameters by type and position . |
10,185 | private static function compareParameterClasses ( \ ReflectionParameter $ a , \ ReflectionParameter $ b ) : int { $ a = $ a -> getClass ( ) ; $ b = $ b -> getClass ( ) ; if ( $ a && $ b ) { return $ a -> isSubclassOf ( $ b -> name ) ? - 1 : ( int ) $ b -> isSubclassOf ( $ a -> name ) ; } return ( int ) ! $ a - ( int ) ... | Compares reflection parameters by class hierarchy . |
10,186 | public function toXML ( DOMDocument $ dom ) { $ zoneNode = $ dom -> createElement ( 'zone' ) ; foreach ( $ this -> attributes as $ attrName => $ attrValue ) { switch ( $ attrName ) { case 'id' : $ zoneNode -> setAttribute ( 'id' , 'id_' . $ attrValue ) ; break ; case 'action' : $ zoneNode -> setAttribute ( 'action' , $... | Creates DOMElement with zone data |
10,187 | public static function createFromXML ( DOMElement $ node ) { $ newObj = new eZPageZone ( ) ; if ( $ node -> hasAttributes ( ) ) { foreach ( $ node -> attributes as $ attr ) { if ( $ attr -> name == 'id' ) { $ value = explode ( '_' , $ attr -> value ) ; $ newObj -> setAttribute ( $ attr -> name , $ value [ 1 ] ) ; } els... | Creates and return eZPageZone object from given XML |
10,188 | public function sortBlocks ( array $ sortArray ) { $ sortedBlocks = array ( ) ; foreach ( $ sortArray as $ sortItem ) { $ blocksToBeRemoved = array ( ) ; foreach ( $ this -> attributes [ 'blocks' ] as $ block ) { if ( $ block -> attribute ( 'id' ) === $ sortItem ) $ sortedBlocks [ ] = $ block ; if ( $ block -> toBeRemo... | Sorting blocks for given sort array which contains block ids |
10,189 | public function moveBlockUp ( $ currentIndex ) { $ array = & $ this -> attributes [ 'blocks' ] ; $ newIndex = $ currentIndex - 1 ; if ( $ newIndex < 0 || $ newIndex >= count ( $ array ) ) return false ; $ tmpItem = $ array [ $ newIndex ] ; $ array [ $ newIndex ] = & $ array [ $ currentIndex ] ; $ array [ $ currentIndex... | Move current block position up |
10,190 | public function removeProcessed ( ) { if ( $ this -> hasAttribute ( 'action' ) ) { unset ( $ this -> attributes [ 'action' ] ) ; } if ( $ this -> getBlockCount ( ) > 0 ) { foreach ( $ this -> attributes [ 'blocks' ] as $ index => $ block ) { if ( $ block -> toBeRemoved ( ) ) { $ this -> removeBlock ( $ index ) ; } else... | Cleanup processed objects removes action attribute removes all blocks marked with remove action |
10,191 | protected static function exeRead ( string $ entity , $ data = null ) { if ( ! is_array ( $ data ) && ! is_numeric ( $ data ) ) return null ; if ( is_array ( $ data ) ) { $ read = new TableCrud ( $ entity ) ; $ read -> loadArray ( $ data ) ; if ( $ read -> exist ( ) ) $ data = ( int ) $ read -> getDados ( ) [ 'id' ] ; ... | Le a data de uma entidade de forma extendida |
10,192 | public function _beforeSuite ( $ settings = [ ] ) { if ( $ this -> config [ 'check_logs' ] && \ Drupal :: moduleHandler ( ) -> moduleExists ( 'dblog' ) ) { \ Drupal :: database ( ) -> truncate ( 'watchdog' ) -> execute ( ) ; } } | Setup Test environment . |
10,193 | public function _afterSuite ( ) { if ( isset ( $ this -> users ) ) { $ users = User :: loadMultiple ( $ this -> users ) ; foreach ( $ users as $ user ) { $ user -> delete ( ) ; } } if ( $ this -> config [ 'check_logs' ] ) { if ( \ Drupal :: moduleHandler ( ) -> moduleExists ( 'dblog' ) ) { $ query = \ Drupal :: databas... | Tear down after tests . |
10,194 | public function getConfig ( $ key ) { if ( isset ( $ this -> config [ $ key ] ) ) { return $ this -> config [ $ key ] ; } return FALSE ; } | Returns configuration . |
10,195 | public function createUserWithRoles ( array $ roles = [ 'authenticated' ] , $ password = FALSE ) { $ faker = Faker :: create ( ) ; $ user = User :: create ( [ 'name' => $ faker -> userName , 'mail' => $ faker -> email , 'roles' => $ roles , 'pass' => $ password ? $ password : $ faker -> password ( 12 , 14 ) , 'status' ... | Create test user with specified roles . |
10,196 | public function deleteUser ( $ username ) { $ users = \ Drupal :: entityQuery ( 'user' ) -> condition ( "name" , $ username ) -> execute ( ) ; $ users = User :: loadMultiple ( $ users ) ; foreach ( $ users as $ user ) { $ user -> delete ( ) ; } } | Deletes user by username . |
10,197 | public function getColumn ( $ columnKey ) { $ columns = $ this -> searchable ( ) ; if ( array_key_exists ( $ columnKey , $ columns ) ) { return $ columns [ $ columnKey ] ; } foreach ( $ columns as $ column ) { if ( $ column === $ columnKey || ends_with ( $ column , ".{$columnKey}" ) ) { return $ column ; } } } | Get the actual searchable column of the given column key . |
10,198 | public function search ( $ searchStr ) { $ conditions = [ ] ; $ parsedStr = $ this -> parseSearchStr ( $ searchStr ) ; foreach ( $ this -> searchable ( ) as $ column ) { $ conditions [ ] = $ column . ' like "' . $ parsedStr . '"' ; } $ method = $ this -> searchOperator . 'Raw' ; $ query = $ this -> query ( ) -> { $ met... | Apply search query . |
10,199 | protected function applySort ( $ query , $ searchStr ) { if ( empty ( $ searchStr ) || count ( $ sortColumns = $ this -> sortColumns ( ) ) == 0 ) { return $ query ; } $ sortColumns = array_map ( function ( $ column ) { return DB :: raw ( "IFNULL(({$column}), '')" ) ; } , $ sortColumns ) ; $ sqls = [ ] ; $ concatSortCol... | Apply sort in query . By default using mysql locate function . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.