idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
3,800
protected function searchCorrectMenuEntryInArray ( $ menuEntries ) { foreach ( $ menuEntries as $ key => $ menuEntry ) { if ( trim ( $ menuEntry -> getTarget ( ) , '/' ) === trim ( $ this -> framework -> getRequest ( ) -> getRoute ( ) , '/' ) ) { return $ menuEntry ; } if ( $ menuEntry -> hasChildren ( ) ) { $ menuEntr...
Iterates trough an array and searches the needed menu entry . If found return the menu entry otherwise return false .
3,801
protected function validateModel ( ) { if ( ! is_string ( $ this -> model ) ) { $ baseName = $ this -> getControllerBaseName ( ) ; $ this -> findModelClass ( $ baseName ) ; } }
Validate the existence of the controller s corresponding model or determine the model based on the controller s name .
3,802
protected function getControllerBaseName ( ) { $ controllerName = get_called_class ( ) ; $ controllerNameComponents = explode ( '\\' , $ controllerName ) ; $ baseName = array_pop ( $ controllerNameComponents ) ; $ baseName = substr ( $ baseName , 0 , strrpos ( $ baseName , 'Controller' ) ) ; return $ baseName ; }
Determine the Controller s base name
3,803
protected function configureOutputLimit ( ) { if ( $ this -> request -> input ( 'only' ) ) { $ only = explode ( ',' , $ this -> request -> input ( 'only' ) ) ; $ validator = app ( 'validator' ) -> make ( [ 'only' => $ only ] , [ 'only' => 'array|in:data,meta' ] ) ; if ( $ validator -> failed ( ) ) { $ this -> respondWi...
Limit what s returned
3,804
protected function configureOutputFormat ( ) { $ requestFormat = $ this -> request -> input ( 'format' ) ; $ this -> format = config ( 'transfugio.http.format' ) ; if ( $ this -> request -> wantsJson ( ) ) { $ this -> format = 'json_accept' ; } if ( in_array ( $ requestFormat , [ 'json' , 'xml' , 'yaml' , 'html' ] ) ) ...
Configure the output format
3,805
public static function convertAlphabets ( $ base64 ) { $ base64 = rtrim ( $ base64 , '=' ) ; return strtr ( $ base64 , self :: BASE64_ALPHABET , self :: ALPHABET ) ; }
Convert Base64 string to BCrypt string
3,806
public static function createSalt ( ) { $ salt = Random :: createString ( self :: SALT_START_LENGTH ) ; $ base64 = base64_encode ( $ salt ) ; $ salt = self :: convertAlphabets ( $ base64 ) ; return Binary :: getSlice ( $ salt , 0 , self :: SALT_FINAL_LENGTH ) ; }
Creates a salt
3,807
public function methodChanged ( ) : void { assert ( $ this -> offsetExists ( self :: VAR_LINE_METHOD ) ) ; if ( self :: METHOD_POST === $ this -> offsetGet ( self :: VAR_LINE_METHOD ) ) { $ this -> offsetSet ( self :: VAR_BODY , null ) ; if ( $ this -> offsetExists ( self :: VAR_PARSED_POST ) && is_null ( $ this -> off...
Remove method - specific attributes .
3,808
protected function create_color ( & $ image , $ hex , $ alpha ) { extract ( $ this -> create_hex_color ( $ hex ) ) ; if ( $ hex == null ) { $ alpha = 127 ; } else { $ alpha = 127 - floor ( $ alpha * 1.27 ) ; } return imagecolorallocatealpha ( $ image , $ red , $ green , $ blue , $ alpha ) ; }
Creates a new color usable by GD .
3,809
protected function create_transparent_image ( $ width , $ height , $ resource = null ) { $ image = imagecreatetruecolor ( $ width , $ height ) ; $ bgcolor = $ this -> config [ 'bgcolor' ] == null ? '#000' : $ this -> config [ 'bgcolor' ] ; $ color = $ this -> create_color ( $ image , $ bgcolor , 0 ) ; imagesavealpha ( ...
Creates a new transparent image .
3,810
protected function round_corner ( & $ image , $ radius , $ antialias , $ top , $ left ) { $ this -> debug ( "Rounding " . ( $ top ? 'top' : 'bottom' ) . " " . ( $ left ? 'left' : 'right' ) . " corner with a radius of " . $ radius . "px." ) ; $ sX = $ left ? - $ radius : 0 ; $ sY = $ top ? - $ radius : 0 ; $ eX = $ left...
Creates a rounded corner on the image .
3,811
protected function image_merge ( & $ image , $ watermark , $ x , $ y , $ alpha ) { $ wsizes = $ this -> sizes ( $ watermark ) ; $ tmpimage = $ this -> create_transparent_image ( $ wsizes -> width , $ wsizes -> height ) ; imagecopy ( $ tmpimage , $ image , 0 , 0 , $ x , $ y , $ wsizes -> width , $ wsizes -> height ) ; i...
Merges to images together using a fix for transparency
3,812
public function addRecipient ( $ recipient ) { if ( is_string ( $ recipient ) ) { $ recipient = new Recipient ( $ recipient ) ; } elseif ( ! $ recipient instanceof Recipient ) { throw new \ InvalidArgumentException ( '$recipient must be a string or an instance of Recipient.' ) ; } $ this -> recipients [ ] = $ recipient...
Add a message recipient .
3,813
public function setSender ( $ sender ) { if ( is_string ( $ sender ) ) { $ sender = new Sender ( $ sender ) ; } elseif ( ! $ sender instanceof Sender ) { throw new \ InvalidArgumentException ( '$sender must be a string or an instance of Sender.' ) ; } $ this -> sender = $ sender ; return $ this ; }
Set message sender .
3,814
static function log ( $ msg , $ path = "" ) { if ( empty ( $ path ) ) { $ path = MF_FILES_DIR ; } if ( ! is_string ( $ msg ) ) { $ msg = print_r ( $ msg , true ) ; } $ fp = fopen ( $ path . 'magic_fields.log' , 'a+' ) ; $ date = gmdate ( 'Y-m-d H:i:s' ) ; fwrite ( $ fp , "$date - $msg\n" ) ; fclose ( $ fp ) ; }
Writes log info to a file
3,815
public function unserialize ( $ serialized ) { $ s = unserialize ( $ serialized ) ; $ this -> defaults = $ s [ 0 ] ; $ this -> custom = $ s [ 1 ] ; $ this -> merge ( ) ; }
Unserializes the object
3,816
public function remove ( $ k ) { if ( array_key_exists ( $ k , $ this -> custom ) ) { unset ( $ this -> custom [ $ k ] ) ; $ this -> merge ( ) ; return true ; } return false ; }
Removes a custom configuration item
3,817
public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { $ this -> custom [ ] = $ value ; $ this -> merge ( ) ; } else { $ this -> set ( $ offset , $ value ) ; } }
Sets a custom config item
3,818
public function offsetUnset ( $ offset ) { if ( array_key_exists ( $ offset , $ this -> custom ) ) { unset ( $ this -> custom [ $ offset ] ) ; $ this -> merge ( ) ; } }
Removes a custom config item key
3,819
public function compareVersions ( $ version1 , $ version2 ) { $ versions = $ this -> getVersions ( ) ; $ key1 = array_search ( $ version1 , $ versions ) ; $ key2 = array_search ( $ version2 , $ versions ) ; if ( $ key1 === false || $ key2 === false ) { return 0 ; } return $ key1 - $ key2 ; }
Compares two versions .
3,820
public function getDiff ( $ version , $ current = null ) { if ( ! in_array ( $ version , $ this -> getVersions ( ) , true ) ) { throw new \ UnexpectedValueException ( "Invalid log entry $version for {$this->path}." ) ; } $ diff = \ Arbit \ VCSWrapper \ Cache \ Manager :: get ( $ this -> path , $ version , 'diff' ) ; if...
Returns the diff between two different versions .
3,821
protected function setError ( $ ifile , $ iline , $ line , $ token , $ payload = null ) { $ this -> last_error = array ( 'ifile' => $ ifile , 'iline' => $ iline , 'line' => $ line , 'token' => $ token , 'payload' => $ payload ) ; }
Set parser error .
3,822
public function getTokenName ( $ token ) { return ( isset ( $ this -> names [ $ token ] ) ? $ this -> names [ $ token ] : $ token ) ; }
Return name of the token or token value if name could not be resolved .
3,823
public function tokenize ( $ in , $ line = 1 , $ file = '' ) { $ out = array ( ) ; $ mem = $ in ; while ( strlen ( $ in ) > 0 ) { foreach ( $ this -> tokens as $ token => $ regexp ) { if ( preg_match ( '/^(' . $ regexp . ')/' , $ in , $ m ) ) { if ( ! in_array ( $ token , $ this -> ignore ) ) { $ out [ ] = array ( 'tok...
String tokenizer .
3,824
public function object ( string $ key , callable $ closure ) { $ this -> checkKey ( $ key ) ; $ this -> definitions [ 'instance' ] [ $ key ] = $ closure ; }
Add an object definition .
3,825
public function factory ( string $ key , callable $ closure ) { $ this -> checkKey ( $ key ) ; $ this -> definitions [ 'factory' ] [ $ key ] = $ closure ; }
Add a factory definition .
3,826
public function instance ( string $ key , $ object ) { $ this -> checkKey ( $ key ) ; $ this -> definitions [ 'instance' ] [ $ key ] = true ; $ this -> store [ $ key ] = $ object ; }
Add an instance definition .
3,827
public function store ( string $ key , $ object ) { if ( isset ( $ this -> aliases [ $ key ] ) ) { $ key = $ this -> aliases [ $ key ] ; } $ this -> store [ $ key ] = $ object ; }
Boots up an object and stores .
3,828
public function hasObject ( string $ key ) { if ( isset ( $ this -> definitions [ 'instance' ] [ $ key ] ) ) { return true ; } if ( isset ( $ this -> aliases [ $ key ] ) ) { return isset ( $ this -> definitions [ 'instance' ] [ $ this -> aliases [ $ key ] ] ) ; } return false ; }
Checks if the given key has an object definition .
3,829
public function hasStored ( string $ key ) { if ( isset ( $ this -> store [ $ key ] ) ) { return true ; } if ( isset ( $ this -> aliases [ $ key ] ) ) { return isset ( $ this -> store [ $ this -> aliases [ $ key ] ] ) ; } return false ; }
Checks if the given key has already been booted and stored .
3,830
public function getDefinition ( $ key ) { if ( isset ( $ this -> definitions [ 'instance' ] [ $ key ] ) ) { return $ this -> definitions [ 'instance' ] [ $ key ] ; } return $ this -> definitions [ 'instance' ] [ $ this -> aliases [ $ key ] ] ; }
Returns a raw object definition .
3,831
public function getStored ( string $ key ) { if ( isset ( $ this -> store [ $ key ] ) ) { return $ this -> store [ $ key ] ; } return $ this -> store [ $ this -> aliases [ $ key ] ] ; }
Returns a stored object .
3,832
public function getFactory ( string $ key ) { if ( isset ( $ this -> definitions [ 'factory' ] [ $ key ] ) ) { return $ this -> definitions [ 'factory' ] [ $ key ] ; } return $ this -> definitions [ 'factory' ] [ $ this -> aliases [ $ key ] ] ; }
Returns a booted factory definition .
3,833
public function remove ( string $ key ) { if ( isset ( $ this -> aliases [ $ key ] ) ) { $ alias = $ key ; $ key = $ this -> aliases [ $ key ] ; unset ( $ this -> aliases [ $ alias ] ) ; } if ( $ this -> hasFactory ( $ key ) ) { unset ( $ this -> definitions [ 'factory' ] [ $ key ] ) ; $ this -> removeAliasFor ( $ key ...
Removes a given key and all data from the storage .
3,834
public function removeAlias ( $ alias ) { if ( isset ( $ this -> aliases [ $ alias ] ) ) { unset ( $ this -> aliases [ $ alias ] ) ; return true ; } return false ; }
Remove just an alias or binding leaving the object and key intact .
3,835
protected function removeAliasFor ( $ key ) { $ aliases = \ array_keys ( $ this -> aliases , $ key ) ; if ( ! empty ( $ aliases ) ) { foreach ( $ aliases as $ alias ) { unset ( $ this -> aliases [ $ alias ] ) ; } } }
Remove all aliases for a given key .
3,836
protected function checkKey ( string $ key ) { if ( ! \ class_exists ( $ key ) ) { throw new InvalidKeyException ( "Key [$key] was invalid. All keys must be valid class names" ) ; } if ( $ this -> hasObject ( $ key ) || $ this -> hasFactory ( $ key ) ) { throw new KeyExistsException ( "Key [$key] already exists within ...
Performs some safety checks on a key when adding to the container .
3,837
public function addFile ( $ options ) { if ( is_string ( $ options ) ) { $ options = [ 'target' => $ options ] ; } elseif ( ! is_array ( $ options ) ) { throw new Exception \ InvalidArgumentException ( 'Invalid options to rename filter provided' ) ; } $ this -> _convertOptions ( $ options ) ; return $ this ; }
Adds a new file or directory as target to the existing ones
3,838
public function getNewName ( $ value , $ source = false ) { $ file = $ this -> _getFileName ( $ value ) ; if ( ! is_array ( $ file ) ) { return $ file ; } if ( $ file [ 'source' ] == $ file [ 'target' ] ) { return $ value ; } if ( ! file_exists ( $ file [ 'source' ] ) ) { return $ value ; } if ( $ file [ 'overwrite' ] ...
Returns only the new filename without moving it But existing files will be erased when the overwrite option is true
3,839
protected function _convertOptions ( $ options ) { $ files = [ ] ; foreach ( $ options as $ key => $ value ) { if ( is_array ( $ value ) ) { $ this -> _convertOptions ( $ value ) ; continue ; } switch ( $ key ) { case "source" : $ files [ 'source' ] = ( string ) $ value ; break ; case 'target' : $ files [ 'target' ] = ...
Internal method for creating the file array Supports single and nested arrays
3,840
protected function _getFileName ( $ file ) { $ rename = [ ] ; foreach ( $ this -> files as $ value ) { if ( $ value [ 'source' ] == '*' ) { if ( ! isset ( $ rename [ 'source' ] ) ) { $ rename = $ value ; $ rename [ 'source' ] = $ file ; } } if ( $ value [ 'source' ] == $ file ) { $ rename = $ value ; break ; } } if ( !...
Internal method to resolve the requested source and return all other related parameters
3,841
public function readLine ( bool $ removeNewlines = true , bool $ fast = false ) { if ( ! $ fast ) { if ( ! $ this -> isOpen ( ) ) { return false ; } if ( ! $ this -> hasReadAccess ( ) ) { throw FileAccessException :: Read ( $ this -> file , \ sprintf ( 'Current mode of opened file is "%s" and not read!' , $ this -> acc...
Reads the next line and returns it .
3,842
public function readChar ( bool $ fast = false ) { if ( ! $ fast ) { if ( ! $ this -> isOpen ( ) ) { return false ; } if ( ! $ this -> hasReadAccess ( ) ) { throw FileAccessException :: Read ( $ this -> file , \ sprintf ( 'Current mode of opened file is "%s" and not read!' , $ this -> access ) ) ; } } try { if ( \ feof...
Reads the next char and returns it .
3,843
public function readCsv ( string $ delimiter = ',' , int $ maxLineLength = 1024 , bool $ fast = false ) { if ( ! $ fast ) { if ( ! $ this -> isOpen ( ) ) { return false ; } if ( ! $ this -> hasReadAccess ( ) ) { throw FileAccessException :: Read ( $ this -> file , \ sprintf ( 'Current mode of opened file is "%s" and no...
Reads a CSV row and returns it .
3,844
public function readToEnd ( bool $ getLines = false , bool $ removeNewlines = true , bool $ fast = false ) { if ( ! $ fast ) { if ( ! $ this -> isOpen ( ) ) { return false ; } if ( ! $ this -> hasReadAccess ( ) ) { throw FileAccessException :: Read ( $ this -> file , \ sprintf ( 'Current mode of opened file is "%s" and...
Reads all from current pointer to EOF .
3,845
public function writeLine ( string $ str , string $ newline = "\n" , bool $ fast = false ) : bool { if ( ! $ fast ) { if ( ! $ this -> isOpen ( ) ) { return false ; } if ( ! $ this -> hasWriteAccess ( ) ) { throw FileAccessException :: Write ( $ this -> file , \ sprintf ( 'Current mode of opened file is "%s" and not wr...
Writes a a string to current file with a trailing linebreak .
3,846
public function close ( ) { if ( ! \ is_resource ( $ this -> fp ) ) { return ; } \ fclose ( $ this -> fp ) ; $ this -> fp = null ; if ( $ this -> access == static :: ACCESS_WRITE || $ this -> access == static :: ACCESS_READWRITE ) { if ( ! \ is_null ( $ this -> mode ) && '\\' !== DIRECTORY_SEPARATOR ) { \ chmod ( $ thi...
Closes the current file pointer .
3,847
public static function ZipList ( array $ sourceFiles , string $ zipFile , string $ zipFolderName = null ) { if ( ! \ class_exists ( '\\ZipArchive' ) ) { throw new IOException ( $ zipFile , '\UK\IO\File::ZipList() fails with no ZIP-Support.' ) ; } $ oldFile = null ; if ( \ file_exists ( $ zipFile ) ) { $ oldFile = $ zip...
Compresses multiple files in a ZIP archive file .
3,848
public static function getCurrencySymbol ( $ isocode ) { return empty ( self :: $ currencySymbols [ $ isocode ] ) ? $ isocode : self :: $ currencySymbols [ $ isocode ] ; }
Returns the currency symbol based on the currency ISO 4217 code .
3,849
public function toggle ( $ force = null ) { $ this -> active = ( null === $ force ? ! $ this -> active : $ force ) ; }
Toggles this model s state
3,850
public static function convert ( $ data ) { if ( is_object ( $ data ) and method_exists ( $ data , '__toArray' ) ) { return $ data -> __toArray ( ) ; } elseif ( is_object ( $ data ) ) { $ array = array ( ) ; foreach ( get_class_vars ( $ data ) as $ var => $ val ) { $ array [ $ var ] = $ val ; } return $ array ; } elsei...
Converts the given data to an array .
3,851
public static function removeKeys ( $ array , $ keys ) { foreach ( $ array as $ key => $ value ) { if ( ! is_numeric ( $ key ) and in_array ( $ key , $ keys ) ) { unset ( $ array [ $ key ] ) ; continue ; } $ array [ $ key ] = is_array ( $ value ) ? static :: removeKeys ( $ value , $ keys ) : $ value ; } return $ array ...
Removes the specified keys from the array .
3,852
public static function load ( $ file = false , $ data = false ) { if ( $ file && ! Text :: contains ( $ file , '.php' ) ) { $ file .= '.php' ; } $ path = DOC_ROOT . Config :: get ( 'paths' , 'modules' ) ; if ( $ file && File :: isFile ( $ path . $ file ) ) { require $ path . $ file ; return true ; } return false ; }
Load a given view .
3,853
public static function js ( $ file = false ) { if ( $ file && ! Text :: contains ( $ file , '.js' ) ) { $ file .= '.js' ; } $ path = DOC_ROOT . Config :: get ( 'paths' , 'js' ) ; if ( $ file && File :: isFile ( $ path . $ file ) ) { echo '<script>' ; require $ path . $ file ; echo '</script>' ; return true ; } return f...
Load a given JavaScript file .
3,854
public static function json ( $ input = false , $ exit = true ) { if ( $ input ) { echo Format :: toJson ( $ input ) ; if ( $ exit ) { exit ( ) ; } } return false ; }
Echo JSON and exit .
3,855
protected function createAndFill ( array $ attributes ) { $ entityClass = static :: makes ( ) ; $ entity = new $ entityClass ; foreach ( $ attributes as $ attribute => $ value ) { $ entity -> $ attribute = $ value ; } return $ entity ; }
Create a new entity instance and return it filled with attributes
3,856
public function getError ( $ key = false ) { if ( ! $ key ) { return $ this -> errorMessages ; } if ( $ this -> hasError ( $ key ) ) { return $ this -> errorMessages [ $ key ] ; } return false ; }
Return the error array from the last validation run .
3,857
public function validate ( array $ input , array $ ruleset ) { $ this -> errors = array ( ) ; foreach ( $ ruleset as $ field => $ rules ) { $ rules = explode ( '|' , $ rules ) ; if ( in_array ( 'required' , $ rules ) || ( isset ( $ input [ $ field ] ) && trim ( $ input [ $ field ] ) != '' ) ) { foreach ( $ rules as $ r...
Perform data validation against the provided ruleset .
3,858
public function filter ( array $ input , array $ filterset ) { foreach ( $ filterset as $ field => $ filters ) { if ( ! array_key_exists ( $ field , $ input ) ) { continue ; } $ filters = explode ( '|' , $ filters ) ; foreach ( $ filters as $ filter ) { $ params = null ; if ( strstr ( $ filter , ',' ) !== false ) { $ f...
Filter the input data according to the specified filter set .
3,859
protected function validate_integer ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! filter_var ( $ input [ $ field ] , FILTER_VALIDATE_INT ) ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTION_...
Determine if the provided value is a valid integer .
3,860
protected function validate_float ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! filter_var ( $ input [ $ field ] , FILTER_VALIDATE_FLOAT ) ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTION_...
Determine if the provided value is a valid float .
3,861
protected function validate_url_exists ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } $ url = parse_url ( strtolower ( $ input [ $ field ] ) ) ; if ( isset ( $ url [ 'host' ] ) ) { $ url = $ url [ 'host' ] ; } if ( function_exists ( 'checkdn...
Determine if a URL exists & is accessible .
3,862
protected function validate_iban ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } $ character = array ( 'A' => 10 , 'C' => 12 , 'D' => 13 , 'E' => 14 , 'F' => 15 , 'G' => 16 , 'H' => 17 , 'I' => 18 , 'J' => 19 , 'K' => 20 , 'L' => 21 , 'M' => ...
Determine if the provided value is a valid IBAN .
3,863
public function setHash ( string $ hash ) : self { $ this -> hash = ( string ) hex2bin ( $ hash ) ; return $ this ; }
Sets the hash of the icon .
3,864
public function getImage ( ) : string { if ( is_resource ( $ this -> image ) ) { $ this -> image = ( string ) stream_get_contents ( $ this -> image ) ; } return $ this -> image ; }
Returns the actual image data .
3,865
public static function __ ( $ short , $ chunks ) { $ translated = self :: _ ( $ short ) ; foreach ( $ chunks as $ k => $ v ) { $ translated = str_replace ( '%' . $ k . '%' , $ v , $ translated ) ; } return $ translated ; }
Function to get language translated string and replace the
3,866
public function key ( $ reset = false ) { static $ key ; $ key = $ reset ? false : $ key ; if ( ! $ key ) { $ key = $ this -> instance -> get ( 'memcached_adapter_namespace' , function ( $ memc , $ key , & $ value ) { $ value = bin2hex ( openssl_random_pseudo_bytes ( 8 ) ) ; return true ; } ) ; } return $ key ; }
Get the value of a namespace key .
3,867
public function validateConnectionId ( $ attribute , $ params ) { $ db = \ Yii :: app ( ) -> getComponent ( $ this -> connectionId ) ; if ( $ db === null || ! ( $ db instanceof \ CDbConnection ) ) { $ this -> addError ( 'connectionId' , 'A valid database connection is required to run this generator.' ) ; } }
Validates the connection id for this generator .
3,868
public function validateTableName ( $ attribute , $ params ) { if ( $ this -> hasErrors ( ) ) { return ; } $ invalidTables = array ( ) ; $ invalidColumns = array ( ) ; if ( $ this -> tableName [ strlen ( $ this -> tableName ) - 1 ] === '*' ) { if ( ( $ pos = strrpos ( $ this -> tableName , '.' ) ) !== false ) { $ schem...
Validates the table name for this generator .
3,869
protected function getTableSchema ( $ tableName ) { $ connection = \ Yii :: app ( ) -> getComponent ( $ this -> connectionId ) ; return $ connection -> schema -> getTable ( $ tableName , $ connection -> schemaCachingDuration !== 0 ) ; }
Returns the table schema for a specific table .
3,870
public function hydrate ( $ value ) { if ( $ value === '' || $ value === null ) { return ; } if ( $ this -> timezone ) { $ hydrated = $ this -> useImmutable ? \ DateTimeImmutable :: createFromFormat ( $ this -> format , $ value , $ this -> timezone ) : \ DateTime :: createFromFormat ( $ this -> format , $ value , $ thi...
Converts date time string to DateTime instance for injecting to object
3,871
public function get ( ) { $ rows = [ ] ; foreach ( $ this -> db as $ key => $ value ) { $ rows [ ] = ( object ) [ 'key' => $ key , 'value' => is_string ( $ value ) ? $ value : print_r ( $ value , true ) , ] ; } return $ rows ; }
Return the entire dataset of the underlying database .
3,872
public static function isValidHtml ( $ value ) { return ( true === self :: isValidHtmlName ( $ value ) ) || ( true === self :: isValidHtmlValue ( $ value ) ) ; }
Checks whether the specified value is a valid CSS color .
3,873
private function executeEagerLoad ( $ models = array ( ) , $ attrs = array ( ) , $ includes = array ( ) ) { if ( ! is_array ( $ includes ) ) $ includes = array ( $ includes ) ; foreach ( $ includes as $ index => $ name ) { if ( is_array ( $ name ) ) { $ nestedIncludes = count ( $ name ) > 0 ? $ name : $ name [ 0 ] ; $ ...
Executes an eager load of a given named relationship for this table .
3,874
public function getRelationship ( $ name , $ strict = false ) { if ( $ this -> hasRelationship ( $ name ) ) return $ this -> _relationships [ $ name ] ; if ( $ strict ) throw new RelationshipException ( "Relationship named $name has not been declared for class: {$this->class->getName()}" ) ; return null ; }
Retrieve a relationship object for this table . Strict as true will throw an error if the relationship name does not exist .
3,875
private function mapNames ( & $ hash , & $ map ) { $ ret = array ( ) ; foreach ( $ hash as $ name => & $ value ) { if ( array_key_exists ( $ name , $ map ) ) $ name = $ map [ $ name ] ; $ ret [ $ name ] = $ value ; } return $ ret ; }
Replaces any aliases used in a hash based condition .
3,876
public function validateUsername ( $ username = null ) { if ( $ username === null ) { $ username = $ this -> _username ; } if ( strlen ( $ username ) === 0 ) { return true ; } $ status = @ preg_match ( '/^(?:' . $ this -> _regex [ 'escaped' ] . '|[' . self :: CHAR_ALNUM . self :: CHAR_MARK . ';:&=+$,' . '])+$/' , $ use...
Returns true if and only if the username passes validation . If no username is passed then the username contained in the instance variable is used .
3,877
public function setHost ( $ host ) { if ( $ this -> validateHost ( $ host ) === false ) { throw new Zend_Uri_Exception ( "Host \"$host\" is not a valid HTTP host" ) ; } $ oldHost = $ this -> _host ; $ this -> _host = $ host ; return $ oldHost ; }
Sets the host for the current URI and returns the old host
3,878
public function validateQuery ( $ query = null ) { if ( $ query === null ) { $ query = $ this -> _query ; } if ( strlen ( $ query ) === 0 ) { return true ; } $ pattern = '/^' . $ this -> _regex [ 'uric' ] . '*$/' ; $ status = @ preg_match ( $ pattern , $ query ) ; if ( $ status === false ) { throw new Zend_Uri_Exceptio...
Returns true if and only if the query string passes validation . If no query is passed then the query string contained in the instance variable is used .
3,879
public function setQuery ( $ query ) { $ oldQuery = $ this -> _query ; if ( empty ( $ query ) === true ) { $ this -> _query = '' ; return $ oldQuery ; } if ( is_array ( $ query ) === true ) { $ query = http_build_query ( $ query , '' , '&' ) ; } else { $ query = ( string ) $ query ; if ( $ this -> validateQuery ( $ que...
Set the query string for the current URI and return the old query string This method accepts both strings and arrays .
3,880
public static function redirect ( $ location , $ permanent = false ) { $ redirect = new static ( $ permanent ? 301 : 302 ) ; $ redirect -> setHeader ( 'Location' , $ location ) ; return $ redirect ; }
Create redirect response
3,881
public function load ( $ class ) { if ( static :: exist ( $ class ) ) return true ; else { $ class = ltrim ( $ class , '\\' ) ; $ path = explode ( '\\' , $ class ) ; $ name = array_pop ( $ path ) ; foreach ( $ this -> definition as $ namespace => list ( $ directory , $ length ) ) { if ( strpos ( $ class , $ namespace )...
Import class files based on the class name and the namespace
3,882
protected function search ( $ name , $ path , $ root ) { $ path = ltrim ( implode ( DIRECTORY_SEPARATOR , $ path ) . DIRECTORY_SEPARATOR , DIRECTORY_SEPARATOR ) ; if ( $ this -> read ( $ name , $ path , $ root ) ) return true ; else { $ tmp = $ this -> explode ( $ name ) ; foreach ( $ tmp as $ name ) if ( $ this -> rea...
Find the class file and load it
3,883
protected function explode ( $ name ) { $ result = [ ] ; $ buffer = '' ; $ counter = 0 ; for ( $ uppercase = ctype_upper ( $ name { 0 } ) , $ count = strlen ( $ name ) , $ i = 0 ; $ i < $ count ; ++ $ i ) { $ character = $ name { $ i } ; if ( $ character == '_' ) return [ ] ; else if ( ! is_numeric ( $ character ) ) { ...
Split the class name into subclassnames through the camel or TitleCase . The full classname is not included in the result array
3,884
public static function exist ( $ name ) { return class_exists ( $ name , false ) || interface_exists ( $ name , false ) || trait_exists ( $ name ) ; }
Check for class interface or trait existance
3,885
public function initialize ( ) { if ( null !== $ this -> menus ) { return ; } $ this -> menus = [ ] ; foreach ( $ this -> getMenuDefinitions ( ) as $ name => $ itemData ) { if ( isset ( $ itemData [ '.menu_class_name' ] ) ) { $ menuClass = $ itemData [ '.menu_class_name' ] ; unset ( $ itemData [ '.menu_class_name' ] ) ...
Initialize the menus defined in the menuDefinitions .
3,886
public function getMenu ( $ name = 'default' ) { $ this -> initialize ( ) ; if ( ! isset ( $ this -> menus [ $ name ] ) ) { throw new MenuDoesNotExistException ( sprintf ( 'Menu %s does not exist' , $ name ) ) ; } return $ this -> menus [ $ name ] ; }
Get a menu by name
3,887
public static function hash ( $ string ) { $ salt = self :: createSalt ( ) ; return self :: PREFIX . $ salt . '$' . self :: createSubHash ( $ string , $ salt ) ; }
Hash a string
3,888
public static function verify ( $ string , $ hash ) { $ pattern = '~^' . preg_quote ( self :: PREFIX ) . '(?<salt>[A-Za-z0-9\./]{8})\$(?<sub>[A-Za-z0-9\./]+)$~is' ; if ( ! preg_match ( $ pattern , $ hash , $ matches ) ) { return false ; } return ( $ matches [ 'sub' ] === self :: createSubHash ( $ string , $ matches [ '...
Verifies a string hash
3,889
public static function createSalt ( ) { $ alphabet = self :: ALPHABET ; $ length = strlen ( $ alphabet ) ; $ salt = [ ] ; for ( $ i = 0 ; $ i < self :: SALT_LENGTH ; $ i ++ ) { $ index = mt_rand ( 0 , $ length - 1 ) ; $ salt [ ] = substr ( $ alphabet , $ index , 1 ) ; } return implode ( '' , $ salt ) ; }
Creates a random salt
3,890
public static function createSubHash ( $ string , $ salt ) { $ context = self :: createContext ( $ string , $ salt ) ; $ null = chr ( 0 ) ; $ hash = '' ; for ( $ i = 0 ; $ i < self :: HASH_COUNT_STEPS ; $ i ++ ) { $ k = $ i + 6 ; $ j = $ i + 12 ; if ( $ j === 16 ) { $ j = 5 ; } $ hash = $ context [ $ i ] . $ context [ ...
Creates a hash for a string and a salt
3,891
public function remove ( $ key ) { if ( isset ( $ this -> fields [ $ key ] ) ) { unset ( $ this -> fields [ $ key ] ) ; } return $ this ; }
Removes a field key from the definition .
3,892
protected function newBaseQueryBuilder ( ) { $ conn = $ this -> getConnection ( ) ; $ grammar = $ conn -> getQueryGrammar ( ) ; return new MbDatabaseQueryBuilder ( $ conn , $ grammar , $ conn -> getPostProcessor ( ) ) ; }
New base query builder
3,893
public final static function createSchemaModel ( $ deleteIfExists = false ) { $ model = new static ( ) ; if ( ! MbMigration :: schema ( ) -> hasTable ( $ model -> getTable ( ) ) ) { MbMigration :: schema ( ) -> create ( $ model -> getTable ( ) , function ( Blueprint $ table ) use ( $ model ) { $ table -> engine = 'Inno...
Call createSchema when activating deactivating or uninstalling plugin
3,894
public final static function updateSchemaModel ( ) { $ model = new static ( ) ; if ( MbMigration :: schema ( ) -> hasTable ( $ model -> getTable ( ) ) ) { MbMigration :: schema ( ) -> table ( $ model -> getTable ( ) , function ( Blueprint $ table ) use ( $ model ) { $ table -> engine = 'InnoDB' ; $ model -> updateSchem...
Call updateSchema when activating deactivating or uninstalling plugin
3,895
protected function setRequestType ( string $ type ) : void { if ( $ type !== Protocol :: REQUEST_TYPE_NOTIFY && $ type !== Protocol :: REQUEST_TYPE_FORWARD && $ type !== protocol :: REQUEST_TYPE_REGISTER ) { throw new \ TypeError ( "Unsupported request type: $type!" ) ; } $ this -> requestType = $ type ; $ this -> setH...
Update header of message by the request type .
3,896
public function authenticate ( string $ password ) : void { $ salt = random_bytes ( 10 ) ; $ keyBasis = $ password . $ salt ; $ key = hash ( Protocol :: PASSWORD_HASH_TYPE , $ keyBasis , true ) ; $ keyHash = hash ( Protocol :: PASSWORD_HASH_TYPE , $ key ) ; $ this -> setHeader ( $ this -> getHeader ( ) . " " . strtoupp...
Add authentication part to message header .
3,897
public function findUpdated ( $ rootParagraphIds , $ global = null ) { if ( $ rootParagraphIds instanceof Traversable ) { $ rootParagraphIds = ArrayUtils :: iteratorToArray ( $ rootParagraphIds ) ; } else if ( ! is_array ( $ rootParagraphIds ) ) { $ rootParagraphIds = ( array ) $ rootParagraphIds ; } if ( null === $ gl...
Find updated times
3,898
public function store ( Asset $ asset , $ path = null , $ filename = null ) { return $ this -> getStorageEngine ( ) -> store ( $ asset , $ path , $ filename ) ; }
Stores an asset
3,899
protected static function aggregateDefinitions ( ) { array_map ( function ( TypesDefinition $ definition ) { static :: $ compounds = array_merge ( static :: $ compounds , $ definition -> getCompounds ( ) ) ; static :: $ scalars = array_merge ( static :: $ scalars , $ definition -> getScalars ( ) ) ; static :: $ special...
Aggregate the all the types in the definitions .