idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
6,100
public function AddValidationError ( $ errorMsg = '' , array $ errorMsgArgs = [ ] , callable $ replacingCallable = NULL ) { $ errorMsg = $ this -> translateAndFormatValidationError ( $ errorMsg , $ errorMsgArgs , $ replacingCallable ) ; $ this -> form -> AddError ( $ errorMsg , $ this -> name ) ; return $ this ; }
This INTERNAL method is called from \ MvcCore \ Ext \ Forms \ Field in submit processing . Do not use this method even if you don t develop any form field or field validator .
6,101
protected function translateAndFormatValidationError ( $ errorMsg = '' , array $ errorMsgArgs = [ ] , callable $ replacingCallable = NULL ) { $ customReplacing = $ replacingCallable !== NULL ; $ fieldLabelOrName = '' ; if ( $ this -> translate ) { $ errorMsg = $ this -> form -> Translate ( $ errorMsg ) ; $ fieldLabelOr...
Format form error with given error message containing possible replacements for array values .
6,102
protected function throwNewInvalidArgumentException ( $ errorMsg ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; $ str = '[' . $ selfClass . '] ' . $ errorMsg . ' (' ; if ( $ this -> form ) { $ str .= 'form id: `' . $ this -> form -> GetId ( ) . '`, ' . 'form type: `' . get...
Throw new \ InvalidArgumentException with given error message and append automatically current class name current form id form class type and current field class type .
6,103
public static function SetOverloadFrontend ( $ bStatus = false ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( is_bool ( $ bStatus ) ) $ oThis -> bOverloadFrontend = $ bStatus ; }
Function to set the overload frontend
6,104
public static function Set ( $ sRoute , $ sRequestType = "GET" , $ fCallback ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ oThis -> aRoutes [ $ sRequestType . "_" . strtolower ( $ sRoute ) ] = $ fCallback ; }
Function to route configuration
6,105
public static function RestParams ( $ bReturn = false ) { $ sBuffer = file_get_contents ( "php://input" ) ; $ aParams = explode ( "&" , $ sBuffer ) ; $ aReturn = array ( ) ; foreach ( $ aParams as $ sParam ) { @ list ( $ mKey , $ mValue ) = @ explode ( "=" , $ sParam ) ; $ mValue = urldecode ( $ mValue ) ; if ( ! empty...
Function to return parameters passed by PUT or DELETE methods
6,106
public static function CRUD ( $ sRouteName , $ sController ) { if ( method_exists ( $ sController , "Index" ) ) Routes :: Set ( $ sRouteName , "GET" , $ sController . "::Index" ) ; if ( method_exists ( $ sController , "CRUDInsert" ) ) Routes :: Set ( $ sRouteName , "POST" , array ( $ sController . "::CRUDInsert" , new ...
Function to create default routes CRUD
6,107
protected function getPrompt ( ) { $ prompt = $ this -> application -> getName ( ) . '>> ' ; return $ this -> output -> getFormatter ( ) -> format ( $ prompt ) ; }
Renders a prompt .
6,108
public function get ( $ key = NULL ) { if ( is_null ( $ key ) ) { return $ this -> operationQueue ; } else { if ( ! isset ( $ this -> operationQueue [ $ key ] ) ) { throw new OperationStateException ( "\$key {$key} was not present in the OperationStateManager queue" ) ; } else { return $ this -> operationQueue [ $ key ...
Get the OperationState queue or a single object based on a paseed key
6,109
public function remove ( OperationState $ operation = NULL ) { if ( is_null ( $ operation ) ) { array_pop ( $ this -> operationQueue ) ; return TRUE ; } else { if ( $ this -> isInQueue ( $ operation ) ) { unset ( $ this -> operationQueue [ $ operation -> getKey ( ) ] ) ; return TRUE ; } return FALSE ; } }
Remove an object from the execution queue
6,110
public function executeAll ( ) { $ results = array ( ) ; foreach ( $ this -> operationQueue as $ object ) { $ results [ $ object -> getKey ( ) ] = $ this -> execute ( $ object ) ; } return $ results ; }
Execute all the OperationState objects and return the results of the calls
6,111
public function head ( Request $ request , Fractal $ fractal ) { $ this -> beforeRequest ( $ request , func_get_args ( ) ) ; $ id = $ this -> parseObjectId ( $ request ) ; $ model = $ this -> loadAuthorizeObject ( $ id , 'read' ) ; return $ this -> respondWithEmptyItem ( $ fractal -> createData ( $ this -> getFractalIt...
Check if the object exists
6,112
public function getTransformedValue ( $ value ) { if ( is_scalar ( $ value ) || ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) ) { foreach ( $ this -> regex as $ regex => $ replace ) { if ( preg_match ( $ regex , ( string ) $ value ) ) return preg_replace ( $ regex , $ replace , $ value ) ; } } r...
Transforms the value if it is a string or an object that can be casted into a string .
6,113
public function getUthandoConfig ( ) : array { $ config = [ ] ; $ configFilePattern = join ( '/' , [ $ this -> getModulePath ( ) , $ this -> configDirectory , $ this -> filePattern , ] ) ; foreach ( glob ( $ configFilePattern ) as $ filename ) { $ configFile = include $ filename ; $ config = array_merge ( $ config , $ ...
Get all uthando configs for this module .
6,114
public function getModulePath ( ) : string { $ reflector = new ReflectionClass ( get_class ( $ this ) ) ; $ fn = $ reflector -> getFileName ( ) ; $ directory = dirname ( $ fn ) ; return $ directory ; }
Get the directory the module is in .
6,115
private function _getFilePath ( $ pKey ) { $ keyArr = explode ( static :: SECTION_DELIMITER , $ pKey , 2 ) ; $ fileName = $ keyArr [ 0 ] ; if ( ! isset ( $ this -> _paths [ $ fileName ] ) ) { $ encodedFileName = md5 ( $ fileName ) ; $ this -> _paths [ $ fileName ] = $ this -> _dir . FileData :: getSubPath ( $ encodedFi...
Return the cache file path .
6,116
private function _createFile ( $ pFile ) { $ pathInfo = pathinfo ( $ pFile ) ; $ dir = $ pathInfo [ 'dirname' ] ; if ( ! DirecoryData :: create ( $ dir ) ) { throw new Exception ( "Unable to create the cache directory '$dir'" ) ; } if ( ! is_readable ( $ pFile ) and ! FileData :: create ( $ pFile , self :: DEFAULT_CONT...
Create the requested cache file and directories .
6,117
private function _checkTtl ( $ pFile , $ pKey ) { $ ttl = $ this -> _files [ $ pFile ] [ $ pKey ] [ static :: AGL_CACHE_EXPIRE ] ; if ( $ ttl > 0 and $ ttl < $ this -> _time ) { unset ( $ this -> _files [ $ pFile ] [ $ pKey ] ) ; $ this -> _save ( $ pFile ) ; return false ; } return true ; }
Remove cache entry if expired .
6,118
private function _loadFile ( $ pKey ) { $ file = ( isset ( $ this -> _paths [ $ pKey ] ) ) ? $ this -> _paths [ $ pKey ] : $ this -> _getFilePath ( $ pKey ) ; if ( isset ( $ this -> _files [ $ file ] ) ) { return $ file ; } $ this -> _createFile ( $ file ) ; $ this -> _files [ $ file ] = json_decode ( file_get_contents...
Load the requested cache file and create it if required .
6,119
private function _save ( $ pFile ) { if ( isset ( $ this -> _files [ $ pFile ] ) ) { return FileData :: write ( $ pFile , json_encode ( $ this -> _files [ $ pFile ] ) ) ; } }
Save cache of the specified file .
6,120
public function remove ( $ pKey ) { $ file = $ this -> _loadFile ( $ pKey ) ; if ( isset ( $ this -> _files [ $ file ] [ $ pKey ] ) ) { unset ( $ this -> _files [ $ file ] [ $ pKey ] ) ; $ this -> _save ( $ file ) ; } return $ this ; }
Unset a value from the cache .
6,121
public static function normalize ( $ input ) { $ input = strtolower ( preg_replace_callback ( '@([a-z0-9])(_|\\\\)?([A-Z])@' , function ( $ match ) { return $ match [ 1 ] . '_' . strtolower ( $ match [ 3 ] ) ; } , $ input ) ) ; return trim ( strtolower ( $ input ) , '_' ) ; }
Normalize the inputted string for use in Ornament models .
6,122
public static function modelSaveMethod ( $ object ) { if ( is_object ( $ object ) ) { if ( in_array ( 'Ornament\Model' , class_uses ( $ object ) ) || method_exists ( $ object , 'save' ) ) { return 'save' ; } } return null ; }
Returns the name of the save function if the input is an Ornament - compatible object null otherwise .
6,123
protected function callback ( $ row ) { foreach ( $ this -> getConfig ( 'callbacks' ) as $ column => $ callbacks ) { if ( strpos ( $ column , '/' ) === 0 ) { foreach ( array_keys ( $ row ) as $ name ) { if ( preg_match ( $ column , $ name ) === 1 ) { foreach ( ( array ) $ callbacks as $ callback ) { $ row [ $ name ] = ...
Apply callbacks .
6,124
public function getIterator ( ) { $ csv = fopen ( $ this -> getConfig ( 'file' ) , 'r' ) ; if ( $ csv === false ) { throw new \ RuntimeException ( 'Unable to open file: ' . $ this -> getConfig ( 'file' ) ) ; } while ( true ) { $ fields = fgetcsv ( $ csv , 0 , $ this -> getConfig ( 'delimiter' ) , $ this -> getConfig ( ...
Required by \ IteratorAggregate interface .
6,125
protected function map ( $ fields ) { $ list = [ ] ; if ( count ( $ this -> columns ) !== count ( $ fields ) ) { throw new \ RuntimeException ( 'Column mismatch on line ' . $ this -> line ) ; } foreach ( $ this -> columns as $ column ) { $ list [ $ column ] = array_shift ( $ fields ) ; } return $ list ; }
Map a line s fields to an associative array key according to the headers .
6,126
public function toArray ( $ column = null ) { $ array = [ ] ; foreach ( $ this as $ line ) { if ( $ column === null ) { $ array [ ] = $ line ; } else { $ array [ $ line [ $ column ] ] = $ line ; } } return $ array ; }
Convert the entire CSV file to one big array .
6,127
public function confirm ( string $ confirmationToken ) : bool { if ( $ confirmationToken === $ this -> confirmationToken ) { $ this -> confirmed = true ; $ stmt = $ this -> db -> prepare ( "UPDATE accounts " . "SET confirmation='confirmed' " . "WHERE id=?" ) ; $ stmt -> bind_param ( "i" , $ this -> id ) ; $ stmt -> exe...
Tries to confirm a user s account . This will succeed if the provided confirmationToken is the same as the one in the database .
6,128
public function login ( string $ password ) : bool { if ( ! $ this -> confirmed ) { return false ; } elseif ( $ this -> isLoggedIn ( ) ) { return true ; } elseif ( $ this -> doesPasswordMatch ( $ password ) ) { $ loginToken = $ this -> sessionManager -> login ( ) ; $ _SESSION [ "user_id" ] = $ this -> id ; $ _SESSION [...
Attempts to perform a login with this user . The user account must be confirmed before logging in
6,129
public function isLoggedIn ( ) : bool { if ( isset ( $ _SESSION [ "login_token" ] ) ) { $ loginToken = $ _SESSION [ "login_token" ] ; return $ this -> sessionManager -> isValidLoginToken ( $ loginToken ) ; } else { return false ; } }
Checks if the user is logged in .
6,130
public function generateNewApiKey ( ) : ? string { if ( $ this -> confirmed ) { $ apiKey = bin2hex ( random_bytes ( 64 ) ) ; $ this -> sessionManager -> storeApiKey ( $ apiKey ) ; return $ apiKey ; } else { return null ; } }
Generates a new API key and stores it in the database Previous API keys will be overwritten
6,131
public function resetPassword ( ) : string { $ newPass = bin2hex ( random_bytes ( 20 ) ) ; $ newHash = password_hash ( $ newPass , PASSWORD_BCRYPT ) ; $ stmt = $ this -> db -> prepare ( "UPDATE accounts SET pw_hash=? WHERE id=?;" ) ; $ stmt -> bind_param ( "si" , $ newHash , $ this -> id ) ; $ stmt -> execute ( ) ; $ t...
Resets the password and sets it to a new randomized 20 - character long password .
6,132
public function changeUsername ( string $ newUsername ) : bool { if ( $ this -> isLoggedIn ( ) ) { $ auth = new Authenticator ( $ this -> db ) ; if ( $ auth -> getUserFromUsername ( $ newUsername ) === null ) { $ stmt = $ this -> db -> prepare ( "UPDATE accounts SET username=? WHERE id=?;" ) ; $ stmt -> bind_param ( "s...
Changes the username of a user
6,133
public function changeEmail ( string $ newEmail ) : bool { if ( $ this -> isLoggedIn ( ) ) { $ auth = new Authenticator ( $ this -> db ) ; if ( $ auth -> getUserFromEmailAddress ( $ newEmail ) === null ) { $ stmt = $ this -> db -> prepare ( "UPDATE accounts SET email=? WHERE id=?;" ) ; $ stmt -> bind_param ( "si" , $ n...
Changes the email address of a user
6,134
public function get ( $ index ) { if ( ! isset ( $ this -> config [ $ index ] ) ) { return null ; } return $ this -> config [ $ index ] ; }
Get all configuration for an index
6,135
public function getSettings ( $ index ) { $ config = $ this -> get ( $ index ) ; if ( null === $ config ) { return null ; } if ( ! isset ( $ config [ 'settings' ] ) ) { return [ ] ; } return $ config [ 'settings' ] ; }
Get settings for an index
6,136
public function getMappings ( $ index ) { $ config = $ this -> get ( $ index ) ; if ( null === $ config || ! isset ( $ config [ 'mappings' ] ) ) { return null ; } return $ config [ 'mappings' ] ; }
Get mappings for an index
6,137
public function getMapping ( $ index , $ type ) { $ mappings = $ this -> getMappings ( $ index ) ; if ( ! isset ( $ mappings [ $ type ] ) ) { return null ; } if ( ! isset ( $ mappings [ $ type ] [ 'properties' ] ) ) { return [ ] ; } return $ mappings [ $ type ] [ 'properties' ] ; }
Get mapping for a type
6,138
protected function getTitle ( $ color , TestInterface $ test ) { $ description = "" ; $ test -> forEachNodeTopDown ( function ( TestInterface $ node ) use ( & $ description ) { $ description .= " " . $ node -> getDescription ( ) ; } ) ; return $ this -> color ( $ color , trim ( $ description ) ) ; }
Build a title by navigating a test s tree
6,139
public static function _sendCacheHeaders ( $ expire = 5 ) { if ( ! is_numeric ( $ expire ) || $ expire < 1 || $ expire > 240 ) { $ expire = 5 ; _Log :: warn ( "Attempt to send cache headers with invalid expiration" ) ; } header ( "Cache-Control: public" ) ; header ( "Expires: " . gmdate ( "D, d M Y H:i:s" , time ( ) + ...
Sends headers to cache for the specified number of MINUTES
6,140
public static function _sendHTTPStatusCode ( $ code , $ customDescription = FALSE ) { if ( ! preg_match ( '/\d\d\d/' , $ code ) ) { _Log :: warn ( "Invalid status code: $code - Using default '200 OK' response" ) ; $ code = 200 ; } if ( $ customDescription === FALSE ) { $ description = isset ( _WebResponseIncludes :: $ ...
Sends the HTTP status code
6,141
protected function Init ( ) { $ fieldset = ContentFieldset :: Schema ( ) -> ByContent ( $ this -> Content ( ) ) ; $ this -> id = $ this -> CssID ( ) ; $ this -> classes = $ this -> CssClass ( ) ; $ this -> legend = $ fieldset -> GetLegend ( ) ; return parent :: Init ( ) ; }
Initialzes the fieldset module
6,142
public function getParser ( ) { if ( ! isset ( $ this -> parser ) ) { $ this -> parser = new Parser ( $ this ) ; } return $ this -> parser ; }
Get a parser for this standard .
6,143
protected function _setDefaults ( ) { $ defaults = [ 'authenticate' => [ 'Form' => [ 'finder' => 'auth' , 'userModel' => 'Community.Users' , 'fields' => [ 'username' => 'login' , 'password' => 'password' ] , ] ] , 'flash' => [ 'key' => 'auth' , 'element' => 'error' , 'params' => [ 'class' => 'error' ] ] , 'loginAction'...
Sets defaults for configs .
6,144
public static function setLanguage ( $ language ) { if ( preg_match ( '/[a-z]{1,8}(-[a-z0-9]{1,8})*/i' , $ language ) === 1 ) { self :: $ language = $ language ; } else { trigger_error ( 'Invalid language tag: ' . $ language , E_USER_WARNING ) ; } }
Set current language .
6,145
public static function load ( Locale $ locale , $ extend = true ) { if ( ! isset ( self :: $ locale ) ) { self :: $ locale = $ locale ; } else { self :: $ locale -> extend ( $ locale ) ; } }
Load a localization .
6,146
public static function loadFrom ( $ dir , $ extend = true ) { $ file = $ dir . '/' . self :: $ language . '.' ; if ( isset ( self :: $ cache ) ) { $ cached = self :: $ cache -> getItem ( $ file ) ; if ( $ cached -> isHit ( ) ) { $ value = $ cached -> get ( ) ; if ( is_array ( $ value ) ) { $ localization = new Locale (...
Load a localization for the current language from a directory .
6,147
public static function nget ( $ plural , $ singular , $ number ) { $ args = func_get_args ( ) ; return call_user_func_array ( array ( self :: getLocale ( ) , 'nget' ) , $ args ) ; }
Translate a string containing a numeric value .
6,148
public static function number ( $ number , $ decimals = 0 ) { $ l = self :: getLocale ( ) ; return number_format ( $ number , $ decimals , $ l -> decimalPoint , $ l -> thousandsSep ) ; }
Format a number using the preferred decimal point and thousands separator .
6,149
public static function formatTime ( $ timestamp = null , $ style = 'short' ) { $ property = $ style . 'Time' ; return self :: date ( self :: getLocale ( ) -> $ property , $ timestamp ) ; }
Format time using preferred locale format .
6,150
public static function formatDate ( $ timestamp = null , $ style = 'short' ) { $ property = $ style . 'Date' ; return self :: date ( self :: getLocale ( ) -> $ property , $ timestamp ) ; }
Format date using preferred locale format .
6,151
public static function formatDateTime ( $ timestamp = null , $ style = 'short' ) { $ property = $ style . 'DateTime' ; return self :: date ( self :: getLocale ( ) -> $ property , $ timestamp ) ; }
Format date and time using preferred locale format .
6,152
public static function longDate ( $ timestamp = null ) { $ l = self :: getLocale ( ) ; return self :: date ( $ l -> shortDateTime , $ timestamp ) ; }
Format a timestamp using preferred long format .
6,153
public static function shortDate ( $ timestamp = null ) { $ l = self :: getLocale ( ) ; $ cYear = date ( 'Y' ) ; $ date = date ( 'Y-m-d' , $ timestamp ) ; if ( date ( 'Y-m-d' ) == $ date ) { return I18n :: get ( 'Today %1' , self :: formatTime ( $ timestamp ) ) ; } elseif ( date ( 'Y-m-d' , strtotime ( 'yesterday' ) ) ...
Format a timestamp using a short style .
6,154
public static function isValidUrl ( $ path ) { if ( Strings :: startsWith ( $ path , [ '#' , '//' , 'mailto:' , 'tel:' , 'http://' , 'https://' ] ) ) { return true ; } return filter_var ( $ path , FILTER_VALIDATE_URL ) !== false ; }
Check if Url is valid .
6,155
public static function root ( $ secure = null ) { $ framework = '/public/index.php' ; $ server = request ( 'PHP_SELF' , '' , 'server' ) ; $ scheme = ( is_null ( $ secure ) ? request ( 'REQUEST_SCHEME' , '' , 'server' ) : ( $ secure ? 'https' : 'http' ) ) . '://' ; $ serverName = request ( 'SERVER_NAME' , '' , 'server' ...
Get the app rooted url .
6,156
public static function run ( ) { if ( $ _SERVER [ 'argc' ] < 2 ) { self :: helpAction ( ) ; exit ( ) ; } $ method = $ _SERVER [ 'argv' ] [ 1 ] . 'Action' ; if ( method_exists ( static :: getCurrentClass ( ) , $ method ) ) { $ params = $ _SERVER [ 'argv' ] ; array_shift ( $ params ) ; array_shift ( $ params ) ; call_use...
Bootstrap of the controller
6,157
protected static function displayError ( $ errorMessage , $ displayHelp = false , $ exit = true ) { echo "\n " . self :: red ( ) . 'Error: ' . self :: resetColor ( ) . $ errorMessage . "\n" ; if ( $ displayHelp ) { self :: helpAction ( ) ; } else { echo "\n" ; } if ( $ exit ) { exit ( 1 ) ; } }
Display an error .
6,158
protected static function helpAction ( ) { $ class = new \ ReflectionClass ( static :: getCurrentClass ( ) ) ; $ methods = $ class -> getMethods ( ) ; $ commands = array ( ) ; $ comments = array ( ) ; $ commandLen = 0 ; foreach ( $ methods as $ method ) { $ methodName = ( string ) $ method -> getName ( ) ; if ( substr ...
Display this message
6,159
public static function beginActionMessage ( string $ message , int $ lineLen = 80 ) : string { return sprintf ( "- " . self :: blue ( ) . "%'.-" . ( $ lineLen - 11 ) . "s" . self :: resetColor ( ) , $ message . ' ' ) ; }
New action message need to be ended by a endActionXxx method
6,160
public function requireDefaultRecords ( ) { parent :: requireDefaultRecords ( ) ; $ pages = SiteTree :: get ( ) ; if ( $ pages -> count ( ) > 0 ) { $ count = 0 ; foreach ( $ pages as $ page ) { if ( $ page -> OpenGraphData == null ) { $ page -> OpenGraphData = json_encode ( self :: $ OpenGraphProtocol ) ; $ page -> wri...
Require Default Records
6,161
public function MarkupOpenGraph ( $ property , $ content , $ encode = false ) { if ( $ encode ) $ content = htmlentities ( $ content , ENT_QUOTES , $ this -> owner -> Charset ) ; return '<meta property="' . $ property . '" content="' . $ content . '" />' . PHP_EOL ; }
Returns markup for an Open Graph meta element .
6,162
public function beforePrepare ( Event $ event ) { $ command = $ event [ 'command' ] ; $ operation = $ command -> getOperation ( ) ; $ client = $ command -> getClient ( ) ; if ( $ command -> getName ( ) !== 'createEntity' ) return ; if ( $ command [ 'collection' ] !== 'files' && $ client -> getCollectionName ( ) !== 'fi...
Add parameters Kinvey needs to properly process the file .
6,163
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; if ( $ model -> isAuthor ) { if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'article' , 'Article updated.' ) ) ; return $ this -> ...
Updates an existing Article model . If update is successful the browser will be redirected to the view page .
6,164
protected function updateFavicon ( $ new , $ old ) { $ this -> removeFile ( $ old ) ; $ new = $ this -> addFile ( $ new , 'settings/favicon.%2$s' ) ; $ this -> setSetting ( 'faviconType' , $ this -> getMime ( $ new ) ) ; return $ new ; }
Update favicon setting
6,165
protected function updateLogo ( $ new , $ old ) { $ this -> removeFile ( $ old ) ; $ new = $ this -> addFile ( $ new , 'settings/logo.%2$s' ) ; $ this -> setSetting ( 'logoType' , $ this -> getMime ( $ new ) ) ; return $ new ; }
Update logo setting
6,166
private function detectFlags ( $ argument ) { if ( ( substr ( $ argument , 0 , 2 ) === '--' ) && ( ! strpos ( $ argument , '=' ) ) ) { $ this -> flags -> push ( ltrim ( $ argument , '--' ) ) ; return true ; } return false ; }
Detects and sets flag type arguments .
6,167
private function detectConcatFlag ( $ argument ) { if ( substr ( $ argument , 0 , 1 ) === '-' ) { for ( $ i = 1 ; isset ( $ argument [ $ i ] ) ; $ i ++ ) { $ this -> flags -> push ( $ argument [ $ i ] ) ; } return true ; } return false ; }
Detects and sets concatenated flag type arguments .
6,168
private function detectOptions ( $ argument ) { if ( substr ( $ argument , 0 , 2 ) === '--' ) { $ name = substr ( $ argument , 2 ) ; $ value = '' ; if ( strpos ( $ name , '=' ) ) { list ( $ name , $ value ) = explode ( '=' , $ argument , 2 ) ; } $ this -> options -> put ( ltrim ( $ name , '-' ) , trim ( $ value , '"' )...
Detects and sets option type arguments .
6,169
public function requiredOptions ( $ options = [ ] ) { if ( ! count ( $ options ) ) { return true ; } foreach ( $ options as $ option ) { if ( ! $ this -> options ( ) -> get ( $ option ) ) { return false ; } } return true ; }
Checks that an array of options have been set at runtime .
6,170
protected function validate ( InputInterface $ input ) { $ host = $ input -> getArgument ( 'host' ) ? $ input -> getArgument ( 'host' ) : null ; $ ip = $ input -> hasArgument ( 'ip' ) ? $ input -> getArgument ( 'ip' ) : null ; $ this -> hostFile -> validate ( $ host , $ ip ) ; }
shortcut to run hostFile validation with all inputs .
6,171
public static function getSettings ( $ package , $ setting = null ) { $ package_ = preg_replace ( '/\/|\\\\/' , "." , $ package ) ; $ settings = SettingsCache :: getInstance ( ) -> getData ( $ package_ ) ; if ( $ settings === NULL ) { $ packageConfigFile = self :: getConfigFile ( $ package ) ; $ settings = json_decode ...
this method retrieves settings of a package settings are saved as config . json file in package root directory
6,172
public function render ( $ template , $ data = null ) { if ( substr ( $ template , - 5 ) != '.twig' ) { $ template .= '.twig' ; } $ env = $ this -> getInstance ( ) ; $ parser = $ env -> loadTemplate ( $ template ) ; return $ parser -> render ( $ this -> all ( ) , $ data ) ; }
Render Twig Template
6,173
protected function parseOrder ( ) { if ( ! isset ( $ this -> parts [ 'order' ] ) || ! is_array ( $ this -> parts [ 'order' ] ) || count ( $ this -> parts [ 'order' ] ) < 1 ) { return false ; } $ orderParts = [ ] ; foreach ( $ this -> parts [ 'order' ] as $ itemOrder ) { if ( $ itemOrder ) { if ( ! is_array ( $ itemOrde...
Parses ORDER BY entries
6,174
public function process ( \ SS_HTTPRequest $ request ) { $ identifier = $ request -> param ( 'Processor' ) ; return $ this -> outputHandler -> process ( $ identifier , $ this , $ this -> inputHandler -> process ( $ identifier , $ request ) ) ; }
Process the request to the controller and direct it to the correct input and output controllers via the input and output processor services .
6,175
public static function ini ( ) { $ files = glob ( static :: path ( ) . '*.php' ) ; foreach ( $ files as $ file ) { $ table = need ( $ file ) ; foreach ( $ table as $ key => $ value ) { $ file = static :: getFileName ( $ file ) ; self :: $ links [ $ file ] [ $ key ] = $ value ; } } }
Initiate the Links surface .
6,176
public static function get ( $ key ) { exception_if ( ! array_has ( self :: $ links , $ key ) , LinkKeyNotFoundException :: class , $ key ) ; return array_get ( self :: $ links , $ key ) ; }
Get the link by dotted key .
6,177
public static function set ( $ key , $ value ) { $ segements = dot ( $ key ) ; if ( count ( $ segements ) == 2 ) { self :: $ links [ $ segements [ 0 ] ] [ $ segements [ 1 ] ] = $ value ; } else { exception ( LogicException :: class , 'The link surface doesn\'t support many indexes' ) ; } }
Set a new link value in runtime .
6,178
protected function loadMetadataFor ( $ value ) { $ definitions = $ this -> getDefinitions ( ) ; foreach ( $ definitions as $ name => $ options ) { if ( $ value == $ options [ 'type' ] ) { $ definition = $ options ; break ; } } if ( ! isset ( $ definition ) ) { throw new NoSuchMetadataException ( sprintf ( 'No metadata ...
Loads metadata for a given type
6,179
public function getDefinitions ( ) { if ( false !== $ this -> definitions ) { return $ this -> definitions ; } $ config = $ this -> metadataLoader -> load ( $ this -> resource , $ this -> resourceType ) ; if ( null === $ config ) { return [ ] ; } return $ this -> definitions = $ config ; }
Returns the metadata definitions
6,180
public function register ( $ user , $ token ) { return $ this -> to ( $ user [ 'email' ] ) -> subject ( 'Please confirm your email' ) -> template ( 'Users.welcome' ) -> layout ( false ) -> set ( [ 'username' => $ user [ 'username' ] , 'token' => $ token , ] ) -> emailFormat ( 'html' ) ; }
Email sent on registration
6,181
public function canAuthenticate ( \ TYPO3 \ Flow \ Security \ Authentication \ TokenInterface $ authenticationToken ) { $ canAuthenticate = parent :: canAuthenticate ( $ authenticationToken ) ; if ( $ canAuthenticate && $ authenticationToken -> isAuthenticated ( ) ) { try { $ this -> touchSessionIfNeeded ( $ authentica...
This method is overridden to touch the global session if needed
6,182
protected function touchSessionIfNeeded ( SingleSignOnToken $ token ) { $ currentTime = time ( ) ; if ( $ currentTime - $ token -> getLastTouchTimestamp ( ) > $ this -> globalSessionTouchInterval ) { $ ssoClient = $ this -> ssoClientFactory -> create ( ) ; $ ssoServer = $ this -> createSsoServer ( ) ; $ sessionId = $ t...
Touches the global session on the server to synchronize expiration between clients and the server
6,183
protected function createSsoServer ( ) { if ( ! isset ( $ this -> options [ 'server' ] ) ) { throw new Exception ( 'Missing "server" option for SingleSignOnProvider authentication provider "' . $ this -> name . '". Please specifiy one using the providerOptions setting.' , 1351690847 ) ; } $ ssoServer = $ this -> ssoSer...
Create an SSO server instance from the provider options
6,184
public static function encode ( String $ str ) : String { $ chars = self :: $ numericalCodes ; return str_replace ( array_keys ( $ chars ) , array_values ( $ chars ) , $ str ) ; }
Encode Foreign Char
6,185
public function selectAll ( $ limit = 0 ) { $ stmt = $ this -> pdo -> prepare ( <<<EOTSELECT t1.*, t2.ProjectId AS "Project.ProjectId", t2.Name AS "Project.Name", t2.Description AS "Project.Description", t2.Created AS "Project.Created" FROM `$this->tableName` AS t1 LEFT JOIN Projects AS t2 ON t1.ProjectId = t2.Proje...
Select all records .
6,186
public function selectRecentActivities ( $ limit ) { $ stmt = $ this -> pdo -> prepare ( <<<EOTSELECT t1.*, t2.ProjectId AS "Project.ProjectId", t2.Name AS "Project.Name", t2.Description AS "Project.Description", t2.Created AS "Project.Created"FROM `$this->tableName` AS t1 LEFT JOIN Projects AS t2 ON t1.ProjectId = t2...
Select recent activities .
6,187
public function selectRunningActivity ( ) { $ stmt = $ this -> pdo -> prepare ( <<<EOTSELECT t1.*, t2.ProjectId AS "Project.ProjectId", t2.Name AS "Project.Name", t2.Description AS "Project.Description", t2.Created AS "Project.Created"FROM `$this->tableName` AS t1 LEFT JOIN Projects AS t2 ON t1.ProjectId = t2.ProjectI...
Select currently running activity .
6,188
public function selectActivitiesForInterval ( $ dateFrom , $ dateTo ) { $ stmt = $ this -> pdo -> prepare ( <<<EOTSELECT t1.*, t2.ProjectId AS "Project.ProjectId", t2.Name AS "Project.Name", t2.Description AS "Project.Description", t2.Created AS "Project.Created"FROM `$this->tableName` AS t1 LEFT JOIN Projects AS t2 O...
Select activities which was started in given interval .
6,189
public function stopRunningActivity ( ) { $ runningActivity = $ this -> selectRunningActivity ( ) ; if ( ! ( $ runningActivity instanceof ActivityEntity ) ) { return false ; } $ nowObj = new \ DateTime ( 'now' ) ; $ nowStr = $ nowObj -> format ( \ DateTime :: RFC3339 ) ; $ activityId = $ runningActivity -> getActivityI...
Stops currently running activity .
6,190
public function parseEntities ( $ entities , AutoTablesConfiguration $ config ) { $ entityList = array ( ) ; foreach ( $ entities as $ entity ) { $ entityList [ ] = $ this -> parseEntity ( $ entity , $ config ) ; } return $ entityList ; }
Inspects the given entities and returns a list of Entity objects for each of them .
6,191
public function parseEntity ( $ entity , AutoTablesConfiguration $ config ) { $ entityDescriptor = $ entityDescriptor = $ this -> fetchEntityDescriptor ( $ config ) ; $ columns = array ( ) ; foreach ( $ entityDescriptor -> getColumnDescriptors ( ) as $ columnDescriptor ) { $ columns [ ] = new Column ( $ columnDescripto...
Inspects the given entity and returns an Entity object for it .
6,192
public function initializeEntity ( $ entity , AutoTablesConfiguration $ config ) { $ entityDescriptor = $ this -> fetchEntityDescriptor ( $ config ) ; foreach ( $ entityDescriptor -> getColumnDescriptors ( ) as $ column ) { if ( $ column -> getInitializer ( ) ) { $ value = null ; if ( $ column -> getInitializer ( ) -> ...
Executes any initializer configured for the given entity .
6,193
public function fetchCrudService ( AutoTablesConfiguration $ config ) { if ( $ config -> getServiceId ( ) ) { $ this -> logger -> info ( sprintf ( 'Create CrudService from serviceId [%s]' , $ config -> getServiceId ( ) ) ) ; $ crudService = $ this -> get ( $ config -> getServiceId ( ) ) ; Ensure :: isNotNull ( $ crudSe...
Returns the CrudService according to the given config .
6,194
public function setValue ( $ entity , $ columnDescriptorId , $ value , AutoTablesConfiguration $ config ) { Ensure :: isNotNull ( $ entity , 'entity musst not be null' ) ; $ columnDescriptor = $ this -> getColumnDescriptor ( $ entity , $ columnDescriptorId , $ config ) ; if ( $ columnDescriptor -> getType ( ) == 'datet...
Updates the specified value in the given entity .
6,195
public function fetchEntityDescriptor ( AutoTablesConfiguration $ config ) { $ reflClass = new \ ReflectionClass ( $ this -> fetchCrudService ( $ config ) -> getEntityClassName ( ) ) ; $ entityDescriptor = util :: array_get ( $ this -> entityDescriptorMap [ $ reflClass -> getName ( ) ] ) ; if ( ! $ entityDescriptor ) {...
Returns the EntityDescriptor for the class found in the config .
6,196
public function delete ( $ key ) { if ( ! $ this -> exists ( $ key ) ) { return false ; } unset ( $ this -> data [ $ key ] ) ; return true ; }
Deletes an individual key from the cache
6,197
public function generateHeader ( ) { $ format = 'Rounds="%s", App="%s", Nonce="%s", Token="%s", Realm="%s", User="%s"' ; $ expiresAt = null ; if ( $ this -> getExpiresAt ( ) ) { $ format = $ format . ', ExpiresAt="%s"' ; $ expiresAt = $ this -> getExpiresAt ( ) -> format ( \ DateTime :: ATOM ) ; } return sprintf ( $ fo...
Generates authorization header
6,198
public function generateParameter ( ) { $ parts = array ( '' , self :: PREFIX_ROUNDS . $ this -> getRounds ( ) , self :: PREFIX_APP . $ this -> getApp ( ) , self :: PREFIX_NONCE . $ this -> getNonce ( ) , self :: PREFIX_TOKEN . $ this -> getToken ( ) , self :: PREFIX_REALM . $ this -> getRealm ( ) , self :: PREFIX_USER...
Generates authorization parameter
6,199
public function fromAbstract ( $ tokenAbstract ) { $ re = "/(~" . self :: PREFIX_APP . "|~" . self :: PREFIX_NONCE . "|~" . self :: PREFIX_TOKEN . "|~" . self :: PREFIX_REALM . ")/m" ; if ( preg_match_all ( $ re , $ tokenAbstract , $ matches ) == 4 ) { $ token = $ this -> fromParameter ( $ tokenAbstract ) ; } else { $ ...
Gets token from Abstract