idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
56,600 | public function searchSimpleFormAction ( ) { $ form = new SearchSimple ( $ this -> generateUrl ( 'home_autocomplete_name' ) ) ; return $ this -> render ( 'AnimeDbCatalogBundle:Home:searchSimpleForm.html.twig' , [ 'form' => $ this -> createForm ( $ form ) -> createView ( ) , ] ) ; } | Search simple form . |
56,601 | public function autocompleteNameAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( 'AnimeDbCatalogBundle:Item' , - 1 , new JsonResponse ( ) ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ term = mb_strtolower ( $ request -> get ( 'term' ) , 'UTF8... | Autocomplete name . |
56,602 | public function searchAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( [ 'AnimeDbCatalogBundle:Item' , 'AnimeDbCatalogBundle:Storage' ] ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ form = $ this -> createForm ( 'animedb_catalog_search' , new... | Search item . |
56,603 | public function settingsAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ entity = ( new GeneralEntity ( ) ) -> setTaskScheduler ( $ this -> container -> getParameter ( 'task_scheduler.enabled' ) )... | General settings . |
56,604 | public static function log ( $ message , $ options = array ( ) ) { if ( array_key_exists ( 'inputs' , $ options ) ) { $ inputs = $ options [ 'inputs' ] ; } else { $ inputs = array ( self :: getTimestamp ( ) , 'LOG' , self :: getFilename ( ) , self :: getLineNumber ( ) ) ; } if ( ! array_key_exists ( 'output' , $ option... | Output log message |
56,605 | public static function warn ( $ message , $ options = array ( ) ) { $ options [ 'inputs' ] = array ( self :: getTimestamp ( ) , 'WARN' , self :: getFilename ( ) , self :: getLineNumber ( ) ) ; self :: log ( $ message , $ options ) ; } | Output warn message |
56,606 | public function createUserFromOAuth ( $ data ) { $ user = $ this -> createUser ( ) ; $ user -> setAuthDataByProvider ( $ data [ 'provider' ] , [ 'id' => $ data [ 'id' ] , 'token' => $ data [ 'token' ] ] ) ; $ user -> setAuthProvider ( $ data [ 'provider' ] ) ; $ user -> setFirstAuthProvider ( $ data [ 'provider' ] ) ; ... | Creates a new User from oAuth data |
56,607 | public function updateFromGeoIp ( User $ user , array $ ipInfo ) { $ contact = $ user -> getContact ( ) ; $ country = $ contact -> getCountry ( ) ; $ city = $ contact -> getCity ( ) ; $ region = $ contact -> getRegion ( ) ; if ( ! $ country ) { $ contact -> setCountry ( $ ipInfo [ 'country' ] ) ; } if ( ! $ city ) { $ ... | Update User contact data from geoIp |
56,608 | public function signupLog ( User $ user , array $ ipInfo ) { $ user -> setAttribute ( 'signupIp' , $ ipInfo ) ; $ this -> dm -> persist ( $ user ) ; $ this -> dm -> flush ( ) ; return $ this ; } | Set signup attributes for geoIp on signup |
56,609 | public function loginLog ( User $ user , array $ geoIp ) { $ geoIp [ 'date' ] = date ( 'Y-m-d H:i:s' ) ; $ loginIps = $ user -> getAttribute ( 'lastLoginIps' ) ; if ( ! $ loginIps ) { $ loginIps = [ ] ; } array_unshift ( $ loginIps , $ geoIp ) ; $ loginIps = array_slice ( $ loginIps , 0 , 3 ) ; $ user -> setAttribute (... | Save login geoIp last 20 events |
56,610 | public function setLocale ( User $ user , $ locale ) { $ user -> getContact ( ) -> setLocale ( $ locale ) ; $ this -> dm -> persist ( $ user ) ; $ this -> dm -> flush ( ) ; return $ this ; } | Set locale for an user |
56,611 | public function enableRememberMe ( $ user ) { $ rememberMeValue = $ this -> generateRememberMeCookie ( $ user -> getUsername ( ) ) ; $ this -> session -> set ( 'REMEMBER_ME' , $ rememberMeValue ) ; } | Enable Remember Me feature |
56,612 | protected function generateRememberMeCookie ( $ username ) { $ key = 'ThisTokenIsNotSoSecretChangeIt' ; $ class = 'WobbleCode\UserBundle\Document\User' ; $ password = 'none' ; $ expires = time ( ) + 2592000 ; $ hash = hash ( 'sha256' , $ class . $ username . $ expires . $ password . $ key ) ; return $ this -> encodeCoo... | Generate remember me cookie final value |
56,613 | public function ip ( $ return_type = null , $ ip_addresses = [ ] ) { $ ip_elements = array ( 'HTTP_X_FORWARDED_FOR' , 'HTTP_FORWARDED_FOR' , 'HTTP_X_FORWARDED' , 'HTTP_FORWARDED' , 'HTTP_X_CLUSTER_CLIENT_IP' , 'HTTP_CLUSTER_CLIENT_IP' , 'HTTP_X_CLIENT_IP' , 'HTTP_CLIENT_IP' , 'REMOTE_ADDR' ) ; foreach ( $ ip_elements a... | Get client ip address |
56,614 | public function insert ( $ query , array $ data ) { $ this -> conn -> prepare ( $ query ) -> execute ( $ data ) ; return $ this -> conn -> lastInsertId ( ) ; } | Insert a record in the storage |
56,615 | public function update ( $ query , array $ data ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return $ stmt -> rowCount ( ) ; } | Update an existing record in the storage |
56,616 | public function delete ( $ query , array $ data ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return $ stmt -> rowCount ( ) ; } | Delete a record in the storage |
56,617 | public function findOne ( $ query , array $ data = null ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; } | Fetch a record from the storage |
56,618 | public function findMany ( $ query , array $ data = null ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return ( $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ) ; } | Fetch all records from a certain location in the storage |
56,619 | private function executeQuery ( $ query , $ data = null ) { $ stmt = $ this -> conn -> prepare ( $ query ) ; $ stmt -> execute ( $ data ) ; return $ stmt ; } | Execute a raw query |
56,620 | public static function each ( array $ set , Closure $ callback , $ recursive = true ) { foreach ( $ set as $ key => $ value ) { if ( is_array ( $ value ) && $ recursive ) { $ set [ $ key ] = static :: each ( $ value , $ callback , $ recursive ) ; } else { $ set [ $ key ] = $ callback ( $ value , $ key ) ; } } return $ ... | Calls a function for each key - value pair in the set . If recursive is true will apply the callback to nested arrays as well . |
56,621 | public static function every ( array $ set , Closure $ callback ) { foreach ( $ set as $ key => $ value ) { if ( ! $ callback ( $ value , $ key ) ) { return false ; } } return true ; } | Returns true if every element in the array satisfies the provided testing function . |
56,622 | public static function expand ( array $ set ) { $ data = array ( ) ; foreach ( $ set as $ key => $ value ) { $ data = static :: insert ( $ data , $ key , $ value ) ; } return $ data ; } | Expand an array to a fully workable multi - dimensional array where the values key is a dot notated path . |
56,623 | public static function extract ( array $ set , $ path ) { if ( ! $ set ) { return null ; } if ( strpos ( $ path , '.' ) === false ) { return isset ( $ set [ $ path ] ) ? $ set [ $ path ] : null ; } $ search = & $ set ; $ paths = explode ( '.' , ( string ) $ path ) ; $ total = count ( $ paths ) ; while ( $ total > 0 ) {... | Extract the value of an array depending on the paths given represented by key . key . key notation . |
56,624 | public static function flatten ( array $ set , $ path = null ) { if ( $ path ) { $ path = $ path . '.' ; } $ data = array ( ) ; foreach ( $ set as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( $ value ) { $ data += static :: flatten ( $ value , $ path . $ key ) ; } else { $ data [ $ path . $ key ] = null ; } ... | Flatten a multi - dimensional array by returning the values with their keys representing their previous pathing . |
56,625 | public static function inject ( array $ set , $ path , $ value ) { if ( static :: has ( $ set , $ path ) ) { return $ set ; } return static :: insert ( $ set , $ path , $ value ) ; } | Includes the specified key - value pair in the set if the key doesn t already exist . |
56,626 | public static function insert ( array $ set , $ path , $ value ) { if ( ! $ path ) { return $ set ; } if ( strpos ( $ path , '.' ) === false ) { $ set [ $ path ] = $ value ; return $ set ; } $ search = & $ set ; $ paths = explode ( '.' , $ path ) ; $ total = count ( $ paths ) ; while ( $ total > 0 ) { $ key = $ paths [... | Inserts a value into the array set based on the given path . |
56,627 | public static function keyOf ( array $ set , $ match ) { $ return = null ; $ isArray = array ( ) ; foreach ( $ set as $ key => $ value ) { if ( $ value === $ match ) { $ return = $ key ; } if ( is_array ( $ value ) ) { $ isArray [ ] = $ key ; } } if ( ! $ return && $ isArray ) { foreach ( $ isArray as $ key ) { if ( $ ... | Returns the key of the specified value . Will recursively search if the first pass doesn t match . |
56,628 | public static function pluck ( array $ set , $ path ) { $ data = array ( ) ; foreach ( $ set as $ array ) { if ( $ value = static :: extract ( $ array , $ path ) ) { $ data [ ] = $ value ; } } return $ data ; } | Pluck a value out of each child - array and return an array of the plucked values . |
56,629 | public static function reduce ( array $ set , array $ keys ) { $ array = array ( ) ; foreach ( $ set as $ key => $ value ) { if ( in_array ( $ key , $ keys ) ) { $ array [ $ key ] = $ value ; } } return $ array ; } | Reduce an array by removing all keys that have not been defined for persistence . |
56,630 | public static function set ( array $ set , $ path , $ value = null ) { if ( is_array ( $ path ) ) { foreach ( $ path as $ key => $ value ) { $ set = static :: insert ( $ set , $ key , $ value ) ; } } else { $ set = static :: insert ( $ set , $ path , $ value ) ; } return $ set ; } | Set a value into the result set . If the paths is an array loop over each one and insert the value . |
56,631 | public static function some ( array $ set , Closure $ callback ) { foreach ( $ set as $ value ) { if ( $ callback ( $ value , $ value ) ) { return true ; } } return false ; } | Returns true if at least one element in the array satisfies the provided testing function . |
56,632 | public function moveFile ( $ file , $ model ) { $ path = $ this -> getUploadPath ( $ model , $ this -> options ) ; $ this -> makeDirectoryBeforeUpload ( $ path , true ) ; if ( ! is_null ( $ this -> elfinderFilePath ) ) { $ this -> copy ( $ this -> elfinderFilePath , $ path . '/' . $ this -> fileName ) ; } else { $ this... | move upload file |
56,633 | protected function setFileName ( $ file ) { if ( isset ( $ this -> options [ 'thumbnails' ] ) ) { $ thumbs = isset ( $ this -> options [ 'changeThumb' ] ) ? $ this -> options [ 'thumbnails' ] [ $ this -> options [ 'changeThumb' ] ] : $ this -> options [ 'thumbnails' ] ; $ thumbs = array_values ( $ thumbs ) ; $ firstThu... | set file name |
56,634 | protected function setFileSize ( $ file ) { $ this -> fileSize = ! is_null ( $ this -> elfinderFilePath ) ? $ this -> getFileSize ( ) : ( is_string ( $ file ) ? $ this -> size ( $ file ) : $ file -> getClientSize ( ) ) ; } | set file size |
56,635 | public function createFileName ( $ file ) { if ( ! is_null ( $ this -> elfinderFilePath ) ) { return $ this -> getFileName ( ) ; } if ( is_string ( $ file ) ) { return substr ( strrchr ( $ file , '/' ) , 1 ) ; } $ filename = $ file -> getClientOriginalName ( ) ; $ mime = $ file -> getClientOriginalExtension ( ) ; $ par... | create file name |
56,636 | protected function getFile ( $ request ) { $ columns = explode ( '.' , $ this -> options [ 'column' ] ) ; $ column = count ( $ columns ) > 1 ? $ columns [ 1 ] : $ columns [ 0 ] ; $ inputName = isset ( $ this -> options [ 'group' ] ) ? "{$this->options['group']}.{$this->options['index']}.{$column}" : $ column ; $ inputN... | get file or string path |
56,637 | public function getFileName ( ) { $ filename = substr ( strrchr ( $ this -> elfinderFilePath , '/' ) , 1 ) ; $ parts = explode ( '.' , $ filename ) ; $ last = array_pop ( $ parts ) ; $ filename = str_slug ( implode ( '_' , $ parts ) ) . '_' . time ( ) ; return $ filename . '.' . $ last ; } | get file name of the elfinder file |
56,638 | public function getDatas ( $ request ) { $ relation = $ this -> options [ 'relation' ] ; $ columnParams = explode ( '.' , $ this -> options [ 'column' ] ) ; if ( ! $ relation ) { return [ 'relation_type' => 'not' , 'datas' => [ $ columnParams [ 0 ] => $ this -> fileName , 'size' => $ this -> fileSize ] ] ; } $ datas = ... | get datas for save the database |
56,639 | public function deletePhoto ( $ model , $ parentRelation = null ) { $ thumbs = $ this -> options [ 'photo' ] [ 'thumbnails' ] ; $ id = is_null ( $ parentRelation ) ? $ model -> id : $ model -> $ parentRelation -> id ; $ path = $ this -> options [ 'photo' ] [ 'path' ] . "/{$id}" ; $ this -> delete ( $ path . "/original/... | delete file with model path |
56,640 | public function deleteDirectories ( $ model , $ parentRelation = null ) { $ id = is_null ( $ parentRelation ) ? $ model -> id : $ model -> $ parentRelation -> id ; foreach ( $ this -> options as $ option ) { $ this -> deleteDirectory ( $ option [ 'path' ] . "/{$id}" ) ; } } | delete multiple directories with model path |
56,641 | public function makeDirectoryBeforeUpload ( $ path , $ cleanDirectory = false ) { if ( ! $ this -> exists ( $ path ) ) { $ this -> makeDirectory ( $ path , 0775 , true ) ; return true ; } if ( ( $ this -> exists ( $ path ) && $ cleanDirectory ) || ( isset ( $ this -> options [ 'is_reset' ] ) && $ this -> options [ 'is_... | if not exists make directory or clean directory |
56,642 | public function staticProperty ( $ class , $ property , $ args = array ( ) ) { if ( ! class_exists ( $ class ) ) return null ; if ( ! property_exists ( $ class , $ property ) ) return null ; $ vars = get_class_vars ( $ class ) ; return $ vars [ $ property ] ; } | Calls a static method on the given class |
56,643 | public function start ( InputInterface $ input = null , OutputInterface $ output = null ) : int { return ContainerScope :: runScope ( $ this -> container , function ( ) use ( $ input , $ output ) { return $ this -> getApplication ( ) -> run ( $ input , $ output ) ; } ) ; } | Run console application . |
56,644 | public function run ( ? string $ command , $ input = [ ] , OutputInterface $ output = null ) : CommandOutput { if ( is_array ( $ input ) ) { $ input = new ArrayInput ( $ input + compact ( 'command' ) ) ; } $ output = $ output ?? new BufferedOutput ( ) ; $ command = $ this -> getApplication ( ) -> find ( $ command ) ; $... | Run selected command . |
56,645 | public function getApplication ( ) : Application { if ( ! empty ( $ this -> application ) ) { return $ this -> application ; } $ this -> application = new Application ( $ this -> config -> getName ( ) , $ this -> config -> getVersion ( ) ) ; $ this -> application -> setCatchExceptions ( false ) ; $ this -> application ... | Get associated Symfony Console Application . |
56,646 | protected function format ( ) { $ number = $ this -> getParameter ( 'number' ) ; if ( $ number instanceof Meta ) { $ number = $ number -> getValue ( ) ; } if ( empty ( $ number ) || ! is_numeric ( $ number ) ) { return 0 ; } $ decimals = $ this -> getParameter ( 'decimals' ) ; $ decimal_sep = $ this -> getParameter ( '... | wrapper for number_format |
56,647 | protected function bound ( ) { $ number = $ this -> getParameter ( 'number' ) ; $ min = $ this -> getParameter ( 'min' ) ; $ max = $ this -> getParameter ( 'max' ) ; if ( $ number instanceof Meta ) { $ number = $ number -> getValue ( ) ; } return NumberUtils :: bound ( $ number , $ min , $ max ) ; } | Return a number within a range . |
56,648 | public function create ( $ id , ContainerInterface $ container ) { if ( isset ( $ this -> registeredList [ 'services' ] [ $ id ] ) ) { $ data = $ this -> createService ( $ id , $ container ) ; } elseif ( isset ( $ this -> registeredList [ 'params' ] [ $ id ] ) ) { $ data = $ this -> registeredList [ 'params' ] [ $ id ]... | Create service or parameter based on configured dependencies . |
56,649 | public function createResolver ( $ namespace , $ resolution , $ newInstance = false ) { if ( ! $ this -> hasResolution ( $ namespace ) ) { if ( $ newInstance ) { $ resolution = [ $ resolution , true ] ; } $ this -> registeredList [ 'resolves' ] [ $ namespace ] = $ resolution ; } } | Resolve a given namespace to given resolution . |
56,650 | public function resolveAndCreate ( $ namespace , ContainerInterface $ container ) { $ class = new \ ReflectionClass ( $ namespace ) ; $ arguments = $ this -> resolveReflectionArguments ( $ class , $ container ) ; return $ class -> newInstanceArgs ( $ arguments ) ; } | Instantiate a new object using constructor injection . |
56,651 | public function processNodes ( DOMNode $ node ) { $ allLinkNodes = $ this -> xp -> query ( './/a' , $ node ) ; $ allLinkNodesSortedByLength = [ ] ; foreach ( $ allLinkNodes as $ linkNode ) { $ allLinkNodesSortedByLength [ ] = [ 'href' => $ linkNode -> getAttribute ( 'href' ) , 'node' => $ linkNode , ] ; } usort ( $ all... | Process node . |
56,652 | public function filterRange ( $ range ) { if ( is_int ( $ range ) ) { $ level = $ range ; $ depth = 0 ; } else { reset ( $ range ) ; $ level = key ( $ range ) ; $ depth = current ( $ range ) ; } if ( 1 === $ level ) { $ nodeList = $ this -> xp -> query ( '/descendant-or-self::*[ name() = "ul" and count( ancestor-or-sel... | Restrict navigation to given range . |
56,653 | public function filterBreadcrumb ( ) { $ nodeList = $ this -> xp -> query ( '//li[ contains(@class, "open") or contains(@class, "active")]' ) ; if ( 0 !== $ nodeList -> length ) { $ ul = $ this -> dom -> createElement ( 'ul' ) ; foreach ( $ nodeList as $ node ) { $ li = $ this -> dom -> createElement ( 'li' ) ; $ li ->... | Create breadcrumb for current page . |
56,654 | public static function render ( $ navigationFile , $ requestedUri = false , $ options = null ) { $ instance = new Navigation ( $ navigationFile , $ requestedUri ) ; if ( $ options ) { if ( isset ( $ options [ 'breadcrumb' ] ) ) { $ temp = $ instance -> filterBreadcrumb ( ) ; if ( $ temp ) { return $ instance -> dom -> ... | Static helper function to render Navigation . |
56,655 | public function sites ( ) { if ( ! class_exists ( \ Modules \ Site \ Entities \ Page :: class , false ) ) { throw new \ Exception ( 'in order to use User::sites() you have to install the \'vain-sites\' module' ) ; } return $ this -> hasMany ( \ Modules \ Site \ Entities \ Page :: class ) ; } | created static pages . |
56,656 | public function scopeOnline ( $ query ) { $ expiryDate = Carbon :: now ( ) -> subMinutes ( config ( 'session.lifetime' ) ) ; return $ query -> where ( 'last_active_at' , '>' , $ expiryDate ) -> andWhere ( 'logged_out' , false ) ; } | queries all possible online users . |
56,657 | public function getOnlineAttribute ( $ value ) { $ expiryDate = Carbon :: now ( ) -> subMinutes ( config ( 'session.lifetime' ) ) ; return ( ! $ this -> logged_out ) && $ expiryDate -> lt ( $ this -> last_active_at ) ; } | accessor for current online state . |
56,658 | public function saveWithoutTimestamps ( array $ options = [ ] ) { $ this -> timestamps = false ; $ this -> save ( $ options ) ; $ this -> timestamps = true ; } | Save the model to the database without updating the timestamps . |
56,659 | private function getCountryCode ( ) { $ posted = $ this -> appRequest -> getPostValue ( ) ; if ( isset ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_COUNTRY_CODE ] ) ) { $ result = $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_COUNTRY_CODE ] ; } else { $ result = ... | Extract code for customer s registration country from posted data . |
56,660 | private function getMlmId ( $ customer ) { $ posted = $ this -> appRequest -> getPostValue ( ) ; if ( isset ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_OWN_MLM_ID ] ) && ! empty ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_OWN_MLM_ID ] ) ) { $ result = $ post... | Extract customer s MLM ID from posted data or generate new one . |
56,661 | private function getParentId ( ) { $ posted = $ this -> appRequest -> getPostValue ( ) ; if ( isset ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_PARENT_MLM_ID ] ) ) { $ mlmId = $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_PARENT_MLM_ID ] ; $ found = $ this -> da... | Extract customer s parent ID from posted data or set null to extract it in service later from referral code . |
56,662 | public static function findExistingReferences ( $ model , $ field ) { $ invalid = true ; $ uniqueString = null ; while ( $ invalid == true ) { $ uniqueString = Str :: random ( $ model :: $ uniqueStringLimit ) ; $ existingReferences = $ model :: where ( $ field , $ uniqueString ) -> count ( ) ; if ( $ existingReferences... | Make sure the uniqueId is always unique . |
56,663 | public function setDirectory ( $ directory ) { if ( class_exists ( '\Latte\Engine' , true ) ) { $ this -> latte = new Latte ; $ this -> latte -> setTempDirectory ( realpath ( Core :: $ tempDir . DS . 'Latte' ) ) ; } else { throw new LayoutException ( "Could not load LatteEngine. Is it installed or Composer not loaded?"... | Set the directory of the current template . |
56,664 | public function set ( string $ abstract , $ concrete , $ singleton = false ) { if ( $ this -> has ( $ abstract ) ) { throw new ContainerException ( sprintf ( 'An entry with the id "%s" already exists.' , $ abstract ) ) ; } $ this -> bindings [ $ abstract ] = new ContainerEntry ( $ abstract , $ concrete , $ singleton ) ... | Bind a abstract to a concrete . If the concrete is a object and not a string it will be stored as it is . |
56,665 | public static function snippet ( string $ text , int $ length = 150 ) { $ breakerPos = mb_strpos ( $ text , self :: WYSIWYG_BREAK_HTML , null , 'UTF-8' ) ; if ( $ breakerPos !== false ) { $ text = Str :: sub ( $ text , 0 , $ breakerPos ) ; } else { $ breakerPos = mb_strpos ( $ text , '</p>' , null , 'UTF-8' ) ; if ( $ ... | Make snippet from text or html - text content . |
56,666 | protected function assignEntity ( $ entity ) { $ entityClass = $ this -> model -> entity ( ) ; if ( $ entity === null ) { throw new QueryException ( sprintf ( 'Missing required entity of class "%s"' , $ entityClass ) ) ; } if ( ! is_array ( $ entity ) && ! $ entity instanceof $ entityClass ) { throw new QueryException ... | Assigns entity instance Asserts if entity instance is of expected type |
56,667 | protected function setPrimaryKeyConditions ( ) { foreach ( $ this -> model -> primaryFields ( ) as $ field ) { $ value = $ this -> accessor -> getPropertyValue ( $ this -> instance , $ field -> name ( ) ) ; $ this -> builder -> andWhere ( sprintf ( '%s = %s' , $ this -> connection -> quoteIdentifier ( $ field -> mapped... | Assigns primary condition |
56,668 | public function clearToken ( $ service ) { $ service = $ this -> normalizeServiceName ( $ service ) ; $ tokens = $ this -> sessionScope -> get ( self :: SESSION_TOKEN ) ; if ( array_key_exists ( $ service , $ tokens ) ) { unset ( $ tokens , $ service ) ; } $ this -> sessionScope -> set ( self :: SESSION_TOKEN , $ token... | Delete the users token . Aka log out . |
56,669 | public function hasAuthorizationState ( $ service ) { $ service = $ this -> normalizeServiceName ( $ service ) ; $ states = $ this -> sessionScope -> get ( self :: SESSION_STATE ) ; return isset ( $ states [ $ service ] ) ; } | Check if an authorization state for a given service exists |
56,670 | public function clearAuthorizationState ( $ service ) { $ service = $ this -> normalizeServiceName ( $ service ) ; $ states = $ this -> sessionScope -> get ( self :: SESSION_STATE ) ; if ( array_key_exists ( $ service , $ states ) ) { unset ( $ states , $ service ) ; } $ this -> sessionScope -> set ( self :: SESSION_ST... | Clear the authorization state of a given service |
56,671 | public function getParameterDefinition ( $ name ) { if ( $ this -> hasParametersDefinitions ( ) ) { foreach ( $ this -> getParametersDefinitions ( ) as $ parameterDefinition ) { if ( $ parameterDefinition -> name === $ name ) { return $ parameterDefinition ; } } } return null ; } | Get specified parameter definition . |
56,672 | public function getParameterTemplate ( $ name ) { if ( $ this -> hasParametersTemplates ( ) ) { foreach ( $ this -> getParametersTemplates ( ) as $ parameterTemplate ) { if ( $ parameterTemplate -> name === $ name ) { return $ parameterTemplate ; } } } return null ; } | Get specified parameter template . |
56,673 | private function addShopFieldset ( FormInterface $ form ) { $ shopsData = $ form -> addChild ( $ this -> getElement ( 'nested_fieldset' , [ 'name' => 'shops_data' , 'label' => $ this -> trans ( 'common.fieldset.shops' ) ] ) ) ; $ shopsData -> addChild ( $ this -> getElement ( 'multi_select' , [ 'name' => 'shops' , 'lab... | Adds shop selector fieldset to form |
56,674 | public function fromMessage ( $ message ) { static $ parser ; if ( ! $ parser ) { $ parser = new MessageParser ( ) ; } if ( strtoupper ( substr ( $ message , 0 , 4 ) ) == 'HTTP' ) { $ data = $ parser -> parseResponse ( $ message ) ; return $ this -> createResponse ( $ data [ 'code' ] , $ data [ 'headers' ] , $ data [ '... | Create a request or response object from an HTTP message string |
56,675 | protected function addPostData ( RequestInterface $ request , array $ body ) { static $ fields = [ 'string' => true , 'array' => true , 'NULL' => true , 'boolean' => true , 'double' => true , 'integer' => true ] ; $ post = new PostBody ( ) ; foreach ( $ body as $ key => $ value ) { if ( isset ( $ fields [ gettype ( $ v... | Apply POST fields and files to a request to attempt to give an accurate representation . |
56,676 | public static function read ( $ file , $ force = false ) { if ( ! is_readable ( $ file ) ) { if ( $ force === true ) { return [ ] ; } else { throw new Exception ( sprintf ( 'Unable to read file "%s"' , $ file ) , ExitApp :: RUNTIME_ERROR ) ; } } $ fileContent = file_get_contents ( $ file ) ; if ( $ fileContent === fals... | Parse a JSON file |
56,677 | public static function write ( $ file , array $ content ) { $ jsonString = json_encode ( $ content , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ; if ( $ jsonString === false ) { throw new Exception ( 'Unable to convert array to JSON string' , ExitApp :: RUNTIME_ERROR ) ; } $ status = file_put_contents ( $ file , $ js... | Write JSON - formatted content to file |
56,678 | public function generate ( string $ path , string $ namespace , string $ name ) { $ name = $ this -> camelize ( $ name ) ; $ vars = [ 'NAMESPACE' => $ namespace , 'NAME' => $ name , 'NAME:CAMELIZED' => $ name , 'NAME:UNDERSCORE' => $ this -> underscore ( $ name ) , 'NAME:UPPERCASE' => strtoupper ( $ name ) , ] ; $ this... | Generate a new ModelStructure folder . |
56,679 | public function getField ( array $ args = [ ] ) { if ( empty ( $ args ) ) { $ args = $ this -> args ; } $ className = sprintf ( 'GeminiLabs\Castor\Forms\Fields\%s' , ucfirst ( $ args [ 'type' ] ) ) ; if ( ! class_exists ( $ className ) ) { throw new ReflectionException ( "Class does not exist: {$className}" ) ; } retur... | Get a specific Field |
56,680 | public function normalize ( array $ args = [ ] ) { $ defaults = [ 'after' => '' , 'attributes' => '' , 'before' => '' , 'class' => '' , 'default' => null , 'depends' => null , 'desc' => '' , 'errors' => [ ] , 'inline' => false , 'label' => '' , 'name' => '' , 'options' => [ ] , 'path' => '' , 'placeholder' => '' , 'pre... | Normalize the field arguments |
56,681 | public function render ( $ print = true ) { if ( $ this -> args [ 'render' ] === false ) return ; $ field = $ this -> getField ( ) ; $ class = 'glsr-field' ; $ class .= $ this -> args [ 'errors' ] ? ' glsr-has-error' : '' ; $ renderedString = '%s' ; if ( ( isset ( $ field -> args [ 'required' ] ) && $ field -> args [ '... | Render the field |
56,682 | protected function checkForErrors ( array $ atts ) { $ args = $ this -> args ; if ( ! array_key_exists ( $ atts [ 'name' ] , $ args [ 'errors' ] ) ) { $ this -> args [ 'errors' ] = '' ; return ; } $ field_errors = $ args [ 'errors' ] [ $ atts [ 'name' ] ] ; $ errors = array_reduce ( $ field_errors [ 'errors' ] , functi... | Check for form submission field errors |
56,683 | protected function parseAttributes ( array $ args ) { if ( empty ( $ args [ 'attributes' ] ) ) { return [ ] ; } $ attributes = ( array ) $ args [ 'attributes' ] ; foreach ( $ attributes as $ key => $ value ) { if ( is_string ( $ key ) ) continue ; unset ( $ attributes [ $ key ] ) ; if ( ! isset ( $ attributes [ $ value... | Parse the field attributes and convert to an array if needed |
56,684 | protected function parseId ( array $ args ) { if ( isset ( $ args [ 'id' ] ) && ! $ args [ 'id' ] ) return ; ! $ args [ 'suffix' ] ? : $ args [ 'suffix' ] = "-{$args['suffix']}" ; return str_replace ( [ '[]' , '[' , ']' , '.' ] , [ '' , '-' , '' , '-' ] , $ this -> parseName ( $ args ) . $ args [ 'suffix' ] ) ; } | Parse the field ID from the field path |
56,685 | protected function parseName ( array $ args ) { $ name = $ args [ 'name' ] ; $ prefix = $ this -> parsePrefix ( $ args ) ; if ( $ prefix === false ) { return $ name ; } $ paths = explode ( '.' , $ name ) ; return array_reduce ( $ paths , function ( $ result , $ value ) { return $ result .= "[$value]" ; } , $ prefix ) ;... | Parse the field name |
56,686 | protected function parseType ( array $ args ) { $ type = $ args [ 'type' ] ; return false !== stripos ( $ type , '_inline' ) ? str_replace ( '_inline' , '' , $ type ) : $ type ; } | Parse the field type |
56,687 | protected function parseValue ( array $ args ) { $ default = $ args [ 'default' ] ; $ name = $ args [ 'name' ] ; $ prefix = $ args [ 'prefix' ] ; $ value = $ args [ 'value' ] ; if ( $ default == ':placeholder' ) { $ default = '' ; } return ( ! empty ( $ value ) || ! $ name || $ prefix === false ) ? $ value : $ default ... | Parse the field value |
56,688 | public function output ( $ response ) { switch ( $ this -> format ) { case 'json' : $ response = array_merge_recursive ( $ response , $ this -> extra ) ; $ this -> header ( 'Content-type: application/json; charset=utf-8' ) ; $ response = json_encode ( $ response ) ; $ response = preg_replace ( '/(")([0-9]+)(")/is' , '\... | Echoes out the response |
56,689 | public function error ( $ code , $ message , $ extra = [ ] ) { $ response [ 'success' ] = false ; $ this -> extra ( $ extra ) ; if ( ! in_array ( $ code , array_keys ( $ this -> errors ) ) ) { $ code = 500 ; } $ response [ 'error' ] [ 'code' ] = $ code ; $ this -> header ( $ this -> errors [ $ code ] ) ; $ response [ '... | Sets an error header and echoes out the response |
56,690 | private function html ( $ data ) { if ( ! is_array ( $ data ) ) { return $ data ; } $ return = '' ; foreach ( $ data as $ key => $ value ) { $ return .= '<li>' . $ key . ': ' . ( is_array ( $ value ) ? $ this -> html ( $ value ) : $ value ) . '</li>' ; } return '<ul>' . $ return . '</ul>' ; } | Transforms an array into an HTML list |
56,691 | private function flashManagement ( ) { $ flashdata = $ _SESSION [ $ this -> flashdataId ] ?? null ; if ( $ flashdata !== null ) { $ flashdata = unserialize ( base64_decode ( $ flashdata ) ) ; unset ( $ _SESSION [ $ this -> flashdataId ] ) ; if ( ! empty ( $ flashdata ) ) { $ this -> flashdata = $ flashdata ; $ this -> ... | Processes current requests flashdata recycles old . |
56,692 | public function set ( string $ key , $ value ) { $ key = $ this -> security -> normalize ( $ key ) ; $ value = $ this -> security -> normalize ( $ value ) ; parent :: set ( $ key , $ value ) ; $ _SESSION [ $ key ] = $ value ; } | In addition most superglobals are immuteable whereas session is not |
56,693 | public function destroy ( ) { $ _SESSION = [ ] ; if ( ini_get ( "session.use_cookies" ) ) { $ params = session_get_cookie_params ( ) ; $ time = time ( ) - 42000 ; $ path = $ params [ 'path' ] ; $ domain = $ params [ 'domain' ] ; $ secure = $ params [ 'secure' ] ; $ http = $ params [ 'httponly' ] ; setcookie ( session_n... | destroys a session and related cookies |
56,694 | protected function loadItemsForCurrentPage ( ) { $ items = $ this -> adapter -> getItems ( $ this -> getOffset ( ) , $ this -> itemsCountPerPage , $ this -> sort ) ; if ( ! ( $ items instanceof \ Traversable ) ) { $ this -> items = new \ ArrayIterator ( $ items ) ; } else { $ this -> items = $ items ; } } | Method load items for current page |
56,695 | protected function initialize ( array $ options ) { foreach ( $ options as $ option ) { if ( ! $ option instanceof Option ) { throw InvalidOption :: fromOption ( $ option ) ; } $ option = $ this -> identityMap -> put ( $ option , $ this ) ; $ this -> schema [ $ option -> getKey ( ) ] = $ option ; } } | Initialize the internal state of the repository . |
56,696 | public function getConnectionString ( ) { $ settings = $ this -> connectionInfo ; unset ( $ settings [ 'search_path' ] ) ; foreach ( $ settings as $ key => & $ value ) { $ value = sprintf ( "%s='%s'" , $ key , $ value ) ; } return implode ( ' ' , $ settings ) ; } | Generate a property formatted postgres connection string |
56,697 | public function findAllWithPagination ( $ filters , $ limit , $ offset , $ resultInArray = FALSE ) { $ where = $ this -> getQueryFilter ( $ filters ) ; $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT m FROM FulgurioLightCMSBundle:Media m ' . $ where . ' ORDER BY m.created_at DESC' ) -> setMaxResults (... | Find media with pagination |
56,698 | public function count ( $ filters ) { $ where = $ this -> getQueryFilter ( $ filters ) ; $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT COUNT(m) FROM FulgurioLightCMSBundle:Media m' . $ where ) ; if ( ! empty ( $ filters ) ) { foreach ( $ filters as $ filterKey => $ filterValue ) { $ query -> setPara... | Count number of result |
56,699 | private function getQueryFilter ( $ filters ) { $ where = '' ; if ( ! empty ( $ filters ) ) { foreach ( $ filters as $ filterKey => $ filterValue ) { $ where .= ' AND m.' . $ filterKey . ' LIKE :' . $ filterKey ; } $ where = ' WHERE ' . substr ( $ where , 4 ) ; } return $ where ; } | Make query filter string from given filters |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.