idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
9,700 | public function containers ( $ limit = 0 , $ marker = NULL ) { $ url = $ this -> url ( ) . '?format=json' ; if ( $ limit > 0 ) { $ url .= sprintf ( '&limit=%d' , $ limit ) ; } if ( ! empty ( $ marker ) ) { $ url .= sprintf ( '&marker=%d' , $ marker ) ; } $ containers = $ this -> get ( $ url ) ; $ containerList = array ... | Fetch a list of containers for this account . |
9,701 | public function container ( $ name ) { $ url = $ this -> url ( ) . '/' . rawurlencode ( $ name ) ; $ data = $ this -> req ( $ url , 'HEAD' , FALSE ) ; $ status = $ data -> status ( ) ; if ( $ status == 200 || $ status == 204 ) { $ container = Container :: newFromResponse ( $ name , $ data , $ this -> token ( ) , $ this... | Get a single specific container . |
9,702 | public function hasContainer ( $ name ) { try { $ container = $ this -> container ( $ name ) ; } catch ( \ HPCloud \ Transport \ FileNotFoundException $ fnfe ) { return FALSE ; } return TRUE ; } | Check to see if this container name exists . |
9,703 | public function createContainer ( $ name , ACL $ acl = NULL , $ metadata = array ( ) ) { $ url = $ this -> url ( ) . '/' . rawurlencode ( $ name ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token ( ) , ) ; if ( ! empty ( $ metadata ) ) { $ prefix = Container :: CONTAINER_METADATA_HEADER_PREFIX ; $ headers += Con... | Create a container with the given name . |
9,704 | public function deleteContainer ( $ name ) { $ url = $ this -> url ( ) . '/' . rawurlencode ( $ name ) ; try { $ data = $ this -> req ( $ url , 'DELETE' , FALSE ) ; } catch ( \ HPCloud \ Transport \ FileNotFoundException $ e ) { return FALSE ; } catch ( \ HPCloud \ Transport \ ConflictException $ e ) { throw new Object... | Delete an empty container . |
9,705 | protected function req ( $ url , $ method = 'GET' , $ jsonDecode = TRUE , $ body = '' ) { $ client = \ HPCloud \ Transport :: instance ( ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token ( ) , ) ; $ raw = $ client -> doRequest ( $ url , $ method , $ headers , $ body ) ; if ( ! $ jsonDecode ) { return $ raw ; } ... | Internal request issuing command . |
9,706 | public function setUp ( Template $ template , array $ options ) { $ this -> template = $ template ; $ this -> assets = array ( ) ; $ methods = array ( 'getExternalStylesheets' , 'getExternalJavascripts' , 'getInternalStylesheets' , 'getInternalJavascripts' , ) ; foreach ( $ methods as $ method ) { $ this -> assets [ $ ... | Sets up the object |
9,707 | protected function mergeAssets ( $ method , Template $ template , array $ options ) { $ assetsCollection = $ template -> $ method ( ) ; if ( null !== $ assetsCollection ) { $ assetsCollection = clone ( $ assetsCollection ) ; $ assetsCollection = $ this -> mergeFromTheme ( $ assetsCollection , $ template , $ options ) ;... | Merge assets for the method passed as argument |
9,708 | protected function mergeAppBlocksAssets ( AssetCollection $ assetsCollection , array $ options ) { $ appsAssets = array ( ) ; foreach ( $ this -> availableBlocks as $ className ) { if ( ! in_array ( $ className , $ appsAssets ) ) { $ parameterSchema = '%s.%s_%s' ; $ parameter = sprintf ( $ parameterSchema , strtolower ... | Merges the app block assets to the given collection |
9,709 | protected function addAssetsFromContainer ( AssetCollection & $ assetsCollection , $ parameter ) { if ( ! $ this -> container -> hasParameter ( $ parameter ) ) { return ; } $ assets = $ this -> container -> getParameter ( $ parameter ) ; $ assetsCollection -> addRange ( $ assets ) ; } | Adds a range of assets to the assets collection fetching from the container |
9,710 | protected function addExtraAssets ( & $ assetsCollection , $ baseParam ) { if ( ! $ this -> extraAssets ) { return ; } $ parameter = sprintf ( '%s.cms' , $ baseParam ) ; $ this -> addAssetsFromContainer ( $ assetsCollection , $ parameter ) ; } | Adds to the assets collection the extra parameters defined by extraAssetsSuffixes |
9,711 | public function run ( ) { $ ch = curl_init ( ) ; $ query = '' ; if ( ! empty ( $ this -> parameters ) ) { $ query = '?' . http_build_query ( $ this -> parameters ) ; } $ this -> query = $ this -> url . $ query ; if ( $ this -> method == "GET" ) { curl_setopt ( $ ch , CURLOPT_URL , $ this -> url . $ query ) ; } else { c... | Method called by the new instance to run the job . |
9,712 | public function find ( array $ where = [ ] , array $ field = [ ] ) { return $ this -> createQuery ( $ this -> getQueryBuilder ( ) -> select ( array ( ) === $ field ? $ this -> getAlias ( ) : $ field ) -> from ( $ this -> getTable ( ) ) -> where ( $ where ) ) -> execute ( ) -> getOne ( ) ; } | Fetch one row . |
9,713 | public function findAll ( array $ where = [ ] , array $ field = [ ] ) { return $ this -> createQuery ( $ this -> getQueryBuilder ( ) -> select ( array ( ) === $ field ? $ this -> getAlias ( ) : $ field ) -> from ( $ this -> getTable ( ) ) -> where ( $ where ) ) -> execute ( ) -> getAll ( ) ; } | Fetch all rows . |
9,714 | public function save ( array $ data = [ ] , array $ params = [ ] , array $ where = [ ] ) { if ( empty ( $ where ) ) { return $ this -> createQuery ( $ this -> getQueryBuilder ( ) -> insert ( array ( ) === $ data ? $ this -> data : $ data ) -> from ( $ this -> getTable ( ) ) ) -> setParameter ( [ ] === $ params ? $ this... | Save row into table . |
9,715 | private function createDocument ( ? string $ version = null , ? string $ encoding = null ) : \ DOMDocument { $ doc = new \ DOMDocument ( $ version ? : $ this -> defaultVersion , $ encoding ? : $ this -> defaultEncoding ) ; $ doc -> formatOutput = true ; return $ doc ; } | Create a new document object . |
9,716 | public static function ip2locationRecord ( $ record ) { if ( isset ( $ record [ 'error' ] ) ) { throw new \ Exception ( $ record [ 'error' ] ) ; } self :: $ geot_record = [ ] ; self :: $ geot_record [ 'city' ] [ 'names' ] = isset ( $ record [ 'cityName' ] ) ? [ 'en' => $ record [ 'cityName' ] ] : '' ; self :: $ geot_re... | Normalize Ip2location to match our api Results |
9,717 | public function align ( Template $ template , array $ templateSlots ) { $ slots = array_flip ( $ template -> getSlots ( ) ) ; if ( empty ( $ templateSlots ) || empty ( $ slots ) ) { return null ; } $ templateName = strtolower ( $ template -> getTemplateName ( ) ) ; $ templateSlots = array_intersect_key ( $ templateSlot... | Compares the slots and updates the contents according the new status |
9,718 | protected function updateSlotStatus ( array $ templateSlots , array $ changedSlots ) { try { $ result = true ; $ this -> blockRepository -> startTransaction ( ) ; foreach ( $ changedSlots as $ slotName => $ repeated ) { $ converter = $ this -> slotsConverterFactory -> createConverter ( $ templateSlots [ $ slotName ] , ... | Updates the slot status for the given slots |
9,719 | protected function templateSlotsToArray ( $ slots ) { $ result = array ( ) ; foreach ( $ slots as $ slot ) { $ result [ $ slot -> getSlotName ( ) ] = $ slot -> getRepeated ( ) ; } return $ result ; } | Converts the slots to an array where the key is the slot name and the value is the repeated status |
9,720 | protected function configureOptions ( OptionsResolver $ resolver ) { $ resolver -> setDefaults ( array ( 'csrf_parameter' => '_csrf_token' , 'csrf_protection' => true , 'collection_type' => FormCollectionInterface :: COLLECTION_TYPE_ALL , 'locale' => 'en_EN' , 'fallback_locales' => array ( 'en_EN' ) , 'translator_paths... | prepare default configuration |
9,721 | protected function _generateBytesWithMtRand ( $ amt ) { $ tmp = array ( ) ; for ( $ idx = 0 ; $ idx < $ amt ; $ idx ++ ) { $ tmp [ ] = chr ( $ this -> _mtRand ( 0 , 255 ) ) ; } return join ( '' , $ tmp ) ; } | Generate n Bytes with mt_rand |
9,722 | private function _generateUUIDFromData ( $ data ) { $ data = substr ( $ data , 0 , 16 ) ; $ data [ 6 ] = chr ( ord ( $ data [ 6 ] ) & 0x0f | 0x40 ) ; $ data [ 8 ] = chr ( ord ( $ data [ 8 ] ) & 0x3f | 0x80 ) ; return vsprintf ( '%s%s-%s-%s-%s-%s%s%s' , str_split ( bin2hex ( $ data ) , 4 ) ) ; } | Generate a valid UUIDv4 from provided random data . |
9,723 | public function widen ( $ img , $ width , $ outputFormat = null , $ targetPath = null ) { if ( $ targetPath && $ this -> cache -> cached ( $ targetPath ) ) { return ; } list ( $ ow , $ oh ) = $ imgInfo = ImageFile :: getSize ( $ img ) ; $ srcImg = ImageFile :: get ( $ img , $ imgInfo ) ; if ( $ width == $ ow ) { if ( $... | Set an image to the given width while preserving its ratio |
9,724 | public function maximize ( $ img , $ maxWidth , $ maxHeight , $ outputFormat = null , $ targetPath = null ) { if ( $ targetPath && $ this -> cache -> cached ( $ targetPath ) ) { return ; } list ( $ ow , $ oh ) = $ imgInfo = ImageFile :: getSize ( $ img ) ; $ srcImg = ImageFile :: get ( $ img , $ imgInfo ) ; if ( $ maxW... | Maximize image s size by its longest dimension while preserving its ratio |
9,725 | public function thumbnail ( $ img , $ width , $ height , $ outputFormat = null , $ targetPath = null ) { if ( $ targetPath && $ this -> cache -> cached ( $ targetPath ) ) { return ; } list ( $ ow , $ oh ) = $ imgInfo = ImageFile :: getSize ( $ img ) ; $ srcImg = ImageFile :: get ( $ img , $ imgInfo ) ; $ or = $ ow / $ ... | Make a thumbnail by cropping the image by its shortest dimension |
9,726 | public function getContent ( $ asResource = false ) { $ content = $ this -> request -> getContent ( $ asResource ) ; json_decode ( $ content ) ; if ( json_last_error ( ) == JSON_ERROR_NONE ) { return json_encode ( json_decode ( $ content ) , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ; } return $ content ; } | Returns the request body content and handles unescaping slashes for json content . |
9,727 | public function isValid ( string $ key ) : bool { if ( ! $ this -> headers -> has ( $ this -> algorithmHeader ) ) { return false ; } if ( ! $ this -> headers -> has ( $ this -> signatureHeader ) ) { return false ; } $ signature = new Signature ( new Payload ( $ this -> request ) , $ this -> getAlgorithm ( ) , $ key ) ;... | Determines if the signed request is valid . |
9,728 | public function isExpired ( int $ tolerance ) : bool { $ timestamp = $ this -> headers -> get ( 'X-SIGNED-TIMESTAMP' , '1901-01-01 12:00:00' ) ; $ issuedAt = Carbon :: parse ( $ timestamp ) ; $ isValid = Helpers :: verifyDateTime ( $ timestamp , 'Y-m-d H:i:s' ) ; return ! $ isValid || Carbon :: now ( ) -> diffInSeconds... | Checks if this request was issued within tolerance seconds of now . |
9,729 | public static function useStreamWrappers ( ) { $ swift = stream_wrapper_register ( \ HPCloud \ Storage \ ObjectStorage \ StreamWrapper :: DEFAULT_SCHEME , '\HPCloud\Storage\ObjectStorage\StreamWrapper' ) ; $ swiftfs = stream_wrapper_register ( \ HPCloud \ Storage \ ObjectStorage \ StreamWrapperFS :: DEFAULT_SCHEME , '\... | Register stream wrappers for HPCloud . |
9,730 | public static function autoload ( $ klass ) { $ components = explode ( '\\' , $ klass ) ; if ( empty ( $ components [ 0 ] ) ) { array_shift ( $ components ) ; } if ( $ components [ 0 ] != 'HPCloud' ) { return ; } $ loc = DIRECTORY_SEPARATOR . 'HPCloud' ; $ local_path = substr ( self :: $ basedir , 0 , strrpos ( self ::... | HPCloud autoloader . |
9,731 | public static function config ( $ name = NULL , $ default = NULL ) { if ( empty ( $ name ) ) { return self :: $ config ; } if ( isset ( self :: $ config [ $ name ] ) ) { return self :: $ config [ $ name ] ; } return $ default ; } | Get a configuration option . |
9,732 | public static function getHandlerList ( ) { $ handlerList = array ( ) ; $ ini = eZINI :: instance ( 'http.ini' ) ; if ( $ ini -> hasGroup ( 'HTTPCacheHandlers' ) && $ ini -> hasVariable ( 'HTTPCacheHandlers' , 'Handlers' ) ) $ handlerList = $ ini -> variable ( 'HTTPCacheHandlers' , 'Handlers' ) ; return $ handlerList ;... | Return list of available handler class names |
9,733 | public static function getHandlers ( ) { $ handlers = array ( ) ; $ handlerList = self :: getHandlerList ( ) ; $ cacheHash = md5 ( serialize ( $ handlerList ) ) ; if ( isset ( $ GLOBALS [ 'eZHTTPCacheManager_' . $ cacheHash ] ) ) return $ GLOBALS [ 'eZHTTPCacheManager_' . $ cacheHash ] ; foreach ( $ handlerList as $ ha... | Return list of available handler objects |
9,734 | public static function execute ( $ url ) { $ handlers = self :: getHandlers ( ) ; foreach ( $ handlers as $ handler ) { if ( $ handler -> isEnabled ( ) ) $ handler -> purgeURL ( $ url ) ; } } | Call user definied handler methods |
9,735 | function AES ( $ z ) { $ this -> Nb = 4 ; $ this -> Nk = strlen ( $ z ) / 4 ; $ this -> Nr = $ this -> Nk + $ this -> Nb + 2 ; if ( $ this -> Nk != 4 && $ this -> Nk != 6 && $ this -> Nk != 8 ) die ( "Key is " . ( $ this -> Nk * 32 ) . " bits long. *not* 128, 192, or 256." ) ; $ this -> Nr = $ this -> Nk + $ this -> Nb... | constructs an AES cipher using a specific key . |
9,736 | public function handler ( $ errno , $ errstr , $ errfile , $ errline ) { throw new \ ErrorException ( $ errstr , $ errno , 0 , $ errfile , $ errline ) ; } | Handles errors throws them as Exceptions |
9,737 | public static function settings ( $ settings = array ( ) ) { self :: $ _readOnce = isset ( $ settings [ 'readOnce' ] ) ? ( boolean ) $ settings [ 'readOnce' ] : false ; self :: $ _defaultReturn = ( array_key_exists ( 'defaultReturn' , $ settings ) ) ? $ settings [ 'defaultReturn' ] : 'ST__EXCEPTION' ; } | Global settings setter |
9,738 | protected static function _cleanPrevious ( ) { if ( self :: $ _cleanedPrev ) return true ; self :: $ _cleanedPrev = 1 ; if ( isset ( $ _SESSION ) && is_array ( $ _SESSION ) ) { foreach ( $ _SESSION as $ key => $ value ) { if ( strpos ( $ key , self :: $ _sessionKey ) === 0 ) { if ( $ _SESSION [ $ key ] [ 0 ] < 1 ) { un... | Flash old messages cleaner |
9,739 | public static function reflush ( $ keys = null ) { self :: _cleanPrevious ( ) ; if ( $ keys ) { if ( ! is_array ( $ keys ) ) { $ keys = array ( $ keys ) ; } $ keys = array_flip ( $ keys ) ; } foreach ( $ _SESSION as $ key => $ value ) { if ( strpos ( $ key , self :: $ _sessionKey ) === 0 ) { if ( $ keys ) { $ k = str_r... | Existing messages reflusher allowing them to last till next session |
9,740 | public function fill ( ) { $ languages = $ this -> languageRepository -> activeLanguages ( ) ; $ this -> initPages ( $ languages ) ; $ this -> initBasePages ( $ languages ) ; } | Fills up the PageTree collection |
9,741 | protected function createMail ( array $ config ) { $ mail = $ this -> newMailInstance ( ) ; $ mail -> setName ( ConfigUtil :: getValue ( $ config , 'name' ) ) ; $ mail -> setLabel ( ConfigUtil :: getValue ( $ config , 'label' ) ) ; $ mail -> setDescription ( ConfigUtil :: getValue ( $ config , 'description' ) ) ; $ mai... | Create the mail . |
9,742 | protected function createMailTranslation ( MailInterface $ mail , array $ config ) { $ translation = $ this -> newMailTranslationInstance ( $ mail ) ; $ translation -> setLocale ( ConfigUtil :: getValue ( $ config , 'locale' ) ) ; $ translation -> setLabel ( ConfigUtil :: getValue ( $ config , 'label' ) ) ; $ translati... | Create a mail translation . |
9,743 | public function thumbnail ( $ image , $ targetWidth = 100 , $ targetHeight = 100 ) { $ imagePath = $ this -> container -> getParameter ( 'red_kite_cms.web_folder_full_path' ) . $ image ; if ( ! is_file ( $ imagePath ) ) { return null ; } $ thumbnailer = $ this -> container -> get ( 'red_kite_cms.images_thumbnailer' ) ;... | Generates a thumbnail of the given image |
9,744 | public function addBlockManager ( BlockManagerInterface $ blockManager , array $ attributes ) { if ( empty ( $ attributes [ 'type' ] ) ) { return ; } $ blockManager -> setFactoryRepository ( $ this -> factoryRepository ) ; $ this -> blockManagersItems [ ] = new BlockManagerFactoryItem ( $ blockManager , $ attributes ) ... | Adds a block manager base object . |
9,745 | public function getBlocks ( ) { $ ungroupedKey = 'Ungrouped' ; $ blockGroups = array ( ) ; foreach ( $ this -> blockManagersItems as $ blockManagerItem ) { if ( $ blockManagerItem -> getBlockManager ( ) -> getIsInternalBlock ( ) ) { continue ; } $ groups = array ( $ ungroupedKey ) ; $ group = $ blockManagerItem -> getG... | Returns an array that contains the blocks description objects that can be created by the factory ordered by group |
9,746 | public function register ( $ id , $ definition , $ shared = false ) { if ( is_object ( $ definition ) && ! is_callable ( $ definition ) ) { $ this -> instances [ $ id ] = $ definition ; return $ this ; } $ this -> components [ $ id ] = $ definition ; if ( $ shared || isset ( $ this -> instances [ $ id ] ) ) { $ this ->... | Registers component definition in container |
9,747 | public function unregister ( $ id ) { if ( array_key_exists ( $ id , $ this -> components ) ) { unset ( $ this -> components [ $ id ] ) ; } if ( array_key_exists ( $ id , $ this -> instances ) ) { unset ( $ this -> instances [ $ id ] ) ; } return $ this ; } | Unregisters component from container |
9,748 | public function exists ( $ id ) { if ( array_key_exists ( $ id , $ this -> components ) ) { return true ; } if ( isset ( $ this -> instances [ $ id ] ) ) { return true ; } return false ; } | Returns true if component exists in container |
9,749 | public function & get ( $ id ) { if ( isset ( $ this -> instances [ $ id ] ) ) { return $ this -> instances [ $ id ] ; } $ result = $ this -> resolve ( $ id ) ; if ( array_key_exists ( $ id , $ this -> instances ) ) { $ this -> instances [ $ id ] = & $ result ; } return $ result ; } | Returns component instance or value |
9,750 | protected function resolve ( $ id ) { $ keys = explode ( self :: SEPARATOR , $ id ) ; $ node = & $ this -> components ; while ( $ key = array_shift ( $ keys ) ) { if ( ! is_array ( $ node ) || ! array_key_exists ( $ key , $ node ) ) { throw new ContainerException ( sprintf ( 'Invalid or unknown component/parameter iden... | Resolves component by its id |
9,751 | private function encode64 ( $ input , $ count ) { $ output = '' ; $ i = 0 ; do { $ value = ord ( $ input [ $ i ++ ] ) ; $ output .= self :: $ itoa64 [ $ value & 0x3f ] ; if ( $ i < $ count ) { $ value |= ord ( $ input [ $ i ] ) << 8 ; } $ output .= self :: $ itoa64 [ ( $ value >> 6 ) & 0x3f ] ; if ( $ i ++ >= $ count )... | Encode hash . |
9,752 | public function onBeforeEditPageCommit ( BeforeEditPageCommitEvent $ event ) { if ( $ event -> isAborted ( ) ) { return ; } $ pageManager = $ event -> getContentManager ( ) ; $ pageRepository = $ pageManager -> getPageRepository ( ) ; $ values = $ event -> getValues ( ) ; if ( ! is_array ( $ values ) ) { throw new Inva... | Edits the seo attributes when a new page is edited |
9,753 | public function getClassIndex ( ) : ClassIndex { if ( is_null ( $ this -> classIndex ) ) { $ this -> classIndex = new ClassIndex ( ) ; } return $ this -> classIndex ; } | Get class index . |
9,754 | public function newInstanceOf ( $ class , array $ arguments = [ ] , bool $ dependencyInjection = true ) { try { $ reflectionClass = new \ ReflectionClass ( $ class ) ; if ( ! is_null ( $ constructor = $ reflectionClass -> getConstructor ( ) ) ) { if ( $ dependencyInjection ) { $ arguments = $ this -> getDependencyInjec... | Create new instance of a class . |
9,755 | public function invokeMethod ( $ class , string $ method , array $ arguments = [ ] , bool $ dependencyInjection = true ) { if ( ! ( is_object ( $ class ) || ( is_string ( $ class ) && class_exists ( $ class ) ) ) ) { throw new InstantiatorException ( sprintf ( 'First argument must be a valid class name or an object, %s... | Invocation of method . |
9,756 | public function invokeFunction ( string $ function , array $ arguments = [ ] , bool $ dependencyInjection = true ) { try { $ reflectionFunction = new \ ReflectionFunction ( $ function ) ; if ( $ dependencyInjection ) { $ arguments = $ this -> getDependencyInjectionParameters ( $ reflectionFunction -> getParameters ( ) ... | Invocation of function . |
9,757 | private function getDependencyInjectionParameters ( array $ reflectionParameters , array $ arguments = [ ] ) : array { $ parameters = [ ] ; $ argumentsClass = [ ] ; foreach ( $ arguments as $ name => & $ argument ) { if ( ! is_null ( $ this -> getContainer ( ) ) ) { if ( is_string ( $ argument ) && substr ( $ argument ... | Get parameters ordered to inject . |
9,758 | private function getDependencyInjectionParameter ( \ ReflectionParameter $ reflectionParameter , array & $ arguments , array $ argumentsClass ) { if ( array_key_exists ( $ reflectionParameter -> getName ( ) , $ arguments ) ) { $ parameter = $ arguments [ $ reflectionParameter -> getName ( ) ] ; unset ( $ arguments [ $ ... | Get parameter value for injection . |
9,759 | public function add ( $ message , $ type = 'error' ) { $ this -> session [ $ this -> prefix ] [ ] = [ 'message' => $ message , 'type' => $ type ] ; return $ this ; } | Adds message to flashbag |
9,760 | public function has ( $ type = null ) { if ( $ type === null ) { return ! empty ( $ this -> session [ $ this -> prefix ] ) ; } foreach ( $ this -> session [ $ this -> prefix ] as $ message ) { if ( $ message [ 'type' ] === $ type ) { return true ; } } return false ; } | Returns true if at least one message of set type exists |
9,761 | public function get ( $ type = null ) { $ result = [ ] ; foreach ( $ this -> session [ $ this -> prefix ] as $ offset => $ message ) { if ( $ type === null || $ message [ 'type' ] === $ type ) { $ result [ ] = $ message ; unset ( $ this -> session [ $ this -> prefix ] [ $ offset ] ) ; } } return $ result ; } | Returns array containing messages of set type |
9,762 | public function returnMiddleware ( App $ app , array $ objects , array $ middleware ) { if ( isset ( $ middleware [ 'arguments' ] ) ) { $ params = $ middleware [ 'arguments' ] ; $ count = count ( $ params ) ; } else { $ count = 0 ; } foreach ( $ params as $ k => $ v ) { if ( preg_match ( "#.#" , $ v ) ) { $ explode = e... | Limit of 2 params |
9,763 | private static function containsEscapeCharacters ( $ string ) { $ escapeCodePattern = '#' . static :: ANSI_ESCAPE_CODE_REGEX . '#' ; $ result = preg_match ( $ escapeCodePattern , $ string ) ; return ( boolean ) $ result ; } | Check if given string contains color escape code |
9,764 | public function drawAction ( ) { $ this -> checkGame ( ) ; $ winningEntries = $ this -> getAdminGameService ( ) -> draw ( $ this -> game ) ; $ content = "\xEF\xBB\xBF" ; $ content .= "ID;Pseudo;Nom;Prenom;E-mail;Etat\n" ; foreach ( $ winningEntries as $ e ) { $ etat = 'gagnant' ; $ content .= $ e -> getUser ( ) -> getI... | Only used for Quiz and Lottery |
9,765 | public function exportAction ( ) { $ this -> checkGame ( ) ; $ content = serialize ( $ this -> game ) ; $ response = $ this -> getResponse ( ) ; $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeaderLine ( 'Content-Encoding: UTF-8' ) ; $ headers -> addHeaderLine ( 'Content-Type' , 'text/plain; charset=UTF-8'... | This method serialize a game an export it as a txt file |
9,766 | public function importAction ( ) { $ form = $ this -> getServiceLocator ( ) -> get ( 'playgroundgame_import_form' ) ; $ form -> setAttribute ( 'action' , $ this -> adminUrl ( ) -> fromRoute ( 'playgroundgame/import' ) ) ; $ form -> setAttribute ( 'method' , 'post' ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ d... | This method take an uploaded txt file containing a serialized game and persist it in the database |
9,767 | public function getInfo ( $ opt = null ) { if ( $ opt !== null ) { return curl_getinfo ( $ this -> handle , $ opt ) ; } return curl_getinfo ( $ this -> handle ) ; } | Get info from request |
9,768 | public function registerNamedRoute ( Route $ routeObj ) { $ name = $ routeObj -> getName ( ) ; if ( $ name && isset ( $ this -> namedRoutes [ $ name ] ) ) { if ( $ routeObj !== $ this -> namedRoutes [ $ name ] ) { throw new Exception ( "Can not redeclare route '{$name}'" ) ; } } else { $ this -> namedRoutes [ $ name ] ... | Registers a route with a name |
9,769 | public static function get ( $ route , $ target , $ name = null , $ middleware = null ) { return static :: getInstance ( ) -> map ( 'GET' , $ route , $ target , $ name , $ middleware ) ; } | Route all GET request for a given route to a controller or closure . |
9,770 | public static function post ( $ route , $ target , $ name = null , $ middleware = null ) { return static :: getInstance ( ) -> map ( 'POST' , $ route , $ target , $ name , $ middleware ) ; } | Route all POST request for a given route to a controller or closure . |
9,771 | public static function patch ( $ route , $ target , $ name = null , $ middleware = null ) { return static :: getInstance ( ) -> map ( 'PATCH' , $ route , $ target , $ name , $ middleware ) ; } | Route all PATCH request for a given route to a controller or closure . |
9,772 | public static function delete ( $ route , $ target , $ name = null , $ middleware = null ) { return static :: getInstance ( ) -> map ( 'DELETE' , $ route , $ target , $ name , $ middleware ) ; } | Route all DELETE request for a given route to a controller or closure . |
9,773 | public static function put ( $ route , $ target , $ name = null , $ middleware = null ) { return static :: getInstance ( ) -> map ( 'PUT' , $ route , $ target , $ name , $ middleware ) ; } | Route all PUT request for a given route to a controller or closure . |
9,774 | public static function view ( $ route , $ view , $ data = [ ] , $ name = null , $ middleware = null ) { $ target = function ( ) use ( $ view , $ data ) { return view ( $ view , $ data ) ; } ; return static :: get ( $ route , $ target , $ name , $ middleware ) ; } | Return a view for this route . |
9,775 | public static function redirect ( $ route , $ to , $ name = null , $ middleware = null ) { $ target = function ( ) use ( $ to ) { if ( ! filter_var ( $ to , FILTER_VALIDATE_URL ) ) { $ to = static :: getInstance ( ) -> route ( $ to ) ; } return redirect ( $ to , 301 ) ; } ; return static :: all ( $ route , $ target , $... | Permanently redirect route to another route or URL . |
9,776 | public static function group ( array $ attributes , Closure $ closure ) { $ hash = uniqid ( 'prop_' ) ; if ( isset ( $ attributes [ 'prefix' ] ) ) { static :: $ groupsProps [ 'prefix' ] [ $ hash ] = $ attributes [ 'prefix' ] ; } if ( isset ( $ attributes [ 'namespace' ] ) ) { static :: $ groupsProps [ 'namespace' ] [ $... | For creating a group of routes that have attributes in common |
9,777 | public static function verifyDateTime ( string $ datetime , string $ format ) : bool { $ formatted = DateTime :: createFromFormat ( $ format , $ datetime ) ; $ errors = DateTime :: getLastErrors ( ) ; if ( ! empty ( $ errors [ 'warning_count' ] ) ) { return false ; } return $ formatted !== false ; } | Verifies if the provided date string is in the given format |
9,778 | public static function getIndexRecords ( $ request , $ parameters ) { $ instance = new static ; if ( method_exists ( $ instance , 'addToGetIndexRecords' ) ) $ query = $ instance -> addToGetIndexRecords ( $ request , $ parameters ) ; else if ( method_exists ( $ instance , 'scopeBuilder' ) ) $ query = $ instance -> build... | Function to get data record to list objects |
9,779 | public static function deleteLangDataRecord ( $ parameters ) { $ instance = new static ; $ object = $ instance :: find ( $ parameters [ 'id' ] ) ; if ( $ object != null ) { $ jsonObject = json_decode ( $ object -> { 'data_lang_' . $ instance -> suffix } ) ; $ newArrayLang = [ ] ; foreach ( $ jsonObject -> langs as $ ke... | Function to delete lang record from json field |
9,780 | public static function checkSlug ( $ slugField , $ slug , $ id = null ) { $ instance = new static ; $ slug = $ slug ; $ query = $ instance -> where ( $ slugField , $ slug ) ; if ( $ id != null ) { $ query -> whereNotIn ( $ instance -> getKeyName ( ) , [ $ id ] ) ; } $ nObjects = $ query -> count ( ) ; if ( $ nObjects >... | Function to check if slug exists |
9,781 | protected function doSendRequest ( Request $ request ) : Response { if ( ! $ this -> shouldUseGearman ( ) ) { return $ this -> locator -> getRequestBus ( ) -> receiveRequest ( $ request ) ; } $ envelope = new TransportEnvelope ( $ request , 'php' ) ; $ channel = $ this -> router -> forRequest ( $ request ) ; try { $ cl... | Processes the request in memory synchronously . |
9,782 | private function destroyClient ( ) : void { ++ $ this -> reconnects ; $ this -> client = null ; $ delay = mt_rand ( 0 , ( int ) min ( 5000 , ( int ) pow ( 2 , $ this -> reconnects ) * 100 ) ) ; usleep ( $ delay * 1000 ) ; } | Destroys the current client and creates an exponential backoff with jitter 100ms base 5 sec ceiling . |
9,783 | private function getClient ( ) : \ GearmanClient { if ( null === $ this -> client ) { $ client = new \ GearmanClient ( ) ; $ client -> setTimeout ( $ this -> timeout ) ; if ( empty ( $ this -> servers ) ) { try { if ( ! $ client -> addServer ( ) ) { throw new \ GearmanException ( 'GearmanClient::addServer returned fals... | Creates a gearman client sets the timeout and adds the servers . At least one server must connect successfully otherwise an exception is thrown . |
9,784 | private function validateReturnCode ( \ GearmanClient $ client , string $ channel ) : void { switch ( $ client -> returnCode ( ) ) { case GEARMAN_SUCCESS : case GEARMAN_WORK_DATA : case GEARMAN_WORK_STATUS : return ; case GEARMAN_TIMEOUT : throw new \ GearmanException ( sprintf ( 'Code [%s] :: Timeout reached, no avail... | Checks the return code from gearman and throws an exception if it s a failure . |
9,785 | public function getBlockTypes ( ) { $ types = array ( ) ; foreach ( $ this -> alBlocks as $ block ) { $ type = $ block -> getType ( ) ; if ( ! in_array ( $ type , $ types ) ) { $ types [ ] = $ type ; } } return $ types ; } | Returns the block types associated to this PageBlock |
9,786 | protected function arrangeBlocks ( ) { $ this -> blocks = array ( ) ; foreach ( $ this -> alBlocks as $ alBlock ) { $ this -> blocks [ $ alBlock -> getSlotName ( ) ] [ ] = $ alBlock ; } } | Arranges the blocks retrieved from the database into an array where blocks are grouped by slot name |
9,787 | public function match ( RequestInterface $ request ) { foreach ( $ this -> routes as $ name => $ route ) { if ( ! $ route -> match ( $ request ) ) { continue ; } foreach ( $ route -> arguments ( ) as $ key => $ value ) { $ request -> query ( ) -> set ( $ key , $ value ) ; } $ request -> language ( $ request -> query ( ... | Matches request to route Throws RangeException if no matching route found |
9,788 | public function make ( $ name = null , array $ arguments = [ ] ) { $ name = $ this -> resolveName ( $ name ) ; if ( is_scalar ( $ name ) && isset ( $ this -> routes [ $ name ] ) ) { return $ this -> routes [ $ name ] -> make ( $ this -> defaults [ 'host' ] , $ arguments ) ; } foreach ( $ this -> routes as $ route ) { i... | Makes link If corresponding route exists - friendly link is generated otherwise normal |
9,789 | private function resolveName ( $ name ) { if ( $ name !== null ) { return $ name ; } if ( ! isset ( $ this -> defaults [ 'route' ] ) ) { throw new RouterException ( 'Unable to make "self" url - default route was not defined.' ) ; } return $ this -> defaults [ 'route' ] ; } | Resolves controller from passed value or from defaults |
9,790 | public static function determineShard ( $ string , int $ shards = 256 ) : int { $ num = hexdec ( substr ( md5 ( ( string ) $ string ) , 0 , 4 ) ) ; return $ num % $ shards ; } | Determines what shard the provided string should be on . |
9,791 | protected function createSlider ( ) { $ this -> data [ 'slideWidth' ] = $ this -> sliderWidth ; $ this -> data [ 'slideHeight' ] = $ this -> sliderHeight ; $ this -> data [ 'slidePosition' ] = [ 'left' => 0 , 'top' => 0 ] ; $ this -> data [ 'arrowSkinId' ] = $ this -> arrowSkinId ; $ this -> data [ 'navSkinId' ] = $ th... | Do all important settings for the skin and the view file |
9,792 | protected function createSliderContainer ( ) { $ customCssClass = isset ( $ this -> containerOptions [ 'class' ] ) ? ' ' . $ this -> containerOptions [ 'class' ] : '' ; $ this -> containerOptions = [ ] ; $ this -> containerOptions [ 'style' ] = "width:{$this->sliderWidth}px; height:{$this->sliderHeight}px" ; $ this -> ... | Slider Container settings |
9,793 | protected function createSliderArrow ( ) { $ skin = self :: $ arrowSkins [ $ this -> arrowSkinId ] ; $ this -> data [ 'arrow' ] [ 'left' ] = $ skin [ 'left' ] ; $ this -> data [ 'arrow' ] [ 'right' ] = $ skin [ 'right' ] ; $ skin [ 's' ] [ '$Class' ] = '$JssorArrowNavigator$' ; $ this -> mergeSkinSettings ( $ skin , '$... | Slider Arrows settings |
9,794 | protected function createSliderBullet ( ) { $ skin = self :: $ navSkins [ $ this -> navSkinId ] ; $ skin [ 's' ] [ '$Class' ] = '$JssorBulletNavigator$' ; $ this -> mergeSkinSettings ( $ skin , '$BulletNavigatorOptions' ) ; } | Slider Bullet settings |
9,795 | protected function createSliderThumb ( ) { $ skin = self :: $ navSkins [ $ this -> navSkinId ] ; $ this -> data [ 'template' ] = $ skin [ 'template' ] ; if ( $ skin [ 'position' ] === 'bottom' ) { $ this -> data [ 'thumb' ] [ 'containerWidth' ] = $ this -> sliderWidth ; $ this -> data [ 'thumb' ] [ 'containerHeight' ] ... | Slider Thumb settings |
9,796 | protected function resolvePosition ( $ positions ) { $ str = '' ; foreach ( $ positions as $ pos => $ val ) { $ str .= "{$pos}: {$val}px; " ; } return rtrim ( $ str ) ; } | Helper function to convert a position array to a correct style attribute string . |
9,797 | public function process ( ContainerBuilder $ container ) { $ this -> setupPools ( $ container ) ; $ pools = $ container -> getParameter ( 'gendoria_command_queue.pools' ) ; foreach ( $ container -> findTaggedServiceIds ( self :: QUEUE_MANAGER_TAG ) as $ id => $ tags ) { $ def = $ container -> getDefinition ( $ id ) ; $... | Prepares command queue pools based on bundle configuration . |
9,798 | private function setupPools ( ContainerBuilder $ container ) { $ pools = $ container -> getParameter ( 'gendoria_command_queue.pools' ) ; $ usedServiceIds = array ( ) ; foreach ( $ pools as $ poolData ) { $ sendServiceId = substr ( $ poolData [ 'send_driver' ] , 1 ) ; if ( in_array ( $ sendServiceId , $ usedServiceIds ... | Setup pools . |
9,799 | public function addRunnerService ( $ name , $ id , array $ options = array ( ) ) { if ( ! $ this -> container -> has ( $ id ) ) { throw new InvalidArgumentException ( "Service container does not have required service registered." ) ; } $ this -> runnerServices [ $ name ] = array ( 'id' => $ id , 'options' => $ options ... | Register runner service . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.