idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
52,200 | private function prepareClassTreeInterfaces ( $ className ) { $ interfacesArr = array ( ) ; $ reflection = new ReflectionClass ( $ className ) ; $ interfacesArr [ ] = $ reflection -> getInterfaceNames ( ) ; if ( empty ( $ interfacesArr [ 0 ] ) ) { return array ( ) ; } $ classParents = class_parents ( $ className ) ; fo... | Prepares all interfaces for given class and its parents . |
52,201 | public function findAllTreeItems ( $ publishedOnly = false ) { $ filter = $ publishedOnly ? [ 'published' => true ] : [ ] ; return $ this -> repository -> findBy ( $ filter , [ 'lft' => 'ASC' ] ) ; } | Returns all items in tree structure |
52,202 | public function getUniqueAlias ( $ entity , string $ titleProperty = 'title' , string $ titleValue = null , string $ aliasColumn = 'seoTitle' ) : string { $ alias = Strings :: webalize ( $ titleValue ?? $ entity -> { $ titleProperty } ) ; $ id = $ entity -> id ?? null ; while ( ! $ this -> seoTitleIsUnique ( $ id , $ a... | Returns unique seo alias for entity |
52,203 | private function seoTitleIsUnique ( $ id , string $ generatedAlias , string $ aliasColumn = 'seoTitle' ) : bool { $ alias = Strings :: webalize ( $ generatedAlias ) ; if ( $ id === null ) { $ results = $ this -> repository -> findBy ( [ $ aliasColumn => $ alias ] ) ; } else { $ results = $ this -> repository -> findBy ... | Checks if seo title is unique . |
52,204 | public function removeImage ( $ entityId ) { if ( ! $ entityId ) { return false ; } $ delete = ' UPDATE ' . $ this -> repository -> getClassName ( ) . ' a SET a.image = NULL WHERE a.id = ' . $ entityId . ' ' ; $ q = $ this -> query ( $ delete ) ; $ q -> execute ( ) ; } | Sets image to NULL |
52,205 | public function getNewMaxId ( $ entityClassname ) : int { $ maxId = $ this -> em -> createQueryBuilder ( ) -> select ( 'MAX(e.id) + 1' ) -> from ( $ entityClassname , 'e' ) -> getQuery ( ) -> getSingleScalarResult ( ) ; return ( int ) $ maxId ; } | Returns new MAX ID for entity |
52,206 | public function rebuildTree ( $ entityClass = '' , $ parentEntity ) { if ( $ entityClass === '' ) { throw new Exception ( 'messages.error.classNameNotProvided' ) ; } if ( $ parentEntity === null ) { throw new Exception ( 'messages.error.cantRemakeTree' ) ; } $ dqlLft = ' UPDATE ' . $ entityClass . ' a ... | Rebuilds a tree structure by setting lft and rgt values across the rest of the tree |
52,207 | public function deleteTreeItem ( $ entityClass = '' , $ id ) { if ( $ entityClass === '' ) { throw new Exception ( 'messages.error.classNameNotProvided' ) ; } $ entity = $ this -> findById ( $ id ) ; $ difference = $ entity -> rgt - $ entity -> lft + 1 ; $ deleteTree = ' DELETE FROM ' . $ entityClass . '... | Deletes a tree node and updates rest of the tree |
52,208 | public function deriveColumn ( $ index ) { $ this -> validateColumnIndex ( $ index ) ; $ column = new DerivedColumn ( $ this -> columns [ $ index ] -> getAlias ( ) ) ; return $ column -> setTable ( $ this ) ; } | Derives an expression in the query s select clause as a column of the query s associated resultset . |
52,209 | public function deriveColumns ( ) { $ derived = array ( ) ; for ( $ i = 0 ; $ i < count ( $ this -> columns ) ; $ i ++ ) { $ derived [ ] = $ this -> deriveColumn ( $ i ) ; } return $ derived ; } | Derives all expressions in the query s select clause as columns of the query s associated resultset . |
52,210 | public function setModuleDirs ( $ dirs ) { if ( ! is_array ( $ dirs ) && ! ( $ dirs instanceof \ Traversable ) ) { throw new \ InvalidArgumentException ( 'Invalid argument $dirs; array or instance of Traversable expected' ) ; } $ this -> moduleDirs = array ( ) ; foreach ( $ dirs as $ dir ) { if ( ! is_dir ( $ dir ) || ... | Set module directories |
52,211 | public static function isValidFieldOccurrence ( $ arg ) { if ( $ arg === null || ctype_digit ( $ arg ) ) { $ arg = ( int ) $ arg ; } return is_int ( $ arg ) && $ arg >= 0 && $ arg < 100 ; } | Return TRUE if argument is a valid field occurrence . |
52,212 | public static function match ( $ reBody ) { if ( strpos ( $ reBody , '#' ) !== false ) { $ reBody = str_replace ( '#' , '\#' , $ reBody ) ; } $ regexp = "#{$reBody}#D" ; return function ( Field $ field ) use ( $ regexp ) { return ( bool ) preg_match ( $ regexp , $ field -> getShorthand ( ) ) ; } ; } | Return predicate that matches a field shorthand against a regular expression . |
52,213 | public static function factory ( array $ field ) { foreach ( array ( 'tag' , 'occurrence' , 'subfields' ) as $ index ) { if ( ! array_key_exists ( $ index , $ field ) ) { throw new InvalidArgumentException ( "Missing '{$index}' index in field array" ) ; } } return new Field ( $ field [ 'tag' ] , $ field [ 'occurrence' ... | Return a new field based on its array representation . |
52,214 | public function setSubfields ( array $ subfields ) { $ this -> _subfields = array ( ) ; foreach ( $ subfields as $ subfield ) { $ this -> addSubfield ( $ subfield ) ; } } | Set the field subfields . |
52,215 | public function addSubfield ( \ HAB \ Pica \ Record \ Subfield $ subfield ) { if ( in_array ( $ subfield , $ this -> getSubfields ( ) , true ) ) { throw new InvalidArgumentException ( "Cannot add subfield: Subfield already part of the subfield list" ) ; } $ this -> _subfields [ ] = $ subfield ; } | Add a subfield to the end of the subfield list . |
52,216 | public function removeSubfield ( \ HAB \ Pica \ Record \ Subfield $ subfield ) { $ index = array_search ( $ subfield , $ this -> _subfields , true ) ; if ( $ index === false ) { throw new InvalidArgumentException ( "Cannot remove subfield: Subfield not part of the subfield list" ) ; } unset ( $ this -> _subfields [ $ i... | Remove a subfield . |
52,217 | public function getSubfields ( ) { if ( func_num_args ( ) === 0 ) { return $ this -> _subfields ; } else { $ selected = array ( ) ; $ codes = array ( ) ; $ subfields = $ this -> getSubfields ( ) ; array_walk ( $ subfields , function ( $ value , $ index ) use ( & $ codes ) { $ codes [ $ index ] = $ value -> getCode ( ) ... | Return the field s subfields . |
52,218 | public function getNthSubfield ( $ code , $ n ) { $ count = 0 ; foreach ( $ this -> getSubfields ( ) as $ subfield ) { if ( $ subfield -> getCode ( ) == $ code ) { if ( $ count == $ n ) { return $ subfield ; } $ count ++ ; } } return null ; } | Return the nth occurrence of a subfield with specified code . |
52,219 | public function getSubfieldsWithCode ( $ code ) { return array_filter ( $ this -> _subfields , function ( Subfield $ s ) use ( $ code ) { return $ s -> getCode ( ) == $ code ; } ) ; } | Return all subfields with the specified code . |
52,220 | public function setDefinition ( $ definition ) { if ( $ definition instanceof Expression ) { $ definition = ( string ) $ definition ; } $ this -> definition = $ definition ; } | Set the definition . |
52,221 | private function getDefaultAdapter ( ) { if ( extension_loaded ( 'curl' ) ) { $ this -> parallelAdapter = new MultiAdapter ( $ this -> messageFactory ) ; $ this -> adapter = function_exists ( 'curl_reset' ) ? new CurlAdapter ( $ this -> messageFactory ) : $ this -> parallelAdapter ; if ( ini_get ( 'allow_url_fopen' ) )... | Create a default adapter to use based on the environment |
52,222 | private function mergeDefaults ( & $ options ) { if ( ! isset ( $ options [ 'headers' ] ) || ! isset ( $ this -> defaults [ 'headers' ] ) ) { $ options = array_replace_recursive ( $ this -> defaults , $ options ) ; return null ; } $ defaults = $ this -> defaults ; unset ( $ defaults [ 'headers' ] ) ; $ options = array_... | Merges default options into the array passed by reference and returns an array of headers that need to be merged in after the request is created . |
52,223 | protected function build ( ) { $ content = '' ; if ( isset ( $ this -> parameters ) && is_array ( $ this -> parameters ) ) { $ content = http_build_query ( $ this -> parameters ) ; } if ( isset ( $ this -> body ) ) { $ content = $ this -> body ; } $ content_type = 'application/x-www-form-urlencoded; charset=utf-8' ; if... | Ready the request for transport |
52,224 | protected function sendRequest ( ) { $ context = stream_context_create ( $ this -> request ) ; $ response = trim ( file_get_contents ( $ this -> endpoint , FALSE , $ context ) ) ; $ this -> response = new Response ( $ http_response_header , $ response , $ this -> request ) ; return $ this -> response ; } | Sends the actual request and returns the response . |
52,225 | public function setSubResources ( array $ subResources ) { foreach ( $ subResources as $ name => $ mapping ) { if ( ! is_string ( $ name ) || ! is_array ( $ mapping ) ) { throw Exception :: invalidSubResources ( $ this -> className ) ; } if ( ! isset ( $ mapping [ 'fieldName' ] ) ) { throw Exception :: invalidSubResour... | Sets the set of allowable sub - resources . |
52,226 | public function format ( array $ response ) { $ car = '<br />' ; $ format = '' ; foreach ( $ response as $ media ) { $ format .= '<div class="media">' . '<img src="' . $ media -> getThumburl ( ) . '"' . ' width="' . $ media -> getThumbwidth ( ) . '"' . ' height="' . $ media -> getThumbheight ( ) . '"' . ' title="' . Ap... | format a media response as an HTML string |
52,227 | public function filterCamelCaseToUnderscore ( $ text ) { $ text = StaticFilter :: execute ( $ text , 'Word\CamelCaseToUnderscore' ) ; $ text = StaticFilter :: execute ( $ text , 'StringToLower' ) ; return $ text ; } | Filter camel case to underscore |
52,228 | protected function doLoadClassMetadata ( $ type ) { if ( false === $ this -> classMetadataExists ( $ type ) ) { return null ; } $ className = $ this -> getClassNameForType ( $ type ) ; return $ this -> mf -> getMetadataFor ( $ className ) ; } | Loads Doctrine ClassMetadata for an entity type . |
52,229 | protected function classMetadataExists ( $ type ) { $ className = $ this -> getClassNameForType ( $ type ) ; try { $ metadata = $ this -> mf -> getMetadataFor ( $ className ) ; return true ; } catch ( MappingException $ e ) { return false ; } return false === $ this -> shouldFilterClassMetadata ( $ metadata ) ; } | Determines if Doctrine ClassMetadata exists for an entity type . |
52,230 | protected function getTypeForClassName ( $ className ) { if ( empty ( $ this -> rootNamespace ) ) { return $ className ; } return $ this -> stripNamespace ( $ this -> rootNamespace , $ className ) ; } | Gets the entity type from a Doctrine class name . |
52,231 | protected function getClassNameForType ( $ type ) { if ( ! empty ( $ this -> rootNamespace ) && strstr ( $ type , $ this -> rootNamespace ) ) { $ type = $ this -> stripNamespace ( $ this -> rootNamespace , $ type ) ; } if ( ! empty ( $ this -> rootNamespace ) ) { return sprintf ( '%s\\%s' , $ this -> rootNamespace , $ ... | Gets the Doctrine class name from an entity type . |
52,232 | public function dispatch ( $ action = [ ] , $ group = null ) { if ( is_string ( $ action ) ) { $ action = [ '_controller' => $ action ] ; } $ this -> registerGroup ( $ group , $ action ) ; if ( $ middleware = $ this -> findMiddleware ( $ action ) ) { app ( ) -> call ( [ $ this , 'middleware' ] , $ middleware ) ; } if (... | Dispatch a action from array |
52,233 | protected function findMiddleware ( $ action ) { if ( is_array ( $ action ) && isset ( $ action [ '_middleware' ] ) ) { return $ action [ '_middleware' ] ; } elseif ( isset ( $ this -> group [ '_middleware' ] ) ) { return $ this -> group [ '_middleware' ] ; } return false ; } | find and return middleware |
52,234 | protected function findControllerAndMethod ( array $ action ) { if ( isset ( $ action [ '_controller' ] ) || $ action [ 'uses' ] ) { $ controller = isset ( $ action [ '_controller' ] ) ? $ action [ '_controller' ] : $ action [ 'uses' ] ; if ( strstr ( $ controller , ':' ) ) { list ( $ controller , $ method ) = explode ... | find controller method and namespace in action variable |
52,235 | protected function findNamespaceInController ( & $ controller ) { if ( strstr ( $ controller , '\\' ) ) { $ namespace = explode ( '\\' , $ controller ) ; $ controller = end ( $ namespace ) ; $ namespace = rtrim ( join ( '\\' , array_slice ( $ namespace , 0 , count ( $ namespace ) - 1 ) ) , '\\' ) ; } else { $ namespace... | find namespace in controller |
52,236 | private function handleResponse ( $ response ) { if ( $ response instanceof View ) { $ content = $ response -> render ( ) ; } elseif ( $ response instanceof Response ) { $ content = $ response -> getContent ( ) ; } elseif ( $ response instanceof Request ) { $ content = $ response -> getResponse ( ) -> getContent ( ) ; ... | Handler the controller returned value |
52,237 | protected function setup ( InputInterface $ input ) { return $ this -> setup -> setForcedRollback ( $ input -> getOption ( 'force-rollback' ) ) -> setExecuteQueries ( $ input -> getOption ( 'execute' ) ) -> setRollbackedFirst ( $ input -> getOption ( 'rollback-first' ) ) -> run ( ) ; } | Start migration setup |
52,238 | public function getDocComment ( $ withCommentMark = false ) { $ docComment = $ this -> _reflectionMethod -> getDocComment ( ) ; if ( $ withCommentMark === true ) { $ docComment = PhpDocCommentObject :: ltrim ( $ docComment ) ; } else { $ docComment = PhpDocCommentObject :: stripCommentMarks ( $ docComment ) ; } return ... | Get DocComment of method |
52,239 | public function compile ( ExpressCompiler $ compiler , $ flags = 0 ) { try { if ( $ flags & self :: FLAG_RAW ) { $ compiler -> write ( $ this -> expression -> compile ( $ compiler -> getExpressionContextFactory ( ) , false , '$this->exp' ) ) ; } else { $ compiler -> write ( "\t\ttry {\n" ) ; if ( $ this -> stringify ) ... | Compiles an expression into PHP code . |
52,240 | public function normalize ( & $ data , $ format ) { if ( ! is_array ( $ data ) ) { return $ this -> $ format ( $ data ) ; } foreach ( $ data as $ key => $ value ) { if ( $ key != ( $ normalizedKey = $ this -> $ format ( $ key ) ) ) { if ( array_key_exists ( $ normalizedKey , $ data ) ) { throw new \ InvalidArgumentExce... | Normalize given data If an array is given normalize keys according to given method |
52,241 | public static function fromCurrent ( $ key = null , $ default = null ) { switch ( static :: getMethod ( ) ) { case 'get' : $ data = $ _GET ; break ; case 'post' : $ data = $ _POST ; break ; default : $ data = null ; } return static :: from ( static :: getMethod ( ) , $ key , $ default , $ data ) ; } | Get variable from the current HTTP method |
52,242 | public static function getHeader ( $ header ) { $ headers = static :: getHeaders ( ) ; if ( true === isset ( $ headers [ $ header ] ) ) { return $ headers [ $ header ] ; } return null ; } | Get request header by key |
52,243 | public static function all ( ) { if ( true === isset ( static :: $ method [ 'data' ] ) ) { return static :: $ method [ 'data' ] ; } parse_str ( static :: getBody ( ) , $ vars ) ; return [ 'get' => $ _GET , 'post' => $ _POST , 'put' => static :: isMethod ( 'put' ) ? $ vars : [ ] , 'delete' => static :: isMethod ( 'delet... | Return all the data from get post put delete patch connect head options and trace |
52,244 | public static function getIp ( ) { if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { return $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } if ( isset ( $ _SERVER [ 'HTTP-X-FORWARDED-FOR' ] ) ) { return $ _SERVER [ 'HTTP-X-FORWARDED-FOR' ] ; } if ( isset ( $ _SERVER [ 'HTTP_VIA' ] ) ) { return $ _SERVER [ 'HTTP_VIA' ] ;... | Returns the request IP address |
52,245 | public static function parseUrl ( $ key = null ) { if ( null !== $ key && false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } $ url = [ ] ; $ types = [ 'host' => 'HTTP_HOST' , 'port'... | Returns parsed url by giving an option key for only the value of that key to return |
52,246 | private static function get ( $ key = null , $ default = null ) { if ( null !== $ key && isset ( static :: $ method [ 'method' ] , static :: $ method [ 'data' ] ) ) { if ( static :: isMethod ( static :: $ method [ 'method' ] ) ) { $ helper = new StringToArray ( ) ; $ data = $ helper -> execute ( $ key , $ default , sta... | Returns variable from source while converting an array from string |
52,247 | private static function from ( $ type , $ key , $ default , & $ source = null ) { if ( null === $ source ) { if ( static :: isMethod ( $ type ) ) { $ source = [ ] ; static :: parseRawHttpRequest ( $ source ) ; } } static :: $ method = [ 'method' => $ type , 'data' => & $ source ] ; if ( null !== $ key ) { return static... | Get variable from variable source |
52,248 | private static function parseRawHttpRequest ( array & $ data ) { if ( false === isset ( $ _SERVER [ 'CONTENT_TYPE' ] ) ) { $ _SERVER [ 'CONTENT_TYPE' ] = '' ; } $ input = static :: getBody ( ) ; preg_match ( '/boundary=(.*)$/' , $ _SERVER [ 'CONTENT_TYPE' ] , $ matches ) ; if ( 0 === count ( $ matches ) ) { $ json = @ ... | Parses raw HTTP request string |
52,249 | public function renderCalendarLeftmenuAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; } | Render the leftmenu |
52,250 | public function set ( $ name , $ value ) { parent :: set ( $ name , $ value ) ; $ _SESSION [ $ name ] = $ value ; return $ this ; } | Set value in session . |
52,251 | public function find ( $ url ) { if ( ! array_key_exists ( $ url , $ this -> controllerMap ) ) { return null ; } return $ this -> controllerMap [ $ url ] ; } | Finds the controller for the given url . |
52,252 | public function parse ( ) { $ name_without_parens = preg_replace ( '/[{}]/' , '' , $ this -> full_name ) ; $ parts = explode ( '|' , $ name_without_parens ) ; $ name_without_pipes = trim ( $ parts [ 0 ] ) ; $ parts = explode ( '::' , $ name_without_pipes ) ; $ name_without_case_keys = trim ( $ parts [ 0 ] ) ; array_shi... | Parses token elements |
52,253 | public function with ( $ relation ) { foreach ( ( array ) $ relation as $ node ) { $ instance = $ this -> factory -> build ( $ this -> model ( ) , $ node ) ; $ this -> relations [ $ instance -> name ( ) ] = $ instance ; } return $ this ; } | Adds relation to query |
52,254 | public function relation ( $ relation ) { list ( $ name , $ furtherRelations ) = $ this -> factory -> splitRelationName ( $ relation ) ; if ( ! isset ( $ this -> relations [ $ name ] ) ) { throw new QueryException ( sprintf ( 'Unable to retrieve relation "%s" query, relation does not exists in query "%s"' , $ name , $ ... | Returns relation instance |
52,255 | public function getRealName ( ) { if ( $ this -> firstname || $ this -> surname ) { return trim ( $ this -> getFirstname ( ) . ' ' . $ this -> getSurname ( ) ) ; } return null ; } | Get realname Firstname Surname |
52,256 | public function putTemplate ( $ cacheKey , Template $ template ) { if ( $ template -> getCacheTime ( ) == null && ! is_numeric ( $ template -> getCacheTime ( ) ) ) $ template -> setCacheTime ( $ this -> defaultCacheTime ) ; $ this -> put ( $ cacheKey , $ template , ( int ) $ template -> getCacheTime ( ) ) ; return true... | Stores the specified template to cache using the cacheKey specified . |
52,257 | public function getTemplateCacheKey ( Template $ template , $ globals ) { $ locals = $ template -> getLocals ( ) ; $ cachekey = '' ; if ( $ template -> isTopTemplate ( ) ) $ cachekey .= $ this -> Request -> getAdjustedRequestURI ( ) ; else $ cachekey .= $ template -> getContentType ( ) . $ template -> getName ( ) ; $ c... | Returns a cacheKey for the specified Template |
52,258 | protected function ensureRepository ( $ repository ) { if ( $ repository === null ) { return new Repository ( ) ; } if ( $ repository instanceof RepostoryContract ) { return $ repository ; } if ( is_array ( $ repository ) ) { return new Repository ( $ repository ) ; } throw new \ LogicException ( 'A repository should e... | Ensure a Repository instance . |
52,259 | public function toSQL ( Parameters $ params , bool $ inner_clause ) { if ( $ key = $ this -> getKey ( ) ) { try { $ params -> get ( $ key ) ; } catch ( \ OutOfRangeException $ e ) { $ key = null ; } } if ( $ key === null ) { $ val = $ this -> getValue ( ) ; if ( is_bool ( $ val ) ) $ val = $ val ? 1 : 0 ; $ key = $ par... | Write a constant as SQL query syntax |
52,260 | public function getChildren ( ) { $ output = new BaseContainer ( ) ; foreach ( $ this -> getRelation ( ) -> getChildren ( ) as $ childRelation ) { $ childAttribute = $ childRelation -> getAttributeByName ( $ this -> name ) ; $ output -> add ( $ childAttribute , $ childAttribute -> getChildren ( ) ) ; } return $ output ... | Get all inherited Attributes |
52,261 | public function isInherited ( & $ originalColumn = null ) { $ inhcount = $ this -> attinhcount ; if ( $ inhcount == 0 ) { $ originalColumn = null ; return false ; } if ( func_num_args ( ) === 0 ) { return true ; } $ originalRelation = $ this -> getRelation ( ) ; do { $ originalRelation = $ originalRelation -> getParent... | Is this column inheritied from another relation |
52,262 | public function addReference ( PgAttribute $ primaryKey , $ includeChildTables = true ) { $ this -> references -> add ( $ primaryKey ) ; $ primaryKey -> isReferencedBy -> add ( $ this ) ; if ( $ includeChildTables || true ) { foreach ( $ primaryKey -> getRelation ( ) -> getChildren ( ) as $ child ) { $ this -> addRefer... | Add a reference to this attribute |
52,263 | public function getSequence ( ) { if ( preg_match ( "/^nextval\\('([^']+)'::regclass\\)$/" , $ this -> default , $ matches ) ) { return $ this -> catalog -> pgClasses -> findOneByName ( $ matches [ 1 ] ) ; } return null ; } | Is this column a sequence |
52,264 | public function getEntity ( ) { $ references = $ this -> getReferences ( ) ; foreach ( $ references as $ reference ) { if ( $ reference -> isPrimaryKey ( ) ) { return array ( 'entity' => 'normality' , 'normality' => $ reference -> getRelation ( ) -> getEntityName ( ) , ) ; } } switch ( $ this -> getType ( ) -> name ) {... | Return a reference to the entity |
52,265 | public function isZombie ( ) { $ ref = $ this -> getReferences ( ) ; if ( $ this -> isPrimaryKey ( ) and ! $ ref -> isEmpty ( ) ) { return true ; } if ( $ this -> notNull and ! $ ref -> isEmpty ( ) ) { return true ; } return false ; } | Is this column a zombie - column candidate? Happens when at least one of the following is true |
52,266 | protected function getTableFields ( ) { $ connection = Connection :: connect ( ) ; $ driver = getenv ( 'P_DRIVER' ) ; if ( $ driver == 'pgsql' ) { $ describe = '\d ' ; } $ describe = 'describe ' ; $ q = $ connection -> prepare ( $ describe . $ this -> getTableName ( $ this -> className ) ) ; $ q -> execute ( ) ; return... | Get all the column names in a table |
52,267 | protected function getAssignedValues ( ) { $ tableFields = $ this -> getTableFields ( ) ; $ newPropertiesArray = get_object_vars ( $ this ) ; $ columns = $ values = $ tableData = [ ] ; foreach ( $ newPropertiesArray as $ index => $ value ) { if ( in_array ( $ index , $ tableFields ) ) { array_push ( $ columns , $ index... | Get user assigned column values |
52,268 | public static function getSpinnerCombinations ( $ text ) { $ matches = self :: getSpinnerMatches ( $ text ) ; foreach ( $ matches as $ row ) { if ( ! preg_match ( '/[{}]/' , $ row ) ) { $ all [ ] = explode ( '|' , $ row ) ; } } $ combinations = call_user_func_array ( __CLASS__ . '::arrayCartesian' , $ all ) ; foreach (... | Get all combinations for spinner sentence |
52,269 | public static function arrayCartesian ( ) { $ args = func_get_args ( ) ; if ( count ( $ args ) == 0 ) { return [ [ ] ] ; } $ work = array_shift ( $ args ) ; $ cartesian = call_user_func_array ( __METHOD__ , $ args ) ; $ result = [ ] ; foreach ( $ work as $ value ) { foreach ( $ cartesian as $ product ) { $ result [ ] =... | Calculate cartesian product of multiple arrays |
52,270 | public static function arrayChangeKeys ( $ data , $ keyName = 'id' ) { $ temp = [ ] ; if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ row ) { if ( isset ( $ row [ $ keyName ] ) ) { $ temp [ $ row [ $ keyName ] ] = $ row ; } else { $ temp [ ] = $ row ; } } } return $ temp ; } | Rearange array keys to use selected field from row element |
52,271 | public static function elapsedTime ( $ timestamp ) { $ dateDiff = self :: timeDiff ( $ timestamp ) ; unset ( $ dateDiff [ 'month' ] ) ; $ dateDiff [ 'week' ] = floor ( $ dateDiff [ 'days_total' ] / 7 ) ; $ dateDiff [ 'day' ] = $ dateDiff [ 'days_total' ] % 7 ; return $ dateDiff ; } | Calculate time period and return it in separated time segments |
52,272 | public function getRealIP ( $ allowPrivateRange = false , array $ prependHeaders = null ) { $ headers = [ 'HTTP_CF_CONNECTING_IP' , 'CLIENT_IP' , 'FORWARDED' , 'FORWARDED_FOR' , 'FORWARDED_FOR_IP' , 'HTTP_CLIENT_IP' , 'HTTP_FORWARDED' , 'HTTP_FORWARDED_FOR' , 'HTTP_FORWARDED_FOR_IP' , 'HTTP_PC_REMOTE_ADDR' , 'HTTP_PROX... | Return real users IP address even if behind proxy |
52,273 | public static function timeDiff ( $ timestamp ) { $ dateRef = new \ DateTime ( '@' . $ timestamp ) ; $ dateNow = new \ DateTime ( ) ; $ dateDiff = $ dateNow -> diff ( $ dateRef ) ; return [ 'past_time' => $ dateDiff -> invert , 'year' => $ dateDiff -> y , 'month' => $ dateDiff -> m , 'day' => $ dateDiff -> d , 'hour' =... | Calculates time difference between current time and specified timestamp and returns array with human readable properties of time interval |
52,274 | public function verify ( $ assertion ) { $ response = $ this -> _post ( array ( 'audience' => $ this -> audience , 'assertion' => $ assertion ) ) ; if ( $ response -> status !== 'okay' ) { throw new Exception ( 'Invalid assertion - ' . $ response -> reason ) ; } return $ response ; } | Verifies a BrowserID assertion |
52,275 | protected function _post ( $ data ) { $ ch = curl_init ( ) ; curl_setopt_array ( $ ch , array ( CURLOPT_URL => static :: ENDPOINT , CURLOPT_POST => true , CURLOPT_POSTFIELDS => json_encode ( $ data ) , CURLOPT_HEADER => false , CURLOPT_RETURNTRANSFER => true , CURLOPT_SSL_VERIFYPEER => true , CURLOPT_SSL_VERIFYHOST => ... | Makes an HTTP POST request to verification endpoint |
52,276 | public static function parseUserNick ( $ userId = null , $ onEmpty = 'guest' ) : ? string { if ( ! Any :: isInt ( $ userId ) ) { return \ App :: $ Security -> strip_tags ( $ onEmpty ) ; } $ identity = App :: $ User -> identity ( $ userId ) ; if ( ! $ identity ) { return \ App :: $ Security -> strip_tags ( $ onEmpty ) ;... | Get user nickname by user id with predefined value on empty or not exist profile |
52,277 | public function validate ( $ value , $ options ) { $ this -> value = $ value ; $ this -> options = $ options ; $ this -> errors = [ ] ; return $ this -> checkIt ( ) ; } | Main validation function |
52,278 | protected function resolveDependencies ( array $ dependencies , array $ parameters = [ ] ) { $ results = [ ] ; foreach ( $ dependencies as $ dependency ) { if ( array_key_exists ( $ dependency -> name , $ parameters ) ) { $ results [ ] = $ parameters [ $ dependency -> name ] ; } else { $ results [ ] = is_null ( $ class... | Resolves dependencies recursively |
52,279 | public function resolveMethod ( $ instance , string $ method , array $ parameters = [ ] ) { $ name = get_class ( $ instance ) ; $ reflection = new \ ReflectionMethod ( $ name , $ method ) ; $ dependencies = $ reflection -> getParameters ( ) ; $ instances = $ this -> resolveDependencies ( $ dependencies , $ parameters )... | Calls the method of an instance after resolving dependencies |
52,280 | public function resolveClosure ( \ Closure $ closure ) { $ reflection = new \ ReflectionFunction ( $ closure ) ; $ dependencies = $ reflection -> getParameters ( ) ; $ instances = $ this -> resolveDependencies ( $ dependencies ) ; $ o = $ reflection -> invokeArgs ( $ instances ) ; return $ o ; } | Resolves the dependencies of a function |
52,281 | public function setView ( \ Zend \ View \ Renderer \ RendererInterface $ view ) { $ this -> view = $ view ; return $ this ; } | Set the View object |
52,282 | private static function _isResolved ( array $ dependenciesList , array $ resolved ) { foreach ( $ dependenciesList as $ dependency ) { if ( ! array_key_exists ( $ dependency , $ resolved ) ) { return false ; } } return true ; } | Checks whether all items from dependencies list are among keys in resolved |
52,283 | public function setImage ( $ image ) { $ this -> image = base64_encode ( $ image ) ; $ this -> tempPath = sys_get_temp_dir ( ) . '/' . uniqid ( 'ladybug_' ) ; file_put_contents ( $ this -> tempPath , $ image ) ; } | Sets image content |
52,284 | protected function generateCachePath ( string $ resourceId , string $ disk , string $ extension , int $ width = 0 , int $ height = 0 , $ fit = null ) : string { if ( $ this -> isLocalOrPublic ( $ disk ) ) { $ folder = config ( 'filesystems.disks.' . $ disk . '.root' ) . '/cache/' . str_replace ( '-' , '/' , $ resourceI... | Generating resource cache location and name |
52,285 | protected function createImage ( string $ disk , $ source , $ destination , $ width = 0 , $ height = 0 , $ fit = false ) : bool { if ( $ width == 0 ) { $ width = null ; } if ( $ height == 0 ) { $ height = null ; } if ( $ this -> isLocalOrPublic ( $ disk ) ) { $ source = config ( 'filesystems.disks.' . $ disk . '.root' ... | Creating image based on provided data |
52,286 | public function findPostingForId ( $ id ) { $ dql = ' SELECT p FROM %s p WHERE p.id = :id AND p.organization = :organization ' ; return $ this -> em -> createQuery ( sprintf ( $ dql , $ this -> postingFqcn ) ) -> setParameter ( 'id' , $ id ) -> setPar... | Find Posting for id |
52,287 | public function createPosting ( AccountInterface $ account = null , $ amount = null ) { $ posting = new $ this -> postingFqcn ( $ account , $ amount ) ; $ posting -> setOrganization ( $ this -> oh -> getOrganization ( ) ) ; return $ posting ; } | Create new Posting |
52,288 | public function check ( $ driver ) { switch ( $ driver ) { case self :: DRIVER_MEMCACHE : return extension_loaded ( 'memcache' ) ; case self :: DRIVER_MEMCACHED : return extension_loaded ( 'memcached' ) ; } return false ; } | Checks installed extensions |
52,289 | public static function fromNative ( ) { $ codeString = \ func_get_arg ( 0 ) ; $ code = CountryCode :: getByName ( $ codeString ) ; $ country = new self ( $ code ) ; return $ country ; } | Returns a new Country object given a native PHP string country code |
52,290 | public function sameValueAs ( ValueObjectInterface $ country ) { if ( false === Util :: classEquals ( $ this , $ country ) ) { return false ; } return $ this -> getCode ( ) -> sameValueAs ( $ country -> getCode ( ) ) ; } | Tells whether two Country are equal |
52,291 | protected function driverMatcher ( $ tag ) { $ matched = [ ] ; foreach ( $ this -> drivers as $ id => $ driver ) { if ( ! $ driver -> ping ( ) || '' !== $ tag && ( ! $ driver instanceof TaggableInterface || ! $ driver -> hasTag ( $ tag ) ) ) { continue ; } $ f = $ this -> factors [ $ id ] ; for ( $ i = 0 ; $ i < $ f ; ... | Driver tag matcher |
52,292 | public function prependParser ( ValueParserInterface $ parser ) { $ parsers = $ this -> parsers ; if ( array_key_exists ( $ parser -> getName ( ) , $ parsers ) ) { unset ( $ parsers [ $ parser -> getName ( ) ] ) ; } $ this -> parsers = array_merge ( [ $ parser -> getName ( ) => $ parser ] , $ parsers ) ; return $ this ... | Prepend parser to list of parsers HIGH priority . |
52,293 | public static function getSObjectFields ( SObject $ sob ) { if ( ! isset ( $ sob -> fields ) ) return null ; $ fields = $ sob -> fields ; if ( is_object ( $ fields ) ) $ fields = get_object_vars ( $ fields ) ; return $ fields ; } | Gets the Salesforce fields member out of an SObject and guarentees conversion to an associative array . |
52,294 | public static function updateSObjectFields ( SObject $ sob , $ fields ) { if ( ! is_array ( $ fields ) && ! is_object ( $ fields ) ) throw new InvalidArgumentException ( '$fields must be an array or object' ) ; if ( is_object ( $ sob -> fields ) ) $ fields = ( object ) $ fields ; $ sob -> fields = $ fields ; return $ s... | Updates an SObject s fields member using either an object or an associative array . |
52,295 | public static function sendException ( \ Exception $ ex ) { $ class = get_class ( $ ex ) ; switch ( $ class ) { case 'Smalldb\\StateMachine\\TransitionAccessException' : $ http_code = '403' ; break ; case 'Smalldb\\StateMachine\\InstanceDoesNotExistException' : $ http_code = '404' ; break ; default : $ http_code = '500... | Send info about thrown exception and set proper HTTP code . |
52,296 | public static function writeException ( \ Exception $ ex ) { $ response = array ( 'exception' => get_class ( $ ex ) , 'message' => $ ex -> getMessage ( ) , 'code' => $ ex -> getCode ( ) , ) ; static :: writeJson ( $ response ) ; } | Render exception as JSON string |
52,297 | public function string ( $ key , $ language = '' ) { if ( ! $ this -> hasTranslations ( ) ) { return $ this -> container [ 'lang' ] [ $ key ] ; } if ( $ language == '' ) { $ language = I18N :: getCurrent ( ) ; } if ( array_key_exists ( 'lang_' . $ language , $ this -> container ) ) { return $ this -> container [ 'lang_... | Return the textual version of the term |
52,298 | public function translated ( $ language = '' ) { if ( ! $ this -> hasTranslations ( ) ) { return true ; } if ( $ language == '' ) { $ language = I18N :: getCurrent ( ) ; } if ( array_key_exists ( 'lang_' . $ language , $ this -> container ) ) { return $ this -> container [ 'lang_' . $ language ] [ 'translated' ] ; } re... | Is it translated in this language ? |
52,299 | public function editLanguage ( $ language = '' ) { if ( ! array_key_exists ( 'lang_' . $ language , $ this -> container ) ) { throw new UndefinedLanguageException ; } return $ this -> container [ 'lang_' . $ language ] ; } | Retrieve a language for edition |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.