idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
52,100 | public function insert ( $ t , $ nvp = array ( ) ) { $ nvps = $ nvp ; if ( is_array ( $ t ) ) { $ nvps = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } if ( ! isset ( $ nvps [ 0 ] ) ) { $ nvps = array ( $ nvps ) ; } $ columns = [ ] ; foreach ( $ nvps as $ i => $ nvp ) { $ columns [ $ i ] = [ ] ; for... | Start a new INSERT query . |
52,101 | public function update ( $ t , $ nvp = array ( ) ) { if ( is_array ( $ t ) ) { $ nvp = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } $ columns = [ ] ; foreach ( array_keys ( $ nvp ) as $ s ) { $ column = \ Dorsataio \ Squibble \ Resource \ Extract :: fromColumn ( $ s ) ; $ column [ 'value' ] = $ nv... | Start a new UPDATE query . |
52,102 | public function delete ( $ t , $ conditions = array ( ) ) { if ( is_array ( $ t ) ) { $ conditions = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } if ( ! empty ( $ conditions ) ) { $ this -> where ( $ conditions ) ; } $ this -> _sql = $ this -> getDeleteStatement ( ) ; return $ this ; } | Start a new DELETE query . |
52,103 | public function get ( $ path , $ default = null ) { return Arr :: get ( $ this -> items , $ this -> keyFor ( $ path ) , $ default ) ; } | Get an item from the collection by path . |
52,104 | private function inRange ( $ ip , $ cidr , $ range ) { $ ipVersion = $ this -> getIpVersion ( $ ip ) ; $ binIp = $ this -> ip2bin ( $ ip ) ; $ parts = explode ( '/' , $ range ) ; $ net = array_shift ( $ parts ) ; $ range_cidr = array_shift ( $ parts ) ; $ netVersion = $ this -> getIpVersion ( $ net ) ; if ( $ ipVersion... | Checks whether the IP is in subnet range |
52,105 | private function ip2bin ( $ ip ) { if ( $ this -> getIpVersion ( $ ip ) === 4 ) { return str_pad ( base_convert ( ip2long ( $ ip ) , 10 , 2 ) , static :: IPV4_ADDRESS_LENGTH , '0' , STR_PAD_LEFT ) ; } else { $ unpack = unpack ( 'A16' , inet_pton ( $ ip ) ) ; $ binStr = array_shift ( $ unpack ) ; $ bytes = static :: IPV... | Converts IP address to bits representation |
52,106 | public function dump ( ) { $ dump = [ ] ; if ( $ this -> hasClasses ( ) ) { foreach ( $ this -> classes as $ class ) { $ dump [ $ class -> getName ( ) ] = $ class -> dump ( ) ; } } return $ dump ; } | Dump group classes . |
52,107 | public function extract ( ) { return [ 'name' => $ this -> getName ( ) , 'ordering' => $ this -> getOrdering ( ) , 'type' => $ this -> getType ( ) , 'include_pattern' => $ this -> getIncludePattern ( ) , 'exclude_pattern' => $ this -> getExcludePattern ( ) , 'classes' => $ this -> dump ( ) , ] ; } | Extract all group s data in array . |
52,108 | public static function isValid ( $ expression , $ translate = false ) { if ( $ translate ) { $ expression = self :: translate ( $ expression ) ; } return is_bool ( $ expression ) ; } | Check if expression is valid |
52,109 | public function parse ( ) { $ this -> lexer -> moveNext ( ) ; while ( true ) { if ( ! $ this -> lexer -> lookahead ) { break ; } $ this -> lexer -> moveNext ( ) ; $ thisLine = null ; switch ( $ this -> lexer -> token [ 'type' ] ) { case Lexer :: T_OPEN_PARENTHESIS : case Lexer :: T_OPEN_BRACKET : case Lexer :: T_OPEN_C... | parses our stuff |
52,110 | public static function string ( $ string , $ foreground_colour = null , $ background_colour = null ) { $ coloured_string = "" ; if ( isset ( self :: $ foreground_colours [ $ foreground_colour ] ) ) { $ coloured_string .= self :: getForegroundCode ( $ foreground_colour ) ; } if ( isset ( self :: $ background_colours [ $... | Adds colouring control codes to a string . |
52,111 | public static function getForegroundCode ( $ foregroundColour ) { if ( ! isset ( self :: $ foreground_colours [ $ foregroundColour ] ) ) { throw new \ Exception ( 'Invalid foreground colour.' ) ; } return "\033[" . self :: $ foreground_colours [ $ foregroundColour ] . 'm' ; } | Returns the code for a foreground colour . |
52,112 | public static function getBackgroundCode ( $ backgroundColour ) { if ( ! isset ( self :: $ background_colours [ $ backgroundColour ] ) ) { throw new \ Exception ( 'Invalid background colour.' ) ; } return "\033[" . self :: $ background_colours [ $ backgroundColour ] . 'm' ; } | Returns the code for a background colour . |
52,113 | public function withPredefinedRowValues ( FieldBuilderBase $ field , array $ rowValues ) : TableCellValueFieldDefiner { $ this -> fieldBuilder -> attr ( TableType :: ATTR_PREDEFINED_ROWS , array_values ( $ rowValues ) ) ; return $ this -> withRowKeyAs ( $ field ) ; } | Defines the rows as predefined set of values . |
52,114 | public function withRowKeyAsField ( IField $ field ) : TableCellValueFieldDefiner { return new TableCellValueFieldDefiner ( $ this -> fieldBuilder , $ this -> cellClassName , $ this -> columnField , $ field ) ; } | Defines the row key as the supplied field . |
52,115 | private function log ( $ line , $ log_level ) { if ( $ log_level <= $ this -> log_verbosity ) { $ line = $ this -> prepend ( $ log_level ) . $ line . "\n" ; $ this -> writeLine ( $ line ) ; } } | Write the log entry |
52,116 | private function prepend ( $ log_level ) { $ time = date ( 'Y-m-d G:i:s' ) ; switch ( $ log_level ) { case self :: FATAL : return $ time . ' - FATAL - ' ; break ; case self :: ERROR : return $ time . ' - ERROR - ' ; break ; case self :: WARN : return $ time . ' - WARN - ' ; break ; case self :: INFO : return $ time . ... | format the line prefix |
52,117 | public function all ( $ dotify = false ) { return $ dotify ? $ this -> dotify ( $ this -> data ) : $ this -> data ; } | Returns all the stored configurations . |
52,118 | public function get ( $ key , $ default = null , $ dotify = false ) { $ items = $ this -> data ; $ keys = array_filter ( explode ( '.' , $ key ) ) ; $ length = count ( $ keys ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ index = $ keys [ ( int ) $ i ] ; $ items = & $ items [ $ index ] ; } if ( $ items === null ) { ... | Returns the value from the specified key . |
52,119 | public function load ( $ path ) { list ( $ data , $ items ) = array ( array ( ) , array ( $ path ) ) ; if ( substr ( ( string ) $ path , - 4 ) !== '.php' ) { $ directory = new \ RecursiveDirectoryIterator ( $ path ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directory ) ; $ regex = new \ RegexIterator ( $ itera... | Loads an array of values from a specified file or directory . |
52,120 | protected function dotify ( array $ data , $ result = array ( ) , $ key = '' ) { foreach ( ( array ) $ data as $ name => $ value ) { if ( is_array ( $ value ) && empty ( $ value ) === false ) { $ text = ( string ) $ key . $ name . '.' ; $ item = $ this -> dotify ( $ value , $ result , $ text ) ; $ result = array_merge ... | Converts the data into dot notation values . |
52,121 | protected function rename ( $ item , $ path ) { $ name = str_replace ( $ path , '' , ( string ) $ item ) ; $ name = str_replace ( array ( '\\' , '/' ) , '.' , $ name ) ; $ regex = preg_replace ( '/^./i' , '' , $ name ) ; return basename ( strtolower ( $ regex ) , '.php' ) ; } | Renames the item into a dot notation one . |
52,122 | protected function save ( array & $ keys , & $ data , $ value ) { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ data [ $ key ] ) ) { $ data [ $ key ] = array ( ) ; } if ( empty ( $ keys ) ) { return $ data [ $ key ] = $ value ; } return $ this -> save ( $ keys , $ data [ $ key ] , $ value ) ; } | Saves the specified key in the list of data . |
52,123 | protected function InitForm ( ) { $ this -> logout = $ this -> LoadElement ( ) ; $ this -> AddNextUrlField ( ) ; $ this -> AddCssIDField ( ) ; $ this -> AddCssClassField ( ) ; $ this -> AddTemplateField ( ) ; $ this -> AddSubmit ( ) ; } | Intializes the form |
52,124 | protected function SaveElement ( ) { $ this -> logout -> SetNextUrl ( $ this -> selectorNext -> Save ( $ this -> logout -> GetNextUrl ( ) ) ) ; return $ this -> logout ; } | Saves the element and returns it |
52,125 | public function generate ( $ target , $ type = 'post' ) { $ form = new \ Pegase \ Extension \ Form \ Objects \ Form ( $ target , $ this -> sm -> get ( 'pegase.security.token_csrf_container' ) , $ type ) ; return $ form ; } | generate a form |
52,126 | public static function fromNative ( ) { $ args = func_get_args ( ) ; if ( \ count ( $ args ) < 2 ) { throw new \ BadMethodCallException ( 'You must provide from 2 to 4 arguments: 1) street name, 2) street number, 3) elements, 4) format (optional)' ) ; } $ nameString = $ args [ 0 ] ; $ numberString = $ args [ 1 ] ; $ el... | Returns a new Street from native PHP string name and number . |
52,127 | public function sameValueAs ( ValueObjectInterface $ street ) { if ( false === Util :: classEquals ( $ this , $ street ) ) { return false ; } return $ this -> getName ( ) -> sameValueAs ( $ street -> getName ( ) ) && $ this -> getNumber ( ) -> sameValueAs ( $ street -> getNumber ( ) ) && $ this -> getElements ( ) -> sa... | Tells whether two Street objects are equal |
52,128 | protected function validate ( ApiServiceInterface $ service ) { $ validator = Validation :: createValidatorBuilder ( ) -> enableAnnotationMapping ( ) -> getValidator ( ) ; $ violations = $ validator -> validate ( $ service ) ; foreach ( $ violations as $ violation ) { $ errorMessage = $ violation -> getMessage ( ) ; if... | Validate a service data using Symfony validation component |
52,129 | public static function factory ( $ time = null , $ timezone = null ) { $ timezone = static :: timezone ( $ timezone ) ; if ( $ time instanceof DateTime ) { return $ time -> setTimezone ( $ timezone ) ; } if ( is_numeric ( $ time ) ) { $ time = '@' . $ time ; } $ dt = new DateTime ( $ time ) ; $ dt -> setTimezone ( $ ti... | Return a DateTime object based on the current time and timezone . |
52,130 | public static function isWithinNext ( $ time , $ span ) { $ span = static :: factory ( $ span ) ; $ time = static :: factory ( $ time ) ; $ now = static :: factory ( ) ; return ( $ time <= $ span && $ time >= $ now ) ; } | Returns true if the date passed will be within the next time frame span . |
52,131 | public static function toUnix ( $ time ) { if ( ! $ time ) { return time ( ) ; } else if ( $ time instanceof DateTime ) { return $ time -> format ( 'U' ) ; } return is_string ( $ time ) ? strtotime ( $ time ) : ( int ) $ time ; } | Return a unix timestamp . If the time is a string convert it else cast to int . |
52,132 | public static function wasLastWeek ( $ time ) { $ start = static :: factory ( 'last week 00:00:00' ) ; $ end = clone $ start ; $ end -> modify ( 'next week -1 second' ) ; $ time = static :: factory ( $ time ) ; return ( $ time >= $ start && $ time <= $ end ) ; } | Returns true if date passed was within last week . |
52,133 | public static function wasLastMonth ( $ time ) { $ start = static :: factory ( 'first day of last month 00:00:00' ) ; $ end = clone $ start ; $ end -> modify ( 'next month -1 second' ) ; $ time = static :: factory ( $ time ) ; return ( $ time >= $ start && $ time <= $ end ) ; } | Returns true if date passed was within last month . |
52,134 | public static function wasLastYear ( $ time ) { $ start = static :: factory ( 'last year January 1st 00:00:00' ) ; $ end = clone $ start ; $ end -> modify ( 'next year -1 second' ) ; $ time = static :: factory ( $ time ) ; return ( $ time >= $ start && $ time <= $ end ) ; } | Returns true if date passed was within last year . |
52,135 | public static function wasWithinLast ( $ time , $ span ) { $ span = static :: factory ( $ span ) ; $ time = static :: factory ( $ time ) ; $ now = static :: factory ( ) ; return ( $ time >= $ span && $ time <= $ now ) ; } | Returns true if the date passed was within the last time frame span . |
52,136 | public function delete ( PersistentCollectionInterface $ coll ) { $ mapping = $ coll -> getMapping ( ) ; if ( $ mapping -> isInverseSide ) { return ; } if ( $ mapping -> strategy === PropertyMetadata :: STORAGE_STRATEGY_ATOMIC_SET ) { throw new \ UnexpectedValueException ( sprintf ( '%s delete collection strategy shoul... | Deletes a PersistentCollection instance completely from a document using REMOVE . |
52,137 | public function getQueryPathAndParent ( PersistentCollectionInterface $ coll , QueryBuilder $ qb = null ) { $ collMapping = $ coll -> getMapping ( ) ; $ parent = $ coll -> getOwner ( ) ; $ paths [ ] = [ $ collMapping -> name , null ] ; while ( ( $ association = $ this -> uow -> getParentAssociation ( $ parent ) ) !== n... | Create and return a QueryBuilder and Path instance representing the provided collection s document path along with the top - level document . |
52,138 | public function randomStr ( $ length = 16 ) { $ arr = array_merge ( range ( 0 , 9 ) , range ( 'a' , 'z' ) , range ( 'A' , 'Z' ) ) ; $ str = '' ; $ arr_len = count ( $ arr ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ rand = mt_rand ( 0 , $ arr_len - 1 ) ; $ str .= $ arr [ $ rand ] ; } return $ str ; } | generate a random string include uppercase and lowercase letters and numbers |
52,139 | public function get ( string $ id ) : DatabaseConfiguration { if ( isset ( $ this -> configurations [ $ id ] ) ) { return $ this -> configurations [ $ id ] ; } throw new \ OutOfBoundsException ( 'No database configuration known for database requested with id ' . $ id ) ; } | returns database configuration for given id |
52,140 | public function getTables ( ) { $ statement = $ this -> connection -> prepare ( "SELECT * FROM information_schema.tables WHERE table_catalog = :database AND table_schema = 'public'" ) ; $ statement -> execute ( [ ':database' => $ this -> Databaser -> database ] ) ; return $ statement -> fetchAll ( \ PDO :: FETCH_ASSOC ... | Get all tables for a database |
52,141 | public function getTableRows ( string $ tableName ) { $ statement = $ this -> connection -> prepare ( "SELECT * FROM information_schema.columns WHERE table_catalog = :database AND table_name = :table" ) ; $ statement -> execute ( [ ':database' => $ this -> Databaser -> database , ':table' => $ tableName ] ) ; return $ ... | Get all rows for all tables |
52,142 | public static function wrap ( $ callable ) { $ parts = explode ( '::' , static :: represent ( $ callable ) ) ; if ( count ( $ parts ) == 1 ) { $ reflector = new \ ReflectionFunction ( $ callable ) ; } else { if ( ! is_array ( $ callable ) ) { $ callable = array ( $ callable , $ parts [ 1 ] ) ; } $ reflector = new \ Ref... | Wraps an existing callable piece of code . |
52,143 | public static function initialize ( ) { static $ initialized = false ; static $ structures = array ( ) ; if ( defined ( 'T_CALLABLE' ) ) { return ; } if ( ! $ initialized ) { spl_autoload_register ( function ( $ class ) { $ parts = array_map ( 'strrev' , explode ( '\\' , strrev ( $ class ) , 2 ) ) ; $ short = array_shi... | Initialize the wrapper . |
52,144 | public function subscribe ( $ handler , $ priority = Event :: DEFAULT_CALLBACKS_PRIORITY ) { $ _priority = \ is_int ( $ priority ) ? $ priority : self :: DEFAULT_CALLBACKS_PRIORITY ; if ( ! ( $ _priority >= self :: DEFAULT_CALLBACKS_MAX_PRIORITY && $ _priority <= self :: DEFAULT_CALLBACKS_MIN_PRIORITY ) ) { $ _priority... | Subscribe to this event . |
52,145 | public function setPostFields ( $ value ) { if ( is_array ( $ value ) ) { return $ this -> setOption ( CURLOPT_POSTFIELDS , http_build_query ( $ value ) ) ; } else { return $ this -> setOption ( CURLOPT_POSTFIELDS , $ value ) ; } } | Set post fields |
52,146 | public function doesFileExist ( $ url ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_NOBODY , true ) ; curl_exec ( $ ch ) ; $ httpCode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; curl_close ( $ ch ) ; return $ httpCode == 200 ; } | Checks if a file exists |
52,147 | public function getStatus ( string $ url ) { $ resource = curl_init ( $ url ) ; curl_setopt ( $ resource , CURLOPT_NOBODY , true ) ; curl_setopt ( $ resource , CURLOPT_CONNECTTIMEOUT , 10 ) ; curl_setopt ( $ resource , CURLOPT_HEADER , true ) ; curl_setopt ( $ resource , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( ... | Get the response code of a url |
52,148 | public function run ( ) { $ resource = curl_init ( ) ; foreach ( $ this -> settings as $ option => $ setting ) { curl_setopt ( $ resource , $ option , $ setting ) ; } $ headers = [ ] ; foreach ( $ this -> headers as $ key => $ value ) { if ( ! empty ( $ value ) ) { $ headers [ ] = implode ( ' : ' , [ $ key , $ value ] ... | Actually executes the cURL request |
52,149 | public static function init ( $ config = null ) { $ defaults = [ 'driver' => 'mysql' , 'host' => 'localhost' , 'database' => 'mysql' , 'username' => 'root' , 'password' => null , 'log_queries' => true , 'charset' => 'utf8' , 'collation' => 'utf8_unicode_ci' , 'prefix' => null ] ; $ capsule = new Capsule ; if ( is_strin... | Initialize the connection to the database . |
52,150 | public static function parseDsn ( $ string = null ) { $ opts = null ; if ( ! empty ( $ string ) ) { $ dsn = new DSN ( $ string ) ; $ port = empty ( $ dsn -> getFirstPort ( ) ) ? '' : ( ':' . $ dsn -> getFirstPort ( ) ) ; $ password = empty ( $ dsn -> getPassword ( ) ) ? null : $ dsn -> getPassword ( ) ; $ opts = [ 'dri... | Take a string DSN and parse it into an array of its pieces |
52,151 | public function commit ( ) { if ( empty ( $ this -> NodeCounts ) ) { $ this -> Logger -> debug ( __FUNCTION__ . '-> No nodes to change counts on.' ) ; return ; } foreach ( $ this -> NodeCounts as $ nodeRefUrl => $ count ) { $ nodeRef = $ this -> NodeRefService -> parseFromString ( $ nodeRefUrl ) ; if ( $ count != 0 ) {... | Update all meta on nodes queued |
52,152 | public function increment ( NodeRef $ nodeRef , NodeRef $ extNodeRef , $ tag ) { $ nodeRefUrl = $ nodeRef -> getRefURL ( ) ; if ( ! isset ( $ this -> NodeCounts [ $ nodeRefUrl ] ) ) $ this -> NodeCounts [ $ nodeRefUrl ] = 0 ; $ this -> NodeCounts [ $ nodeRefUrl ] ++ ; $ this -> Logger -> debug ( __FUNCTION__ . "-> Incr... | Queue a node to have its meta incremented |
52,153 | protected function getWebpackAssets ( ) { $ assets = public_path ( 'builds/manifest.json' ) ; $ assets = file_get_contents ( $ assets ) ; $ assets = json_decode ( $ assets , true ) ; return $ assets ; } | Get the manifest of assets compiled by Webpack . |
52,154 | protected function makeMenu ( $ menu ) { $ links = [ ] ; foreach ( $ menu as $ key => $ item ) { if ( is_string ( $ item ) ) { $ item = [ $ key , $ item ] ; } list ( $ endpoint , $ label ) = $ item ; $ attributes = array_get ( $ item , 4 , [ ] ) ; $ parameters = array_get ( $ item , 2 , [ ] ) ; $ link = $ this -> route... | Make a menu from a list of links . |
52,155 | protected function isOnPage ( $ page , $ loose = true ) { $ page = $ loose ? $ page : '^' . $ page . '$' ; $ page = str_replace ( '#' , '\#' , $ page ) ; return ( bool ) preg_match ( '#' . $ page . '#' , $ this -> request -> path ( ) ) ; } | Check if a string matches the given url . |
52,156 | protected function translate ( $ string ) { $ translated = $ this -> app [ 'translator' ] -> get ( $ string ) ; return is_string ( $ translated ) ? $ translated : $ string ; } | Act on a string to translate it . |
52,157 | public function check ( $ obj ) { foreach ( $ this -> findFilterComponents as $ findFilterComponent ) { if ( $ findFilterComponent -> check ( $ obj ) ) { return true ; } } return false ; } | Pass a entity through a filter . Does it match? |
52,158 | public function cmdGetCache ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = $ this -> cache -> get ( $ id ) ; if ( ! isset ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> outpu... | Callback for cache - get command |
52,159 | public function cmdClearCache ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { $ pattern = $ this -> getParam ( 'pattern' ) ; if ( iss... | Callback for cache - clear command |
52,160 | private function setRequestOptions ( $ url , $ vars , $ options = array ( ) ) { curl_setopt ( $ this -> request , CURLOPT_URL , $ url ) ; if ( ! empty ( $ vars ) ) { curl_setopt ( $ this -> request , CURLOPT_POSTFIELDS , $ vars ) ; } curl_setopt ( $ this -> request , CURLOPT_HEADER , true ) ; curl_setopt ( $ this -> re... | Sets the CURLOPT options for the current request |
52,161 | private function setRequestHeaders ( $ headers = array ( ) ) { foreach ( $ this -> headers as $ key => $ value ) { $ headers [ ] = $ key . ': ' . $ value ; } curl_setopt ( $ this -> request , CURLOPT_HTTPHEADER , $ headers ) ; } | Formats and adds custom headers to the current request |
52,162 | public function addRoutes ( array $ routes = [ ] ) { foreach ( $ routes as $ route ) { if ( $ route instanceof RouteInterface ) $ this -> routes [ ] = $ route ; } } | Add all routes which are available |
52,163 | public function dispatch ( Request $ request ) { if ( ltrim ( $ _SERVER [ 'REQUEST_URI' ] , '/' ) === '' ) { return new DispatcherResult ( 200 , $ this -> defaultHandler ) ; } $ dispatcher = $ this -> getDispatcher ( ) ; $ match = $ dispatcher -> dispatch ( $ request -> getMethod ( ) , $ _SERVER [ 'REQUEST_URI' ] ) ; $... | Once called the router should examine the current request by request method and url and find a matching route . If no route was find dispatch a http error instead . |
52,164 | static public function flatten ( array $ array , $ prefix = '' , $ keepEmptyArrayNode = TRUE , $ segmentationCharacter = self :: SEGMENTATION_CHARACTER ) { $ flatArray = array ( ) ; foreach ( $ array as $ key => $ value ) { $ key = rtrim ( $ key , $ segmentationCharacter ) ; if ( ! is_array ( $ value ) || ( count ( $ v... | Converts a multidimensional array to a flat representation . |
52,165 | public function getAttributeValue ( $ key ) { $ value = $ this -> getAttributeFromArray ( $ key ) ; if ( isset ( $ this -> enums [ $ key ] ) && is_scalar ( $ value ) ) { $ enumClass = $ this -> enums [ $ key ] ; return new $ enumClass ( $ value ) ; } return parent :: getAttributeValue ( $ key ) ; } | Gets the value of attribute taking enums typecast into consideration |
52,166 | public function setAttribute ( $ key , $ value ) { if ( isset ( $ this -> enums [ $ key ] ) && is_scalar ( $ value ) ) { $ enumClass = $ this -> enums [ $ key ] ; $ this -> attributes [ $ key ] = new $ enumClass ( $ value ) ; } else { parent :: setAttribute ( $ key , $ value ) ; } return $ this ; } | Sets the value of attribute taking enums typecast into consideration |
52,167 | protected static function getEnumValidationRule ( string $ enumClass ) : array { if ( ! is_a ( $ enumClass , Enum :: class , true ) ) { throw new \ UnexpectedValueException ( 'Class is not enum' ) ; } return array_merge ( [ 'in' ] , $ enumClass :: getConstants ( ) ) ; } | Gets validation rule for given enum class |
52,168 | public function get ( string $ name = null ) : DatabaseConnection { if ( null == $ name ) { $ name = DatabaseConfiguration :: DEFAULT_ID ; } if ( isset ( $ this -> connections [ $ name ] ) ) { return $ this -> connections [ $ name ] ; } $ this -> connections [ $ name ] = new PdoDatabaseConnection ( $ this -> configurat... | returns the connection |
52,169 | protected function init ( ) { if ( $ this -> policy != self :: POLICY_NONE ) { foreach ( $ this -> _role as $ role ) { $ this -> role [ $ role ] = [ 'id' => $ role , 'role' => $ role ] ; $ this -> permission -> addRole ( $ role ) ; } foreach ( $ this -> _resource as $ resource ) { $ this -> resource [ $ resource ] = [ ... | Init data . |
52,170 | public function setFlashData ( $ newdata , $ value = '' ) { if ( is_string ( $ newdata ) ) { $ newdata = [ $ newdata => $ value ] ; } if ( ! empty ( $ newdata ) ) { foreach ( $ newdata as $ key => $ val ) { $ this -> newFlashData [ $ key ] = $ val ; } } } | Set Flash Data |
52,171 | public function getFlashData ( $ key = null ) { if ( $ key === null ) { return $ this -> lastFlashData ; } return isset ( $ this -> lastFlashData [ $ key ] ) ? $ this -> lastFlashData [ $ key ] : null ; } | Get Flash Data |
52,172 | private function write ( ) { $ sessionData [ 'data' ] = $ this -> data ; $ sessionData [ 'flash' ] = $ this -> newFlashData ; $ stmt = $ this -> db -> prepare ( "UPDATE {$this->tableName} SET data = ? WHERE session_id = ?" ) ; $ stmt -> execute ( [ json_encode ( $ sessionData ) , $ this -> sessionId ] ) ; } | Write Session Data |
52,173 | private function cleanExpired ( ) { if ( mt_rand ( 1 , 10 ) == 1 ) { $ expiredTime = $ this -> now - $ this -> secondsUntilExpiration ; $ stmt = $ this -> db -> prepare ( "DELETE FROM {$this->tableName} WHERE time_updated < {$expiredTime}" ) ; $ stmt -> execute ( ) ; } } | Clean Old Sessions |
52,174 | private function generateId ( ) { $ randomNumber = mt_rand ( 0 , mt_getrandmax ( ) ) ; $ ipAddressFragment = md5 ( substr ( $ this -> ipAddress , 0 , 5 ) ) ; $ timestamp = md5 ( microtime ( true ) . $ this -> now ) ; return hash ( 'sha256' , $ randomNumber . $ ipAddressFragment . $ this -> salt . $ timestamp ) ; } | Generate New Session ID |
52,175 | public function hasValue ( $ value , bool $ strict = false ) : bool { return in_array ( $ value , $ this -> data , $ strict ) ; } | Has value . |
52,176 | public function pullAll ( array $ keys , $ valueDefault = null ) : array { return Arrays :: pullAll ( $ this -> data , $ keys , $ valueDefault ) ; } | Pull all . |
52,177 | protected function isAllowed ( ServerRequestInterface $ request , string $ role ) : bool { $ route = $ request -> getAttribute ( 'route' ) ; $ config = 'routes.' . $ route -> getGroups ( ) [ 0 ] -> getPattern ( ) . '.' . \ strtr ( '/' . $ route -> getName ( ) , [ $ route -> getGroups ( ) [ 0 ] -> getPattern ( ) => '' ,... | Check if request allowed for current user . |
52,178 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ frontController = FrontController :: getInstance ( ) ; $ frontController -> setDispatcher ( $ serviceLocator -> get ( 'Dispatcher' ) ) ; $ frontController -> setRequest ( $ serviceLocator -> get ( 'Request' ) ) ; $ frontController -> setResp... | Create front controller service |
52,179 | protected function findOr404 ( Request $ request , array $ criteria = [ ] ) { if ( ! $ request -> attributes -> has ( 'id' ) ) { throw new \ LogicException ( 'Request does not have "id" attribute set.' ) ; } $ criteria [ 'id' ] = $ request -> attributes -> get ( 'id' ) ; if ( null === $ resource = $ this -> getManager ... | Returns resource by ID parameter |
52,180 | public function iconDownload ( ) { if ( $ this -> iconIsLocal ( "client_icon_id" ) || $ this [ "client_icon_id" ] == 0 ) { return ; } $ download = $ this -> getParent ( ) -> transferInitDownload ( rand ( 0x0000 , 0xFFFF ) , 0 , $ this -> iconGetName ( "client_icon_id" ) ) ; $ transfer = Teamspeak :: factory ( "filetran... | Downloads and returns the clients icon file content . |
52,181 | public static function uploadsUrl ( $ url = '' ) { $ url = Config :: get ( 'congraph::congraph.uploads_url' ) . '/' . $ url ; $ rtrim = ! empty ( $ url ) ; $ url = url ( self :: normalizeUrl ( $ url , $ rtrim ) ) ; return $ url ; } | Get uploads url from config and optionally concatonates given url to uploads url |
52,182 | public static function normalizePath ( $ path , $ rtrim = true ) { $ path = trim ( $ path ) ; $ path = str_replace ( '\\' , '/' , $ path ) ; $ path = preg_replace ( '/\/+/' , '==DS==' , $ path ) ; $ segments = explode ( '==DS==' , $ path ) ; $ path = implode ( DIRECTORY_SEPARATOR , $ segments ) ; if ( $ rtrim ) { $ pat... | Normalizes path slashes when mixed between path and url conversion |
52,183 | public static function normalizeUrl ( $ url , $ rtrim = true ) { $ url = trim ( $ url ) ; $ url = str_replace ( '\\' , '/' , $ url ) ; $ url = preg_replace ( '/\/+/' , '==DS==' , $ url ) ; $ segments = explode ( '==DS==' , $ url ) ; $ url = implode ( '/' , $ segments ) ; if ( $ rtrim ) { $ url = rtrim ( $ url , '/' ) ;... | Normalizes url slashes when mixed between path and url conversion |
52,184 | public static function uniqueFilename ( $ path ) { $ dir = self :: getDirectory ( $ path ) ; $ filename = self :: getFileName ( $ path ) ; $ filename = self :: sanitizeFileName ( $ filename ) ; $ info = pathinfo ( $ filename ) ; $ ext = ! empty ( $ info [ 'extension' ] ) ? '.' . $ info [ 'extension' ] : '' ; $ name = b... | Get a filename that is sanitized and unique for the given directory . |
52,185 | public static function sanitizeFileName ( $ filename ) { $ special_chars = array ( "?" , "[" , "]" , "/" , "\\" , "=" , "<" , ">" , ":" , ";" , "," , "'" , "\"" , "&" , "$" , "#" , "*" , "(" , ")" , "|" , "~" , "`" , "!" , "{" , "}" , chr ( 0 ) ) ; $ filename = str_replace ( $ special_chars , '' , $ filename ) ; $ file... | Sanitizes a filename replacing whitespace with dashes |
52,186 | public static function getFileName ( $ path , $ includeExtension = true ) { $ option = ( $ includeExtension ) ? PATHINFO_BASENAME : PATHINFO_FILENAME ; return pathinfo ( $ path , $ option ) ; } | Extracts filename from path with or without extension |
52,187 | public function index ( ) { $ options = $ this -> getQueryHelperOptions ( ) ; $ items = $ this -> repo -> allPaged ( $ options ) ; if ( ! $ items ) { return $ this -> respondNotFound ( 'Unable to fetch the selected resources' ) ; } $ response = [ 'data' => [ ] , 'meta' => [ 'pagination' => [ ] ] ] ; $ resource = new Fr... | Return items in a paged way |
52,188 | public function show ( $ id ) { $ item = $ this -> repo -> getById ( $ id ) ; if ( ! $ item ) { return $ this -> respondNotFound ( ) ; } $ resource = new Fractal \ Resource \ Item ( $ item , new $ this -> transformerClass ) ; return $ this -> fractal -> createData ( $ resource ) -> toArray ( ) ; } | Return an item by it s id |
52,189 | public function setDefaultModel ( $ model ) { if ( is_string ( $ model ) ) { $ model = new ReflectionClass ( $ model ) ; $ model = $ model -> newInstanceWithoutConstructor ( ) ; } if ( $ model instanceof Model ) { $ this -> defaultModel = get_class ( $ model ) ; return ; } throw new \ InvalidArgumentException ( 'Collec... | Set default model class |
52,190 | protected function checkItems ( array $ data ) { foreach ( $ data as & $ item ) { if ( ! $ item instanceof Model ) { $ item = new $ this -> defaultModel ( $ item ) ; } } return $ data ; } | Check if all items are instance of Model if not create new Model for each item |
52,191 | public function findJournalForId ( $ id ) { $ dql = ' SELECT j,p FROM %s j LEFT JOIN j.postings p WHERE j.id = :id AND j.organization = :organization ' ; return $ this -> em -> createQuery ( sprintf ( $ dql , $ this -> journalFqcn ) ) -> se... | Find Journal for id |
52,192 | public function createJournal ( ) { $ journal = new $ this -> journalFqcn ( ) ; $ journal -> setOrganization ( $ this -> oh -> getOrganization ( ) ) ; return $ journal ; } | Create new Journal |
52,193 | public function addRoute ( $ expression , $ route ) { if ( strpos ( $ expression , '*' ) !== false ) { return $ this -> addRegexpRoute ( $ expression , $ route ) ; } else { return $ this -> addSimpleRoute ( $ expression , $ route ) ; } } | Add new route . |
52,194 | private function addRegexpRoute ( $ expression , $ route ) { $ expression = '|^' . str_replace ( array ( '*' , '\\' ) , array ( '.*' , '\\\\' ) , $ expression ) . '$|i' ; if ( array_key_exists ( $ expression , $ this -> regexpRoutes ) && $ this -> regexpRoutes [ $ expression ] == $ route ) { return false ; } $ this -> ... | Add new regexp route . |
52,195 | private function addSimpleRoute ( $ expression , $ route ) { if ( array_key_exists ( $ expression , $ this -> simpleRoutes ) && $ this -> simpleRoutes [ $ expression ] == $ route ) { return false ; } $ this -> simpleRoutes [ $ expression ] = ( string ) $ route ; return true ; } | Add new simple route . |
52,196 | private function doDetect ( $ className , $ performInterfaceDetection = true ) { $ detection = $ this -> doDetectByRoutes ( $ className ) ; if ( $ detection ) { return $ detection ; } $ parentClass = get_parent_class ( $ className ) ; if ( $ parentClass ) { $ parentDetection = $ this -> doDetect ( $ parentClass , false... | Detect pool . |
52,197 | private function doDetectByRoutes ( $ className ) { if ( ! empty ( $ this -> simpleRoutes [ $ className ] ) ) { return new ClassDetection ( $ this -> simpleRoutes [ $ className ] ) ; } foreach ( $ this -> regexpRoutes as $ regexpRoute => $ poolName ) { if ( preg_match ( $ regexpRoute , $ className ) ) { return new Clas... | Perform detection based on class name and routes registered for this class . |
52,198 | private function doDetectByInterfaces ( $ className ) { $ interfaces = $ this -> getOrderedInterfaces ( $ className ) ; foreach ( $ interfaces as $ interface ) { $ candidate = $ this -> doDetectByRoutes ( $ interface ) ; if ( $ candidate ) { return $ candidate ; } } return ; } | Perform detection based on class interfaces . |
52,199 | private function getOrderedInterfaces ( $ className ) { $ interfacesArr = $ this -> prepareClassTreeInterfaces ( $ className ) ; $ interfaces = array ( ) ; foreach ( $ interfacesArr as $ classInterfaces ) { foreach ( $ classInterfaces as $ interface ) { if ( array_search ( $ interface , $ interfaces ) === false ) { arr... | Get a list of class interfaces ordered by plase of interface declaration . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.