idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
56,500 | public function setExpires ( $ timestamp ) { $ this -> data [ 'Expires' ] = is_numeric ( $ timestamp ) ? ( int ) $ timestamp : strtotime ( $ timestamp ) ; return $ this ; } | Set the unix timestamp for which the cookie will expire |
56,501 | public function setImage ( $ file ) { if ( false === is_string ( $ file ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ file ) ) , E_USER_ERROR ) ; } if ( false === is_file ( $ file ) ) { return trigger_error ( sprintf ( 'File "%s" pas... | Set a new image |
56,502 | public function flip ( $ mode = self :: FLIP_HORIZONTAL ) { if ( false === in_array ( $ mode , [ self :: FLIP_HORIZONTAL , self :: FLIP_VERTICAL , self :: FLIP_BOTH ] ) ) { return trigger_error ( sprintf ( 'Unknown mode passed %s(), "%s" given' , __METHOD__ , gettype ( $ mode ) ) , E_USER_ERROR ) ; } $ this -> add ( __... | Flip the current image horizontal vertical or both |
56,503 | private function call ( ) { if ( null === $ this -> driver ) { return trigger_error ( 'Driver is not set. Set the driver with the setDriver() method' , E_USER_ERROR ) ; } if ( null === $ this -> image ) { return trigger_error ( 'Image has not been set. Set the image with the setImage() method' , E_USER_ERROR ) ; } if (... | Check if image and driver is set and returns the driver |
56,504 | private function getQuality ( $ quality , $ extension ) { if ( false === ( '-' . intval ( $ quality ) == '-' . $ quality ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ quality ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ ext... | Validates and returns quality based on image extension |
56,505 | public function output ( ) { $ methodName = 'http_' . $ this -> request -> httpMethod ( ) ; if ( method_exists ( $ this , $ methodName ) ) { return $ this -> $ methodName ( ) ; } else { return $ this -> response -> send ( 405 , 'The requested resource does not support the HTTP method' . ' "' . $ this -> request -> http... | Generate the output of the requested Resource instance . |
56,506 | public static function fromOption ( $ option ) { $ message = sprintf ( 'Could not add invalid Option of type "%1$s" to option repository.' , is_object ( $ option ) ? get_class ( $ option ) : gettype ( $ option ) ) ; return new static ( $ message ) ; } | Get a new exception based on the type of an invalid option . |
56,507 | public function middleware ( $ name ) { if ( is_string ( $ name ) ) { app ( ) -> addRouteMiddleware ( $ name ) ; } else if ( is_array ( $ name ) ) { foreach ( $ name as $ middlewareName ) { app ( ) -> addRouteMiddleware ( $ middlewareName ) ; } } } | Middlewares to add . |
56,508 | public static function createNormalizer ( $ key = 'default' ) { return isset ( self :: $ instancePool [ $ key ] ) ? self :: $ instancePool [ $ key ] : self :: $ instancePool [ $ key ] = new static ( PropertyAccess :: createPropertyAccessor ( ) ) ; } | Create and return an instantiated normalizer returns always the same throught this call . |
56,509 | private function createReadingDelegate ( ) { return $ this -> readDelegate ? : $ this -> readDelegate = function ( $ property , PropertyAccessor $ propertyAccessor ) { switch ( true ) { case $ propertyAccessor -> isReadable ( $ this , $ property ) : return $ propertyAccessor -> getValue ( $ this , $ property ) ; case p... | Create and return a Closure available to read an object property through a property path or a private property . |
56,510 | public function normalize ( $ object , $ scope = 'default' ) { switch ( true ) { case ! is_object ( $ object ) : return $ object ; case $ object instanceof StdClass : return ( array ) $ object ; case $ object instanceof \ DateTime : return $ object -> format ( \ DateTime :: ISO8601 ) ; case ! $ object instanceof Normal... | Normalize given object using given scope . |
56,511 | public function scopify ( NormalizableInterface $ object , $ scope ) { $ scopes = $ object -> getScopes ( ) ; if ( ! isset ( $ scopes [ $ scope ] ) ) { throw new ScopeNotFoundException ( sprintf ( 'Invalid scope for %s object, only ["%s"] supported, "%s" given.' , get_class ( $ object ) , implode ( '", "' , array_keys ... | Normalize given normalizable following given scope . |
56,512 | private function createWrittingDelegate ( ) { return $ this -> writeDelegate ? : $ this -> writeDelegate = function ( PropertyPathInterface $ property , $ value , PropertyAccessor $ propertyAccessor ) { switch ( true ) { case $ propertyAccessor -> isWritable ( $ this , $ property ) : return $ propertyAccessor -> setVal... | Create and return a Closure available to write an object property through a property path or a private property . |
56,513 | public function getModuleHydrator ( ) { if ( $ this -> moduleHydrator == null ) { $ moduleHydratorClass = $ this -> getOptions ( ) -> getPuppetModuleHydratorClass ( ) ; $ this -> moduleHydrator = new $ moduleHydratorClass ; } return $ this -> moduleHydrator ; } | Get ModuleHydrator . |
56,514 | public function getClassHydrator ( ) { if ( $ this -> classHydrator == null ) { $ classHydratorClass = $ this -> getOptions ( ) -> getPuppetClassHydratorClass ( ) ; $ this -> classHydrator = new $ classHydratorClass ; } return $ this -> classHydrator ; } | Get ClassHydrator . |
56,515 | protected function validateType ( $ relType ) { $ valid = [ 'one' , 'many' ] ; if ( ! in_array ( $ relType , $ valid ) ) { throw MetadataException :: invalidRelType ( $ relType , $ valid ) ; } return true ; } | Validates the relationship type . |
56,516 | public function getConfigurationParameterName ( $ value = null ) { $ output = '' ; if ( ! empty ( $ this -> _parent ) && $ this -> _parent instanceof Parameter ) { $ output .= $ this -> _parent -> getConfigurationParameterName ( ) ; } if ( ! empty ( $ this -> _name ) ) { if ( ! empty ( $ output ) ) $ output .= '->' ; $... | Get name of configuration value |
56,517 | public function flattenResult ( ) { $ output = [ ] ; $ vars = ( array ) $ this ; foreach ( $ vars as $ field => $ value ) { if ( ord ( $ field [ 0 ] ) == 0 ) continue ; if ( $ value instanceof Parameter ) { $ output [ $ field ] = $ value -> flattenResult ( ) ; } else { $ output [ $ field ] = $ value ; } } return $ outp... | Get flattened scalars from a configuration parameter recursively |
56,518 | public function toArray ( ) { if ( ! $ this -> getMethod ( ) ) { throw new \ InvalidArgumentException ( 'Method must be provided for request' ) ; } $ data = array ( 'jsonrpc' => self :: VERSION , 'method' => $ this -> getMethod ( ) , ) ; if ( $ this -> getParams ( ) ) { $ data [ 'params' ] = $ this -> getParams ( ) ; }... | Serialize into array |
56,519 | public function isSerialized ( $ string ) { if ( ! is_string ( $ string ) ) { return false ; } $ string = trim ( $ string ) ; if ( $ string === 'N;' ) { return true ; } $ string_encoding = mb_detect_encoding ( $ string ) ; $ length = mb_strlen ( $ string , $ string_encoding ) ; $ last_char = mb_substr ( $ string , - 1 ... | Is serialized string . |
56,520 | public function addLink ( $ url , $ title , $ icon = NULL , $ priority = 0 ) { $ link = [ "moduleUrl" => str_replace ( "#" , NULL , substr ( $ url , 0 , strpos ( $ url , ":" ) ) ) , "url" => $ url , "title" => $ title , "icon" => $ icon , "priority" => $ priority ] ; $ this -> links [ ] = $ link ; } | Adds link to mainPanel |
56,521 | public function render ( Exception $ e , $ debug ) { $ e = FlattenException :: create ( $ e ) ; $ handler = new SymfonyExceptionHandler ( $ debug ) ; $ status = $ e -> getStatusCode ( ) ; $ response = SymfonyResponse :: create ( $ handler -> getHtml ( $ e ) , $ status , $ e -> getHeaders ( ) ) ; $ rex = explode ( "\n" ... | Renders the error . |
56,522 | public function multiGet ( array $ keys , $ localOnly = false ) { $ keys = array_unique ( $ keys ) ; $ results = array ( ) ; $ others = array ( ) ; foreach ( $ keys as $ key ) { $ cacheKey = $ this -> cacheKey ( $ key ) ; if ( $ this -> keepLocalCache && array_key_exists ( $ cacheKey , $ this -> localCache ) ) $ result... | Returns an array of nodes from cache specified by key |
56,523 | public function put ( $ key , $ value , $ duration , $ localOnly = false ) { $ cacheKey = $ this -> cacheKey ( $ key ) ; if ( $ this -> keepLocalCache ) $ this -> localCache [ $ cacheKey ] = $ value ; if ( ! $ localOnly ) $ this -> cacheStore -> put ( $ cacheKey , $ value , $ duration ) ; } | Stores the value specified with the cacheKey given . |
56,524 | protected function translateRoutes ( array $ routes = [ ] ) { foreach ( $ routes as $ routeKey => $ routeParams ) { if ( isset ( $ routeParams [ 'description' ] ) ) { $ routes [ $ routeKey ] [ 'description' ] = $ this -> translator -> translate ( $ routeParams [ 'description' ] ) ; } if ( isset ( $ routeParams [ 'short... | Translate the route texts |
56,525 | public function writeApplicationBanner ( AdapterInterface $ console ) { $ console -> writeLine ( ) ; $ console -> writeLine ( str_pad ( '' , $ console -> getWidth ( ) - 1 , '=' , STR_PAD_RIGHT ) , Color :: GREEN ) ; $ console -> write ( '=' , Color :: GREEN ) ; $ console -> write ( str_pad ( '' . $ this -> name . ' - '... | Write application banner |
56,526 | public function writeApplicationFooter ( AdapterInterface $ console ) { $ console -> writeLine ( str_pad ( '' , $ console -> getWidth ( ) - 1 , '=' , STR_PAD_RIGHT ) , Color :: GREEN ) ; $ console -> writeLine ( ) ; } | Write application footer |
56,527 | public function clean ( $ string , $ allowedTags = null ) { if ( is_array ( $ string ) ) { $ new_array = array ( ) ; foreach ( $ string as $ key => $ val ) { $ new_array [ $ key ] = $ this -> clean ( $ val , $ allowedTags ) ; } return $ new_array ; } $ string = $ this -> cleanHTMLPurify ( $ string , $ allowedTags ) ; r... | Cleans XSS by removing all tags |
56,528 | protected function cleanHTMLPurify ( $ string , $ allowedTags = null ) { if ( strlen ( $ string ) == 0 ) return '' ; if ( $ allowedTags === null ) $ allowedTags = $ this -> defaultAllowedTags ; if ( $ allowedTags == '*' ) return $ string ; if ( is_null ( $ this -> purifier ) ) { require_once PATH_SYSTEM . '/vendors/HTM... | Produces a nicely - formatted HTML string with all non - matching tags stripped . |
56,529 | public function autoParagraph ( $ string , $ allowedTags = null , $ linkUrls = true ) { if ( is_null ( $ allowedTags ) ) $ allowedTags = $ this -> defaultAllowedTags ; if ( is_null ( $ this -> purifier ) ) { require_once PATH_SYSTEM . '/vendors/HTMLPurifier.php' ; $ this -> purifier = HTMLPurifier :: instance ( ) ; Fil... | Marks up a string with paragraphs and automatically links any urls . |
56,530 | public function unAutoParagraph ( $ string ) { $ string = str_replace ( array ( "<p>" , "</p>" , "<br/>" , "<br />" ) , array ( "" , "\n\n" , "\n" , "\n" ) , $ string ) ; $ string = preg_replace ( "/\<a href\=\"(" . URLUtils :: URL_MATCH . ")\"\>\\1\<\/a\>/i" , '$1' , $ string ) ; $ string = preg_replace_callback ( "/\... | Removes the markup added by autoParagraph . |
56,531 | public static function makeSetterGetterDoc ( Entity $ entity ) { $ properties = $ entity -> toArray ( false ) ; $ entityName = $ entity -> calledClassName ( ) ; echo "<pre>\n" ; foreach ( $ properties as $ name => $ value ) { $ methodName = ucfirst ( $ name ) ; $ type = $ entity -> typeof ( $ name ) ; echo " * @method ... | Generate the setter and getter method PHPDoc declaration to paste into your entity class . |
56,532 | public static function makePublicProperties ( array $ properties ) { echo '<pre>' . "\n" ; foreach ( $ properties as $ key => $ value ) { $ type = gettype ( $ value ) ; if ( $ type === 'object' ) { $ type = get_class ( $ value ) ; } echo <<<EODOC /** * @var $type */ public \$$key;EODOC ; } echo '</pre>' ... | Generate the public properties PHPDoc declarations to paste into your entity class . |
56,533 | final public static function getInstance ( ) { $ className = get_called_class ( ) ; if ( ! isset ( self :: $ _instances [ $ className ] ) ) { self :: $ _instances [ $ className ] = new static ( ) ; } self :: $ _instances [ $ className ] -> initialize ( ) ; return self :: $ _instances [ $ className ] ; } | Return event instance |
56,534 | final public static function clearInstance ( $ className ) { if ( isset ( self :: $ _instances [ $ className ] ) ) { $ name = self :: _configName ( $ className ) ; Config :: clearInstance ( $ name ) ; self :: $ _instances [ $ className ] -> _loadObservers ( ) ; } } | Unloads event instance . |
56,535 | final public function notify ( ) { $ observers = array_values ( $ this -> _observers ) ; foreach ( $ observers as $ observer ) { switch ( false ) { case is_array ( $ observer ) : case isset ( $ observer [ 0 ] ) : case isset ( $ observer [ 1 ] ) : case is_string ( $ observer [ 0 ] ) : break ; default : Loader :: loadCla... | Notify observers . |
56,536 | final public function attach ( $ observer ) { if ( ! in_array ( $ observer , $ this -> _observers ) ) { array_push ( $ this -> _observers , $ observer ) ; } return $ this ; } | Attach new observer . |
56,537 | final public function detach ( $ observer ) { $ key = array_search ( $ observer , $ this -> _observers ) ; if ( $ key !== false ) { unset ( $ this -> _observers [ $ key ] ) ; } return $ this ; } | Detach observer . |
56,538 | private function _loadObservers ( ) { $ class = $ this -> name ( ) ; $ name = self :: _configName ( $ class ) ; $ config = Config :: getInstance ( $ name ) ; $ this -> _observers = $ config -> valueOf ( ) ; } | Load observers . |
56,539 | public function getSystemLoadInfo ( ) { $ cpuMemDto = new CpuMemDto ( ) ; $ cpuMemDto = $ this -> getMemFree ( $ cpuMemDto ) ; $ cpuMemDto = $ this -> getCpuIdle ( $ cpuMemDto ) ; return $ cpuMemDto ; } | Get current cpu idle and memory free |
56,540 | public function getPidByPpid ( $ ppid ) { $ commandsDto = new CommandsExecutionDto ( ) ; $ commandsDto -> setCommandName ( CommandsConstants :: GET_PID_BY_PPID ) ; $ commandsDto -> setPid ( $ ppid ) ; return $ this -> getCommandExecutionResult ( $ commandsDto ) ; } | Return PID of the child s process by parent PID |
56,541 | public function write ( string $ filename , string $ contents ) : int { return ( int ) file_put_contents ( $ filename , $ contents ) ; } | Write the given contents to the given file . |
56,542 | public function ls ( string $ path ) : array { $ files = [ ] ; $ d = dir ( $ path ) ; while ( false !== ( $ entry = $ d -> read ( ) ) ) { if ( in_array ( $ entry , [ '.' , '..' ] , true ) ) { continue ; } $ entryPath = $ path . $ entry ; if ( is_dir ( $ entryPath ) ) { foreach ( $ this -> ls ( $ entryPath . DIRECTORY_S... | List all files in a directory and it s subdirectories . |
56,543 | public function qualityFactorComparator ( $ mediaType1 , $ mediaType2 ) { $ diff = $ mediaType2 [ 'q' ] - $ mediaType1 [ 'q' ] ; if ( $ diff > 0 ) { $ diff = 1 ; } elseif ( $ diff < 0 ) { $ diff = - 1 ; } return $ diff ; } | Comparator function for sorting a list of arrays by their q factor . |
56,544 | public function addAsset ( $ name , $ path ) { if ( ! is_file ( $ path ) ) { throw new \ RuntimeException ( 'The asset file "' . $ path . '" does not exist.' ) ; } $ this -> assets [ $ name ] = $ path ; } | Adds an asset . |
56,545 | public function copyTo ( $ path ) { foreach ( $ this -> assets as $ assetName => $ assetPath ) { $ outputPath = $ path . '/' . $ assetName ; $ this -> copyFromTo ( $ assetPath , $ outputPath ) ; } } | Copies all assets to the given path . |
56,546 | private function copyFromTo ( $ from , $ to ) { $ directory = dirname ( $ to ) ; if ( ! is_dir ( $ directory ) ) { mkdir ( $ directory , 0777 , true ) ; } copy ( $ from , $ to ) ; } | Copies a single asset from a path to a path . |
56,547 | private function setInput ( ) { $ this -> inputFile = $ _FILES [ $ this -> field ] [ 'name' ] ; $ this -> inputHash = hash_file ( 'md5' , $ _FILES [ $ this -> field ] [ 'tmp_name' ] ) ; } | Stores input informations |
56,548 | public function handleUpload ( & $ uploader ) { $ this -> uploader = & $ uploader ; $ this -> setInput ( ) ; $ this -> uploader -> setField ( $ this -> field ) ; $ this -> uploader -> setDestination ( sys_get_temp_dir ( ) ) ; foreach ( $ this -> validations as $ validation ) { $ options = isset ( $ validation [ 'option... | Handles an upload |
56,549 | public function text ( $ text ) { if ( false === is_string ( $ text ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ text ) ) , E_USER_ERROR ) ; } $ this -> text = $ text ; return $ this ; } | Set the text of the button |
56,550 | public function getLanguage ( string $ default = null ) : string { $ language = $ default ? : 'en' ; if ( TYPO3_MODE === 'FE' ) { if ( isset ( $ GLOBALS [ 'TSFE' ] -> lang ) ) { $ language = $ GLOBALS [ 'TSFE' ] -> lang ; } } elseif ( is_object ( $ GLOBALS [ 'LANG' ] ) ) { if ( isset ( $ GLOBALS [ 'LANG' ] -> lang ) ) ... | Gets the current language . |
56,551 | public function getLanguageUid ( int $ default = null ) : int { $ languageUid = $ default ? : 0 ; if ( TYPO3_MODE === 'FE' ) { if ( isset ( $ GLOBALS [ 'TSFE' ] -> sys_language_uid ) ) { $ languageUid = $ GLOBALS [ 'TSFE' ] -> sys_language_uid ; } } elseif ( is_object ( $ GLOBALS [ 'LANG' ] ) ) { if ( isset ( $ GLOBALS... | Gets the current language UID . |
56,552 | public function loadSchemaFile ( ) : Schema { if ( ! file_exists ( $ this -> schemaFile ) ) { return new Schema ( ) ; } $ content = file_get_contents ( $ this -> schemaFile ) ; $ desc = Yaml :: parse ( $ content ) ; if ( empty ( $ desc ) ) { return new Schema ( ) ; } $ builder = new SchemaBuilder ( ) ; return $ builder... | Load schema from config file . |
56,553 | public function applySchema ( bool $ strict = false ) : array { $ sqlStatements = $ this -> getMigrationSql ( ) ; foreach ( $ sqlStatements as $ sqlStatement ) { $ this -> connection -> exec ( $ sqlStatement ) ; } if ( $ strict ) { $ reorderSql = $ this -> reorderSql ( ) ; $ sqlStatements = array_merge ( $ sqlStatement... | Alter schema in database according to config file . |
56,554 | public function getSchemaDiff ( bool $ reverseDiff = false ) : SchemaDiff { $ currentSchema = $ this -> getCurrentSchema ( ) ; $ newSchema = $ this -> loadSchemaFile ( ) ; $ comparator = new Comparator ( ) ; if ( $ reverseDiff ) { return $ comparator -> compare ( $ newSchema , $ currentSchema ) ; } else { return $ comp... | Get diff between current schema and config file |
56,555 | public function dumpSchema ( ) { $ schema = $ this -> getCurrentSchema ( ) ; $ normalizer = new SchemaNormalizer ( ) ; $ desc = $ normalizer -> normalize ( $ schema ) ; $ yamlSchema = Yaml :: dump ( [ 'schema' => $ desc ] , 10 , 2 ) ; $ directory = dirname ( $ this -> schemaFile ) ; if ( ! file_exists ( $ directory ) )... | Write current database schema in config file |
56,556 | public function addDocumentType ( $ postValues ) { $ documentTypeObject = DocumentTypeFactory :: createDocumentTypeFromPostValues ( $ postValues ) ; $ documentTypes = $ this -> repository -> documentTypes ; $ documentTypes [ ] = $ documentTypeObject ; $ this -> repository -> documentTypes = $ documentTypes ; $ this -> ... | Add a document type from post values |
56,557 | public function deleteDocumentTypeBySlug ( $ slug ) { $ documentTypes = $ this -> repository -> documentTypes ; foreach ( $ documentTypes as $ key => $ documentTypeObject ) { if ( $ documentTypeObject -> slug == $ slug ) { unset ( $ documentTypes [ $ key ] ) ; } } $ documentTypes = array_values ( $ documentTypes ) ; $ ... | Delete document type |
56,558 | public function getDocumentTypeBySlug ( $ slug , $ getBricks = false ) { $ documentTypes = $ this -> repository -> documentTypes ; foreach ( $ documentTypes as $ documentType ) { if ( $ documentType -> slug == $ slug ) { if ( $ getBricks === true ) { foreach ( $ documentType -> bricks as $ key => $ brick ) { $ brickStr... | Get document type by its slug |
56,559 | public function saveDocumentType ( $ slug , $ postValues ) { $ documentTypeObject = DocumentTypeFactory :: createDocumentTypeFromPostValues ( $ postValues ) ; $ documentTypes = $ this -> repository -> documentTypes ; foreach ( $ documentTypes as $ key => $ documentType ) { if ( $ documentType -> slug == $ slug ) { $ do... | Save changes to a document type |
56,560 | public function addItem ( $ path , $ object = array ( ) , $ class = null ) { $ path = explode ( '/' , $ path ) ; $ object [ 'class' ] = $ class ; $ args = array ( ) ; foreach ( $ path as $ key ) { $ args [ ] = $ key ; $ args [ ] = 'children' ; } $ tree = eden ( 'registry' , $ this -> tree ) ; $ last = count ( $ args ) ... | Adds item to the tree |
56,561 | public function map ( $ modelList ) { $ self = $ this ; return $ this -> wrapInTransaction ( function ( ) use ( $ self , $ modelList ) { forward_static_call ( [ get_class ( $ self -> model ) , 'unguard' ] ) ; $ result = $ self -> mapTree ( $ modelList ) ; forward_static_call ( [ get_class ( $ self -> model ) , 'reguard... | Maps a tree structure into the database . Unguards & wraps in transaction . |
56,562 | public function mapTree ( $ modelList ) { $ tree = $ modelList instanceof Arrayable ? $ modelList -> toArray ( ) : $ modelList ; $ affectedKeys = [ ] ; $ result = $ this -> mapTreeRecursive ( $ tree , $ this -> model -> getKey ( ) , $ affectedKeys ) ; if ( $ result && count ( $ affectedKeys ) > 0 ) $ this -> deleteUnaf... | Maps a tree structure into the database without unguarding nor wrapping inside a transaction . |
56,563 | protected function SaveElement ( ) { $ this -> login -> SetNextUrl ( $ this -> selectorNext -> Save ( $ this -> login -> GetNextUrl ( ) ) ) ; $ this -> login -> SetPasswordUrl ( $ this -> selectorPassword -> Save ( $ this -> login -> GetPasswordUrl ( ) ) ) ; return $ this -> login ; } | Saves the login element and returns it |
56,564 | public function setMinLength ( string $ elementName , int $ minLength , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = sprintf ( __ ( 'ivopetkov.form.The length of this field must be atleast %s characters.' ) , $ minLength ) ; ... | Sets a minimum length requirement for an element |
56,565 | public function setMaxLength ( string $ elementName , int $ maxLength , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = sprintf ( __ ( 'ivopetkov.form.The length of this field must be atmost %s characters.' ) , $ maxLength ) ; }... | Sets a maximum length requirement for an element |
56,566 | public function setEmail ( string $ elementName , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = __ ( 'ivopetkov.form.This is not a valid email address.' ) ; } $ this -> data [ ] = [ 'email' , $ errorMessage , $ elementName ] ;... | Requires the element value to be a valid email address |
56,567 | public function setRegularExpression ( string $ elementName , string $ regularExpression , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = __ ( 'ivopetkov.form.This is not a valid value.' ) ; } $ this -> data [ ] = [ 'regExp' , ... | Performs a regular expression validation |
56,568 | public function validate ( array $ values , array & $ errorsList ) : bool { $ hasErrors = false ; foreach ( $ this -> data as $ item ) { $ type = $ item [ 0 ] ; $ errorMessage = $ item [ 1 ] ; $ elementName = $ item [ 2 ] ; $ value = isset ( $ values [ $ elementName ] ) ? ( string ) $ values [ $ elementName ] : '' ; $ ... | Validates the values passed |
56,569 | public function isDSAffiliate ( $ targetCountyCode ) { $ foundAffiliate = false ; $ affiliates = [ 'GB' , 'UK' , 'CA' , 'ID' , 'BW' , 'KE' , 'GH' , 'NG' , 'CD' , 'BR' , 'MX' , ] ; if ( in_array ( $ targetCountyCode , $ affiliates ) ) { $ affiliateURL = [ 'GB' => 'https://uk.dosomething.org' , 'UK' => 'https://uk.dosome... | Test if country code has a DoSomething affiliate . |
56,570 | public function createNorthstarUser ( $ user ) { $ northstarAPIConfig = $ this -> mbConfig -> getProperty ( 'northstar_config' ) ; if ( empty ( $ northstarAPIConfig [ 'host' ] ) ) { throw new Exception ( 'MB_Toolbox->createNorthstarUser() northstar_config missing host setting.' ) ; } $ requiredSet = false ; if ( ! empt... | Create a user entry in Northstar the DoSomething User API . |
56,571 | public function lookupNorthstarUser ( $ user ) { $ northstarAPIConfig = $ this -> mbConfig -> getProperty ( 'northstar_config' ) ; if ( empty ( $ northstarAPIConfig [ 'host' ] ) ) { throw new Exception ( 'MB_Toolbox->lookupNorthstarUser() northstar_config missing host setting.' ) ; } $ northstarUrl = $ northstarAPIConf... | Lookup user on Northstar . |
56,572 | public function parseNorthstarUserResponse ( $ response ) { if ( ! is_array ( $ response ) || empty ( $ response [ 0 ] ) || empty ( $ response [ 1 ] ) ) { throw new Exception ( '- Unexpected Northstar response:' . var_export ( $ response , true ) ) ; } list ( $ user , $ httpCode ) = $ response ; if ( $ httpCode === 201... | Parse Northstar user response throw exception on failure . |
56,573 | public function cmdGetUser ( ) { $ result = $ this -> getListUser ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableUser ( $ result ) ; $ this -> output ( ) ; } | Callback for user - get command |
56,574 | public function cmdUpdateUser ( ) { $ 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' ) ) ; } $ this -> ... | Callback for user - update command |
56,575 | protected function submitAddUser ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmittedJson ( 'data' ) ; $ this -> validateComponent ( 'user' ) ; $ this -> addUser ( ) ; } | Add a new user at once |
56,576 | protected function addUser ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> user -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new user |
56,577 | protected function wizardAddUser ( ) { $ this -> validatePrompt ( 'email' , $ this -> text ( 'E-mail' ) , 'user' ) ; $ this -> validatePrompt ( 'password' , $ this -> text ( 'Password' ) , 'user' ) ; $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'user' ) ; $ this -> validatePrompt ( 'role_id' , $ this... | Add a new user step by step |
56,578 | public function setStatusUser ( $ status ) { $ options = $ id = $ result = null ; if ( $ this -> getParam ( 'all' ) ) { $ options = array ( ) ; } else { $ id = $ this -> getParam ( 0 ) ; if ( ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } if ( $ this -> getParam ( 'role' ... | Sets a user status |
56,579 | public function setQueueId ( $ id ) { if ( $ id === null ) { $ this -> queueId = null ; return $ this ; } if ( ! is_string ( $ id ) ) { throw new InvalidArgumentException ( 'Queue ID must be a string' ) ; } $ this -> queueId = $ id ; return $ this ; } | Set the queue s ID . |
56,580 | public function initialize ( ) { $ request = $ this -> router -> getAction ( ) ; $ isRouteCallback = $ this -> processRequestParameters ( $ request ) ; $ this -> start ( $ isRouteCallback ) ; return $ this ; } | Calls the proper shell for app execution |
56,581 | protected function processNode ( $ node ) { if ( $ node instanceof DOMDocumentType ) { return '' ; } if ( $ node instanceof DOMText ) { return preg_replace ( "/\\s+/im" , " " , $ node -> wholeText ) ; } $ tag = strtolower ( $ node -> nodeName ) ; if ( in_array ( $ tag , $ this -> ignoredBlockTags ) ) { return '' ; } $ ... | Recursively called method that creates the plain text required for a give tag . |
56,582 | protected function lastTagName ( $ node ) { $ lastNode = $ node -> previousSibling ; while ( $ lastNode != null ) { if ( $ lastNode instanceof DOMElement ) { break ; } $ lastNode = $ lastNode -> previousSibling ; } $ lastTag = '' ; if ( $ lastNode instanceof DOMElement && $ lastNode != null ) { $ lastTag = strtolower (... | Find the previous sibling tag name for this node |
56,583 | protected function nextTagName ( $ node ) { $ nextNode = $ node -> nextSibling ; while ( $ nextNode != null ) { if ( $ nextNode instanceof DOMElement ) { break ; } $ nextNode = $ nextNode -> nextSibling ; } $ nextTag = '' ; if ( $ nextNode instanceof DOMElement && $ nextNode != null ) { $ nextTag = strtolower ( $ nextN... | Find the next sibling tag name for this node |
56,584 | public function getToken ( $ tokenId ) { $ sessionToken = $ this -> sessionDataBag -> get ( $ this -> namespace . '/' . $ tokenId ) ; if ( ! $ sessionToken ) { throw new CsrfTokenException ( sprintf ( "CSRF token with id '%s' not found." , $ tokenId ) ) ; } return $ sessionToken ; } | retrieves token stored in session under namespaced token id |
56,585 | public function setToken ( $ tokenId , CsrfToken $ token ) { if ( ! trim ( ( string ) $ tokenId ) ) { throw new \ InvalidArgumentException ( 'Invalid token id.' ) ; } $ this -> sessionDataBag -> set ( $ this -> namespace . '/' . $ tokenId , $ token ) ; } | store token under namespaced token id in session |
56,586 | public function register ( callable $ callback , $ priority = null ) { $ priority = $ this -> getPriority ( $ priority ) ; if ( ! isset ( $ this -> callbacks [ $ priority ] ) ) { $ this -> callbacks [ $ priority ] = [ ] ; } $ this -> callbacks [ $ priority ] [ ] = $ callback ; $ this -> lowestPriority = max ( $ priorit... | Registers a callback to be called on shutdown . |
56,587 | public function addProcessor ( Processor $ processor , int $ precedence = ProcessChain :: RUN_DEFAULT ) { return $ this -> appendProcessor ( $ processor , static :: STAGE_PROCESS , $ precedence ) ; } | Add a processor to the chain in the PROCESS stage . Any operator in this stage is expected to produce a response . |
56,588 | public function addPostProcessor ( Processor $ processor , int $ precedence = ProcessChain :: RUN_DEFAULT ) { return $ this -> appendProcessor ( $ processor , static :: STAGE_POSTPROCESS , $ precedence ) ; } | Adds a post processor to the pipeline . A postprocessor is a filter that operates on the response rather than producing it . |
56,589 | protected function appendProcessor ( Processor $ processor , int $ stage , int $ precedence = ProcessChain :: RUN_DEFAULT ) { $ stage = WF :: clamp ( $ stage , static :: STAGE_FILTER , static :: STAGE_POSTPROCESS ) ; $ precedence = WF :: clamp ( $ precedence , static :: RUN_FIRST , static :: RUN_LAST ) ; $ this -> proc... | Helper to add a processor to the pipeline |
56,590 | public function getProcessors ( int $ stage ) { $ list = [ ] ; foreach ( $ this -> processors as $ proc ) { if ( $ proc [ 'stage' ] === $ stage ) $ list [ ] = $ proc [ 'processor' ] ; } return $ list ; } | Get a list of processor for a stage |
56,591 | public function process ( Request $ request ) { $ result = new Result ; $ stage = static :: STAGE_FILTER ; foreach ( $ this -> processors as $ processor ) { if ( $ processor [ 'stage' ] < $ stage ) continue ; $ stage = $ processor [ 'stage' ] ; $ processor = $ processor [ 'processor' ] ; try { $ processor -> process ( ... | Process a request - put it through the pipeline and return the response . The request will be routed through each processor until one throws an exception at which point the stage is advanced to the post processing stage . |
56,592 | public function fetchRequestMethod ( $ server = null ) { $ server || $ server = $ this -> _SERVER ; if ( isset ( $ _POST [ '_method' ] ) ) { if ( strtoupper ( $ _POST [ '_method' ] ) == 'PUT' || strtoupper ( $ _POST [ '_method' ] ) == 'PATCH' || strtoupper ( $ _POST [ '_method' ] ) == 'DELETE' ) { return strtoupper ( $... | Fetch the http method |
56,593 | public function parseCliArgs ( $ server = null ) { $ server || $ server = $ this -> _SERVER ; if ( ! isset ( $ server [ 'argv' ] ) ) { throw new \ Exception ( '$_SERVER["argv"] is not available' ) ; } $ args = array_slice ( $ server [ 'argv' ] , 1 ) ; return $ args ? '/' . implode ( '/' , $ args ) : '' ; } | Formats cli args like a uri |
56,594 | public function explodeSegments ( $ uri ) { $ segments = [ ] ; $ pattern = "|/*(.+?)/*$|" ; $ elements = explode ( "/" , preg_replace ( $ pattern , "\\1" , $ uri ) ) ; foreach ( $ elements as $ val ) { $ val = trim ( $ this -> filterUri ( $ val ) ) ; empty ( $ val ) || $ segments [ ] = $ val ; } return $ segments ; } | Explodes the uri string |
56,595 | static function write ( $ filename , $ contents , $ overwriteExisting = true ) { if ( file_exists ( $ filename ) && self :: isWritable ( $ filename ) ) { if ( $ overwriteExisting ) unlink ( $ filename ) ; } file_put_contents ( $ filename , $ contents ) ; } | Create or updates file |
56,596 | static function read ( $ filename ) { if ( file_exists ( $ filename ) && self :: isReadable ( $ filename ) ) { return file_get_contents ( $ filename ) ; } return NULL ; } | Gets the contents of a file |
56,597 | static function rename ( $ src , $ dest ) { if ( self :: exists ( $ dest ) ) { throw new \ Lollipop \ Exception \ Runtime ( 'File already exists: ' . $ dest ) ; } if ( is_uploaded_file ( $ src ) ) { return \ move_uploaded_file ( $ src , $ dest ) ; } return \ rename ( $ src , $ dest ) ; } | Alias rename file |
56,598 | public function isValid ( ) { if ( $ this -> isRequired ( ) ) { if ( $ this -> getValue ( ) == null ) return false ; if ( $ this -> getValue ( ) == "" ) return false ; } return true ; } | Validate value of control |
56,599 | protected function getCompiledAttributes ( $ prependClass = "" , $ skipValue = false ) { $ attrs = "" ; if ( $ this -> id ) $ attrs .= " id='$this->id'" ; $ attrs .= " class='$prependClass $this->class'" ; if ( $ this -> name ) $ attrs .= " name='$this->name'" ; if ( $ this -> placeholder ) $ attrs .= " placeholder='$t... | Compile the HTML attributes for using in the controls tag |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.