idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
1,700
protected function createPaginatedQueryBuilder ( array $ criteria = [ ] , $ indexBy = null , array $ orderBy = null ) { $ qb = new PaginatedQueryBuilder ( $ this -> _em ) ; $ qb -> from ( $ this -> _entityName , $ this -> getEntityAlias ( ) , $ indexBy ) ; $ this -> processCriteria ( $ qb , $ criteria ) ; return $ qb ;...
Creates a query builder for pagination
1,701
protected function reduce ( ) { $ gcd = $ this -> gcd ( $ this -> value [ 'num' ] -> get ( ) , $ this -> value [ 'den' ] -> get ( ) ) ; if ( $ gcd > 1 ) { $ this -> value [ 'num' ] -> set ( $ this -> value [ 'num' ] -> get ( ) / $ gcd ) ; $ this -> value [ 'den' ] -> set ( $ this -> value [ 'den' ] -> get ( ) / $ gcd )...
Reduce this number to it s lowest form
1,702
public function get ( $ key , $ default = null , $ save = false ) { $ this -> load ( ) ; if ( $ this -> has ( $ key ) ) { return Arr :: get ( $ this -> settings , $ key , $ default ) ; } if ( $ save ) { $ this -> set ( $ key , $ default ) ; } if ( $ this -> config -> has ( $ key ) ) { return $ this -> config -> get ( $...
Get setting by key
1,703
public function connect ( ) { if ( ! $ this -> connection ) { $ errNum = $ errStr = null ; $ this -> connection = @ fsockopen ( $ this -> host , $ this -> port , $ errNum , $ errStr , $ this -> options [ 'timeout' ] ) ; if ( ! $ this -> connection or $ errNum > 0 ) { $ message = sprintf ( 'Could not connect to beanstal...
Connect the socket to the beanstalk server .
1,704
public function isAllowed ( $ spec , $ pattern ) { if ( ! array_key_exists ( $ spec , $ this -> catalogue ) ) { return false ; } $ features = $ this -> catalogue [ $ spec ] ; if ( ! is_array ( $ pattern ) ) { $ pattern = [ $ pattern ] ; } $ needle = 0 ; foreach ( $ pattern as $ term ) { $ needle |= $ term ; } return $ ...
Returns true if and only if the file specification is allowed for a given pattern .
1,705
protected function findByType ( $ pattern , $ part ) { if ( ! is_array ( $ pattern ) ) { $ pattern = [ $ pattern ] ; } $ needle = 0 ; foreach ( $ pattern as $ term ) { $ needle |= $ term ; } $ matches = [ ] ; foreach ( $ this -> catalogue as $ spec => $ features ) { if ( $ needle === ( $ features & $ needle ) ) { $ pro...
Each new term does not extend the search results but makes them more specific .
1,706
public function createNullDriver ( array $ config ) { return $ this -> adapt ( $ this -> createFlysystem ( new \ League \ Flysystem \ Adapter \ NullAdapter , $ config ) ) ; }
Create an instance of the null driver .
1,707
public function defineStyleCommands ( ) { if ( $ this -> css === null ) { throw new Exception ( 'LaTeX formatter has not been set a theme' ) ; } $ cmds = array ( ) ; $ round = function ( $ n ) { return round ( $ n , 2 ) ; } ; foreach ( $ this -> css -> rules ( ) as $ name => $ properties ) { if ( ! preg_match ( '/^\w+$...
Defines all the styling commands these are obtained from the css parser
1,708
private function getFullNameBit ( $ bit ) { if ( empty ( $ this -> full_name_bits ) ) { $ full_name = $ this -> getFullName ( ) ; if ( empty ( $ full_name ) ) { list ( $ first_name , $ last_name ) = $ this -> getFirstAndLastNameFromEmail ( ) ; if ( $ first_name && $ last_name ) { $ this -> full_name_bits = ( new HumanN...
Return first name bit .
1,709
public function onMoveContent ( EventInterface $ event ) { $ translator = $ this -> getTranslator ( ) ; $ mapper = $ this -> getLayoutMapper ( ) ; if ( is_null ( $ event -> getParam ( 'tid' ) ) ) { throw new InvalidArgumentException ( $ translator -> translate ( "Unknown transaction identifier. Missing event param 'tid...
If the content has been moved all the rules of widget visibility are cleared .
1,710
protected function replaceInText ( $ text ) { $ text = str_replace ( "##YEAR##" , date ( 'Y' ) , $ text ) ; $ text = str_replace ( "##DATE##" , date ( 'Y-m-d' ) , $ text ) ; return $ text ; }
Replaces placeholders in the copyright header Todo separate and make configurable and extensible
1,711
protected function addHeader ( \ SplFileInfo $ file , $ text ) { $ content = file_get_contents ( $ file -> getRealPath ( ) ) ; $ lines = explode ( PHP_EOL , $ content ) ; $ text = explode ( "\n" , $ text ) ; foreach ( $ lines as $ i => $ l ) { $ l = trim ( $ l ) ; if ( strpos ( $ l , "<?php" ) === 0 ) { continue ; } ar...
Adds copyright headers in file
1,712
public function whenStarted ( ) { $ milliseconds = $ this -> event -> getOrigin ( ) ; $ seconds = $ milliseconds / 1000 ; return is_float ( $ seconds ) ? date ( 'Y-m-d H:i:s' , $ seconds ) : null ; }
Convert start time to datetime from milliseconds .
1,713
private function parseData ( array $ data ) { $ field = $ data [ 'field' ] ; foreach ( $ data [ 'policies' ] as $ rule => $ policy ) { $ passes = call_user_func_array ( [ new Rule ( ) , $ rule ] , [ $ field , $ data [ 'value' ] , $ policy ] ) ; if ( ! $ passes ) { ErrorHandler :: set ( str_replace ( [ ':attribute' , ':...
Perform validation for the data provider and set error messages .
1,714
protected function parseContent ( $ content , TokenList $ tokenList = null , $ independent = false ) { $ parser = new Parser ( ) ; $ lexer = new Lexer ( ) ; $ this -> set -> init ( $ parser , $ lexer ) ; $ parser -> setStartRule ( $ this ) ; $ tokenList = $ parser -> parse ( $ content , $ tokenList , ! $ independent ) ...
Parse token match content
1,715
static public function display ( ) { Sorter :: sort ( Listing :: $ files ) ; $ content = '<!DOCTYPE html>' ; $ content .= sprintf ( '<html xmlns="http://www.w3.org/1999/xhtml" lang="%s">' , Translation :: getCanonicalLocale ( ) ) ; $ content .= ' <head> <meta charset="utf-8"> <meta name="viewport" cont...
Display directory listing
1,716
public static function dataTypeSelectOptions ( ) { return [ Property :: DATA_TYPE_STRING => Module :: t ( 'app' , 'String' ) , Property :: DATA_TYPE_TEXT => Module :: t ( 'app' , 'Text' ) , Property :: DATA_TYPE_INTEGER => Module :: t ( 'app' , 'Integer' ) , Property :: DATA_TYPE_FLOAT => Module :: t ( 'app' , 'Float' ...
Returns array of data types for select inputs
1,717
public function setMagicFile ( $ file ) { if ( $ file === false ) { $ this -> options [ 'magicFile' ] = false ; } elseif ( empty ( $ file ) ) { $ this -> options [ 'magicFile' ] = null ; } elseif ( ! ( class_exists ( 'finfo' , false ) ) ) { $ this -> options [ 'magicFile' ] = null ; throw new Exception \ RuntimeExcepti...
Sets the magicfile to use if null the MAGIC constant from php is used if the MAGIC file is erroneous no file will be set if false the default MAGIC file from PHP will be used
1,718
public function retrieveByCredentials ( array $ credentials ) { $ u = $ credentials [ 'username' ] ; $ p = $ credentials [ 'password' ] ; $ m = $ this -> modelName ; try { $ user = $ m :: where ( $ this -> username , $ u ) -> first ( ) ; if ( empty ( $ user ) ) { return null ; } if ( ! $ this -> allow_no_pass ) { $ pw_...
Retrieves the user with the specified credentials from the database . Returns null if the model instance could not be found .
1,719
public function retrieveByToken ( $ identifier , $ token ) { $ m = $ this -> modelName ; return $ m :: findForAuthToken ( $ identifier , $ token ) ; }
Returns the user with the specified identifier and Remember Me token .
1,720
public function updateRememberToken ( AuthenticatableContract $ user , $ token ) { if ( ! empty ( $ user ) ) { if ( $ user -> canHaveRememberToken ( ) ) { $ user -> remember_token = $ token ; $ user -> save ( ) ; } } }
Updates the Remember Me token for the specified identifier .
1,721
public static function load ( $ arg ) { if ( is_object ( $ arg ) && $ arg instanceof Entity ) { $ class = get_class ( $ arg ) ; } elseif ( is_object ( $ arg ) && $ arg instanceof Collection ) { $ class = $ arg -> getEntityClass ( ) ; } elseif ( is_object ( $ arg ) && $ arg instanceof Reflection ) { $ class = $ arg -> g...
Load and register reflection
1,722
private function _parseProperties ( $ docComment , \ ReflectionClass $ reflectionClass ) { $ properties = [ ] ; foreach ( Reflection \ Annotation :: parseProperties ( $ docComment ) as $ definition ) { try { $ property = new Reflection \ Property ( $ definition [ 2 ] , $ definition [ 3 ] , $ this , ! $ definition [ 1 ]...
Parse properties from annotations
1,723
public function getProperty ( $ name ) { if ( ! $ this -> hasProperty ( $ name ) ) { throw new Exception \ InvalidArgumentException ( "Unknown property " . $ name . "!" ) ; } return $ this -> properties [ $ name ] ; }
Get property reflection object
1,724
public function getRelatedFiles ( array $ files = [ ] ) { if ( in_array ( $ this -> fileName , $ files ) ) { return $ files ; } $ files [ ] = $ this -> fileName ; foreach ( $ this -> properties as $ property ) { if ( in_array ( $ property -> getType ( ) , [ Reflection \ Property :: TYPE_COLLECTION , Reflection \ Proper...
Get arg s related files
1,725
public function getPrimaryProperty ( ) { foreach ( $ this -> properties as $ property ) { if ( $ property -> hasOption ( Entity \ Reflection \ Property \ Option \ Primary :: KEY ) ) { return $ property ; } } throw new \ Exception ( "Primary property not defined in " . $ this -> className . "!" ) ; }
Get primary property reflection
1,726
public function saveImage ( \ Illuminate \ Http \ UploadedFile $ imageFile , $ path , $ name = null , Array $ sizes = [ ] , $ callback = null ) { $ extension = $ imageFile -> extension ( ) ; if ( ! in_array ( $ extension , [ 'png' , 'jpeg' , 'jpg' , 'gif' ] ) ) throw new NotSupportedImageFormatException ( $ extension ....
Save Uploaded File Image
1,727
public function saveImages ( Array $ images , $ path , $ name = null , Array $ sizes = [ ] , $ callback = null ) { $ array = [ ] ; foreach ( $ images as $ file ) { $ array [ ] = $ this -> saveImage ( $ file , $ path ) ; } if ( is_callable ( $ callback ) ) call_user_func ( $ callback , $ this , $ array ) ; return $ arra...
Save Array Of Uploaded Files Image
1,728
public static function getSize ( $ size ) { $ dim = [ ] ; if ( is_array ( $ size ) ) { $ dim [ 'w' ] = $ size [ 0 ] ; $ dim [ 'h' ] = isset ( $ size [ 1 ] ) ? $ size [ 1 ] : $ size [ 0 ] ; } else { $ dim [ 'w' ] = $ size ; $ dim [ 'h' ] = null ; } return $ dim ; }
Get Width Height values
1,729
public function saveLocalImage ( $ imageFile , $ path , $ name = null , Array $ sizes = [ ] , $ callback = null ) { $ arr = explode ( '.' , $ imageFile ) ; $ extension = end ( $ arr ) ; if ( ! in_array ( $ extension , [ 'png' , 'jpeg' , 'jpg' , 'gif' ] ) ) throw new NotSupportedImageFormatException ( $ extension . ' ex...
Save Locale Images
1,730
public function to_avro ( ) { $ avro = array ( "protocol" => $ this -> name , "namespace" => $ this -> namespace ) ; if ( ! is_null ( $ this -> doc ) ) $ avro [ "doc" ] = $ this -> doc ; $ types = array ( ) ; $ avro [ "types" ] = $ this -> schemata -> to_avro ( ) ; $ messages = array ( ) ; foreach ( $ this -> messages ...
Internal represention of this Avro Protocol .
1,731
protected function flushForModel ( $ index , $ modelId ) { $ query = [ 'index' => $ index , 'body' => [ 'query' => [ 'bool' => [ 'filter' => [ 'bool' => [ 'must' => [ 'term' => [ 'model_id' => $ modelId ] ] ] ] , ] ] ] ] ; $ pks = IndexHelper :: primaryKeysByCondition ( $ this -> client , $ query ) ; if ( count ( $ pks...
Flushes all elasticsearch indices for given model id
1,732
protected function fillForModel ( $ index , $ model ) { if ( false === empty ( $ model -> propertiesIds ) && false === empty ( $ model -> propertiesValues ) ) { $ workingProps = array_filter ( $ model -> propertiesValues , function ( $ e ) { if ( true === is_array ( $ e ) ) { foreach ( $ e as $ val ) { return ( count (...
Performs model index filling
1,733
private static function prepareStatic ( $ props , $ modelId , $ workingProps , $ index , $ type , $ languages ) { $ res = $ valIds = [ ] ; $ workingProps = array_intersect_key ( $ workingProps , $ props ) ; $ workingProps = array_flip ( $ workingProps ) ; $ values = ( new Query ( ) ) -> from ( StaticValueTranslation ::...
Prepares bulk data to store in elasticsearch index for model properties static values
1,734
private static function prepareEav ( $ model , $ props , $ index , $ type , $ languages ) { $ eavTable = $ model -> eavTable ( ) ; $ values = ( new Query ( ) ) -> from ( $ eavTable ) -> where ( [ 'model_id' => $ model -> id , 'property_id' => array_keys ( $ props ) ] ) -> select ( [ 'id' , 'property_id' , 'value_intege...
Prepares bulk data to store in elasticsearch index for model properties eav values
1,735
public function convert ( $ source , $ adapter = 'hpricot' , $ base_url = null , $ line_length = 65 , $ link_query_string = null , $ preserve_styles = true , $ remove_ids = true , $ remove_classes = true , $ remove_comments = true ) { $ params = array ( 'adapter' => $ adapter , 'base_url' => $ base_url , 'line_length' ...
Convert an email using Premailer
1,736
private function request ( array $ params = array ( ) ) { $ request = $ this -> client -> createRequest ( 'POST' , $ this -> url ) ; $ body = $ request -> getBody ( ) ; foreach ( $ params as $ key => $ value ) { $ body -> setField ( $ key , $ value ) ; } try { $ response = $ this -> client -> send ( $ request ) ; } cat...
Make the request to Premailer
1,737
public function addPattern ( $ pattern , $ childRuleName = null ) { preg_match_all ( '/\\\\.|' . '\(\?|[()]|' . '\[\^?\]?(?:\\\\.|\[:[^]]*:\]|[^]\\\\])*\]|' . '[^[()\\\\]+/' , $ pattern , $ matches ) ; $ groupDeep = 0 ; $ pattern = '(' ; foreach ( $ matches [ 0 ] as $ match ) { switch ( $ match ) { case '(' : $ pattern...
Add pattern to rule pattern
1,738
public function split ( $ text ) { if ( count ( $ this -> patterns ) === 0 ) { return false ; } if ( $ this -> concatenatedPatterns === null ) { $ this -> concatenatedPatterns = '/' . implode ( '|' , array_map ( function ( $ pattern ) { return $ pattern [ 'pattern' ] ; } , $ this -> patterns ) ) . '/msSi' ; } if ( ! pr...
Split subject into pieces
1,739
public function addCondition ( $ validation ) { if ( ! $ this -> property ) { throw new Exception \ InvalidArgumentException ( "Condition can be called only on properties!" ) ; } $ condition = new Validator \ Condition ( $ this -> _getValidation ( $ validation ) , $ this ) ; $ this -> rules [ ] = $ condition ; return $...
Add validation condition
1,740
public function addError ( $ message , $ severity = Validator \ Rule :: ERROR , array $ indexes = [ ] ) { $ rule = new Validator \ Rule ( $ this -> entity , function ( ) { return false ; } , $ message , $ this -> property , $ severity , $ this -> child ) ; $ rule -> setChildFailed ( $ indexes ) ; $ this -> rules [ ] = ...
Add permanent error manually
1,741
public function on ( $ name , $ child = null ) { $ reflection = $ this -> entity -> getReflection ( ) ; if ( ! $ reflection -> hasProperty ( $ name ) ) { throw new Exception \ InvalidArgumentException ( "Unknown property '" . $ name . "'!" ) ; } $ this -> property = $ reflection -> getProperty ( $ name ) ; if ( $ this ...
Set property which is validation configured on
1,742
public function addRule ( $ validation , $ message , $ severity = Validator \ Rule :: ERROR ) { $ this -> rules [ ] = new Validator \ Rule ( $ this -> entity , $ this -> _getValidation ( $ validation ) , $ message , $ this -> property , $ severity , $ this -> child ) ; return $ this ; }
Addd validation rule
1,743
public function validate ( $ failOn = Validator \ Rule :: ERROR ) { $ this -> warnings = [ ] ; $ this -> errors = [ ] ; foreach ( $ this -> rules as $ rule ) { if ( $ rule instanceof Validator \ Condition ) { $ condition = $ rule ; if ( $ condition -> validate ( ) ) { if ( ! $ condition -> getValidator ( ) -> validate ...
Run all validations
1,744
public function html ( ) { if ( ! $ this -> getPublicKey ( ) ) { throw new Exception ( 'You must set public key provided by reCaptcha' ) ; } $ error = ( $ this -> getError ( ) ? '&amp;error=' . $ this -> getError ( ) : null ) ; $ theme = null ; if ( $ this -> theme ) { $ theme = '<script> var RecaptchaOptions = {theme:...
Generates reCaptcha form to output to your end user
1,745
public function check ( $ captcha_challenge = false , $ captcha_response = false ) { if ( ! $ this -> getPrivateKey ( ) ) { throw new Exception ( 'You must set private key provided by reCaptcha' ) ; } if ( ! $ captcha_challenge && ! $ captcha_response ) { if ( isset ( $ _POST [ 'recaptcha_challenge_field' ] ) && isset ...
Checks and validates user s response
1,746
protected function process ( $ parameters ) { $ parameters = $ this -> encode ( $ parameters ) ; $ request = "POST /recaptcha/api/verify HTTP/1.0\r\n" ; $ request .= "Host: " . self :: VERIFY_SERVER . "\r\n" ; $ request .= "Content-Type: application/x-www-form-urlencoded;\r\n" ; $ request .= "Content-Length: " . strlen...
Make a signed validation request to reCaptcha s servers
1,747
protected function encode ( array $ parameters ) { $ uri = '' ; if ( $ parameters ) { foreach ( $ parameters as $ parameter => $ value ) { $ uri .= $ parameter . '=' . urlencode ( stripslashes ( $ value ) ) . '&' ; } } $ uri = substr ( $ uri , 0 , strlen ( $ uri ) - 1 ) ; return $ uri ; }
Construct encoded URI string from an array
1,748
public function setTheme ( $ theme ) { if ( ! self :: isValidTheme ( $ theme ) ) { throw new Exception ( 'Theme ' . $ theme . ' is not valid. Please use one of [' . join ( ', ' , self :: $ themes ) . ']' ) ; } $ this -> theme = $ theme ; }
Set a reCaptcha theme
1,749
public function invoke ( $ callable , array $ namedParams = [ ] , array $ classParams = [ ] ) { $ classParams = $ this -> reindexclassParams ( $ classParams ) ; if ( $ callable instanceof \ Closure ) { return $ this -> invokeFunction ( $ callable , $ namedParams , $ classParams ) ; } if ( is_string ( $ callable ) ) { i...
Invokes a method or anonymous function and returns the result .
1,750
private function invokeClassMethod ( $ class , $ method , $ namedParams , $ classParams ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( "Class $class does not exist." ) ; } $ object = new $ class ( ) ; return $ this -> invokeObjectMethod ( $ object , $ method , $ namedParams , $ classPara...
Invokes a method on a class by creating an instance of the class and then invoking the method .
1,751
private function invokeObjectMethod ( $ object , $ method , $ namedParams , $ classParams ) { if ( ! method_exists ( $ object , $ method ) ) { $ class = get_class ( $ object ) ; throw new \ InvalidArgumentException ( "Method $class::$method does not exist." ) ; } $ reflection = new \ ReflectionMethod ( $ object , $ met...
Invokes a method on an object .
1,752
private function invokeFunction ( $ function , $ namedParams , $ classParams ) { $ reflection = new \ ReflectionFunction ( $ function ) ; $ params = $ reflection -> getParameters ( ) ; $ invokeParams = $ this -> mapParameters ( $ params , $ namedParams , $ classParams ) ; return call_user_func_array ( $ function , $ in...
Invokes an anonymous function .
1,753
private function reindexClassParams ( array $ classParams ) { $ reindexed = [ ] ; foreach ( $ classParams as $ param ) { if ( ! is_object ( $ param ) ) { throw new \ InvalidArgumentException ( "\$classParams entries must be objects." ) ; } for ( $ class = get_class ( $ param ) ; $ class !== false ; $ class = get_parent...
Reindexes an array of objects by class name .
1,754
public function toJson ( ) { $ json = array ( ) ; $ json [ 'id' ] = $ this -> id ; $ json [ 'from' ] = $ this -> from ; $ json [ 'color' ] = $ this -> color ; $ json [ 'message' ] = $ this -> message ; $ json [ 'notify' ] = $ this -> notify ; $ json [ 'message_format' ] = $ this -> messageFormat ; $ json [ 'date' ] = $...
Serializes Message object
1,755
public function scanChild ( $ lang ) { assert ( isset ( $ this -> childScanners [ $ lang ] ) ) ; $ scanner = $ this -> childScanners [ $ lang ] ; $ scanner -> pos ( $ this -> pos ( ) ) ; $ substr = $ scanner -> main ( ) ; $ this -> record ( $ scanner -> tagged ( ) , 'XML' , true ) ; $ this -> pos ( $ scanner -> pos ( )...
c + p from HTML scanner
1,756
public function getValidator ( ) { if ( ! $ this -> validator ) { $ this -> validator = new Validator ( $ this ) ; } return $ this -> validator -> onEntity ( ) ; }
Get entity validator
1,757
public function toArray ( $ nesting = false ) { $ output = [ ] ; foreach ( $ this :: getReflection ( ) -> getProperties ( ) as $ propertyName => $ property ) { $ value = $ this -> { $ propertyName } ; if ( ( $ value instanceof Entity \ Collection || $ value instanceof Entity ) && $ nesting ) { $ output [ $ propertyName...
Get entity values as array
1,758
public function jsonSerialize ( ) { $ output = [ ] ; foreach ( $ this :: getReflection ( ) -> getProperties ( ) as $ propertyName => $ property ) { $ value = $ this -> { $ propertyName } ; if ( $ value instanceof Entity \ Collection || $ value instanceof Entity ) { $ output [ $ propertyName ] = $ value -> jsonSerialize...
Gets data which should be serialized to JSON
1,759
public function menu_tree_all_data ( $ menu_name , $ link = NULL , $ max_depth = NULL ) { return menu_tree_all_data ( $ menu_name , $ link , $ max_depth ) ; }
Get the data structure representing a named menu tree .
1,760
public function menu_tree_page_data ( $ menu_name , $ max_depth = NULL , $ only_active_trail = FALSE ) { return menu_tree_page_data ( $ menu_name , $ max_depth , $ only_active_trail ) ; }
Get the data structure representing a named menu tree based on the current page .
1,761
public function menu_link_maintain ( $ module , $ op , $ link_path , $ link_title ) { return menu_link_maintain ( $ module , $ op , $ link_path , $ link_title ) ; }
Insert update or delete an uncustomized menu link related to a module .
1,762
public function build ( $ basePath , $ production = false ) { $ minifine = new Minifine ( $ basePath , $ production ) ; $ minifine -> appendJsMinifier ( new MatthiasMullieJs ( new JS ( ) ) ) ; $ minifine -> appendCssMinifier ( new MatthiasMullieCss ( new Css ( ) ) ) ; return $ minifine ; }
Builds a new minifine instance
1,763
public function getEntityLine ( ) { if ( $ this -> definition ) { foreach ( file ( $ this -> getEntityPath ( ) , FILE_IGNORE_NEW_LINES ) as $ lineNumber => $ line ) { if ( strpos ( $ line , $ this -> definition ) !== false ) { return $ lineNumber + 1 ; } } } return 0 ; }
Get problematic entity line number
1,764
public function runFileGeneratorCommand ( $ path , $ argument ) { if ( $ this -> filesystem -> exists ( $ path ) ) { return 'File with the name ' . $ argument . ' already exist' ; } $ folder_name = explode ( '/' , $ argument ) ; $ folder = '' ; if ( count ( $ folder_name ) > 1 ) { $ folder_path = array_slice ( $ folder...
Generate and move file to specified path .
1,765
public function getMatchingRoute ( $ routes , Request $ request ) { foreach ( $ routes as $ matchingRoute ) { if ( $ matchingRoute -> matches ( $ request ) ) { return $ matchingRoute ; } } return null ; }
Check which of the given routes matches the given request .
1,766
public function getByMethod ( $ method = null ) { if ( is_null ( $ method ) ) { return $ this -> getRoutes ( ) ; } return ArrayHelper :: get ( $ this -> routes , $ method , [ ] ) ; }
Get all matched routes according to the given request method .
1,767
public function compare ( MatchedPreferenceInterface $ lValue , MatchedPreferenceInterface $ rValue ) { $ result = $ this -> compareQualityFactorPair ( $ lValue , $ rValue ) ; if ( 0 === $ result ) { $ result = $ this -> comparePrecedence ( $ lValue , $ rValue ) ; } if ( 0 === $ result ) { $ result = $ this -> compareV...
Comparison function used for ordering matched preferences .
1,768
private function compareQualityFactorPair ( MatchedPreferenceInterface $ lValue , MatchedPreferenceInterface $ rValue ) { $ compareList = array ( array ( 'left' => $ lValue , 'right' => $ rValue ) , array ( 'left' => $ lValue -> getClientPreference ( ) , 'right' => $ rValue -> getClientPreference ( ) ) , array ( 'left'...
Comparison function for quality factors of matched preferences .
1,769
private function compareQualityFactor ( PreferenceInterface $ lValue , PreferenceInterface $ rValue ) { if ( $ rValue -> getQualityFactor ( ) < $ lValue -> getQualityFactor ( ) ) { return - 1 ; } elseif ( $ rValue -> getQualityFactor ( ) > $ lValue -> getQualityFactor ( ) ) { return 1 ; } else { return 0 ; } }
Compare quality factors of preferences .
1,770
private function comparePrecedence ( PreferenceInterface $ lValue , PreferenceInterface $ rValue ) { if ( $ rValue -> getPrecedence ( ) < $ lValue -> getPrecedence ( ) ) { return - 1 ; } elseif ( $ rValue -> getPrecedence ( ) > $ lValue -> getPrecedence ( ) ) { return 1 ; } else { return 0 ; } }
Compare precedences of preferences .
1,771
private function compareVariant ( MatchedPreferenceInterface $ lValue , MatchedPreferenceInterface $ rValue ) { return strcasecmp ( $ lValue -> getVariant ( ) , $ rValue -> getVariant ( ) ) ; }
Compare preferences alphabetically
1,772
function post ( $ payload ) { $ this -> requestDecorator -> setPayload ( $ payload ) ; $ result = $ this -> client -> post ( $ this -> requestDecorator -> makeResource ( ) , $ this -> requestDecorator -> makePayload ( ) , $ this -> requestDecorator -> makeHeaders ( ) ) ; $ this -> refresh ( ) ; return $ result ; }
Make a post request .
1,773
function put ( $ id , $ payload ) { $ this -> requestDecorator -> setId ( $ id ) ; $ this -> requestDecorator -> setPayload ( $ payload ) ; if ( ( is_array ( $ payload ) ) && ( ! empty ( $ payload [ 'sys' ] [ 'version' ] ) ) ) { $ this -> requestDecorator -> addHeader ( 'X-Contentful-Version' , $ payload [ 'sys' ] [ 'v...
Make a put request .
1,774
function delete ( $ id ) { $ this -> requestDecorator -> setId ( $ id ) ; $ result = $ this -> client -> delete ( $ this -> requestDecorator -> makeResource ( ) , $ this -> requestDecorator -> makeHeaders ( ) ) ; $ this -> refresh ( ) ; return $ result ; }
Make a delete request .
1,775
public function push ( AbstractJob $ job ) { if ( $ job -> getRunAt ( ) > time ( ) ) { return $ this -> addJobToRetrySet ( $ job , $ job -> getRunAt ( ) ) ; } return ( bool ) $ this -> client -> rpush ( $ this -> getQueueNameWithPrefix ( $ job -> getQueue ( ) ) , serialize ( $ job ) ) ; }
push a job to the queue
1,776
public function pop ( $ queue ) { $ this -> migrateRetryJobs ( $ queue ) ; $ data = $ this -> client -> lpop ( $ this -> getQueueNameWithPrefix ( $ queue ) ) ; if ( ! empty ( $ data ) ) { $ job = @ unserialize ( $ data ) ; if ( $ job instanceof AbstractJob ) { return $ job ; } } return null ; }
get a job from the queue
1,777
public function retry ( AbstractJob $ job ) { if ( $ job -> shouldRetry ( ) ) { return $ this -> addJobToRetrySet ( $ job , $ job -> getRetryTime ( ) ) ; } return false ; }
retry a job
1,778
protected function migrateRetryJobs ( $ queue ) { $ luaScript = <<<LUA-- Get all of the jobs with an expired "score"...local val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])-- If we have values in the array, we will remove them from the first queue-- and add them onto the destination queue in chunks of 100,...
migrate the retry jobs of a queue
1,779
protected function addJobToRetrySet ( $ job , $ retryAt ) { return ( bool ) $ this -> client -> zadd ( $ this -> getRetryZsetNameWithPrefix ( $ job -> getQueue ( ) ) , $ retryAt , serialize ( $ job ) ) ; }
add job to the retry set
1,780
public static function SSHA ( $ password , $ salt = null ) { if ( empty ( $ salt ) ) { if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ salt = bin2hex ( openssl_random_pseudo_bytes ( 4 ) ) ; } else { throw new Exception ( "You must have the openssl extension installed and enabled to use a random salt" ) ; }...
Generates and returns a new password as a SSHA hash for use in LDAP . If the salt is not specified one will be generated using the openssl extension and have a length of four bytes .
1,781
public function editAction ( ) { $ id = $ this -> params ( ) -> fromRoute ( 'id' ) ; if ( ! is_numeric ( $ id ) ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'The article identifier was not specified.' ) ) ; return $ this -> redirect ( ) -> toRoute ( 'sc-admin/content-manager' ) -> setStatusC...
Edit File .
1,782
public function generateRoutes ( $ name , array $ localesWithPaths , Route $ baseRoute ) { $ this -> assertLocalesAreSupported ( array_keys ( $ localesWithPaths ) ) ; return $ this -> routeGenerator -> generateRoutes ( $ name , $ localesWithPaths , $ baseRoute ) ; }
Generate localized versions of the given route .
1,783
protected static function buildTableName ( $ suffix = '' ) { if ( true === empty ( static :: $ tablePrefix ) ) { if ( strpos ( static :: tableName ( ) , '}}' ) !== false ) { $ name = str_replace ( '}}' , $ suffix . '}}' , static :: tableName ( ) ) ; } else { $ name = static :: tableName ( ) . $ suffix ; } } else { $ na...
Build a valid table name with suffix
1,784
public function propertiesRules ( ) { $ rules = [ ] ; $ this -> ensurePropertiesAttributes ( ) ; if ( empty ( $ this -> propertiesIds ) === false ) { foreach ( $ this -> propertiesIds as $ propertyId ) { $ property = Property :: findById ( $ propertyId ) ; $ handler = $ property -> handler ( ) ; $ rules = ArrayHelper :...
Array of validation rules for properties
1,785
public function drupal_set_message ( $ message = null , $ type = 'status' , $ repeat = true ) { return drupal_set_message ( $ message , $ type , $ repeat ) ; }
Sets a message to display to the user .
1,786
public function & drupal_static ( $ name , $ default_value = null , $ reset = false ) { return drupal_static ( $ name , $ default_value , $ reset ) ; }
Provides central static variable storage .
1,787
public function getModel ( $ model ) { $ ns = $ this -> getAppNamespace ( ) ; if ( $ ns ) { $ qm = $ ns . $ model ; if ( class_exists ( $ qm ) ) { return new $ qm ; } $ qm = $ ns . 'Models' . '\\' . $ model ; if ( class_exists ( $ qm ) ) { return new $ qm ; } } return false ; }
Attempt to get an apps model from namespace .
1,788
public function apply_filters ( ) { $ args = func_get_args ( ) ; $ tag = current ( array_splice ( $ args , 1 , 1 ) ) ; return apply_filters_ref_array ( $ tag , $ args ) ; }
Call WordPress filter .
1,789
public function onRunnerStart ( ) { $ rootSuite = Context :: getInstance ( ) -> getCurrentSuite ( ) ; $ rootSuite -> getScope ( ) -> peridotAddChildScope ( $ this -> scope ) ; }
When the runner starts we will mix in the http kernel scope into the root suite thereby making it available EVERYWHERE .
1,790
public function actionDelete ( ) { $ rr = new RequestResponse ( ) ; if ( $ rr -> isRequestAjaxPost ( ) ) { try { $ model = $ this -> model ; $ id = $ model -> name ; $ model = $ this -> findModel ( $ id ) ; if ( ! in_array ( $ model -> item -> name , CmsManager :: protectedPermissions ( ) ) ) { if ( \ Yii :: $ app -> g...
Deletes an existing Game model . If deletion is successful the browser will be redirected to the index page .
1,791
public function down ( ) { try { $ this -> buildMapper ( 'ScContent.Migration.MapperBase.Content' ) -> down ( ) ; } catch ( Exception $ e ) { } try { $ this -> buildMapper ( 'ScContent.Migration.MapperBase.Search' ) -> down ( ) ; } catch ( Exception $ e ) { } try { $ this -> buildMapper ( 'ScContent.Migration.MapperBas...
Remove migration from the database .
1,792
public function get ( $ name = '' ) { if ( ! $ this -> _app -> name ) return [ ] ; if ( ! $ this -> _config ) $ this -> getConfig ( ) ; return $ name ? ( isset ( $ this -> _config [ '_' . $ name ] ) ? $ this -> _config [ '_' . $ name ] : [ ] ) : $ this -> _config ; }
Gets a specific mod config array .
1,793
public function matches ( $ url ) { $ pattern = $ this -> getRegexPattern ( ) ; if ( preg_match ( $ pattern , $ url , $ matches ) ) { foreach ( $ matches as $ key => $ value ) { if ( is_int ( $ key ) ) { unset ( $ matches [ $ key ] ) ; } } return $ matches ; } return false ; }
Checks whether this route matches the given url .
1,794
public function run ( Application $ app , Request $ request , array $ arguments = [ ] ) { return $ this -> processRequest ( $ app , $ request , $ this -> callback , $ arguments ) ; }
Processes the Request and returns a Response .
1,795
public function method ( $ method ) { if ( ! in_array ( $ method , $ this -> methods ) ) { throw new \ InvalidArgumentException ( "Unknown HTTP method: $method" ) ; } $ this -> method = $ method ; return $ this ; }
Sets the route s HTTP method .
1,796
private function compileRegex ( ) { $ path = $ this -> prefix . $ this -> path ; $ asserts = $ this -> asserts ; $ callback = function ( $ matches ) use ( $ asserts ) { $ name = $ matches [ 1 ] ; $ pattern = isset ( $ asserts [ $ name ] ) ? $ asserts [ $ name ] : ".+" ; return "(?<$name>$pattern)" ; } ; $ pattern = pre...
Compiles a regex pattern which matches this route .
1,797
protected function fixUrl ( $ url , $ encode ) { if ( strpos ( $ url , "http" ) !== 0 ) { $ url = "http://" . $ url ; } if ( $ encode ) { $ url = urlencode ( $ url ) ; } return $ url ; }
Returns a corrected URL
1,798
protected function exec ( $ url ) { $ client = $ this -> getRequest ( ) ; $ response = $ client -> request ( 'GET' , $ url ) ; return $ this -> handleResponse ( $ response -> getBody ( ) ) ; }
Executes a CURL request to the Bitly API
1,799
public function search ( $ filter , $ fields ) { $ param = array ( 'filter' => json_encode ( $ filter ) , 'fields' => json_encode ( $ fields ) ) ; return $ this -> get ( 'inventory/resources/' , $ param ) ; }
Search a service