idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
50,500
public function set_restrictions ( array $ restrictions ) { $ this -> restrictions = array ( ) ; foreach ( $ restrictions as $ k => $ v ) { switch ( $ k ) { case 'maxsize' : if ( is_int ( $ v ) ) { $ this -> restrictions [ 'maxsize' ] = $ v ; } break ; case 'mediatype' : if ( is_array ( $ v ) ) { $ this -> restrictions...
Set restrictions on file uploads .
50,501
public function validate_upload ( UploadedFile $ file ) { foreach ( $ this -> restrictions as $ k => $ v ) { switch ( $ k ) { case 'maxsize' : if ( $ v < $ file -> get_size ( ) ) { throw new Exception ( 'Received file was too large.' , Exception :: ERR_BAD_REQUEST ) ; } break ; case 'mediatype' : if ( ! in_array ( $ fi...
Validate an UploadedFile object against the list of restrictions .
50,502
public function handleupload ( $ savedir , $ savefilename = null , $ quotadata = array ( ) ) { if ( ! isset ( $ _FILES [ 'pdynfileuploader' ] ) ) { throw new Exception ( 'No file received.' , Exception :: ERR_BAD_REQUEST ) ; } if ( empty ( $ savedir ) || ! is_string ( $ savedir ) ) { throw new Exception ( 'Invalid save...
Receive an uploaded file validate it and save it .
50,503
static function fieldDefs ( $ childs = null ) { $ gname = get_called_class ( ) ; $ key = $ gname . ( $ childs ? '::' . $ childs : '' ) ; if ( key_exists ( $ key , static :: $ fieldDefCache ) ) { return static :: $ fieldDefCache [ $ key ] ; } $ defs = static :: selfFieldDefs ( $ key ) ; foreach ( class_uses ( $ gname ) ...
their traits ) . Caches results for faster lookup .
50,504
static protected function refDefs ( $ childs = null ) { $ gname = get_called_class ( ) ; $ key = $ gname . ( $ childs ? '::' . $ childs : '' ) ; if ( key_exists ( $ key , static :: $ refDefCache ) ) { return static :: $ refDefCache [ $ key ] ; } $ defs = static :: selfRefDefs ( $ key ) ; foreach ( class_uses ( $ gname ...
results for faster lookup .
50,505
static function ownsRef ( $ fname ) { $ refDefs = static :: refDefs ( ) ; $ owns = $ refDefs [ $ fname ] [ static :: OWNS ] ; if ( $ owns === null ) { throw new \ Exception ( "Invalid fname `$fname` called for ownsRef" ) ; } return $ owns ; }
Throws an exception if fname is unrecognized .
50,506
static function gnameForRef ( $ fname ) { $ refDefs = static :: refDefs ( ) ; $ gname = $ refDefs [ $ fname ] [ static :: GNAME ] ; if ( $ gname === null ) { throw new \ Exception ( "Invalid fname `$fname` called for gnameForRef" ) ; } return $ gname ; }
class . Throws an exception if fname is unrecognized .
50,507
function setKey ( $ key ) { $ this -> cnxn -> confirmTransaction ( 'setKey' ) ; $ currKey = $ this -> key ; if ( ! is_null ( $ currKey ) && is_null ( $ key ) ) { $ this -> cnxn -> unregisterStructWithKey ( $ this , $ currKey ) ; } else if ( is_null ( $ currKey ) && ! is_null ( $ key ) ) { $ this -> cnxn -> registerStru...
Subclasses can override to indicate the connection should look for a key when the struct is fetched .
50,508
private function validateTag ( $ tag ) { if ( ! preg_match ( '/[.0-9a-z]{3,3}|[.0-9A-Z]{3,3}/' , $ tag ) ) { throw new InvalidMARCspecException ( InvalidMARCspecException :: FS . InvalidMARCspecException :: FTAG , $ tag ) ; } return true ; }
validate a field tag .
50,509
public function addMethod ( $ name , $ overrideOnDefined = false ) { if ( $ this -> methods -> offsetExists ( $ name ) === true ) { if ( $ overrideOnDefined === false ) { throw Exception \ ClassFile :: methodAlreadyDefined ( $ this -> className , $ name ) ; } $ this -> methods -> offsetUnset ( $ name ) ; } if ( PHPUtil...
Create a new class method
50,510
public function addConstant ( $ name , $ value , $ overrideOnDefined = false ) { if ( $ this -> classConstants -> offsetExists ( $ name ) === true ) { if ( $ overrideOnDefined === false ) { throw Exception \ ClassFile :: constantAlreadyDefined ( $ this -> className , $ name ) ; } $ this -> classConstants -> offsetUnset...
Add a new class constant
50,511
public function addTrait ( $ trait ) { if ( $ this -> isTraitDefined ( $ trait ) === false ) { throw Exception \ Type :: isNotDefined ( $ trait ) ; } $ trait = new Element \ ClassTrait ( $ this , $ trait ) ; $ this -> classTraits -> append ( $ trait ) ; return $ trait ; }
Create a new trait
50,512
public function createSetter ( $ name , $ type = self :: PHP_TYPE_MIXED , $ default = null ) { return $ this -> internalCreateGetterAndOrSetter ( $ name , $ type , $ default , true , false ) ; }
Create property and setter method for the given name
50,513
public function index ( ) { $ this -> data [ 'page' ] -> title = 'Manage Blogs' ; $ this -> data [ 'blogs' ] = $ this -> blog_model -> getAll ( ) ; if ( empty ( $ this -> data [ 'blogs' ] ) ) { if ( ! userHasPermission ( 'admin:blog:blog:create' ) ) { $ status = 'message' ; $ message = '<strong>You don\'t have a blog!<...
Browse existing blogs
50,514
public function edit ( ) { if ( ! userHasPermission ( 'admin:blog:blog:edit' ) ) { unauthorised ( ) ; } $ this -> data [ 'blog' ] = $ this -> blog_model -> getById ( $ this -> uri -> segment ( 5 ) ) ; if ( empty ( $ this -> data [ 'blog' ] ) ) { show404 ( ) ; } $ this -> data [ 'page' ] -> title = 'Manage Blogs &rsaquo...
Edit an existing blog
50,515
public function delete ( ) { if ( ! userHasPermission ( 'admin:blog:blog:delete' ) ) { unauthorised ( ) ; } $ blog = $ this -> blog_model -> getById ( $ this -> uri -> segment ( 5 ) ) ; if ( empty ( $ blog ) ) { $ this -> session -> set_flashdata ( 'error' , 'You specified an invalid Blog ID.' ) ; redirect ( 'admin/blo...
Delete an existing blog
50,516
public static function mayHaveBody ( $ code ) { return ( $ code < self :: HTTP_CONTINUE || $ code >= self :: HTTP_OK ) && $ code != self :: HTTP_NO_CONTENT && $ code != self :: HTTP_NOT_MODIFIED ; }
Returns true for HTTP response codes that may have body .
50,517
public function isValid ( array $ values ) { foreach ( $ values as $ value ) { if ( ! $ this -> checkType ( $ value ) ) { return false ; } } return true ; }
Is the value a valid one?
50,518
protected function setValue ( $ value ) { if ( ! isset ( $ this -> value ) || null === $ this -> value ) { $ this -> value = $ value ; } return $ this ; }
Sets the value of value .
50,519
protected function setValid ( $ valid ) { if ( ! isset ( $ this -> valid ) || true === $ this -> valid ) { $ this -> valid = $ valid ; } return $ this ; }
Sets the value of valid .
50,520
public function validate ( $ value ) { return class_exists ( $ value ) || interface_exists ( $ value ) ? Ok :: unit ( ) : Error :: unit ( [ Error :: CLASS_NOT_EXISTS ] ) ; }
Tells if a given value is a fully qualified class name of an existing php class .
50,521
public function init ( $ config = NULL ) { $ this -> config = $ config ; if ( isset ( $ config [ 'debug' ] ) ) { $ this -> debug = $ config [ 'debug' ] ; } $ this -> log = $ this -> filter ( self :: ON_SET_LOG_FILTER , NULL ) ; $ this -> doAction ( self :: ON_COMPONENT_INIT_ACTION ) ; }
Initialises the component .
50,522
public function addAction ( $ action , $ callback , $ priority = 10 ) { if ( ! isset ( $ this -> actions [ $ action ] ) ) { $ this -> actions [ $ action ] = array ( ) ; } $ this -> actions [ $ action ] [ ] = array ( 'priority' => $ priority , 'callback' => $ callback , ) ; if ( 1 < count ( $ this -> actions [ $ action ...
Add a callback to execute on an action .
50,523
public function removeAction ( $ action , $ callback ) { $ i = 0 ; foreach ( $ this -> actions as $ key => $ value ) { if ( $ action === $ key ) { foreach ( $ value as $ a => $ call ) { if ( get_class ( $ callback [ 0 ] ) === get_class ( $ call [ 'callback' ] [ 0 ] ) ) { if ( $ callback [ 1 ] === $ call [ 'callback' ] ...
Removes a callback for an action .
50,524
public function doAction ( $ action , $ params = array ( ) ) { if ( isset ( $ this -> actions [ $ action ] ) ) { foreach ( $ this -> actions [ $ action ] as $ callback ) { call_user_func_array ( $ callback [ 'callback' ] , $ params ) ; if ( $ this -> debug ) { echo PHP_EOL . '->ACTION: ' . $ action . ' -> ' . $ this ->...
Executes callbacks for an action .
50,525
public function addFilter ( $ filter , $ callback , $ priority = 10 ) { if ( ! isset ( $ this -> filters [ $ filter ] ) ) { $ this -> filters [ $ filter ] = array ( ) ; } $ this -> filters [ $ filter ] [ ] = array ( 'priority' => $ priority , 'callback' => $ callback , ) ; if ( 1 < count ( $ this -> filters [ $ filter ...
Add a callback to execute to filter content .
50,526
public function removeFilter ( $ filter , $ callback ) { $ i = 0 ; foreach ( $ this -> filters as $ key => $ value ) { if ( $ filter === $ key ) { foreach ( $ value as $ f => $ call ) { if ( get_class ( $ callback [ 0 ] ) === get_class ( $ call [ 'callback' ] [ 0 ] ) ) { if ( $ callback [ 1 ] === $ call [ 'callback' ] ...
Removes a callback for a filter .
50,527
public function filter ( $ filter , $ params ) { $ argList = func_get_args ( ) ; array_shift ( $ argList ) ; if ( isset ( $ this -> filters [ $ filter ] ) ) { foreach ( $ this -> filters [ $ filter ] as $ callback ) { $ argList [ 0 ] = call_user_func_array ( $ callback [ 'callback' ] , $ argList ) ; if ( $ this -> debu...
Executes callbacks for a filter and returns the result .
50,528
public static function validIndex ( $ index , $ value ) { if ( is_array ( $ value ) ) { return ( count ( $ value ) > $ index && $ index >= 0 ) ; } elseif ( is_string ( $ value ) ) { return ( strlen ( $ value ) > $ index && $ index >= 0 ) ; } return FALSE ; }
Checks whether the value index position is valid .
50,529
private function _serializeCallback ( $ callback ) { $ retVal = $ callback ; if ( is_array ( $ callback ) && 2 === count ( $ callback ) ) { $ retVal = get_class ( $ callback [ 0 ] ) . '/' . $ callback [ 1 ] ; } return $ retVal ; }
Helper method to serialize a callback .
50,530
public static function read ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return @ file_get_contents ( $ path ) ; }
Read file content from local storage
50,531
public static function executable ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return is_executable ( $ path ) ; }
Check is file executable
50,532
public static function copy ( $ source , $ target ) { $ source = Normalize :: diskFullPath ( $ source ) ; $ target = Normalize :: diskFullPath ( $ target ) ; $ targetArray = explode ( DIRECTORY_SEPARATOR , $ target ) ; array_pop ( $ targetArray ) ; $ targetDir = implode ( DIRECTORY_SEPARATOR , $ targetArray ) ; if ( ! ...
Copy file from source to target destination
50,533
public static function inc ( $ path , $ return = false , $ once = false ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } if ( $ return ) { return $ once === true ? require_once ( $ path ) : require $ path ; } else { ( $ once == true ) ? require_once ( $ path ) : r...
Alternative of functions include require include_once and etc in 1 function
50,534
public static function mTime ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return 0 ; } return filemtime ( $ path ) ; }
Get file make time in unix timestamp
50,535
public static function getMd5 ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return md5_file ( $ path ) ; }
Get file md5 hash
50,536
public function injectView ( $ helper ) { $ view = $ this -> getView ( ) ; if ( null === $ view ) { return ; } $ helper -> setView ( $ view ) ; }
Inject a helper instance with the registered view
50,537
public function generate ( ) { $ session = new Session ( ) ; if ( false === $ session -> has ( '_token' ) ) { $ session -> add ( '_token' , [ ] ) ; } $ name = TokenHash :: create ( 20 , true , true , true ) ; $ value = TokenHash :: create ( 40 , true , true , true ) ; $ session -> add ( '_token' , [ $ name => $ value ]...
Generates a new token and saves it into the session
50,538
public static function Parse ( $ timeDefinition ) { if ( $ timeDefinition instanceof Time ) { return $ timeDefinition ; } if ( $ timeDefinition instanceof DateTime ) { return $ timeDefinition -> getTime ( ) ; } if ( $ timeDefinition instanceof \ DateTime ) { return ( new DateTime ( $ timeDefinition ) ) -> getTime ( ) ;...
Parses a time definition to a \ Beluga \ Date \ Time instance .
50,539
public static function TryParse ( $ timeDefinition , Time & $ refTime ) : bool { if ( $ timeDefinition instanceof Time ) { $ refTime = $ timeDefinition ; return true ; } if ( $ timeDefinition instanceof DateTime ) { $ refTime = $ timeDefinition -> getTime ( ) ; return true ; } if ( $ timeDefinition instanceof \ DateTim...
Tries to parse a time definition to a \ Beluga \ Time instance .
50,540
private function getLength ( $ type = true ) { if ( $ type ) { $ start = $ this -> getCharStart ( ) ; $ end = $ this -> getCharEnd ( ) ; } else { $ start = $ this -> getIndexStart ( ) ; $ end = $ this -> getIndexEnd ( ) ; } if ( is_null ( $ start ) && is_null ( $ end ) ) { return ; } if ( ! is_null ( $ start ) && is_nu...
Calculate the length of charrange or index range .
50,541
private function validateStartEnd ( $ start , $ end ) { $ _startEnd = [ ] ; if ( preg_match ( '/[0-9]/' , $ start ) ) { $ _startEnd [ 0 ] = ( int ) $ start ; } elseif ( '#' === $ start ) { $ _startEnd [ 0 ] = '#' ; } else { throw new InvalidMARCspecException ( InvalidMARCspecException :: PR . InvalidMARCspecException :...
Validate starting and ending position .
50,542
private function validateStartLength ( $ start , $ length ) { $ _startEnd = [ ] ; if ( preg_match ( '/[0-9]/' , $ start ) ) { $ _startEnd [ 0 ] = ( int ) $ start ; } elseif ( '#' === $ start ) { $ _startEnd [ 0 ] = '#' ; } else { throw new \ UnexpectedValueException ( 'First argument must be positive int, 0 or characte...
Validate starting position and length .
50,543
public function changeState ( $ id , $ newState = 0 ) { if ( ! $ object = $ this -> find ( $ id ) ) { return false ; } $ object -> setIsActive ( $ newState ) ; $ this -> save ( $ object ) ; return true ; }
Change the state of a room type
50,544
public function readExtendedMetadata ( $ meta , array & $ config ) { $ tableName = $ meta -> getTableName ( ) ; if ( ! isset ( $ GLOBALS [ 'TL_DCA' ] [ $ tableName ] ) ) { $ this -> loadDataContainer ( $ tableName ) ; } $ dca = ( array ) $ GLOBALS [ 'TL_DCA' ] [ $ tableName ] ; $ fields = ( array ) $ dca [ 'fields' ] ;...
Read extended metadata configuration for a single mapped class
50,545
static function base ( $ url = '' , $ cacheBuster = false ) { $ cacheb = $ cacheBuster ? ( '?' . ( Config :: get ( 'app.version' , '1.0.0' ) ) ) : '' ; $ servern = $ _SERVER [ 'SERVER_NAME' ] ; $ serverp = $ _SERVER [ 'SERVER_PORT' ] ; $ server = $ serverp == '8080' || $ serverp == '80' || $ serverp == '443' ? $ server...
Get base url
50,546
static function redirect ( $ uri ) { if ( ! filter_var ( $ uri , FILTER_VALIDATE_URL ) ) { throw new \ Lollipop \ Exception \ Argument ( 'URL is invalid' , true ) ; } header ( 'location: ' . $ uri ) ; exit ( ) ; }
Redirect page to another urldecode
50,547
public function roomFormAction ( Request $ request ) { $ room = new Room ( ) ; $ this -> currentRoom = $ request -> get ( 'room' ) ; if ( $ this -> currentRoom ) { $ room = $ this -> get ( "ydle.room.manager" ) -> find ( $ request -> get ( 'room' ) ) ; } $ action = $ this -> get ( 'router' ) -> generate ( 'submitRoomFo...
Display a form to create or edit a room
50,548
protected static function splitFirstLine ( $ firstLine ) { $ parts = preg_split ( '/\\s/' , $ firstLine , null , PREG_SPLIT_NO_EMPTY ) ; if ( count ( $ parts ) > 1 ) { return $ parts ; } $ parts = explode ( ',' , $ firstLine ) ; if ( count ( $ parts ) > 1 ) { return $ parts ; } return preg_split ( '/(\\d+\\D*)/' , $ fi...
Tries to split first line into parts
50,549
public static function unload ( ViewModel $ viewmodel ) { if ( true === isset ( static :: $ views [ $ viewmodel -> getIdentifier ( ) ] ) ) { unset ( static :: $ views [ $ viewmodel -> getIdentifier ( ) ] ) ; } }
Unregister existing viewmodel
50,550
public static function output ( ViewModel $ viewmodel ) { $ viewmodel -> assign ( static :: getVariables ( ) ) ; $ template = new Template ( $ viewmodel ) ; $ template -> setDirectory ( Path :: get ( 'cache-template' ) ) ; $ template -> render ( ) ; $ file = $ template -> getFile ( ) -> entity ( ) -> getBasepath ( ) ; ...
Outputs parsed code
50,551
public static function assign ( $ key , $ value = null ) { if ( true === is_array ( $ key ) ) { static :: $ variables = array_merge ( static :: $ variables , $ key ) ; } else { static :: $ variables [ $ key ] = $ value ; } }
Assign variables to the current view
50,552
public function onComplete ( CompleteEvent $ event ) { $ code = ( string ) $ event -> getResponse ( ) -> getStatusCode ( ) ; if ( $ code [ 0 ] === '4' || $ code [ 0 ] === '5' ) { throw RequestException :: create ( $ event -> getRequest ( ) , $ event -> getResponse ( ) ) ; } }
Throw a RequestException on an HTTP protocol error
50,553
public function isPathValid ( ExecutionContextInterface $ context ) { if ( $ this -> getStorage ( ) instanceof Storage && $ this -> getStorage ( ) -> isPathRequired ( ) && ! $ this -> getPath ( ) ) { $ context -> addViolationAt ( 'path' , 'Path is required to fill for current type of storage' ) ; } }
Is valid path for current type .
50,554
public function freez ( Registry $ doctrine ) { $ em = $ doctrine -> getManager ( ) ; if ( $ this -> country ) { $ this -> country = $ em -> getReference ( get_class ( $ this -> country ) , $ this -> country -> getId ( ) ) ; } if ( $ this -> storage ) { $ this -> storage = $ em -> getReference ( get_class ( $ this -> s...
Freeze item .
50,555
public function doClearPath ( ) { if ( $ this -> not_cleared_path && $ this -> getStorage ( ) instanceof Storage && $ this -> getStorage ( ) -> getPath ( ) && strpos ( $ this -> not_cleared_path , $ this -> getStorage ( ) -> getPath ( ) ) === 0 ) { $ this -> path = substr ( $ this -> not_cleared_path , strlen ( $ this ...
Remove storage path in item path .
50,556
public function process ( $ withOutput = false ) { $ it = $ this -> _iterationCount ; if ( ! $ withOutput ) ob_start ( ) ; $ start = Snapshot :: create ( ) ; while ( $ it -- ) { call_user_func_array ( $ this -> _operation , $ this -> _args ) ; } $ end = Snapshot :: create ( ) ; if ( ! $ withOutput ) ob_get_clean ( ) ; ...
Performs the benchmark . At the start and at the end of the procedure call loop it takes a snapshot of PHP background data and returns the difference of both
50,557
protected function setDBParameters ( $ driver , $ host , $ username , $ password , $ database , $ schema = false , $ charset = 'utf8' , $ collation = 'utf8_unicode_ci' , $ options = array ( ) ) { $ this -> DBParameters = [ 'driver' => $ driver , 'host' => $ host , 'username' => $ username , 'password' => $ password , '...
sets database parameters
50,558
public function connectToDB ( ) { if ( $ this -> queryBuilder -> isConnected ( ) ) { return ; } if ( empty ( $ this -> DBParameters ) ) { throw new \ Exception ( 'missing database parameters' ) ; } $ this -> queryBuilder -> connect ( $ this -> DBParameters [ 'driver' ] , $ this -> DBParameters [ 'host' ] , $ this -> DB...
Connects to database
50,559
protected function handleError ( $ exception ) { $ error = $ this -> queryBuilder -> handleQueryException ( $ exception ) ; if ( $ error [ 0 ] && isset ( $ this -> translations [ $ this -> name ] [ $ error [ 0 ] . '_' . $ error [ 1 ] ] ) ) { $ message = $ this -> translations [ $ this -> name ] [ $ error [ 0 ] . '_' . ...
Handles a database error
50,560
protected function walk ( array $ array , $ path = '' ) { foreach ( $ array as $ k => $ v ) if ( ! is_array ( $ v ) || ! ( bool ) count ( array_filter ( array_keys ( $ v ) , 'is_string' ) ) ) $ this -> data [ $ path . $ k ] = $ v ; else $ this -> walk ( $ v , $ path . $ k . '.' ) ; }
Recursively walks over an array to flatten it s keys for faster look up .
50,561
public function get ( $ path , $ def = null ) { if ( $ this -> has ( $ path ) ) return $ this -> data [ $ path ] ; return $ def ; }
Returns the value stored at the given path .
50,562
public function save ( $ file ) { if ( ! is_writable ( dirname ( $ file ) ) ) return false ; $ f = fopen ( $ file , 'w+' ) ; if ( $ f === false ) $ check = false ; else $ check = fwrite ( $ f , $ this -> stringify ( ) ) ; fclose ( $ f ) ; return $ check ; }
Attempts to save the loaded mapping in the given file .
50,563
public function toArray ( ) { $ array = array ( ) ; foreach ( $ this -> data as $ k => $ v ) { $ nodes = explode ( '.' , $ k ) ; $ loc = & $ array ; foreach ( $ nodes as $ i => $ node ) if ( $ i === sizeof ( $ nodes ) - 1 ) $ loc [ $ node ] = $ v ; else if ( ! isset ( $ array [ $ node ] ) ) { $ loc [ $ node ] = array (...
Returns an array contaning the data held by a Yaml instance .
50,564
public static function parse ( $ input , $ typeCheck = false , $ objectSupport = false ) { return new Yaml ( parent :: parse ( $ input , $ typeCheck , $ objectSupport , $ objectForMap ) ) ; }
Parses YAML into a Yaml object .
50,565
protected function getRulesFromField ( FieldInterface $ field ) : array { $ ret = [ ] ; foreach ( $ field -> getRules ( ) as $ rule ) { $ ret [ ] = [ "description" => $ rule -> getDescription ( ) , "errorMessage" => $ rule -> getErrorMessage ( ) , ] ; } return $ ret ; }
Retreive a rules from a field
50,566
public function run ( ) { if ( $ this -> documentor ) { $ this -> documentor -> setMethodData ( $ this -> methods ) ; } $ request_xml = file_get_contents ( 'php://input' ) ; if ( ! $ request_xml ) { if ( ( $ query = $ _SERVER [ 'QUERY_STRING' ] ) && isset ( $ this -> wsdl [ $ query ] ) && $ this -> wsdl [ $ query ] ) {...
Runs the rpc server . Automatically handles an incoming request .
50,567
public function call ( $ method , $ args = null ) { if ( $ this -> methods [ $ method ] ) { $ call = $ this -> methods [ $ method ] [ 'call' ] ; return call_user_func_array ( $ call , $ args ) ; } else { if ( substr ( $ method , 0 , 7 ) == 'system.' ) { if ( $ method == 'system.multiCall' ) { throw new Ripcord_InvalidA...
Calls a method by its rpc name .
50,568
protected function readHeaders ( ) { $ ret = [ ] ; foreach ( $ this -> environment as $ key => $ value ) { if ( strpos ( $ key , "HTTP_" ) === 0 ) { $ key = substr ( $ key , 5 ) ; $ key = strtolower ( $ key ) ; $ key = str_replace ( "_" , "-" , $ key ) ; $ ret [ $ key ] = $ value ; } } return $ ret ; }
Create an array of all headers in the
50,569
protected function parseCookies ( ) : array { $ header = $ this -> getHeader ( "cookie" ) ; if ( empty ( $ header ) ) { return [ ] ; } $ options = $ this -> getDecoderOptions ( ) ; $ collection = new \ sndsgd \ http \ data \ Collection ( $ options -> getMaxVars ( ) , $ options -> getMaxNestingLevels ( ) ) ; foreach ( e...
Parse cookies from the cookie header
50,570
function route ( $ path = '/' , array $ actions = [ ] , $ method = Router :: ANY_METHOD , $ name = '' ) { $ this -> path ( $ path ) ; $ this -> actions [ $ method ] = $ actions ; $ this -> name = $ name ; return $ this ; }
Set route params
50,571
public function connect ( ) { if ( false === $ this -> connection instanceof \ mysqli ) { $ this -> connection = new \ mysqli ( $ this -> data -> host , $ this -> data -> username , $ this -> data -> password , $ this -> data -> db , $ this -> data -> port ) ; if ( $ this -> data -> charset ) { $ this -> connection -> ...
Connect to Mysql server and set charset
50,572
public function fetch ( $ type = null ) { if ( null !== $ type && false === is_string ( $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ query ) ) , E_USER_ERROR ) ; } $ results = new ResultSet ( [ ] , $ type ) ; $ copy = functio...
Returns results from statement as an result set
50,573
public function query ( $ query , $ params = [ ] ) { if ( false === is_string ( $ query ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ query ) ) , E_USER_ERROR ) ; } if ( null !== $ params && false === is_array ( $ params ) ) { return...
Prepare a raw query
50,574
public function multiquery ( $ query , $ params = [ ] ) { if ( true === is_array ( $ query ) ) { $ query = implode ( ";\n" , $ query ) ; } if ( false === is_string ( $ query ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ quer...
Execute a multiquery
50,575
public function escape ( $ data ) { if ( null === $ data ) { return $ data ; } if ( false === is_string ( $ data ) && false === is_numeric ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, float or int, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR )...
Escapes string for statement usage
50,576
public function close ( ) { if ( false === $ this -> connection instanceof \ mysqli ) { return trigger_error ( 'Connection already closed' ) ; } $ this -> connection -> close ( ) ; return $ this ; }
Closes the database connection
50,577
public function getLastErrno ( ) { if ( true === $ this -> connection instanceof \ mysqli ) { $ this -> connect ( ) ; } return $ this -> connection -> errno ; }
Returns the last error number
50,578
public function getLastError ( ) { if ( true === $ this -> connection instanceof \ mysqli ) { $ this -> connect ( ) ; } return $ this -> connection -> error ; }
Returns the last error message
50,579
private function escapeSemicolon ( $ query , $ params ) { preg_match_all ( '#:((?:[a-zA-Z_])(?:[a-zA-Z0-9-_]+)?)#' , $ query , $ variables ) ; if ( true === isset ( $ variables [ 0 ] ) ) { foreach ( $ variables [ 0 ] as $ index => $ variable ) { if ( false === array_key_exists ( $ variables [ 1 ] [ $ index ] , $ params...
Escape variables bind with a semicolon
50,580
private function escapeQuestionmark ( $ query , $ params ) { preg_match_all ( '#([\\\]{0,})(\?)#' , $ query , $ variables ) ; if ( true === isset ( $ variables [ 0 ] ) ) { foreach ( $ variables [ 0 ] as $ index => $ variable ) { if ( strlen ( $ variables [ 1 ] [ $ index ] ) % 2 !== 0 ) { continue ; } if ( false === iss...
Escape variables bind with a question mark
50,581
private function executeStatement ( $ stmt ) { if ( true !== $ stmt -> execute ( ) ) { if ( $ this -> getLastErrno ( ) > 0 ) { return trigger_error ( sprintf ( 'A database error occured with error number "%s" and message: "%s"' , $ this -> getLastErrno ( ) , $ this -> getLastError ( ) ) , E_USER_ERROR ) ; } return fals...
Executes one statement
50,582
private function parse ( & $ params , & $ query ) { if ( 0 !== count ( array_filter ( array_keys ( $ params ) , 'is_string' ) ) ) { preg_match_all ( '#:((?:[a-zA-Z_])(?:[a-zA-Z0-9-_]+)?)#' , $ query , $ variables ) ; if ( true === isset ( $ variables [ 0 ] ) ) { $ parameters = [ ] ; foreach ( $ variables [ 0 ] as $ ind...
Parse parameters and return it with types
50,583
private function bind ( $ stmt ) { $ meta = $ stmt -> result_metadata ( ) ; $ double = [ ] ; $ vars = [ ] ; if ( $ stmt -> field_count > 0 ) { while ( $ field = $ meta -> fetch_field ( ) ) { $ columnname = $ field -> name ; $ { $ columnname } = null ; if ( true === array_key_exists ( $ columnname , $ vars ) ) { $ doubl...
Bind the result to the variables and returns it
50,584
public function registerData ( array $ entityData ) { foreach ( $ entityData as $ data ) { $ this -> registerEntity ( $ this -> normalizer -> denormalize ( $ data , $ this -> entityCollection -> getEntityClass ( ) ) ) ; } }
Register given set of data into datastore .
50,585
public function registerEntity ( CollectionableInterface $ entity ) { if ( ! is_a ( $ entity , $ this -> entityCollection -> getEntityClass ( ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Only "%s" object allowed into "%s" store, "%s" given.' , $ this -> entityCollection -> getEntityClass ( ) , get_class ( ...
Register a new Collectionable entity into datastore .
50,586
public function warmUp ( $ cacheDir ) { $ stepList = $ this -> stepManager -> getStepList ( ) ; if ( null === $ stepList ) { return ; } foreach ( $ stepList as $ stepName => $ step ) { $ stepFinalConfig = $ this -> stepManager -> getResultingConfig ( $ stepName ) ; $ stepFinalConfig = $ this -> stepManager -> normalize...
Writes the workflow proxy cache file .
50,587
public function markEmailAsRead ( $ id ) { $ emailMessage = $ this -> model -> find ( $ id ) ; $ emailMessage -> read = 1 ; return $ emailMessage -> save ( ) ; }
Mark an email as read by setting the read field to true
50,588
public function markEmailAsSent ( $ id ) { $ emailMessage = $ this -> model -> find ( $ id ) ; $ emailMessage -> sent = 1 ; return $ emailMessage -> save ( ) ; }
Mark an email as sent by setting the sent field to true
50,589
public function disc ( string $ storage ) { if ( isset ( $ this -> storage [ $ storage ] ) ) { $ this -> disc = strtolower ( $ storage ) ; return $ this ; } throw new UnknownStorageException ; }
Set default disc storage
50,590
protected function _loop ( ) { if ( ! $ this -> _hasParents ( ) ) { return $ this -> _createIteration ( null , null ) ; } $ parent = & $ this -> _getCurrentIterable ( ) ; $ current = $ this -> _createCurrentIteration ( $ parent ) ; if ( $ current -> getKey ( ) === null ) { return $ this -> _backtrackLoop ( ) ; } if ( !...
Advances the iterator and computes the new state .
50,591
protected function _backtrackLoop ( ) { $ this -> _popParent ( ) ; if ( ! $ this -> _hasParents ( ) ) { return $ this -> _createIteration ( null , null ) ; } $ parent = & $ this -> _getCurrentIterable ( ) ; $ current = $ this -> _createCurrentIteration ( $ parent ) ; next ( $ parent ) ; if ( $ this -> _isMode ( R :: MO...
Backtracks up one parent yielding the parent or resuming the loop whichever is appropriate .
50,592
protected function _pushParent ( & $ parent ) { $ children = & $ this -> _getElementChildren ( $ parent ) ; $ pathSegment = $ this -> _getElementPathSegment ( null , $ parent ) ; $ this -> _pushPathSegment ( $ pathSegment ) ; reset ( $ children ) ; array_unshift ( $ this -> parents , $ children ) ; }
Adds an iterable parent onto the stack .
50,593
protected function _createCurrentIteration ( & $ iterable ) { $ key = $ this -> _getCurrentIterableKey ( $ iterable ) ; $ val = $ this -> _getCurrentIterableValue ( $ iterable ) ; $ path = $ this -> _getCurrentPath ( $ key , $ val ) ; return $ this -> _createIteration ( $ key , $ val , $ path ) ; }
Creates an iteration instance for the current state of a given iterable .
50,594
protected function _getCurrentPath ( $ key , $ value ) { $ path = $ this -> _getPathSegments ( ) ; $ path [ ] = $ this -> _getElementPathSegment ( $ key , $ value ) ; return array_filter ( $ path ) ; }
Retrieves the current path .
50,595
public function sendLogsTo ( LogConsumer $ logConsumer ) { if ( $ logConsumer === $ this ) { throw new LogicException ( 'Operation not allowed' ) ; } while ( ! empty ( $ this -> collectedLogs ) ) { $ log = array_shift ( $ this -> collectedLogs ) ; $ logConsumer -> consumeLog ( $ log [ 'message' ] , $ log [ 'context' ] ...
Send all logs to other LogConsumer . Be aware that logs are removed during this process .
50,596
protected function parseTag ( $ line ) { $ tagAndValue = preg_split ( '/\\s/' , $ line , 2 ) ; $ tag = substr ( $ tagAndValue [ 0 ] , 1 ) ; if ( count ( $ tagAndValue ) > 1 ) { $ this -> tags [ $ tag ] [ ] = trim ( $ tagAndValue [ 1 ] ) ; } else { $ this -> tags [ $ tag ] = [ ] ; } }
Parses a line of a doc comment for a tag and its value . The result is stored in the interal tags array .
50,597
public function parseRequest ( $ message ) { if ( ! ( $ parts = $ this -> parseMessage ( $ message ) ) ) { return false ; } if ( isset ( $ parts [ 'start_line' ] [ 2 ] ) ) { $ startParts = explode ( '/' , $ parts [ 'start_line' ] [ 2 ] ) ; $ protocol = strtoupper ( $ startParts [ 0 ] ) ; $ version = isset ( $ startPart...
Parse an HTTP request message into an associative array of parts .
50,598
public function parseResponse ( $ message ) { if ( ! ( $ parts = $ this -> parseMessage ( $ message ) ) ) { return false ; } list ( $ protocol , $ version ) = explode ( '/' , trim ( $ parts [ 'start_line' ] [ 0 ] ) ) ; return [ 'protocol' => $ protocol , 'protocol_version' => $ version , 'code' => $ parts [ 'start_line...
Parse an HTTP response message into an associative array of parts .
50,599
private function parseMessage ( $ message ) { if ( ! $ message ) { return false ; } $ startLine = null ; $ headers = [ ] ; $ body = '' ; $ lines = preg_split ( '/(\\r?\\n)/' , $ message , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 0 , $ totalLines = count ( $ lines ) ; $ i < $ totalLines ; $ i += 2 ) { $ line = $ l...
Parse a message into parts