idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
4,200 | protected function assertClass ( $ class ) { if ( ! preg_match ( '/^([a-zA-Z_]\w*\\\\)*[a-zA-Z_]\w*$/' , $ class ) ) { throw new \ UnexpectedValueException ( "Can't route to controller '$class': invalid classname" ) ; } if ( ! class_exists ( $ class ) ) { throw new \ UnexpectedValueException ( "Can't route to controlle... | Assert that a class exists and will provide a callable object |
4,201 | protected function studlyCase ( $ string ) { return preg_replace_callback ( '/(?:^|(\w)-)(\w)/' , function ( $ match ) { return $ match [ 1 ] . strtoupper ( $ match [ 2 ] ) ; } , strtolower ( addcslashes ( $ string , '\\' ) ) ) ; } | Turn kabab - case into StudlyCase . |
4,202 | private function setYamlPath ( string $ yamlPath ) : void { $ chars = preg_quote ( ':._-\/\\\\' , '#' ) ; $ pattern = '#^[\w' . $ chars . ']+\.(yaml|yml)$#' ; if ( ! preg_match ( $ pattern , $ yamlPath ) ) { throw new ParserException ( 'Given path to YAML file is invalid' ) ; } $ givenPath = $ yamlPath ; $ yamlPath = r... | Validates path checks if starting Yaml file exists |
4,203 | public function setEOL ( string $ eol = PHP_EOL ) : self { if ( ! in_array ( $ eol , [ "\n" , "\r\n" ] ) ) { throw new ParserException ( 'Invalid EOL character' ) ; } $ this -> eolChar = $ eol ; return $ this ; } | Set EOL character |
4,204 | public function addUserAgentNormalizer ( WURFL_Request_UserAgentNormalizer_Interface $ normalizer ) { $ userAgentNormalizers = $ this -> _userAgentNormalizers ; $ userAgentNormalizers [ ] = $ normalizer ; return new WURFL_Request_UserAgentNormalizer ( $ userAgentNormalizers ) ; } | Adds a new UserAgent Normalizer to the chain |
4,205 | public function get ( $ key ) { $ items = Arr :: get ( $ this -> items , $ key ) ; return $ this -> firstOrAll ( $ items ) ; } | Get the resolved resource by key . |
4,206 | public static function Range ( int $ num , int $ from , int $ to ) : bool { return ( $ num >= $ from && $ num <= $ to ) ? true : false ; } | Check if specified number is with in specified range |
4,207 | private function surroundInDiv ( DOMNode $ element , $ class ) { $ div = $ this -> createElement ( 'div' ) ; $ div -> setAttribute ( 'class' , $ class ) ; $ div -> appendChild ( $ element ) ; return $ div ; } | Surround an element in a div with a given class |
4,208 | public static function forBindingClass ( $ typeName , $ bindingClass , Exception $ cause = null ) { return new static ( sprintf ( 'The type "%s" does accept bindings of class "%s".' , $ typeName , $ bindingClass ) , 0 , $ cause ) ; } | Creates a new exception . |
4,209 | public function addManagedCollections ( $ collections ) { if ( ! is_array ( $ collections ) ) { $ collections = array ( $ collections ) ; } $ this -> managedCollections = array_merge ( $ this -> managedCollections , $ collections ) ; return $ this ; } | function addManagedCollections . |
4,210 | public function shortenUrl ( $ url ) { if ( $ this -> getOptions ( ) -> getBitlyApiKey ( ) && $ this -> getOptions ( ) -> getBitlyUsername ( ) ) { $ client = new \ Zend \ Http \ Client ( $ this -> getOptions ( ) -> getBitlyUrl ( ) ) ; $ client -> setParameterGet ( array ( 'format' => 'json' , 'longUrl' => $ url , 'logi... | This method call Bit . ly to shorten a given URL . |
4,211 | public function setValidationRules ( $ attr , $ validationRules = null ) { $ rules = is_array ( $ attr ) ? $ attr : [ $ attr => $ validationRules ] ; $ this -> validationRules = array_merge ( $ this -> validationRules , $ rules ) ; return $ this ; } | Set validation rules array |
4,212 | public static function create ( $ conn , Configuration $ config = null , EventManager $ eventManager = null ) { if ( null === $ config ) { $ config = new Configuration ( ) ; $ config -> setProxyDir ( __DIR__ . '/../Proxies' ) ; $ config -> setProxyNamespace ( 'Doctrine\Tests\Proxies' ) ; $ config -> setMetadataDriverIm... | Mock factory method to create an EntityManager . |
4,213 | public function has ( $ id ) { if ( $ this -> isSilverStripeServiceRequest ( $ id ) ) { return ( bool ) $ this -> getSilverStripeService ( $ id ) ; } else { return parent :: has ( $ id ) ; } } | Return true if the service requested is a SilverStripe service and it exists in the SS container |
4,214 | public function importString ( $ content , $ isMandatory = true ) { if ( empty ( $ content ) && $ isMandatory ) { throw new JsonException ( "Json content mandatory but none found." ) ; } $ this -> params = array ( ) ; if ( ! empty ( $ content ) ) { $ this -> params = @ json_decode ( $ content , true ) ; if ( json_last_... | Import string json and parse |
4,215 | private function translatePathElement ( $ path , & $ paramsRef ) { $ dotPos = strpos ( $ path , '.' ) ; $ currPath = $ path ; if ( $ dotPos !== false ) { $ currPath = substr ( $ path , 0 , $ dotPos ) ; } if ( $ currPath == '*' ) { if ( $ dotPos !== false ) { $ newParamsRef = array ( ) ; foreach ( $ paramsRef as $ subAr... | Traverse through params according to path . This is a recursive function . |
4,216 | public function getMandatoryParam ( $ path ) { $ this -> validatePath ( $ path ) ; $ value = $ this -> translatePathElement ( $ path , $ this -> params ) ; if ( null === $ value ) { throw new JsonException ( "Json mandatory param '$path' not found found." ) ; } return $ value ; } | Returns json key value or throws exception if key doesn t exist |
4,217 | public function hasParam ( $ path ) { $ this -> validatePath ( $ path ) ; $ value = $ this -> translatePathElement ( $ path , $ this -> params ) ; return ( null === $ value ) ? false : true ; } | Returns json true if path exists |
4,218 | public function getOptionalParam ( $ path , $ default = false ) { $ this -> validatePath ( $ path ) ; $ value = $ this -> translatePathElement ( $ path , $ this -> params ) ; if ( null === $ value ) { return ( null === $ default ) ? null : $ default ; } return $ value ; } | Returns json key value or false if key doesn t exist |
4,219 | public function sendSeries ( Series $ series ) { $ metrics = $ series -> getMetrics ( ) ; if ( empty ( $ metrics ) ) { throw new EmptySeriesException ( 'The series must contain metric data to send' ) ; } $ this -> send ( self :: ENDPOINT_SERIES . $ this -> getApiKey ( ) , $ series -> toArray ( ) ) ; return $ this ; } | Send a Series object to datadog |
4,220 | public function sendMetric ( Metric $ metric ) { $ points = $ metric -> getPoints ( ) ; if ( empty ( $ points ) ) { throw new EmptyMetricException ( 'The metric must contain points to send' ) ; } $ this -> sendSeries ( new Series ( $ metric ) ) ; return $ this ; } | Send a Metric object to datadog |
4,221 | public function metric ( $ name , array $ points , array $ options = array ( ) ) { return $ this -> sendMetric ( Factory :: buildMetric ( $ name , $ points , $ options ) ) ; } | Send metric data to datadog |
4,222 | public function event ( $ text , $ title = '' , array $ options = array ( ) ) { return $ this -> sendEvent ( Factory :: buildEvent ( $ text , $ title , $ options ) ) ; } | Send an event to datadog |
4,223 | public function sendEvent ( Event $ event ) { $ this -> send ( self :: ENDPOINT_EVENT . $ this -> getApiKey ( ) , $ event -> toArray ( ) ) ; return $ this ; } | Send an Event object to datadog |
4,224 | public function getContactData ( $ addressData , Contact $ contact = null ) { $ result = array ( ) ; if ( $ addressData && isset ( $ addressData [ 'firstName' ] ) && isset ( $ addressData [ 'lastName' ] ) ) { $ result [ 'firstName' ] = $ addressData [ 'firstName' ] ; $ result [ 'lastName' ] = $ addressData [ 'lastName'... | Returns contact data as an array . either by provided address or contact |
4,225 | public function addDatatableButtonExport ( $ text = 'Export CSV' ) { $ this -> hasToken ( ) ? : $ this -> generateToken ( ) ; $ this -> addDatatableButtonLink ( $ text , route ( 'datatable-export' , [ 'token' => $ this -> getToken ( ) ] ) ) ; return $ this ; } | Ajoute un Bouton d export |
4,226 | public function save ( ) { if ( ! $ this -> hasToken ( ) ) { if ( static :: hasSingleToken ( ) ) { $ this -> setToken ( static :: getSingleToken ( ) ) ; } else { $ this -> generateToken ( ) ; } } if ( ! $ this -> hasConstructor ( ) ) { $ this -> setConstructor ( static :: class ) ; } Session :: push ( $ this -> getToke... | Save the Table configuration in Session |
4,227 | static public function load ( $ token = null ) { if ( is_null ( $ token ) && static :: hasSingleToken ( ) ) { $ token = static :: getSingleToken ( ) ; } if ( ! Session :: has ( $ token ) ) { if ( static :: hasSingleToken ( ) ) { Session :: push ( $ token , json_encode ( [ 'constructor' => static :: class ] ) ) ; } else... | Load a datable from a token |
4,228 | public function getRequestToken ( $ callback_uri = NULL ) { $ this -> getOauthPlugin ( ) -> setCallbackUri ( $ callback_uri ) ; $ response = $ this -> get ( $ this -> getConfig ( 'request_token_path' ) ) -> send ( ) ; $ request_token = array ( ) ; parse_str ( $ response -> getBody ( ) , $ request_token ) ; if ( ! isset... | Get a Request Token . |
4,229 | public function getAuthorizeUrl ( $ request_token , $ callback_uri = NULL , $ state = NULL ) { $ request_token = array ( 'oauth_token' => is_array ( $ request_token ) ? $ request_token [ 'oauth_token' ] : $ request_token , ) ; $ url = Url :: factory ( $ this -> getConfig ( 'base_url' ) ) ; $ url -> addPath ( $ this -> ... | Return a authorize url . |
4,230 | public function set ( $ route ) { if ( $ route instanceof Group ) { foreach ( $ route -> all ( ) as $ r ) $ this -> routes [ ] = $ r ; } else $ this -> routes [ ] = $ route ; return $ this ; } | Set a new Route or merge an existing group of routes . |
4,231 | public function setMethod ( $ method ) { foreach ( $ this -> routes as $ route ) $ route -> setMethod ( $ method ) ; return $ this ; } | Set one HTTP method to all grouped routes . |
4,232 | public function setAction ( $ action ) { foreach ( $ this -> routes as $ route ) $ route -> setAction ( $ action ) ; return $ this ; } | Set one action to all grouped routes . |
4,233 | public function setPrefix ( $ prefix ) { $ prefix = "/" . ltrim ( $ prefix , "/" ) ; $ routes = [ ] ; foreach ( $ this -> routes as $ route ) $ routes [ ] = $ route -> setPattern ( rtrim ( $ prefix . $ route -> getPattern ( ) , "/" ) ) ; $ this -> routes = $ routes ; return $ this ; } | Add a prefix to all grouped routes pattern . |
4,234 | public function setMetadata ( $ key , $ value ) { foreach ( $ this -> routes as $ route ) $ route -> setMetadata ( $ key , $ value ) ; return $ this ; } | Set metadata to all grouped routes . |
4,235 | public function setMetadataArray ( array $ metadata ) { foreach ( $ this -> routes as $ route ) $ route -> setMetadataArray ( $ metadata ) ; return $ this ; } | Set a bunch of metadata to all grouped routes . |
4,236 | public function setDefaults ( array $ defaults ) { foreach ( $ this -> routes as $ route ) $ route -> setDefaults ( $ defaults ) ; return $ this ; } | Set default parameters to all grouped routes . |
4,237 | public function setDefault ( $ key , $ value ) { foreach ( $ this -> routes as $ route ) $ route -> setDefault ( $ key , $ value ) ; return $ this ; } | Set a default parameter to all grouped routes . |
4,238 | public function setStrategy ( $ strategy ) { foreach ( $ this -> routes as $ route ) $ route -> setStrategy ( $ strategy ) ; return $ this ; } | Set one dispatch strategy to all grouped routes . |
4,239 | public function setName ( $ name ) { if ( count ( $ this -> routes ) > 1 ) { throw new \ LogicException ( "You cannot set the same name to several routes." ) ; } $ this -> routes [ 0 ] -> setName ( $ name ) ; return $ this ; } | Set a name to a Route . |
4,240 | protected function determineIfModelIsSluggable ( ) { $ this -> context -> modelIsSluggable = false ; $ this -> context -> modelIsParentOfSluggableTranslation = false ; if ( $ this -> data [ 'sluggable' ] ) { if ( ! isset ( $ this -> data -> sluggable_setup [ 'translated' ] ) || ! $ this -> data -> sluggable_setup [ 'tr... | Determines and stores whether model itself is sluggable If so it will have both the trait and implement the interface |
4,241 | private function protect ( ) { if ( ! in_array ( $ this -> certificateType , self :: allAsString ( ) , true ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid certificate type %s' , $ this -> certificateType ) ) ; } } | Check if the certificateType exists in our list |
4,242 | protected function getBasePath ( string $ action ) : string { return sprintf ( 'project/%s/%s?key=%s' , $ this -> getProjectId ( ) , $ action , $ this -> getApiKey ( ) ) ; } | Get the base path for the command including an action . |
4,243 | public function getState ( ) { if ( empty ( $ this -> state ) ) { $ this -> state = \ Drupal :: service ( 'state' ) ; } return $ this -> state ; } | Gets the state storage . |
4,244 | public function merge ( $ headers ) { foreach ( $ headers as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } return $ this ; } | Merge actual headers with an array of headers |
4,245 | public function getFiltered ( $ page , $ numRows , $ sortAttr , $ sortOrder , $ searchAttr , $ searchValue , $ richFilters = [ ] ) { $ query = $ this -> prepareQuery ( ) ; $ query = $ this -> richFiltersOnQuery ( $ query , $ richFilters ) ; if ( $ sortAttr && $ sortOrder && $ this -> inScope ( $ sortAttr ) ) { $ scope ... | Get filtered collection |
4,246 | public function countFiltered ( $ searchAttr , $ searchValue , $ richFilters ) { $ collection = $ this -> getFiltered ( null , null , null , null , $ searchAttr , $ searchValue , $ richFilters ) ; return count ( $ collection ) ; } | Count all rows with condition |
4,247 | public function addPermissions ( $ collection ) { $ newCollection = collect ( [ ] ) ; $ customActions = $ this -> crudeSetup -> getCustomActions ( ) ; $ collection -> each ( function ( $ model ) use ( $ newCollection , $ customActions ) { if ( $ this -> permissionView ( $ model ) ) { $ model = $ this -> addPermissionsF... | Filter collection by permissions and add attributes canBeEdited and canBeRemoved |
4,248 | public function dispatch ( $ dispatchable , $ resolutionType , $ dispatchSource , Request $ request , ... $ rest ) { return $ dispatchable ( $ request , ... $ rest ) ; } | Call the callable providing parameters and returning the returned value . |
4,249 | public function scanCollection ( $ collection , $ fields ) { $ fields = ( array ) $ fields ; foreach ( $ collection as $ item ) { $ this -> collectIdsFromItem ( $ item , $ fields ) ; } return $ this ; } | Add a collection source . |
4,250 | public function scanItem ( $ item , $ fields ) { $ fields = ( array ) $ fields ; $ this -> collectIdsFromItem ( $ item , $ fields ) ; return $ this ; } | Add an item source . |
4,251 | public function addIds ( $ ids ) { foreach ( $ ids as $ id ) { if ( ( int ) $ id ) { $ this -> ids [ ] = ( int ) $ id ; } } return $ this ; } | Add existeing ids array source . |
4,252 | protected function collectIdsFromField ( $ item , $ field ) { $ ids = Arr :: get ( $ item , $ field , [ ] ) ; return is_object ( $ ids ) && method_exists ( $ ids , 'toArray' ) ? $ ids -> toArray ( ) : ( array ) $ ids ; } | Collect ids from field of item |
4,253 | public function segments ( $ highway = NULL ) { if ( $ highway && isset ( $ this -> trafficData [ $ highway ] [ 'segments' ] ) ) { return array_keys ( $ this -> trafficData [ $ highway ] [ 'segments' ] ) ; } return null ; } | This function returns the list of segments in a given highway . |
4,254 | final private function getTrafficData ( $ feedUrl ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ feedUrl ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ response = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; $ xml = simplexml_load_string ( $ response ) ; return $ this -> sanitizeTrafficData... | This function retrieves the traffic data from the MMDA Traffic API . |
4,255 | final private function parseTrafficData ( $ xml ) { $ traffic = [ ] ; foreach ( $ xml -> channel -> item as $ item ) { $ item = get_object_vars ( $ item ) ; $ title = $ item [ 'title' ] ; $ description = $ item [ 'description' ] ; $ pubDate = $ item [ 'pubDate' ] ; $ highway = explode ( '-' , $ title , 2 ) [ 0 ] ; $ se... | This function parses the XML response from the MMDA Traffic API into JSON . |
4,256 | final private function sanitizeTrafficData ( Array $ trafficData ) { $ traffic = [ ] ; foreach ( $ trafficData as $ highway => $ segments ) { $ traffic [ $ highway ] = [ 'name' => $ highway , 'label' => $ this -> convertToTitle ( $ highway ) , ] ; $ traffic [ $ highway ] [ 'segments' ] = [ ] ; $ dataSegments = [ ] ; fo... | This function sanitizes the traffic data and organizes them into an envelope |
4,257 | final private function convertToStatus ( Array $ data ) { $ statusMatrix = [ 'L' => 'Light' , 'ML' => 'Light to Moderate' , 'M' => 'Moderate' , 'MH' => 'Moderate to Heavy' , 'H' => 'Heavy' ] ; $ status = [ 'NB' => [ 'name' => $ data [ 'NB' ] , 'label' => $ statusMatrix [ $ data [ 'NB' ] ] . ' Traffic' , 'last_updated' ... | This function converts traffic data status to readable format . |
4,258 | final private function convertToTitle ( $ string ) { $ string2 = [ ] ; $ string = str_replace ( [ '_' , 'AVE.' , 'BLVD.' ] , [ ' ' , 'AVENUE' , 'BOULEVARD' ] , $ string ) ; $ words = explode ( ' ' , $ string ) ; foreach ( $ words as $ word ) { if ( ! in_array ( $ word , [ 'EDSA' , 'U.N.' ] ) ) { $ word = ucwords ( mb_s... | This function sanitizes certain abbreviations into readable format . |
4,259 | public function findByRecId ( $ recId ) { if ( empty ( $ recId ) ) { throw new \ Exception ( 'No record ID specified' ) ; } $ this -> primeCommandArray ( ) ; $ this -> addToCommandArray ( [ '-recid' => $ recId ] ) ; $ this -> addToCommandArray ( [ '-find' => null ] ) ; return $ this ; } | Find a record based on it s internal FileMaker record ID |
4,260 | public function createRecord ( $ data ) { $ this -> primeCommandArray ( ) ; $ this -> addToCommandArray ( $ data ) ; $ this -> addToCommandArray ( [ '-new' => null ] ) ; return $ this ; } | Create a new record and populate it with data . |
4,261 | public function updateRecord ( $ recId , $ data ) { if ( empty ( $ recId ) ) { throw new \ Exception ( 'No record ID specified' ) ; } $ this -> primeCommandArray ( ) ; $ this -> addToCommandArray ( $ data ) ; $ this -> addToCommandArray ( [ '-recid' => $ recId ] ) ; $ this -> addToCommandArray ( [ '-edit' => null ] ) ;... | Update data in an existing record per it s internal FileMaker record ID . |
4,262 | public function deleteRecord ( $ recId ) { if ( empty ( $ recId ) ) { throw new \ Exception ( 'No record ID specified' ) ; } $ this -> primeCommandArray ( ) ; $ this -> addToCommandArray ( [ '-recid' => $ recId ] ) ; $ this -> addToCommandArray ( [ '-delete' => null ] ) ; return $ this ; } | Delete a record per it s internal FileMaker record ID . |
4,263 | protected function createDocumentManager ( ) { AnnotationDriver :: registerAnnotationClasses ( ) ; $ configuration = new Configuration ( ) ; $ configuration -> setProxyDir ( $ this -> configuration [ 'doctrine' ] [ 'proxyDir' ] ) ; $ configuration -> setProxyNamespace ( $ this -> configuration [ 'doctrine' ] [ 'proxyNa... | Creates the doctrine document mananger for working on the database |
4,264 | protected function initPromises ( $ promisesTrait ) { return $ promisesTrait -> findOne ( $ this -> createFindOneClosure ( ) ) -> findMany ( $ this -> createFindManyClosure ( ) ) -> renderResult ( $ this -> createRenderResultClosure ( ) ) -> allowRequest ( $ this -> createAllowRequestClosure ( ) ) ; } | Method for initializing a PromisesTrait object with the Closures |
4,265 | protected function createHttpException ( $ code , $ message = null ) { if ( $ code == 404 ) { $ message = 'Entity not found' ; } $ exception = new HttpException ( $ message , $ code ) ; return $ exception ; } | Helper method for creating HTTP exceptions |
4,266 | public function resource ( $ className , $ settings = [ ] ) { $ resource = $ this -> initPromises ( Resource :: create ( $ className , $ settings , $ this ) ) ; foreach ( $ resource -> settings [ 'actions' ] as $ action => $ actionSettings ) { $ methodName = "setup$action" ; if ( method_exists ( $ this , $ methodName )... | The second most important method . Will create RESTful routes for MongoDB model . |
4,267 | public function api ( $ request = null , $ response = null , $ sendResponse = true ) { $ this -> klein -> respond ( 'POST' , '/authenticate' , $ this -> authenticate ) ; $ this -> klein -> onHttpError ( $ this -> handleError ) ; if ( $ request === null ) $ request = Request :: createFromGlobals ( ) ; $ uri = $ request ... | The most important method . Will start the hive engine and listening for requests . |
4,268 | private function getFlexLocale ( $ language ) { if ( ! empty ( $ language ) ) { $ split = explode ( "-" , $ language , 2 ) ; if ( count ( $ split ) == 2 && $ split [ 1 ] != "" ) { $ split [ 1 ] = strtoupper ( $ split [ 1 ] ) ; } else { $ split = null ; } } if ( empty ( $ split ) ) $ split = [ 'en' , 'US' ] ; return $ s... | Returns locale with format for flex application |
4,269 | protected function assertPayload ( $ aPayload = null ) { if ( ! array_key_exists ( 'enabled' , $ aPayload ) || ! array_key_exists ( 'interval' , $ aPayload ) ) { throw new \ InvalidArgumentException ( 'Payload does not contain a enabled or interval key' ) ; } if ( ! is_bool ( $ aPayload [ 'enabled' ] ) ) throw new \ In... | Assert that payload contains all required information for this command |
4,270 | public function renderLabel ( $ content , $ class = '' , $ style = '' ) { $ styleAttr = ( $ style ) ? ' style="' . $ style . '"' : '' ; $ classes = ( $ class ) ? ' ' . $ class : '' ; $ renderLabel = '' ; $ renderLabel .= '<span class="fs-label' . $ classes . '"' . $ style . '>' ; $ renderLabel .= $ content ; $ renderLa... | Returns a label . |
4,271 | public function renderSeparator ( $ bold = true , $ class = '' , $ style = '' ) { $ styleAttr = ( $ style ) ? ' style="' . $ style . '"' : '' ; $ classes = ( $ class ) ? ' ' . $ class : '' ; if ( $ bold ) { return '<hr class="fs-hr' . $ classes . '"' . $ styleAttr . '>' ; } else { return '<hr class="fs-hr-dotted' . $ c... | Returns a separator . |
4,272 | public function renderTrace ( $ debug_backtrace ) { $ renderTrace = '' ; $ renderTrace .= '<span class="fs-label">' ; foreach ( $ debug_backtrace as $ index => $ trace ) { $ renderTrace .= '#' . $ index . ' ' ; if ( ! empty ( $ trace [ 'file' ] ) ) { $ renderTrace .= $ trace [ 'file' ] ; } if ( ! empty ( $ trace [ 'lin... | Returns a rendered debug_backtrace . |
4,273 | public function fetch ( $ query ) { $ result = $ this -> query ( $ query ) ; return $ result -> fetch ( \ PDO :: FETCH_ASSOC ) ; } | Return associate array with all data of one row in table |
4,274 | protected function addFields ( $ fields ) { $ fields_array = [ ] ; foreach ( $ fields as $ field => $ value ) { $ fields_array [ ] = $ field ; } return '`' . implode ( '`, `' , $ fields_array ) . '`' ; } | Generates a set of fields that need to be updated or inserted . For the terms INSERT INTO . |
4,275 | protected function _addValue ( $ values ) { $ method = $ this -> getSaveMode ( ) ; $ value_array = [ ] ; foreach ( $ values as $ key => $ value ) { $ value_array [ ] = $ this -> $ method ( $ key , $ value ) ; } return implode ( ',' , $ value_array ) ; } | Handles one - dimensional array of data and generates a set for one group . |
4,276 | protected function getSluggableConfigReplace ( ) { $ setup = $ this -> data -> sluggable_setup ; if ( ! $ this -> context -> modelIsSluggable || ! $ this -> data -> sluggable || empty ( $ setup ) ) return '' ; $ replace = $ this -> tab ( ) . "protected \$sluggable = [\n" ; $ rows = [ ] ; if ( array_get ( $ setup , 'sou... | Returns the replacement for the sluggable config placeholder |
4,277 | public static function meatOnBones ( Event $ event ) { $ basePath = realpath ( "." ) ; $ handler = new ComposerHydrationHandler ( $ event , $ basePath ) ; $ handler -> hydrate ( ) ; } | Composer callback method for Hydration process . |
4,278 | public function setSelectors ( $ selectors ) { $ this -> selectors = [ ] ; if ( ! is_array ( $ selectors ) ) { $ selectors = [ $ selectors ] ; } foreach ( $ selectors as $ selector ) { $ this -> addSelector ( $ selector ) ; } return $ this ; } | Sets the selectors for the style rule . |
4,279 | protected function parseRuleString ( $ ruleString ) { foreach ( $ this -> getSelectorStrings ( $ ruleString ) as $ selectorString ) { if ( $ selectorString === "" ) { $ this -> setIsValid ( false ) ; $ this -> addValidationError ( "Invalid selector at '$ruleString'." ) ; break ; } $ this -> addSelector ( new StyleSelec... | Parses the selector rule . |
4,280 | public function createFromTokens ( array $ tokens ) { $ buffer = $ this -> delimiter . '^' ; foreach ( $ tokens as $ token ) { $ buffer .= $ this -> translateToken ( $ token ) ; } $ buffer .= '$' . $ this -> delimiter . $ this -> modifiers ; return $ buffer ; } | Creates a regular expression based on the supplied tokens . This return expression will be wrapped by the value of the delimiter property and the modifiers contained within the modifiers property will be appended to the end . |
4,281 | protected function translateToken ( array $ token ) { $ identifier = is_string ( $ token [ 0 ] ) ? null : $ token [ 0 ] ; $ value = $ token [ 2 ] ; $ result = $ this -> translateTokenFromIdentifier ( $ identifier , $ value ) ; if ( $ result === null ) { throw new BuildException ( sprintf ( 'No available translation for... | Translates a token into an appropriate regular expression construct . Various map directly to the same values ; others require some massaging and escaping to make them valid within the constructed in the regular expression . |
4,282 | protected function translateTokenFromIdentifier ( $ identifier , $ value ) { $ result = null ; if ( array_key_exists ( $ identifier , self :: $ tokenValueMap ) ) { $ result = $ this -> translateTokenUsingMap ( $ identifier ) ; } elseif ( array_key_exists ( $ identifier , self :: $ tokenCallbackMap ) ) { $ result = $ th... | Translates a token based on the identifier flavour . |
4,283 | protected function translateTokenUsingCallback ( $ identifier , $ value ) { $ method = self :: $ tokenCallbackMap [ $ identifier ] ; return call_user_func ( [ $ this , $ method ] , $ value ) ; } | Calls an internal method to retrieve an appropriate value for use within the regex . |
4,284 | protected function closeOutputBuffers ( int $ targetLevel = 0 , bool $ flush = false ) : void { $ status = ob_get_status ( true ) ; $ level = \ count ( $ status ) ; while ( $ level -- > $ targetLevel ) { $ flush ? ob_end_flush ( ) : ob_end_clean ( ) ; } } | Cleans or flushes output buffers up to target level . Resulting level can be greater than target level if a non - removable buffer has been encountered . |
4,285 | public function getrenderer ( ) { if ( empty ( $ this -> renderer ) ) { $ this -> renderer = \ Drupal :: service ( 'renderer' ) ; } return $ this -> renderer ; } | Gets the renderer . |
4,286 | protected function describe ( ) { if ( is_null ( $ this -> _tableName ) == false ) { $ this -> _query = 'DESCRIBE ' . $ this -> _tableName ; if ( $ this -> _db -> execute ( $ this -> _query ) !== false ) { $ res = $ this -> _db -> getAllRows ( ) ; unset ( $ this -> _fields ) ; unset ( $ this -> _primaryKey ) ; $ this -... | for now this method is intended just for tables with one primary key |
4,287 | public function insert ( $ data ) { unset ( $ this -> _error ) ; if ( is_array ( $ data ) ) { $ fields = '' ; $ values = '' ; reset ( $ data ) ; for ( $ counter = 0 , $ maxIndex = count ( $ data ) , $ valid = true ; $ counter < $ maxIndex && $ valid == true ; $ counter ++ ) { $ elementKey = key ( $ data ) ; $ elementKe... | data is an associative array containing the name of the field and its value |
4,288 | public function incrementTimer ( $ name , $ time ) { if ( ! isset ( $ this -> timers [ $ name ] ) ) { $ this -> timers [ $ name ] = 0 ; } $ this -> timers [ $ name ] += $ this -> getTime ( ) - $ time ; } | Increments named timer . |
4,289 | public function setVendorPrefix ( $ vendorPrefix ) { if ( is_string ( $ vendorPrefix ) ) { $ this -> vendorPrefix = $ vendorPrefix ; } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ vendorPrefix ) . "' for argument 'vendorPrefix' given." ) ; } } | Sets the vendor prefix . |
4,290 | public static function getVendorPrefixRegExp ( $ delimiter = null ) { $ vendorPrefixValues = self :: getVendorPrefixValues ( ) ; foreach ( $ vendorPrefixValues as $ vendorPrefixKey => $ vendorPrefixValue ) { $ vendorPrefixValues [ $ vendorPrefixKey ] = preg_quote ( $ vendorPrefixValue , $ delimiter ) ; } return implode... | Returns a partial regular expression of known vendor prefixes . |
4,291 | public function count ( $ filters = [ ] , $ options = [ ] ) { return $ this -> collection -> count ( $ this -> castQuery ( $ filters ) , $ options ) ; } | Count corresponding documents for filters |
4,292 | public function distinct ( $ fieldName , $ filters = [ ] , $ options = [ ] ) { $ field = $ fieldName ; $ propInfos = $ this -> classMetadata -> getPropertyInfoForField ( $ fieldName ) ; if ( ! $ propInfos ) { $ propInfos = $ this -> classMetadata -> getPropertyInfo ( $ fieldName ) ; } if ( isset ( $ propInfos ) ) { $ f... | Get distinct value for a field |
4,293 | public function findAll ( $ projections = [ ] , $ sorts = [ ] , $ options = [ ] ) { $ options = $ this -> createOption ( $ projections , $ sorts , $ options ) ; $ result = $ this -> collection -> find ( [ ] , $ options ) ; if ( ! isset ( $ options [ 'iterator' ] ) || $ options [ 'iterator' ] === false ) { $ objects = [... | Find all document of the collection |
4,294 | public function findAndModifyOneBy ( $ filters = [ ] , $ update = [ ] , $ projections = [ ] , $ sorts = [ ] , $ options = [ ] ) { $ options = $ this -> createOption ( $ projections , $ sorts , $ options ) ; $ filters = $ this -> castQuery ( $ filters ) ; $ update = $ this -> castQuery ( $ update ) ; $ result = ( array ... | Find a document and make specified update on it |
4,295 | public function getTailableCursor ( $ filters = [ ] , $ options = [ ] ) { $ options [ 'cursorType' ] = \ MongoDB \ Operation \ Find :: TAILABLE_AWAIT ; return $ this -> collection -> find ( $ this -> castQuery ( $ filters ) , $ options ) ; } | Get tailable cursor for query |
4,296 | public function insertOne ( $ document , $ options = [ ] ) { $ query = new InsertOne ( $ this -> documentManager , $ this , $ document , $ options ) ; if ( isset ( $ options [ 'getQuery' ] ) && $ options [ 'getQuery' ] ) { return $ query ; } else { return $ query -> execute ( ) ; } } | Insert a document in collection |
4,297 | public function insertMany ( $ documents , $ options = [ ] ) { $ insertQuery = [ ] ; foreach ( $ documents as $ document ) { $ this -> classMetadata -> getEventManager ( ) -> execute ( EventManager :: EVENT_PRE_INSERT , $ document ) ; $ query = $ this -> hydrator -> unhydrate ( $ document ) ; $ idGen = $ this -> classM... | Insert multiple documents in collection |
4,298 | public function updateMany ( $ filters , $ update , $ options = [ ] ) { $ result = $ this -> collection -> updateMany ( $ this -> castQuery ( $ filters ) , $ update , $ options ) ; if ( $ result -> isAcknowledged ( ) ) { return true ; } else { return false ; } } | Update many document |
4,299 | public function deleteMany ( $ filter , $ options = [ ] ) { $ filter = $ this -> castQuery ( $ filter ) ; $ result = $ this -> collection -> deleteMany ( $ filter , $ options ) ; if ( $ result -> isAcknowledged ( ) ) { return true ; } else { return false ; } } | Delete many document |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.