idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
50,400 | public function setComment ( $ comment ) { if ( $ this -> _comment != $ comment ) { $ this -> _comment = $ comment ; if ( $ this -> _table ) { $ this -> _setComment ( $ comment ) ; } } } | Set Column comment |
50,401 | public function isDifferent ( array $ newSpec , array $ keys = null ) { $ oldSpec = $ this -> toArray ( ) ; if ( $ keys ) { $ keys = array_flip ( $ keys ) ; $ oldSpec = array_intersect_key ( $ oldSpec , $ keys ) ; $ newSpec = array_intersect_key ( $ newSpec , $ keys ) ; } return $ this -> _isDifferent ( $ oldSpec , $ n... | Compare with given specification |
50,402 | public function get ( $ id ) { foreach ( $ this -> getContainers ( ) as $ container ) { if ( $ container -> has ( $ id ) ) { return $ container -> get ( $ id ) ; } } throw new NotFoundException ( Message :: get ( Message :: SERVICE_ID_NOT_FOUND , $ id ) , Message :: SERVICE_ID_NOT_FOUND ) ; } | Get from the delegator |
50,403 | public function make ( ) { return new Response ( $ this -> code , $ this -> headers , $ this -> stream , $ this -> version ) ; } | Creates the response instance . |
50,404 | public function display ( $ message = null ) { if ( ! $ message ) { $ message = $ this -> message ; } $ message = Str :: replace ( root , '$DOCUMENT_ROOT' , $ message ) ; $ message = strip_tags ( $ message ) ; switch ( env_type ) { case 'html' : return $ this -> sendHTML ( $ message ) ; case 'json' : return $ this -> s... | Display native exception |
50,405 | private function AddLogLifetimeField ( ) { $ name = 'LogLifetime' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetLogLifetime ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , new Integer ( 0 , 730 ) ) ; $ this -> SetRequired ( $ name ) ; } | Adds the log lifetime field |
50,406 | private function AddChangeRequestLifetimeField ( ) { $ name = 'ChangeRequestLifetime' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetChangeRequestLifetime ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , new Integer ( 1 , 360 ) ) ; $ this -> SetRequired ( $ name ) ; } | Adds the change request lifetime field |
50,407 | private function AddMailFromEMailField ( ) { $ name = 'MailFromEMail' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetMailFromEMail ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , PhpFilter :: EMail ( ) ) ; } | Adds the smtp mail from e - mail field |
50,408 | private function AddMailFromNameField ( ) { $ name = 'MailFromName' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetMailFromName ( ) ) ; $ this -> AddField ( $ field ) ; } | Adds the mail from name field |
50,409 | private function AddSmtpHostField ( ) { $ name = 'SmtpHost' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpHost ( ) ) ; $ this -> AddField ( $ field ) ; } | Adds the smtp host field |
50,410 | private function AddSmtpPortField ( ) { $ name = 'SmtpPort' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpPort ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , new Integer ( 1 , 65535 ) ) ; } | Adds the smtp port field |
50,411 | private function AddSmtpUserField ( ) { $ name = 'SmtpUser' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpUser ( ) ) ; $ this -> AddField ( $ field ) ; } | Adds the smtp user field |
50,412 | private function AddSmtpPasswordField ( ) { $ name = 'SmtpPassword' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpPassword ( ) ) ; $ this -> AddField ( $ field ) ; } | Adds the smtp password field |
50,413 | private function AddSmtpSecurityField ( ) { $ name = 'SmtpSecurity' ; $ field = new Select ( $ name , $ this -> settings -> GetSmtpSecurity ( ) ) ; $ values = SmtpSecurity :: AllowedValues ( ) ; foreach ( $ values as $ value ) { $ field -> AddOption ( $ value , Trans ( "Core.SettingsForm.SmtpSecurity.$value" ) ) ; } $ ... | Adds the smtp security field |
50,414 | protected function OnSuccess ( ) { $ this -> settings -> SetLogLifetime ( ( int ) $ this -> Value ( 'LogLifetime' ) ) ; $ this -> settings -> SetChangeRequestLifetime ( $ this -> Value ( 'ChangeRequestLifetime' ) ) ; $ this -> settings -> SetMailFromEMail ( $ this -> Value ( 'MailFromEMail' ) ) ; $ this -> settings -> ... | Saves the settings |
50,415 | public function getAll ( ) { $ comm = new Comm ( ) ; $ comm -> setDb ( $ this -> di -> get ( "db" ) ) ; return $ comm -> findAll ( ) ; } | Get details on all comments . |
50,416 | public function setField ( Field $ field , $ index = 0 ) { $ this -> field = $ field ; $ this -> valueIndex = $ index ; } | Set the value s parent field for use in validation |
50,417 | public function getError ( ) { $ error = new Error ( $ this -> getMessage ( ) ) ; $ error -> setValue ( $ this -> value ) ; if ( $ this -> field !== null ) { $ error -> setName ( $ this -> field -> getName ( ) ) ; } if ( $ this -> valueIndex !== null ) { $ error -> setIndex ( $ this -> valueIndex ) ; } return $ error ;... | Get an error instance |
50,418 | public static function camelCase ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return str_replace ( ' ' , '' , mb_convert_case ( str_replace ( array ( '_' , '-' ) , ' ' , preg_replace ( '/[^-_a-z0-9\s]+/i' , '' , $ string ) ) , MB_CASE_TITLE ) ) ; } ) ; } | Inflect a word to a camel case form with the first letter being capitalized . |
50,419 | public static function className ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return Inflector :: camelCase ( Inflector :: singularize ( $ string ) ) ; } ) ; } | Inflect a word to a class name . Singular camel cased form . |
50,420 | public static function fileName ( $ string , $ ext = 'php' , $ capitalize = true ) { if ( mb_strpos ( $ string , '.' ) !== false ) { $ string = mb_substr ( $ string , 0 , mb_strrpos ( $ string , '.' ) ) ; } $ path = static :: camelCase ( $ string ) ; if ( ! $ capitalize ) { $ path = lcfirst ( $ path ) ; } if ( mb_subst... | Inflect a word for a filename . Studly cased and capitalized . |
50,421 | public static function normalCase ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return ucfirst ( mb_strtolower ( str_replace ( '_' , ' ' , $ string ) ) ) ; } ) ; } | Inflect a word to a human readable string with only the first word capitalized and the rest lowercased . |
50,422 | public static function route ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return mb_strtolower ( Inflector :: hyphenate ( str_replace ( '_' , '-' , preg_replace ( '/[^-_a-z0-9\s\.]+/i' , '' , $ string ) ) ) ) ; } ) ; } | Inflect a word to a routeable format . All non - alphanumeric characters will be removed and any spaces or underscores will be changed to dashes . |
50,423 | public static function tableName ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return lcfirst ( Inflector :: camelCase ( Inflector :: pluralize ( $ string ) ) ) ; } ) ; } | Inflect a word for a database table name . Formatted as plural and camel case with the first letter lowercase . |
50,424 | public static function titleCase ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return mb_convert_case ( str_replace ( '_' , ' ' , $ string ) , MB_CASE_TITLE ) ; } ) ; } | Inflect a word to a human readable string with all words capitalized . |
50,425 | public static function underscore ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return trim ( mb_strtolower ( str_replace ( '__' , '_' , preg_replace ( '/([A-Z]{1})/' , '_$1' , preg_replace ( '/[^_a-z0-9]+/i' , '' , preg_replace ( '/[\s]+/' , '_' , $ string ) ... | Inflect a word to an underscore form that strips all punctuation and special characters and converts spaces to underscores . |
50,426 | public static function variable ( $ string ) { $ string = preg_replace ( '/[^_a-z0-9]+/i' , '' , $ string ) ; if ( is_numeric ( mb_substr ( $ string , 0 , 1 ) ) ) { $ string = '_' . $ string ; } return $ string ; } | Inflect a word to be used as a PHP variable . Strip all but letters numbers and underscores . Add an underscore if the first letter is numeric . |
50,427 | public static function parse ( $ ua = NULL ) { self :: $ ua = $ ua ? $ ua : strip_tags ( $ _SERVER [ "HTTP_USER_AGENT" ] ) ; self :: $ accept = empty ( $ _SERVER [ "HTTP_ACCEPT" ] ) ? '' : strip_tags ( $ _SERVER [ "HTTP_ACCEPT" ] ) ; if ( empty ( self :: $ regexes ) ) { if ( file_exists ( __DIR__ . "/resources/regexes.... | Sets up some standard variables as well as starts the user agent parsing process |
50,428 | private static function log ( $ data ) { if ( ! $ data ) { $ data = new \ stdClass ( ) ; $ data -> ua = self :: $ ua ; } $ jsonData = json_encode ( $ data ) ; echo $ jsonData . "\r\n" ; } | Logs the user agent info |
50,429 | public static function get ( ) { if ( $ data = @ file_get_contents ( "https://raw.github.com/tobie/ua-parser/master/regexes.yaml" ) ) { if ( file_exists ( __DIR__ . "/resources/regexes.yaml" ) ) { if ( ! self :: $ nobackup ) { if ( ! self :: $ silent ) { print ( "backing up old YAML file...\n" ) ; } if ( ! copy ( __DIR... | Gets the latest user agent . Back - ups the old version first . it will fail silently if something is wrong ... |
50,430 | public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ func = $ this -> getFunction ( ) ; $ arguments = $ this -> getArguments ( ) ; $ args = array ( ) ; foreach ( $ arguments as $ arg ) $ args [ ] = $ params -> getDriver ( ) -> toSQL ( $ params , $ arg , false ) ; return $ func . '(' . implode ( ', ' ... | Write a function as SQL query syntax |
50,431 | public function current ( ) { $ current = parent :: current ( ) ; if ( null !== $ current ) { if ( false === is_string ( $ current ) && false === is_numeric ( $ current ) && true === $ this -> is_multidimensional ( $ current ) ) { if ( $ this -> convert !== self :: TYPE_ARRAY ) { return trigger_error ( sprintf ( 'Multi... | Converts current array element to entity when requested |
50,432 | public function pluck ( $ column ) { $ plucked = [ ] ; while ( parent :: valid ( ) ) { $ current = parent :: current ( ) ; if ( true === is_array ( $ column ) ) { $ tmp = $ current ; $ insert = true ; foreach ( $ column as $ index ) { if ( false === isset ( $ tmp [ $ index ] ) ) { $ insert = false ; break ; } $ tmp = $... | Plucks a column from a resultset |
50,433 | private function is_multidimensional ( $ array ) { if ( false === is_array ( $ array ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type Array, "%s" given' , __METHOD__ , gettype ( $ array ) ) , E_USER_ERROR ) ; } return ( count ( array_filter ( $ array , 'is_array' ) ) > 0 ) ; } | Returns if an Array is multidimensional |
50,434 | public static function init ( string $ handlerType , array $ resLocations ) : Container { switch ( strtolower ( $ handlerType ) ) { case Config :: PHP_CONFIG_HANDLER : $ handler = new PhpHandler ( $ resLocations ) ; break ; case Config :: XML_CONFIG_HANDLER : $ xml = new \ Desperado \ XmlBundle \ Model \ XmlReader ; $ ... | Instantiate Config class |
50,435 | public function determineCategory ( $ userAgent = null , $ defaultGrade = Grades :: UNSUPPORTED ) { $ logger = $ GLOBALS [ 'logger' ] ; $ app = $ GLOBALS [ 'app' ] ; $ parsedUA = UA :: parse ( $ userAgent ) ; if ( ! empty ( $ app ) && ! $ app -> getConfiguration ( ) -> isLocal ( ) ) { try { $ logger -> info ( 'Attempti... | Categorize Incoming Request |
50,436 | private function _lookupLocal ( $ ua , $ defaultGrade ) { $ logger = $ GLOBALS [ 'logger' ] ; $ browser = new Browser ( ) ; $ gradePrefix = 'X' ; $ gradeSuffix = Grades :: UNSUPPORTED ; if ( ( $ ua -> isMobile || $ ua -> isMobileDevice ) && $ ua -> isTablet ) { $ gradePrefix = DeviceTypes :: TABLET ; $ gradeSuffix == G... | Lookup Device Detection based on File . |
50,437 | private function _lookupDB ( $ ua ) { $ browser = new Browser ( ) ; $ browser -> setGrade ( Grades :: UNSUPPORTED ) ; $ conn = new \ Mongo ( 'mongodb://' . DeviceManager :: HOST ) ; $ collection = $ conn -> selectDB ( DeviceManager :: DB ) -> devices ; $ pattern = $ this -> _getMatchingRegex ( $ ua ) ; $ uaRegex = new ... | Finds closest match given the user agent |
50,438 | public static function random ( $ min , $ max = null ) { if ( String :: isEmpty ( $ max ) || $ max > getrandmax ( ) ) { $ max = getrandmax ( ) ; } return rand ( $ min , $ max ) ; } | Generate random number |
50,439 | public function postIdOfPostupdate ( $ id ) { $ record = DB :: table ( 'postupdates' ) -> select ( 'post_id' ) -> where ( 'id' , '=' , $ id ) -> first ( ) ; return $ record -> post_id ; } | What is the post_id of a given postupdate? |
50,440 | public function postupdateNotExist ( $ post_id ) { if ( $ this -> countPostUpdates ( $ post_id ) == 0 ) { DB :: table ( 'posts' ) -> where ( 'id' , '=' , $ post_id ) -> update ( [ 'postupdate' => 0 ] ) ; } } | When a post update is deleted and no more post updates exist for that post then update the POSTS table to indicate that no post updates for that post exist . |
50,441 | public function hasAppliedValue ( ) { $ customFunction = $ this -> getHasAppliedValueFunction ( ) ; if ( is_callable ( $ customFunction ) ) { $ result = call_user_func ( $ customFunction , $ this ) ; if ( ! is_bool ( $ result ) ) { throw new FilterException ( 'Returned value from callable function must be boolean.' ) ;... | Checks if the filter value was applied . Note that the converted value is used for checking . |
50,442 | public function setApplyFilterFunction ( callable $ function ) { $ validator = $ this -> getCallableValidatorApplyFilters ( ) ; $ validator -> setCallableFunction ( $ function ) ; if ( $ validator -> isValid ( ) === false ) { throw $ validator -> getException ( ) ; } $ this -> applyFilterFunction = $ function ; return ... | Sets custom apply filter function . |
50,443 | public function setAppendFormFieldsFunction ( callable $ function ) { $ validator = $ this -> getCallableValidatorAppendFormFields ( ) ; $ validator -> setCallableFunction ( $ function ) ; if ( $ validator -> isValid ( ) === false ) { throw $ validator -> getException ( ) ; } $ this -> appendFormFieldsFunction = $ func... | Sets custom append form fields function . |
50,444 | public function setConvertValueFunction ( callable $ function ) { $ validator = $ this -> getCallableValidatorConvertValue ( ) ; $ validator -> setCallableFunction ( $ function ) ; if ( $ validator -> isValid ( ) === false ) { throw $ validator -> getException ( ) ; } $ this -> convertValueFunction = $ function ; retur... | Sets custom convert value function . |
50,445 | public function setValuePropertyName ( $ valuePropertyName ) { if ( ! is_string ( $ valuePropertyName ) || $ valuePropertyName === '' ) { throw new InvalidArgumentException ( '"Value property name" argument must be a string and must not empty.' ) ; } if ( ! property_exists ( $ this , $ valuePropertyName ) ) { throw new... | Sets the name of the property which contains the raw value . |
50,446 | public function setFormFieldType ( $ formFieldType ) { if ( ! is_string ( $ formFieldType ) || $ formFieldType === '' ) { throw new InvalidArgumentException ( '"Form field type" argument must be a string and must not empty.' ) ; } $ this -> formFieldType = $ formFieldType ; return $ this ; } | Sets form field type . |
50,447 | public function process ( Response $ response ) { $ content = preg_replace ( '/<!\-\-.[^(\-\-\>)]*?\-\->/i' , '' , $ response -> getContent ( ) ) ; $ content = str_replace ( "\t" , " " , $ content ) ; $ content = preg_replace ( '/(\s)\/\/(.*)(\s)/' , '\\1/* \\2 */\\3' , $ content ) ; $ search = array ( '/(\s+)?(\<.+\>)... | Drop comments & compress response content |
50,448 | public function getQueryHintValue ( ) : SqlConversionInfo { if ( null === $ this -> whereClause ) { throw new BadMethodCallException ( 'Unable to get query-hint value for ConditionGenerator. Call getWhereClause() before calling this method.' ) ; } return new SqlConversionInfo ( $ this -> nativePlatform , $ this -> para... | Returns the Query - hint value for the query object . |
50,449 | public static function read ( $ key = false ) { if ( is_array ( $ key ) && ! empty ( $ key ) ) { $ _value_to_be_returned = self :: $ _config ; foreach ( array_values ( $ key ) as $ key => $ _val ) { $ _value_to_be_returned = $ _value_to_be_returned [ $ _val ] ; } return $ _value_to_be_returned ; } return isset ( self :... | This function returns the value of the key in the config . |
50,450 | public static function loadConfigFiles ( $ configPath = false ) { if ( ! is_dir ( $ configPath ) ) { throw new \ Exception ( "Config directory {$configPath} not found!" ) ; } $ filesToBeLoaded = scandir ( $ configPath ) ; foreach ( $ filesToBeLoaded as $ _file ) { if ( preg_match ( '/.*\.php/' , $ _file ) ) { include_o... | This function is loads all the files in a particular folder this is meant to the config folder . |
50,451 | protected function InitForm ( ) { $ this -> htmlCode = $ this -> LoadElement ( ) ; $ name = 'Code' ; $ this -> AddField ( new Textarea ( $ name , $ this -> htmlCode -> GetCode ( ) ) ) ; $ this -> SetRequired ( $ name ) ; $ this -> AddCssClassField ( ) ; $ this -> AddCssIDField ( ) ; $ this -> AddSubmit ( ) ; } | Initializes the html code content form |
50,452 | public function init ( $ config , $ global ) { $ this -> author = $ global [ 'comment' ] [ 'author' ] ; $ this -> version = $ global [ 'comment' ] [ 'version' ] ; $ this -> classname = $ config [ 'class' ] [ 'classname' ] ; $ this -> namespace = $ config [ 'class' ] [ 'namespace' ] ; $ this -> cacheName = $ config [ 'c... | Initialize config . |
50,453 | public function getValidations ( $ class = null ) { $ reflectionClass = $ class ? new \ ReflectionClass ( $ class ) : false ; if ( $ reflectionClass === false ) { return [ ] ; } $ result = $ this -> buildValidation ( $ class ) ; $ validations = [ ] ; foreach ( $ result as $ keyElement => $ element ) { if ( is_array ( $... | Gets the validations . |
50,454 | protected function buildValidation ( $ class = null ) { $ validations = [ ] ; $ metadata = $ this -> validator -> getMetadataFor ( $ class ) ; $ entityConstraints = [ ] ; foreach ( $ metadata -> getConstraints ( ) as $ constraint ) { $ class = new \ ReflectionClass ( $ constraint ) ; $ fields = $ constraint -> fields ;... | Parses and builds the validation . |
50,455 | protected function constraintMessages ( Constraint $ constraint ) { $ result = [ ] ; if ( isset ( $ constraint -> min ) && $ constraint -> min !== null ) { $ count = new Count ( [ 'min' => $ constraint -> min ] ) ; $ length = new Length ( [ 'min' => $ constraint -> min ] ) ; $ result [ ] = $ constraint -> minMessage ; ... | Parses the constraint message . |
50,456 | public function cmdGetCollectionItem ( ) { $ result = $ this -> getListCollectionItem ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableCollectionItem ( $ result ) ; $ this -> output ( ) ; } | Callback for collection - item - get command |
50,457 | public function cmdDeleteCollectionItem ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ condition = $ id ; if ( $ this -> getParam ( 'collection' ) ) { $ condition = array ( 'collection_id' => $ id ) ; } $ res... | Callback for collection - item - delete command |
50,458 | public function cmdUpdateCollectionItem ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } ... | Callback for collection - item - update command |
50,459 | protected function addCollectionItem ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> collection_item -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new collection item |
50,460 | protected function updateCollectionItem ( $ collection_item_id ) { if ( ! $ this -> isError ( ) && ! $ this -> collection_item -> update ( $ collection_item_id , $ this -> getSubmitted ( ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } } | Updates a collection item |
50,461 | protected function submitAddCollectionItem ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'collection_item' ) ; $ this -> addCollectionItem ( ) ; } | Add a new collection item at once |
50,462 | protected function wizardAddCollectionItem ( ) { $ this -> validatePrompt ( 'collection_id' , $ this -> text ( 'Collection ID' ) , 'collection_item' ) ; $ this -> validatePrompt ( 'entity_id' , $ this -> text ( 'Entity ID' ) , 'collection_item' ) ; $ this -> validatePrompt ( 'weight' , $ this -> text ( 'Weight' ) , 'co... | Add a collection item step by step |
50,463 | public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( MediaTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ Attogram \ Share... | Performs a DELETE on the database given a Media or Criteria object OR a primary key value . |
50,464 | public function registerPostType ( ) { $ nameSingular = 'Shortlink' ; $ namePlural = 'Shortlinks' ; $ description = 'Create shortlinks to your posts or pages' ; $ labels = array ( 'name' => _x ( $ nameSingular , 'post type general name' , 'custom-short-links' ) , 'singular_name' => _x ( $ nameSingular , 'post type sing... | Register shortlinks posttype |
50,465 | public function simpleRedirect ( ) { global $ wp ; if ( ! $ request = $ wp -> request ) { return ; } $ currentSlug = add_query_arg ( array ( ) , $ request ) ; $ post = get_page_by_title ( $ currentSlug , 'OBJECT' , 'custom-short-link' ) ; if ( ! $ post ) { return ; } $ fields = get_fields ( $ post -> ID ) ; $ redirectT... | Make a simple PHP redirect to the target page |
50,466 | protected function validateUrlData ( $ urlData , $ i ) { $ part1 = isset ( $ urlData [ $ i ] ) ? explode ( '~' , $ urlData [ $ i ] ) : [ ] ; $ part2 = isset ( $ urlData [ $ i + 1 ] ) ? explode ( '~' , $ urlData [ $ i + 1 ] ) : [ ] ; $ part3 = isset ( $ urlData [ $ i + 2 ] ) ? explode ( '~' , $ urlData [ $ i + 2 ] ) : [... | This function check for duplicate of page It s need for SEO |
50,467 | public function getMimeTypeFromFile ( $ file ) { $ extension = strtolower ( pathinfo ( $ file , PATHINFO_EXTENSION ) ) ; if ( array_key_exists ( $ extension , $ this -> _alt_mime_types ) ) { return $ this -> _alt_mime_types [ $ extension ] ; } else { return ( new \ Finfo ( FILEINFO_MIME_TYPE ) ) -> file ( $ file ) ; } ... | Get mime - type from file . Checks extensions array first then attempts to get mime - type using Finfo |
50,468 | public function getFriend ( ) { $ userTable = CoreTables :: getTableName ( CoreTables :: TABLE_USER ) ; return $ this -> hasOne ( User :: class , [ 'id' => 'friendId' ] ) -> from ( "$userTable as friend" ) ; } | Return user who got friendship invite . |
50,469 | public function writeOutput ( $ str ) { if ( empty ( $ str ) ) { return $ this ; } $ this -> output [ ] = $ str ; if ( $ this -> consoleOutput ) { $ this -> consoleOutput -> writeln ( $ str ) ; } return $ this ; } | Writes output to the run . |
50,470 | private function changeMigrationTable ( $ migration ) { $ table = $ this -> _cap -> table ( 'migrations' ) ; $ dbm = $ table -> where ( 'migration' , '=' , $ migration ) ; if ( $ dbm -> count ( ) > 0 ) { $ item = $ dbm -> first ( ) ; $ item -> updated_at = date ( 'Y-m-d h:i:s' ) ; $ item -> migrated = 1 ; $ table -> up... | Update migrations table to reflect the migration push . |
50,471 | private function isMigrated ( $ migration , OutputInterface $ output = null ) { if ( $ this -> _db -> schema ( ) -> hasTable ( 'migrations' ) ) { $ table = $ this -> _cap -> table ( 'migrations' ) ; $ m = $ table -> where ( 'migration' , '=' , $ migration ) ; if ( $ m -> count ( ) > 0 ) { $ item = $ m -> first ( ) ; if... | Check whether a migration is in the database or not . |
50,472 | private function createMigrationsTable ( OutputInterface $ output = null ) { if ( ! is_null ( $ output ) ) { $ output -> writeln ( '<info>Creating migrations table</info>' ) ; } $ m = new CreateMigrationsTable ( ) ; $ m -> up ( ) ; } | Creates the migration table if it doesn t exist . |
50,473 | public function up ( ) { $ this -> create ( 'migrations' , function ( $ table ) { $ table -> increments ( 'id' ) ; $ table -> string ( 'migration' ) ; $ table -> integer ( 'migrated' ) ; $ table -> timestamps ( ) ; } ) ; } | For pushing migrations up . |
50,474 | public static function isIterator ( $ arr ) { if ( ! is_array ( $ arr ) ) { return false ; } foreach ( array_keys ( $ arr ) as $ key ) { if ( ! is_numeric ( $ key ) ) { return false ; } } return true ; } | Check if param is an array and can be iterated on indicating this is a collection |
50,475 | public static function parseResponseToPatrolObject ( Patrol $ patrol , $ data , $ class = null , $ defaults = null ) { if ( self :: isIterator ( $ data ) ) { $ parsed = [ ] ; foreach ( $ data as $ item ) { $ parsed [ ] = self :: parseResponseToPatrolObject ( $ patrol , $ item , $ class , $ defaults ) ; } return $ parse... | Parses a response to PatrolModel |
50,476 | public function runThreads ( $ maximumConcurrency = 10 , $ waitForCompletion = false ) { $ remainingThreads = $ this -> threads ; $ activeThreads = array ( ) ; do { foreach ( $ activeThreads as $ pid => $ thread ) { if ( $ thread -> getStatus ( ) == Thread :: THREAD_EXITED ) unset ( $ activeThreads [ $ pid ] ) ; } if (... | Run all threads defined within this thread manager enforcing the maximum concurrency flag and optionally waiting for threads to complete . |
50,477 | public function addRole ( string $ role , ? array $ parents = null ) : void { $ this -> roles [ ] = $ role ; if ( null !== $ parents ) { $ map = [ ] ; foreach ( $ parents as $ parent ) { $ map [ ] = $ parent ; $ map = \ array_merge ( $ map , $ this -> getRoles ( $ parent ) ) ; } unset ( $ map [ 0 ] ) ; $ this -> map [ ... | Add a role into the hierarchy |
50,478 | public function getPaginator ( $ params ) { $ limit = isset ( $ params [ 'limit' ] ) ? ( int ) $ params [ 'limit' ] : 10 ; $ offset = isset ( $ params [ 'offset' ] ) ? ( int ) $ params [ 'offset' ] : 0 ; $ params [ 'limit' ] = $ limit ; $ params [ 'offset' ] = $ offset ; $ fields = isset ( $ params [ 'field' ] ) ? arra... | Create paginator Object |
50,479 | public function getList ( $ params = array ( ) , ServiceManager $ sm ) { $ paginator = $ this -> getPaginator ( $ params ) ; $ data = array ( ) ; foreach ( $ paginator as $ post ) { $ data [ ] = $ this -> get ( $ post , $ sm ) ; } $ queryParams = array ( ) ; $ routeParams = array ( ) ; $ fields = isset ( $ params [ 'fi... | Return a normalized representation of a set of document |
50,480 | public function getPaginationData ( ServiceManager $ sm , $ paginator , $ data , $ routeName , $ routeParams , $ queryParams ) { $ mainService = $ sm -> get ( 'neobazaar.service.main' ) ; return array ( 'data' => $ data , 'paginationData' => Json :: decode ( $ mainService -> getView ( ) -> paginationControl ( $ paginat... | Get a pagination JSON data . |
50,481 | protected function initAutoHide ( ) { if ( $ this -> getIsDelayed ( ) === false ) { return null ; } $ view = $ this -> getView ( ) ; $ view -> registerJs ( $ this -> makeJs ( ) , View :: POS_READY ) ; AlertAssets :: register ( $ view ) ; } | Initialize javascript function for autoHide |
50,482 | public function fields ( $ fields = [ ] ) { $ this -> builder -> select ( [ ] ) ; $ this -> casts = [ ] ; if ( empty ( $ fields ) ) { foreach ( $ this -> model -> fields ( ) as $ field ) { $ this -> assignField ( $ field ) ; } return $ this ; } foreach ( $ fields as $ field ) { $ this -> assignField ( $ this -> model -... | Sets field names which will be read |
50,483 | protected function assignField ( FieldInterface $ field ) { if ( $ field -> mapping ( ) !== null ) { $ this -> builder -> addSelect ( sprintf ( '%s AS %s' , $ this -> connection -> quoteIdentifier ( $ field -> mapping ( ) ) , $ this -> connection -> quoteIdentifier ( $ field -> name ( ) ) ) ) ; } else { $ this -> build... | Assigns field to query |
50,484 | protected function buildSingularFieldCondition ( $ field , $ value , $ comparison ) { $ field = $ this -> model ( ) -> field ( $ field ) ; return $ this -> buildConditionString ( $ this -> connection ( ) -> quoteIdentifier ( $ field -> mappedName ( ) ) , $ value === null ? null : $ this -> bindValues ( $ field -> mappe... | Builds condition for singular field |
50,485 | protected function buildMultipleFieldsCondition ( $ fields , $ value , $ comparison , $ logical ) { $ conditions = [ ] ; foreach ( ( array ) $ fields as $ field ) { $ field = $ this -> model ( ) -> field ( $ field ) ; $ fieldName = $ field -> mappedName ( ) ; $ conditions [ ] = $ this -> buildConditionString ( $ this -... | Builds conditions for multiple fields |
50,486 | protected function buildConditionString ( $ field , $ bind , $ operator ) { if ( is_array ( $ bind ) ) { foreach ( $ bind as & $ val ) { $ val = $ this -> buildConditionString ( $ field , $ val , $ operator ) ; unset ( $ val ) ; } $ logical = $ operator === '!=' ? ' and ' : ' or ' ; return '(' . implode ( $ logical , $... | Builds condition string |
50,487 | protected function normalizeComparison ( $ operator ) { switch ( strtolower ( $ operator ) ) { case '<' : case 'lt' : return '<' ; case '<=' : case 'lte' : return '<=' ; case '>' : case 'gt' : return '>' ; case '>=' : case 'gte' : return '>=' ; case '~' : case '~=' : case '=~' : case 'regex' : case 'regexp' : return "r... | Asserts correct comparison operator |
50,488 | protected function normalizeLogical ( $ operator ) { switch ( strtolower ( $ operator ) ) { case '&&' : case 'and' : return 'and' ; case '||' : case 'or' : return 'or' ; default : throw new QueryException ( sprintf ( 'Query does not supports logical operator "%s" in query "%s"' , $ operator , $ this -> model ( ) -> ent... | Asserts correct logical operation |
50,489 | protected function bindValues ( $ name , $ type , $ values ) { if ( ! is_array ( $ values ) ) { return $ this -> builder -> createNamedParameter ( $ values , $ type ) ; } foreach ( $ values as $ key => $ value ) { $ values [ $ key ] = $ this -> bindValues ( $ name , $ type , $ value ) ; } return $ values ; } | Binds condition value to key |
50,490 | public function order ( $ field , $ order = 'desc' ) { $ field = $ this -> model -> field ( $ field ) ; $ order = $ this -> normalizeOrder ( $ order ) ; $ this -> builder -> addOrderBy ( $ this -> connection -> quoteIdentifier ( $ field -> mappedName ( ) ) , $ order ) ; return $ this ; } | Adds sorting to query |
50,491 | protected function normalizeOrder ( $ order ) { switch ( strtolower ( $ order ) ) { case 'asc' : return 'asc' ; case 'desc' : return 'desc' ; default : throw new QueryException ( sprintf ( 'Unsupported sorting method "%s" in query "%s"' , $ this -> getType ( $ order ) , $ this -> model -> entity ( ) ) ) ; } } | Asserts correct order |
50,492 | public function limit ( $ limit , $ offset = null ) { if ( $ offset !== null ) { $ this -> builder -> setFirstResult ( ( int ) $ offset ) ; } $ this -> builder -> setMaxResults ( ( int ) $ limit ) ; return $ this ; } | Sets limits to query |
50,493 | public function count ( ) { if ( empty ( $ this -> queryString ) ) { $ builder = clone $ this -> builder ; $ builder -> resetQueryPart ( 'orderBy' ) ; $ stmt = $ builder -> execute ( ) ; } else { $ stmt = $ this -> connection -> executeQuery ( $ this -> queryString , $ this -> queryParams ) ; } return ( int ) $ stmt ->... | Returns number of entities that will be read |
50,494 | public function query ( $ query , array $ params = [ ] ) { $ this -> queryString = $ query ; $ this -> queryParams = $ params ; return $ this ; } | Sets custom query to be executed instead of one based on entity structure |
50,495 | protected function executeQuery ( ) { if ( empty ( $ this -> queryString ) ) { return $ this -> builder -> execute ( ) ; } return $ this -> connection -> executeQuery ( $ this -> queryString , $ this -> queryParams ) ; } | Executes query - from builder or custom |
50,496 | protected function fetchAsAssoc ( Statement $ stmt ) { $ stmt -> setFetchMode ( \ PDO :: FETCH_ASSOC ) ; return $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; } | Fetches result as associative array mostly for pivot tables |
50,497 | protected function fetchAsObject ( Statement $ stmt ) { $ stmt -> setFetchMode ( \ PDO :: FETCH_CLASS , $ this -> model -> entity ( ) ) ; $ result = $ stmt -> fetchAll ( ) ; $ ref = new \ ReflectionClass ( $ this -> model -> entity ( ) ) ; foreach ( $ result as $ entity ) { $ this -> restoreObject ( $ entity , $ this -... | Fetches result as entity object |
50,498 | protected function restoreObject ( $ entity , array $ restore , \ ReflectionClass $ ref ) { foreach ( $ restore as $ field => $ type ) { if ( is_array ( $ entity ) ) { if ( ! isset ( $ entity [ $ field ] ) ) { continue ; } $ entity [ $ field ] = $ this -> convertToPHPValue ( $ entity [ $ field ] , $ type ) ; continue ;... | Restores entity values from their stored representation |
50,499 | protected function convertToPHPValue ( $ value , $ type ) { return Type :: getType ( $ type ) -> convertToPHPValue ( $ value , $ this -> connection -> getDatabasePlatform ( ) ) ; } | Converts read value to its php representation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.