idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
53,100
public function create ( ) { if ( ! mysql_query ( "CREATE DATABASE IF NOT EXISTS `{$this->dbName}`" , $ this -> link ) ) { throw new Klarna_DatabaseException ( 'Failed to create! (' . mysql_error ( ) . ')' ) ; } $ create = mysql_query ( "CREATE TABLE IF NOT EXISTS `{$this->dbName}`.`{$this->dbTable}` ( `...
Initialize the DB by creating the necessary database tables .
53,101
public function save ( $ uri ) { $ this -> splitURI ( $ uri ) ; $ this -> connect ( ) ; if ( ! is_array ( $ this -> pclasses ) || count ( $ this -> pclasses ) == 0 ) { return ; } foreach ( $ this -> pclasses as $ pclasses ) { foreach ( $ pclasses as $ pclass ) { mysql_query ( "DELETE FROM `{$this->dbName}`.`{$this->dbT...
Save pclasses to database
53,102
public function clear ( $ uri ) { try { $ this -> splitURI ( $ uri ) ; unset ( $ this -> pclasses ) ; $ this -> connect ( ) ; mysql_query ( "DELETE FROM `{$this->dbName}`.`{$this->dbTable}`" , $ this -> link ) ; } catch ( Exception $ e ) { throw new Klarna_DatabaseException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ...
Clear the pclasses
53,103
public function help ( ) { $ style = new Eurekon \ Style ( ' *** RUN - HELP ***' ) ; Eurekon \ Out :: std ( $ style -> color ( 'fg' , Eurekon \ Style :: COLOR_GREEN ) -> get ( ) ) ; Eurekon \ Out :: std ( '' ) ; $ help = new Eurekon \ Help ( '...' , true ) ; $ help -> addArgument ( '' , 'directory' , 'Config directory ...
Help method .
53,104
public function run ( ) { $ argument = Eurekon \ Argument :: getInstance ( ) ; $ directory = ( string ) $ argument -> get ( 'directory' ) ; $ configName = ( string ) $ argument -> get ( 'item' ) ; $ configNamespace = ( string ) $ argument -> get ( 'namespace' , null , 'global.database' ) ; $ dbName = ( string ) $ argum...
Run method .
53,105
protected function findConfigs ( $ currentFile , array $ data , $ configName = '' , $ doLoadJoins = false ) { $ configs = array ( ) ; $ data = $ this -> replace ( $ currentFile , $ data ) ; foreach ( $ data [ 'configs' ] as $ name => $ config ) { if ( ! empty ( $ configName ) && $ name !== $ configName ) { continue ; }...
Find configs .
53,106
protected function loadJoins ( $ currentFile , & $ config , $ data ) { if ( empty ( $ config [ 'joins' ] ) || ! is_array ( $ config [ 'joins' ] ) ) { $ config [ 'joins' ] = array ( ) ; return $ this ; } foreach ( $ config [ 'joins' ] as $ joinName => & $ joinConfig ) { $ filename = $ currentFile ; if ( isset ( $ joinCo...
Load joined configs .
53,107
protected function buildColRelVal ( $ where ) { $ rel = $ where [ 'rel' ] ; $ col = $ where [ 'col' ] ; $ val = $ where [ 'val' ] ; if ( $ rel == 'EQ' ) { $ val = $ this -> quote ( $ val ) ; $ rel = '=' ; } else { $ val = $ this -> formWhereVal ( $ val ) ; } $ col = $ this -> formWhereCol ( $ col ) ; $ where = trim ( "...
for normal case where condition like col = val
53,108
public function loadEnv ( ) { $ ed = $ this -> loadEnvDefault ( ) ; $ ej = $ this -> loadEnvJson ( ) ; if ( ! $ ed && ! $ ej ) { $ msg = "No configuration files found." ; $ this -> error ( $ msg ) ; die ( $ msg ) ; } }
loads env - default . json and then env . json
53,109
public function find ( ) { $ this -> getFileList ( ) -> clear ( ) ; foreach ( $ this -> searchLocations as $ location ) { if ( ! is_dir ( $ location ) ) { continue ; } $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ location ) ) ; foreach ( $ iterator as $ file ) { if ( ! $ this -> f...
Do the actual searching
53,110
public function filter ( \ SPLFileInfo $ file ) { foreach ( $ this -> filterlist as $ filter ) { if ( ! $ filter -> filter ( $ file ) ) { return false ; } } return true ; }
Filter the file
53,111
public function file ( $ name = '' , $ uploadDir = UPLOAD ) { if ( isset ( $ _FILES [ $ name ] ) ) { $ file = new FileUpload ( $ _FILES [ $ name ] , $ uploadDir ) ; return $ file ; } else { throw new FileNotUploadedException ( sprintf ( 'Your %s file is not uploaded yet' , $ name ) ) ; } }
upload a file with input name and uplaod dir
53,112
private function findDocumentRootInScriptFileName ( ) { $ filename = $ this -> server -> get ( 'SCRIPT_FILENAME' ) ? : false ; if ( false === $ filename ) { return false ; } $ parse = explode ( '/' , $ filename ) ; $ count = count ( $ parse ) ; if ( $ count && $ count > 1 ) { $ path = array_slice ( $ parse , 0 , $ coun...
find document root in server script filename
53,113
public function getBaseUri ( ) { if ( '' !== $ qs = $ this -> getQueryString ( ) ) { $ qs = '?' . $ qs ; } return $ this -> getSchemeAndHost ( ) . $ this -> getRequestUri ( ) . $ qs ; }
find the scheme and request uri
53,114
public function segment ( $ segment ) { $ segments = $ this -> segments ; return isset ( $ segments [ $ segment - 1 ] ) ? $ segments [ $ segment - 1 ] : false ; }
get url segment
53,115
public function inTimezone ( string $ timeZoneId ) : TimezonedDateTime { return new TimezonedDateTime ( \ DateTimeImmutable :: createFromFormat ( self :: DISPLAY_FORMAT , $ this -> format ( self :: DISPLAY_FORMAT ) , new \ DateTimeZone ( $ timeZoneId ) ) ) ; }
Returns the current date time as if it were in the supplied timezone
53,116
public function render ( ) : string { $ obLevel = ob_get_level ( ) ; ob_start ( ) ; extract ( $ this -> data ) ; $ templatesPath = $ this -> config -> projectPath . $ this -> config -> templatesPath ; $ package = '' ; $ template = $ this -> template ; if ( ! empty ( $ this -> section -> module ) ) { $ package = $ this ...
Generate output .
53,117
protected function findTemplate ( string $ templatesPath , string $ package , string $ templateName ) : string { if ( ! empty ( $ package ) ) { $ templatePath = $ templatesPath . $ this -> config -> templatesDefault . '/' . strtolower ( $ package ) . '/' . str_replace ( '.' , '/' , $ templateName ) . $ this -> extensio...
Find full path for requested template . Returned path may not exists .
53,118
public function withGlobalScope ( $ identifier , $ scope ) { $ this -> scopes [ $ identifier ] = $ scope ; if ( method_exists ( $ scope , 'extend' ) ) $ scope -> extend ( $ this ) ; return $ this ; }
Register a new global scope .
53,119
protected function whereCountQuery ( QueryBuilder $ query , $ operator = '>=' , $ count = 1 , $ boolean = 'and' ) { if ( is_numeric ( $ count ) ) { $ count = new Expression ( $ count ) ; } $ this -> query -> addBinding ( $ query -> getBindings ( ) , 'where' ) ; return $ this -> where ( new Expression ( '(' . $ query ->...
Add a sub query count clause to the query .
53,120
public function mergeModelDefinedRelationConstraints ( Builder $ relation ) { $ removedScopes = $ relation -> removedScopes ( ) ; $ relationQuery = $ relation -> getQuery ( ) ; return $ this -> withoutGlobalScopes ( $ removedScopes ) -> mergeWheres ( $ relationQuery -> wheres , $ relationQuery -> getBindings ( ) ) ; }
Merge the constraints from a relation query to the current query .
53,121
public function prePersist ( LifecycleEventArgs $ args ) : void { $ invitation = $ args -> getObject ( ) ; if ( ! $ invitation instanceof Invitation ) { return ; } $ event = $ invitation -> getEvent ( ) ; if ( $ event -> getAuthor ( ) == $ invitation -> getInvitee ( ) ) { $ invitation -> setResponse ( Invitation :: RES...
Checks the invitation author and accepts if they match .
53,122
protected function checkIfEntityExists ( ) { $ query = new ReadQuery ( $ this -> connection , $ this -> model , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; foreach ( $ this -> model -> primaryFields ( ) as $ field ) { $ value = $ this -> accessor -> getPropertyValue ( $ this -> instance , $ field ...
Returns true if entity exists database
53,123
public function setMax ( $ max ) { if ( ! is_string ( $ max ) && ! is_numeric ( $ max ) ) { throw new Zend_Validate_Exception ( 'Invalid options to validator provided' ) ; } $ max = ( integer ) $ this -> _fromByteString ( $ max ) ; $ min = $ this -> getMin ( true ) ; if ( ( $ min !== null ) && ( $ max < $ min ) ) { thr...
Sets the maximum filesize
53,124
public function isValid ( & $ errors = null , $ throwException = false ) { $ descriptorSpec = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) , ) ; $ process = proc_open ( 'php -l' , $ descriptorSpec , $ pipes ) ; if ( ! is_resource ( $ process ) ) { throw new \ Exception...
Run Php through lint checker
53,125
public static function varExport ( $ var , $ indent = 0 , $ dontIndentFirstLine = true ) { $ export = var_export ( $ var , true ) ; $ export = preg_replace ( '/^array \\(/' , 'array(' , $ export ) ; if ( $ export === 'NULL' ) { $ export = 'null' ; } $ export = str_replace ( ' ' , ' ' , $ export ) ; $ lines = explod...
Return a string which is a php - parsable representation of a variable
53,126
public static function exportVar ( $ value ) { $ closures = self :: collectClosures ( $ value ) ; $ res = var_export ( $ value , true ) ; if ( ! empty ( $ closures ) ) { $ subs = [ ] ; foreach ( $ closures as $ key => $ closure ) { $ subs [ "'" . $ key . "'" ] = self :: dumpClosure ( $ closure ) ; } $ res = strtr ( $ r...
Returns a parsable string representation of given value . In contrast to var_dump outputs Closures as PHP code .
53,127
private static function collectClosures ( & $ input ) { static $ closureNo = 1 ; $ closures = [ ] ; if ( is_array ( $ input ) ) { foreach ( $ input as & $ value ) { if ( is_array ( $ value ) || $ value instanceof Closure ) { $ closures = array_merge ( $ closures , self :: collectClosures ( $ value ) ) ; } } } elseif ( ...
Collects closures from given input . Substitutes closures with a tag .
53,128
protected function extractFieldLabels ( WriterFieldInterface ... $ fields ) : array { return array_map ( function ( WriterFieldInterface $ field ) : string { return $ field -> getLabel ( ) ; } , $ fields ) ; }
Extract labels from fields .
53,129
public function createVendor ( $ name = null ) { $ vendor = new $ this -> vendorFqcn ( $ name ) ; $ vendor -> setOrganization ( $ this -> oh -> getOrganization ( ) ) ; return $ vendor ; }
Create new Vendor
53,130
public function findVendorForName ( $ name ) { return $ this -> em -> getRepository ( $ this -> vendorFqcn ) -> findOneBy ( array ( 'name' => $ name , 'organization' => $ this -> oh -> getOrganization ( ) ) ) ; }
Find Vendor for name
53,131
public function findVendorForSlug ( $ slug ) { return $ this -> em -> getRepository ( $ this -> vendorFqcn ) -> findOneBy ( array ( 'slug' => $ slug , 'organization' => $ this -> oh -> getOrganization ( ) ) ) ; }
Find Vendor for slug
53,132
public function run ( array $ sources , array $ destinations ) { $ updatedSources = [ ] ; foreach ( $ sources as $ source ) { $ css = $ this -> getCacheDir ( ) . $ source -> getBasename ( '.scss' ) . '.css' ; $ this -> addNotification ( 'compiling ' . $ source . ' to ' . $ css ) ; $ process = new Process ( $ command = ...
Compile scss file into css file via compass .
53,133
public function checkRequirements ( ) { $ process = new Process ( $ this -> getBin ( ) . ' version' ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { throw new Exception ( 'compass is not found at ' . $ this -> getBin ( ) . '. ' . $ process -> getErrorOutput ( ) ) ; } }
Check that compass is installed and available .
53,134
protected function buildCommandString ( $ source ) { $ commandPattern = '%s %s %s %s %s' ; $ command = sprintf ( $ commandPattern , $ this -> getBin ( ) , 'compile' , $ source -> getRealPath ( ) , '--css-dir=' . $ this -> getCacheDir ( ) , '--sass-dir=' . $ source -> getPath ( ) ) ; return $ command ; }
Build the compass compile command line .
53,135
public function getColumn ( $ name , $ alias = '' ) { $ column = new DerivedColumn ( $ name , $ alias ) ; return $ column -> setTable ( $ this ) ; }
Returns a column object correlated to the current table .
53,136
public function getAllRecords ( ) { $ recordType = $ this -> getRecordType ( ) ; $ all = $ recordType :: get ( ) -> filterByCallBack ( function ( DataObject $ obj ) { return $ obj -> canView ( ) ; } ) ; return new PaginatedList ( $ all , $ this -> request ) ; }
Gets all the records and returns them paginated
53,137
public function getEditableRecords ( ) { $ recordType = $ this -> getRecordType ( ) ; $ all = $ recordType :: get ( ) -> filterByCallBack ( function ( DataObject $ obj ) { return $ obj -> canEdit ( ) ; } ) ; return new PaginatedList ( $ all , $ this -> request ) ; }
Gets all editable records and returns them paginated
53,138
public function create_new ( $ request ) { if ( ! $ this -> canCreate ( ) ) { return $ this -> httpError ( 403 , "You do not have permission to create new " . $ this -> getPluralName ( ) ) ; } $ this -> addCrumb ( 'Create new ' . $ this -> getSingularName ( ) ) ; return $ this -> customise ( [ 'Form' => $ this -> Creat...
URL method to create a new record
53,139
public function CreationForm ( ) { $ fields = singleton ( $ this -> getRecordType ( ) ) -> getFrontEndFields ( ) ; $ fields -> push ( new HiddenField ( 'ID' ) ) ; $ form = new Form ( $ this , 'CreationForm' , $ fields , new FieldList ( new FormAction ( 'doSave' , 'Save' ) , new FormAction ( 'doCancel' , 'Cancel' ) ) ) ...
Scaffolds a form for creating managed data types
53,140
public function doSave ( $ data , $ form ) { $ recordType = $ this -> getRecordType ( ) ; $ record = $ recordType :: create ( ) ; $ form -> saveInto ( $ record ) ; $ record -> write ( ) ; $ this -> redirect ( $ this -> Link ( ) ) ; }
Function for saving the form
53,141
public function AlphabetPages ( ) { $ query = new SQLSelect ( ) ; $ pages = new ArrayList ( ) ; $ sortOn = $ this -> config ( ) -> sort_on ; $ query -> select ( array ( "Left($sortOn, 1) AS Letter" ) ) ; $ query -> from ( $ this -> getRecordType ( ) ) ; $ query -> groupBy ( array ( 'Letter' ) ) ; $ lettersFound = $ que...
Generates a ArrayList of anonymous objects that can be used to create an alphabet menu for all the items linking only when there are items begining with the letter and providing an indication of whether it is currently selected or not
53,142
public function removeHandler ( IHandler $ handler = NULL ) { if ( NULL !== $ handler && $ this -> handler == $ handler ) { $ this -> handler = NULL ; } else { $ this -> handler = NULL ; } }
Remove a handler from the session .
53,143
private function readCsv ( $ fullPath ) { $ result = [ ] ; $ entries = $ this -> hlpCsv -> read ( $ fullPath ) ; foreach ( $ entries as $ one ) { $ i = 0 ; $ fromId = $ one [ $ i ++ ] ; $ fromName = $ one [ $ i ++ ] ; $ toId = $ one [ $ i ++ ] ; $ toName = $ one [ $ i ++ ] ; $ volume = $ one [ $ i ++ ] ; $ item = new D...
Read & parse CSV file .
53,144
public static function fromNative ( ) { $ args = func_get_args ( ) ; $ amount = new Integer ( $ args [ 0 ] ) ; $ currency = Currency :: fromNative ( $ args [ 1 ] ) ; return new static ( $ amount , $ currency ) ; }
Returns a Money object from native int amount and string currency code
53,145
public function sameValueAs ( ValueObjectInterface $ money ) { if ( false === Util :: classEquals ( $ this , $ money ) ) { return false ; } return $ this -> getAmount ( ) -> sameValueAs ( $ money -> getAmount ( ) ) && $ this -> getCurrency ( ) -> sameValueAs ( $ money -> getCurrency ( ) ) ; }
Tells whether two Currency are equal by comparing their amount and currency
53,146
public function add ( Integer $ quantity ) { $ amount = new Integer ( $ this -> getAmount ( ) -> toNative ( ) + $ quantity -> toNative ( ) ) ; $ result = new self ( $ amount , $ this -> getCurrency ( ) ) ; return $ result ; }
Add an integer quantity to the amount and returns a new Money object . Use a negative quantity for subtraction .
53,147
public function filterByPageId ( $ pageId = null , $ comparison = null ) { if ( is_array ( $ pageId ) ) { $ useMinMax = false ; if ( isset ( $ pageId [ 'min' ] ) ) { $ this -> addUsingAlias ( M2PTableMap :: COL_PAGE_ID , $ pageId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ pageId [ '...
Filter the query on the page_id column
53,148
public function usePageQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinPage ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Page' , '\Attogram\SharedMedia\Orm\PageQuery' ) ; }
Use the Page relation Page object
53,149
public static function getInstance ( $ name ) { $ key = self :: _instanceKey ( $ name ) ; if ( ! isset ( self :: $ _instances [ $ key ] ) ) { $ dataSource = self :: getDataAdapter ( ) ; if ( is_null ( $ dataSource ) ) { $ data = array ( ) ; } else { $ data = $ dataSource -> load ( $ key ) ; } $ config = new self ( $ da...
Returns config instance
53,150
public static function newInstance ( $ name , $ data = null ) { if ( ! is_array ( $ data ) ) { $ data = array ( ) ; } $ config = self :: getInstance ( $ name ) ; $ config -> _data = $ data ; return $ config ; }
Shortcut for instance creation .
53,151
public static function clearInstance ( $ name ) { $ key = self :: _instanceKey ( $ name ) ; if ( isset ( self :: $ _instances [ $ key ] ) ) { unset ( self :: $ _instances [ $ key ] ) ; } }
Unloads config instance .
53,152
public static function clearAll ( ) { $ names = array_keys ( self :: $ _instances ) ; foreach ( $ names as $ name ) { self :: clearInstance ( $ name ) ; } }
Upload all configs data
53,153
public static function saveInstance ( $ name ) { $ adapter = self :: getDataAdapter ( ) ; if ( ! is_null ( $ adapter ) ) { $ config = self :: getInstance ( $ name ) ; $ key = self :: _instanceKey ( $ name ) ; $ result = $ adapter -> save ( $ key , $ config ) ; } else { $ result = false ; } return $ result ; }
Save config instance data
53,154
public static function deleteInstance ( $ name ) { $ adapter = self :: getDataAdapter ( ) ; if ( ! is_null ( $ adapter ) ) { $ key = self :: _instanceKey ( $ name ) ; $ result = $ adapter -> delete ( $ key ) ; } else { $ result = false ; } self :: clearInstance ( $ name ) ; return $ result ; }
Delete config instance data
53,155
static function instance ( \ hlin \ archetype \ Filesystem $ fs , array $ filemaps ) { $ i = new static ; $ i -> fs = $ fs ; $ i -> filemaps = $ filemaps ; return $ i ; }
Default filemaps will be used if none are specified .
53,156
public function get ( $ endpoint , $ params = [ ] ) { $ url = $ this -> domain . '/' . $ endpoint ; if ( ! empty ( $ params ) ) { $ url = $ url . '?' . http_build_query ( $ params ) ; } $ request = new Request ( $ url ) ; if ( isset ( $ this -> config [ 'secret' ] ) ) { $ request -> headers -> add ( [ 'X-Client-Secret'...
Make a GET Request to an endpoint
53,157
public function getEndpoint ( $ endpoint ) { $ endpoint = studly_case ( $ endpoint ) ; if ( ! array_key_exists ( $ endpoint , $ this -> endpoints ) ) { throw new InvalidEndpointException ( "Endpoint {$endpoint} does not exists" ) ; } $ class = $ this -> endpoints [ $ endpoint ] ; if ( isset ( $ this -> cachedEndpoints ...
Get an API endpoint .
53,158
public static function routes ( ) { Route :: name ( 'public::blog.' ) -> prefix ( 'blog' ) -> namespace ( '\\Arcanesoft\\Blog\\Http\\Controllers\\Front' ) -> group ( function ( ) { Routes \ PostsRoutes :: register ( ) ; Routes \ CategoriesRoutes :: register ( ) ; Routes \ TagsRoutes :: register ( ) ; } ) ; }
Register the public blog routes .
53,159
public static function find ( array $ query ) { $ pubs = Client :: get ( 'publication' , $ query ) ; return array_map ( function ( $ data ) { return new self ( $ data ) ; } , $ pubs ) ; }
Retrieve an array of Publication objects according to a search query .
53,160
private function transformToHtml ( $ data , $ hypertextRoutes = [ ] ) { $ hypertextHtml = $ this -> getHypertextHtml ( $ hypertextRoutes ) ; if ( ! is_array ( $ data ) ) { return "<p>{$data}</p>\n{$hypertextHtml}" ; } $ html = "<table style=\"border: 1px solid black;\">" ; foreach ( $ data as $ k => $ v ) { if ( is_arr...
Recursively converts the response into an html string . This is an html string with tables and underlying tables .
53,161
private function getHypertextHtml ( $ routes = [ ] ) { if ( ! $ routes ) { return '' ; } $ html = "<table style=\"border: 1px solid black;\">\n" ; foreach ( $ routes as $ name => $ route ) { $ html .= "<tr>\n" ; $ html .= "<td style=\"border: 1px solid black;\">rel: {$name}</td>\n" ; $ html .= "<td style=\"border: 1px ...
Generates the html for the hypertext routes .
53,162
public static function fromResource ( ResourceInterface $ resource , $ path ) { if ( $ resource instanceof FileResourceInterface ) { return $ resource ; } file_put_contents ( $ path , $ resource -> getStream ( ) ) ; $ attr = [ 'mimetype' => $ resource -> getMimetype ( ) , 'lastmodified' => $ resource -> getLastModified...
Converts any resource to a local resource .
53,163
static function FindContentRights ( Content $ content ) { $ result = null ; $ currContent = $ content ; do { $ result = $ currContent -> GetUserGroupRights ( ) ; $ currContent = ContentTreeUtil :: ParentOf ( $ currContent ) ; } while ( ! $ result && $ currContent ) ; if ( $ result ) { return $ result ; } return self ::...
Finds the content rigths by searching in element tree
53,164
static function FindPageRights ( Page $ page ) { $ currPage = $ page ; $ result = null ; do { $ result = $ currPage -> GetUserGroupRights ( ) ; $ currPage = $ currPage -> GetParent ( ) ; } while ( ! $ result && $ currPage ) ; if ( ! $ result && $ page -> GetSite ( ) ) { $ siteRights = $ page -> GetSite ( ) -> GetUserGr...
Gets the rights of the page
53,165
public static function hash ( $ 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 or number, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } return hash ( self :: HASH_ALGORITHM ...
Hashes text and returns it
53,166
public static function validateHash ( $ data , $ hash ) { if ( false === is_string ( $ data ) && false === is_numeric ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or number, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } if ( false === is_st...
Verifies that data matches a hash
53,167
private static function hash_equals ( $ expected , $ actual ) { $ expected = ( string ) $ expected ; $ actual = ( string ) $ actual ; if ( true === function_exists ( 'hash_equals' ) ) { return hash_equals ( $ expected , $ actual ) ; } $ lenExpected = mb_strlen ( $ expected , self :: ENCODING ) ; $ lenActual = mb_strlen...
Hash equals function for PHP 5 . 5 +
53,168
public static function decode ( $ string ) { if ( ! $ string ) { return new ArrayObject ( ) ; } $ array = SymfonyYaml :: parse ( $ string ) ; if ( ! is_array ( $ array ) ) { $ array = [ ] ; } return ArrayObject :: make ( $ array ) ; }
Convert a yaml string to an array .
53,169
public static function mime2ext ( $ mime ) { $ ext2mime = static :: get_mime_map ( ) ; $ mime2ext = array_flip ( $ ext2mime ) ; return ( isset ( $ mime2ext [ $ mime ] ) ) ? $ mime2ext [ $ mime ] : 'unknown' ; }
Get the file extension associated with a given mime type .
53,170
public function isValid ( $ value ) { $ acceptedValues = GeneralUtility :: trimExplode ( '|' , $ this -> options [ 'values' ] ) ; if ( false === in_array ( $ value , $ acceptedValues ) ) { $ errorMessage = $ this -> translateErrorMessage ( 'validator.has_values.not_valid' , 'configuration_object' , [ implode ( ', ' , $...
Checks if the given values is one of the accepted values .
53,171
public function getMethodAnnotations ( \ ReflectionMethod $ method ) { return array_merge ( $ this -> reader -> getMethodAnnotations ( $ method ) , $ this -> converter -> getMethodAnnotations ( $ method ) ) ; }
Collect method annotations .
53,172
public function getPropertyAnnotations ( \ ReflectionProperty $ prop ) { return array_merge ( $ this -> reader -> getPropertyAnnotations ( $ prop ) , $ this -> converter -> getPropertyAnnotations ( $ prop ) ) ; }
Collect property annotations .
53,173
public function processEvent ( Interfaces \ EventInterface $ event , callable $ callback = null ) { $ eventName = $ event -> getName ( ) ; $ queue = $ this -> matchEventQueue ( $ eventName , $ this ) ; $ managers = $ this -> getOtherManagers ( ) ; foreach ( $ managers as $ mgr ) { $ q = $ this -> matchEventQueue ( $ ev...
Process events by all managers in the pool
53,174
public function updateContinent ( Continent $ continent , $ andFlush = true ) { $ this -> objectManager -> persist ( $ continent ) ; if ( $ andFlush ) { $ this -> objectManager -> flush ( ) ; } }
Updates a Continent .
53,175
public function refreshContinent ( Continent $ continent ) { $ refreshedContinent = $ this -> findContinentBy ( array ( 'id' => $ continent -> getId ( ) ) ) ; if ( null === $ refreshedContinent ) { throw new UsernameNotFoundException ( sprintf ( 'User with ID "%d" could not be reloaded.' , $ continent -> getId ( ) ) ) ...
Refreshed a Continent by Continent Instance
53,176
protected static function getModeConstant ( $ value ) { if ( is_int ( $ value ) ) { if ( $ value <= 16 ) { return self :: VT100 ; } else if ( $ value <= 256 ) { return self :: XTERM ; } else { return self :: RGB ; } } else if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; $ value = strtoupper ( $ value ) ; if...
Helper function to take a value and turn it into a valid constant integer value
53,177
public function onKernelEarlyRequest ( GetResponseEvent $ e ) { $ request = $ e -> getRequest ( ) ; foreach ( $ this -> pathConfig as $ regex => $ config ) { if ( preg_match ( $ regex , $ request -> getPathInfo ( ) ) ) { $ this -> enabled = true ; if ( ! $ this -> subscribed ) { $ e -> getDispatcher ( ) -> addSubscribe...
Listens early in the kernel . request cycle for incoming requests and checks for a matching path . If a match is found the rest of the kernel listeners are registered and the relevant path config is stored for use in those listeners .
53,178
public function onKernelLateRequest ( GetResponseEvent $ e ) { if ( ! $ this -> enabled ) return ; $ req = $ e -> getRequest ( ) ; if ( ! $ config = $ req -> attributes -> get ( '_ac_web_service' , false ) ) { return ; } $ config = $ this -> negotiateResponseFormat ( $ req , $ config ) ; $ req -> attributes -> set ( '_...
Fires at the end of the kernel . request cycle - so listeners should receive a request that has already been resolved to a controller .
53,179
public function onKernelResponse ( FilterResponseEvent $ e ) { if ( ! $ this -> enabled ) return ; $ response = $ e -> getResponse ( ) ; $ config = $ e -> getRequest ( ) -> attributes -> get ( '_ac_web_service' ) ; if ( ! $ config [ 'negotiated' ] ) { $ config = $ this -> negotiateResponseFormat ( $ e -> getRequest ( )...
Called when a response object has been resolved .
53,180
public function onKernelTerminate ( PostResponseEvent $ e ) { if ( ! $ this -> enabled ) return ; $ e -> getDispatcher ( ) -> dispatch ( self :: API_TERMINATE , $ e ) ; }
Called after a response has already been sent .
53,181
protected function includes ( ) { $ moduleInclude = ( array ) $ this -> def ( 'include' ) ; $ globalInclude = $ this -> app [ 'config' ] -> get ( 'module::include' ) ; $ specificInclude = array ( $ this -> name . '.php' ) ; $ include = array_merge ( $ moduleInclude , $ specificInclude , $ globalInclude ) ; foreach ( $ ...
Include some files determined in config . php of CheeModule and module . json of modules
53,182
protected function registerProviders ( ) { $ providers = $ this -> def ( 'provider' ) ; if ( $ providers ) { if ( is_array ( $ providers ) ) { foreach ( $ providers as $ provider ) { $ this -> app -> register ( $ instance = new $ provider ( $ this -> app ) ) ; } } else { $ this -> app -> register ( $ instence = new $ p...
Register service providers of module
53,183
protected function validatePagination ( $ pagination ) : void { if ( ! is_array ( $ pagination ) ) { throw new InvalidQueryException ( 'Attribute "page" of query must be an array.' ) ; } $ unexpected = array_diff ( array_keys ( $ pagination ) , [ 'offset' , 'limit' ] ) ; if ( empty ( $ unexpected ) ) { return ; } throw...
Validate pagination definition
53,184
public function substring ( $ start , $ length = null ) { if ( $ length == null ) { $ substring = substr ( $ this -> value , $ start ) ; } else { $ substring = substr ( $ this -> value , $ start , $ length ) ; } $ this -> value = $ substring ; return $ this ; }
Unterschied zu getSubstring !!!
53,185
public function save ( $ id , $ data , $ ttl = 60 , $ raw = FALSE ) { $ contents = array ( 'time' => time ( ) , 'ttl' => $ ttl , 'data' => $ data ) ; if ( write_file ( $ this -> _cache_path . $ id , serialize ( $ contents ) ) ) { chmod ( $ this -> _cache_path . $ id , 0640 ) ; return TRUE ; } return FALSE ; }
Save into cache
53,186
public function delete ( $ id ) { return file_exists ( $ this -> _cache_path . $ id ) ? unlink ( $ this -> _cache_path . $ id ) : FALSE ; }
Delete from Cache
53,187
protected function load ( $ path ) { $ file = require ( $ path ) ; if ( ! is_array ( $ file ) ) { $ message = "{$path} configuration file is not readable." ; throw new ConfigException ( $ message ) ; } return $ file ; }
Load configuration file .
53,188
public function random_string ( $ length = 32 ) { return substr ( str_shuffle ( str_repeat ( $ x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' , ceil ( $ length / strlen ( $ x ) ) ) ) , 1 , $ length ) ; }
Generates a random string based on given length .
53,189
public function tokenize ( $ iv , $ string = '' ) { if ( empty ( $ string ) ) { $ string = $ this -> random_string ( ) ; } return openssl_encrypt ( $ string , 'AES-256-CBC' , $ this -> _config -> get ( 'token' ) , 0 , $ iv ) ; }
Generate a token using OpenSSL extensions .
53,190
public static function isInteger ( $ input ) : bool { return self :: is ( $ input ) && ( string ) ( int ) $ input === ( string ) $ input ; }
Check if the input is true integer number or can be converted from string into integer
53,191
public static function write ( $ input , ? int $ precision = null , $ default = null ) { if ( ! self :: is ( $ input ) ) return $ default ; else { $ input = self :: cast ( $ input ) ; if ( is_int ( $ precision ) ) return number_format ( $ input , $ precision , '.' , '' ) ; else if ( is_int ( $ input ) ) return ( string...
Convert numbers to string
53,192
public static function equal ( $ a , $ b , int $ precision = 0 ) : bool { return self :: write ( $ a , $ precision ) === self :: write ( $ b , $ precision ) ; }
Check if two number is equals . Can handle floats with precision
53,193
protected function BeforeInit ( ) { $ this -> user = User :: Schema ( ) -> ByID ( Request :: GetData ( 'user' ) ) ; if ( ! $ this -> user || ! self :: Guard ( ) -> Allow ( BackendAction :: AssignGroups ( ) , $ this -> user ) ) { Response :: Redirect ( BackendRouter :: ModuleUrl ( new UserList ( ) ) ) ; } return parent ...
Gets and checks the requested user
53,194
public function getComment ( ) { if ( ! $ this -> _commentFetched ) { $ this -> _comment = $ this -> _fetchComment ( ) ; $ this -> _commentFetched = true ; } return $ this -> _comment ; }
Return table comment
53,195
public function setComment ( $ comment ) { if ( $ comment != $ this -> getComment ( ) and $ this -> _setComment ( $ comment ) ) { $ this -> _comment = $ comment ; } }
Set table comment
53,196
protected function _fetchColumns ( ) { $ columns = $ this -> _database -> query ( 'SELECT ' . implode ( ',' , $ this -> _informationSchemaColumns ) . ' FROM information_schema.columns WHERE table_schema=? AND LOWER(table_name)=? ORDER BY ordinal_position' , array ( $ this -> _database -> getTableSchema ( ) , $ this -> ...
Fetch column information from the database
53,197
protected function _fetchConstraints ( ) { $ constraints = $ this -> _database -> query ( <<<EOT SELECT kcu.column_name FROM information_schema.key_column_usage kcu JOIN information_schema.table_constraints tc USING (table_schema, table_name, constraint_schema, co...
Fetch constraint information from the database
53,198
public function requireColumn ( $ name ) { if ( $ name != strtolower ( $ name ) ) { throw new \ DomainException ( 'Column name must be lowercase: ' . $ name ) ; } if ( ! isset ( $ this -> _columns [ $ name ] ) ) { throw new \ RuntimeException ( 'Undefined column: ' . $ this -> _name . '.' . $ name ) ; } }
Force presence of column
53,199
public function alter ( $ operation ) { return $ this -> _database -> exec ( 'ALTER TABLE ' . $ this -> _database -> prepareIdentifier ( $ this -> _name ) . ' ' . $ operation ) ; }
Compose and execute an ALTER TABLE statement