idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
26,800 | final protected function haltOnDemand ( ) { switch ( true ) { case $ this -> hasOption ( 'secure' ) && $ this -> getOptions ( 'secure' ) == true && ! $ this -> request -> isSecure ( ) : case $ this -> hasOption ( 'ajax' ) && $ this -> getOptions ( 'ajax' ) == true && ! $ this -> request -> isAjax ( ) : case $ this -> hasOption ( 'method' ) && ( strtoupper ( $ this -> getOptions ( 'method' ) ) != $ this -> request -> getMethod ( ) ) : $ this -> halt ( ) ; } } | Halts controller s execution on demand |
26,801 | private function loadTranslationMessages ( $ language ) { $ this -> moduleManager -> clearTranslations ( ) ; $ this -> translator -> reset ( ) ; $ this -> moduleManager -> loadAllTranslations ( $ language ) ; $ this -> translator -> extend ( $ this -> moduleManager -> getTranslations ( ) ) ; } | Load translation messages from all available modules |
26,802 | private function loadDefaultTranslations ( ) { $ language = $ this -> appConfig -> getLanguage ( ) ; if ( $ language !== null ) { $ this -> loadTranslationMessages ( $ language ) ; } } | Loads default translations if default language is defined |
26,803 | final protected function loadTranslations ( $ language ) { if ( $ this -> appConfig -> getLanguage ( ) !== $ language ) { $ this -> appConfig -> setLanguage ( $ language ) ; $ this -> loadTranslationMessages ( $ language ) ; return true ; } else { return false ; } } | Load translation messages |
26,804 | final public function initialize ( $ action ) { $ this -> haltOnDemand ( ) ; $ this -> view -> setModule ( $ this -> getModule ( ) ) -> setTheme ( $ this -> appConfig -> getTheme ( ) ) ; if ( method_exists ( $ this , 'bootstrap' ) ) { $ this -> bootstrap ( $ action ) ; } if ( method_exists ( $ this , 'onAuth' ) ) { $ this -> onAuth ( ) ; } $ this -> loadDefaultTranslations ( ) ; } | Invoked right after class instantiation |
26,805 | public static function get ( $ controllerClass ) { if ( ! isset ( self :: $ controllers [ $ controllerClass ] ) ) { if ( class_exists ( $ controllerClass ) ) { $ reflectionClass = new ReflectionClass ( $ controllerClass ) ; self :: $ controllers [ $ controllerClass ] = $ reflectionClass -> isAbstract ( ) ? $ controllerClass : ( new $ controllerClass ) ; } else { self :: $ controllers [ $ controllerClass ] = null ; } } return self :: $ controllers [ $ controllerClass ] ; } | Returns a controller instance |
26,806 | protected function createLaravelDriver ( ) : Sdk \ Client { return \ tap ( $ this -> createHttpClient ( ) , function ( $ client ) { if ( isset ( $ this -> config [ 'client_id' ] ) || isset ( $ this -> config [ 'client_secret' ] ) ) { $ client -> setClientId ( $ this -> config [ 'client_id' ] ) -> setClientSecret ( $ this -> config [ 'client_secret' ] ) ; } if ( isset ( $ this -> config [ 'access_token' ] ) ) { $ client -> setAccessToken ( $ this -> config [ 'access_token' ] ) ; } } ) ; } | Create laravel driver . |
26,807 | public function set ( $ key , $ value , $ ttl ) { if ( ! $ this -> memcached -> set ( $ key , $ value , $ ttl ) ) { return $ this -> memcached -> replace ( $ key , $ value , $ ttl ) ; } else { return true ; } } | Stores into the cache |
26,808 | public function get ( $ key , $ default = false ) { $ value = $ this -> memcached -> get ( $ key ) ; if ( $ this -> memcached -> getResultCode ( ) == 0 ) { return $ value ; } else { return $ default ; } } | Returns from the cache |
26,809 | public function setLayout ( $ layout , $ layoutModule = null ) { $ this -> layout = $ layout ; $ this -> layoutModule = $ layoutModule ; return $ this ; } | Defines global template s layout |
26,810 | public function addVariables ( array $ variables ) { foreach ( $ variables as $ name => $ value ) { $ this -> addVariable ( $ name , $ value ) ; } return $ this ; } | Appends collection of variables |
26,811 | public function url ( ) { $ args = func_get_args ( ) ; $ controller = array_shift ( $ args ) ; $ url = $ this -> urlBuilder -> createUrl ( $ controller , $ args ) ; if ( $ url === false ) { return $ controller ; } else { return $ url ; } } | Generates URL by known controller s syntax and optional arguments This should be used inside templates only |
26,812 | public function mapUrl ( $ controller , array $ args = array ( ) , $ index = 0 ) { return $ this -> urlBuilder -> createUrl ( $ controller , $ args , $ index ) ; } | Generates URL filtered by mapped index |
26,813 | public function show ( $ message , $ translate = true ) { if ( $ translate === true ) { $ message = $ this -> translate ( $ message ) ; } echo $ message ; } | Prints a string |
26,814 | private function createPath ( $ dir , $ path , $ module , $ theme = null ) { if ( $ theme !== null ) { return sprintf ( '%s/%s/%s/%s/%s' , $ path , self :: TEMPLATE_PARAM_MODULES_DIR , $ module , $ dir , $ theme ) ; } else { return sprintf ( '%s/%s/%s/%s' , $ path , self :: TEMPLATE_PARAM_MODULES_DIR , $ module , $ dir ) ; } } | Creates path to view template |
26,815 | private function createSharedThemePath ( $ module , $ theme , $ base ) { if ( is_null ( $ theme ) ) { $ theme = $ this -> theme ; } if ( is_null ( $ module ) ) { $ module = $ this -> module ; } return sprintf ( '%s/%s/%s/%s' , $ base , $ module , self :: TEMPLATE_PARAM_BASE_DIR , $ theme ) ; } | Creates shared theme path |
26,816 | public function createThemeUrl ( $ module = null , $ theme = null ) { return $ this -> createSharedThemePath ( $ module , $ theme , '/' . self :: TEMPLATE_PARAM_MODULES_DIR ) ; } | Creates theme URL |
26,817 | public function createThemePath ( $ module = null , $ theme = null ) { return $ this -> createSharedThemePath ( $ module , $ theme , $ this -> moduleDir ) ; } | Resolves a base path |
26,818 | public function createAssetUrl ( $ module = null , $ path = null ) { if ( is_null ( $ module ) ) { $ module = $ this -> module ; } return sprintf ( '/%s/%s/%s' , self :: TEMPLATE_PARAM_MODULES_DIR , $ module , self :: TEMPLATE_PARAM_ASSETS_DIR ) . $ path ; } | Creates URL for asset |
26,819 | private function createAssetPath ( $ path , $ module , $ absolute , $ fromAssets ) { $ baseUrl = '' ; if ( $ absolute === true ) { $ url = $ baseUrl ; } else { $ url = null ; } if ( is_null ( $ module ) ) { $ module = $ this -> module ; } if ( $ fromAssets !== false ) { $ dir = self :: TEMPLATE_PARAM_ASSETS_DIR ; $ theme = null ; } else { $ dir = self :: TEMPLATE_PARAM_BASE_DIR ; $ theme = $ this -> theme ; } return $ url . sprintf ( '%s/%s' , $ this -> createPath ( $ dir , $ baseUrl , $ module , $ theme ) , $ path ) ; } | Returns asset path by module and its nested path |
26,820 | private function createInclusionPath ( $ name , $ module = null ) { if ( is_null ( $ module ) ) { $ module = $ this -> module ; } $ base = $ this -> createPath ( self :: TEMPLATE_PARAM_BASE_DIR , dirname ( $ this -> moduleDir ) , $ module , $ this -> theme ) ; $ path = sprintf ( '%s.%s' , $ base . \ DIRECTORY_SEPARATOR . $ name , self :: TEMPLATE_PARAM_EXTENSION ) ; return $ path ; } | Returns full path to a file by its name |
26,821 | public function moduleAsset ( $ asset , $ module = null , $ absolute = false ) { return $ this -> createAssetPath ( $ asset , $ module , $ absolute , true ) ; } | Generates a path to module asset file |
26,822 | public function asset ( $ asset , $ module = null , $ absolute = false ) { return $ this -> createAssetPath ( $ asset , $ module , $ absolute , false ) ; } | Generates a full path to an asset |
26,823 | private function createContentWithLayout ( $ layout , $ fragment ) { $ this -> variables [ self :: TEMPLATE_PARAM_FRAGMENT_VAR_NAME ] = $ this -> createFileContent ( $ fragment ) ; return $ this -> createFileContent ( $ layout ) ; } | Returns content of glued layout and its fragment |
26,824 | public function render ( $ template , array $ vars = array ( ) ) { if ( empty ( $ template ) ) { throw new LogicException ( 'Empty template name provided' ) ; } if ( ! $ this -> templateExists ( $ template ) ) { $ base = $ this -> createPath ( self :: TEMPLATE_PARAM_BASE_DIR , dirname ( $ this -> moduleDir ) , $ this -> module , $ this -> theme ) ; throw new RuntimeException ( sprintf ( 'Cannot find "%s.%s" in %s' , $ template , self :: TEMPLATE_PARAM_EXTENSION , $ base ) ) ; } $ file = $ this -> createInclusionPath ( $ template ) ; $ this -> addVariables ( $ vars ) ; if ( $ this -> hasLayout ( ) ) { $ layout = $ this -> createInclusionPath ( $ this -> layout , $ this -> layoutModule ) ; $ content = $ this -> createContentWithLayout ( $ layout , $ file ) ; } else { $ content = $ this -> createFileContent ( $ file ) ; } if ( $ this -> compress === true ) { $ compressor = new HtmlCompressor ( ) ; $ content = $ compressor -> compress ( $ content ) ; } return $ content ; } | Passes variables and renders a template . If there s attached layout then renders it with that layout |
26,825 | public function renderRaw ( $ module , $ theme , $ template , array $ vars = array ( ) ) { $ initialLayout = $ this -> layout ; $ initialModule = $ this -> module ; $ initialTheme = $ this -> theme ; $ this -> setModule ( $ module ) -> setTheme ( $ theme ) -> disableLayout ( ) ; $ response = $ this -> render ( $ template , $ vars ) ; $ this -> layout = $ initialLayout ; $ this -> module = $ initialModule ; $ this -> theme = $ initialTheme ; return $ response ; } | Renders a template with custom Module and its theme |
26,826 | public function loadPartial ( $ name , array $ vars = array ( ) ) { $ partialTemplateFile = $ this -> getPartialBag ( ) -> getPartialFile ( $ name ) ; if ( is_file ( $ partialTemplateFile ) ) { extract ( array_replace_recursive ( $ vars , $ this -> variables ) ) ; include ( $ partialTemplateFile ) ; } else { return false ; } } | Loads partial template |
26,827 | public static function wrapOnDemand ( $ condition , $ tag , $ content ) { if ( $ condition ) { echo sprintf ( '<%s>%s</%s>' , $ tag , $ content , $ tag ) ; } else { echo $ content ; } } | Wraps content into a tag on demand |
26,828 | public function baseContext ( ) { $ baseContext = get_property ( "web.base_context" , "" ) ; if ( empty ( $ baseContext ) ) { $ baseContext = ! empty ( $ _SERVER [ "CONTEXT_PREFIX" ] ) ? $ _SERVER [ "CONTEXT_PREFIX" ] : "" ; } return $ baseContext ; } | Returns the base context |
26,829 | public function setData ( array $ request = [ ] ) { unset ( $ this -> parameters ) ; unset ( $ this -> path ) ; unset ( $ this -> pathParts ) ; $ _REQUEST = $ request ; } | Establece nuevas variables de request |
26,830 | public function beforeProcess ( \ Magento \ Checkout \ Block \ Checkout \ LayoutProcessor $ subject , $ jsLayout ) { if ( ! $ this -> enhancementHelper -> isActiveGoogleAddress ( ) ) { if ( isset ( $ jsLayout [ 'components' ] [ 'checkout' ] [ 'children' ] [ 'steps' ] [ 'children' ] [ 'shipping-step' ] [ 'children' ] [ 'shippingAddress' ] [ 'children' ] [ 'shipping-address-fieldset' ] ) ) { $ jsLayout [ 'components' ] [ 'checkout' ] [ 'children' ] [ 'steps' ] [ 'children' ] [ 'shipping-step' ] [ 'children' ] [ 'shippingAddress' ] [ 'children' ] [ 'shipping-address-fieldset' ] [ 'component' ] = 'uiComponent' ; unset ( $ jsLayout [ 'components' ] [ 'checkout' ] [ 'children' ] [ 'steps' ] [ 'children' ] [ 'shipping-step' ] [ 'children' ] [ 'shippingAddress' ] [ 'children' ] [ 'shipping-address-fieldset' ] [ 'config' ] [ 'template' ] ) ; } } return [ $ jsLayout ] ; } | Revert changes on component shipping - address - fieldset |
26,831 | protected function hasMandatoryItem ( array $ definition ) { foreach ( $ definition as $ key => $ node ) { if ( isset ( $ node [ 'required' ] ) ) { if ( $ node [ 'required' ] ) { return true ; } } else { if ( $ this -> hasMandatoryItem ( $ node ) ) { return true ; } } } return false ; } | Traverse the definition to see if any children are required |
26,832 | public function getDataByUriTemplate ( $ uriTemplate , $ option = null ) { if ( isset ( $ this -> map [ $ uriTemplate ] ) ) { $ target = $ this -> map [ $ uriTemplate ] ; if ( $ option !== null ) { if ( ! isset ( $ target [ $ option ] ) ) { throw new RuntimeException ( sprintf ( 'Can not read non-existing option %s for "%s"' , $ option , $ uriTemplate ) ) ; } else { return $ target [ $ option ] ; } } else { return $ target ; } } else { throw new RuntimeException ( sprintf ( 'URI "%s" does not belong to route map. Cannot get a controller in %s' , $ uriTemplate , __METHOD__ ) ) ; } } | Gets associated options by URI template |
26,833 | public function getControllers ( ) { $ map = $ this -> map ; $ result = array ( ) ; foreach ( $ map as $ template => $ options ) { if ( isset ( $ options [ 'controller' ] ) ) { $ result [ ] = $ options [ 'controller' ] ; } } return $ result ; } | Returns all loaded controllers |
26,834 | public function findUriTemplatesByController ( $ controller ) { $ result = array ( ) ; foreach ( $ this -> map as $ uriTemplate => $ options ) { if ( isset ( $ options [ 'controller' ] ) && $ options [ 'controller' ] == $ controller ) { array_push ( $ result , $ uriTemplate ) ; } } return $ result ; } | Finds all URI templates associated with a controller |
26,835 | public function getUrlTemplateByController ( $ controller ) { $ result = $ this -> findUriTemplatesByController ( $ controller ) ; if ( isset ( $ result [ 0 ] ) ) { return $ result [ 0 ] ; } else { return false ; } } | Gets URL template by its associated controller This method is basically used when building URLs by their associated controllers |
26,836 | public function getControllerByURITemplate ( $ uriTemplate ) { $ controller = $ this -> getDataByUriTemplate ( $ uriTemplate , 'controller' ) ; $ separatorPosition = strpos ( $ controller , '@' ) ; if ( $ separatorPosition !== false ) { $ controller = substr ( $ controller , 0 , $ separatorPosition ) ; return $ this -> notation -> toClassPath ( $ controller ) ; } else { return false ; } } | Returns a controller by its associated URI template |
26,837 | public function getActionByURITemplate ( $ uriTemplate ) { $ controller = $ this -> getDataByUriTemplate ( $ uriTemplate , 'controller' ) ; $ separatorPosition = strpos ( $ controller , '@' ) ; if ( $ separatorPosition !== false ) { $ action = substr ( $ controller , $ separatorPosition + 1 ) ; return $ action ; } else { return false ; } } | Returns action by associated URI template |
26,838 | public function open ( $ host , $ port , $ timeout ) { if ( ( $ this -> socket = @ fsockopen ( $ host , $ port , $ errno , $ errstr , ( $ timeout / 1000 ) ) ) === false ) { return false ; } return true ; } | Open the stream |
26,839 | public function isTimedOut ( ) { if ( is_resource ( $ this -> socket ) ) { $ info = stream_get_meta_data ( $ this -> socket ) ; } return $ this -> socket === null || $ this -> socket === false || $ info [ 'timed_out' ] || feof ( $ this -> socket ) ; } | Has the connection timed out or otherwise gone away? |
26,840 | public function readLine ( ) { do { $ line = rtrim ( fgets ( $ this -> socket ) ) ; if ( $ line === '' && feof ( $ this -> socket ) ) { $ this -> close ( ) ; return false ; } } while ( $ line === '' ) ; return $ line ; } | Read the next line from the stream |
26,841 | public function getServiceNamesByType ( $ type ) { if ( ! $ this -> hasServices ( ) ) { return [ ] ; } $ types = [ ] ; $ services = $ this -> getServices ( ) ; foreach ( $ services as $ name => $ service ) { if ( $ service [ 'type' ] !== $ type ) { continue ; } $ types [ ] = $ name ; } return $ types ; } | Get service names by type . |
26,842 | public function getServiceInstances ( ) { $ instances = [ ] ; foreach ( $ this -> getServices ( ) as $ name => $ info ) { if ( ! isset ( $ info [ 'type' ] ) ) { continue ; } $ type = $ info [ 'type' ] ; unset ( $ info [ 'type' ] ) ; $ instances [ $ name ] = [ 'type' => $ type , 'options' => $ info , 'instance' => static :: loadService ( $ this , $ type , $ name ) , ] ; } return $ instances ; } | Get defined service instances . |
26,843 | public function getServiceInstanceByGroup ( $ group ) { $ services = [ ] ; $ services_map = static :: services ( ) ; foreach ( $ this -> getServiceInstances ( ) as $ name => $ info ) { if ( ! isset ( $ info [ 'type' ] ) || ! isset ( $ info [ 'instance' ] ) ) { continue ; } $ type = $ info [ 'type' ] ; if ( ! isset ( $ services_map [ $ type ] ) ) { continue ; } $ classname = $ services_map [ $ type ] ; if ( $ group !== $ classname :: group ( ) ) { continue ; } $ services [ $ name ] = $ info [ 'instance' ] ; } return $ services ; } | Get service instance by group . |
26,844 | public function getServiceInstanceByType ( $ type ) { $ services = [ ] ; $ instances = $ this -> getServiceInstances ( ) ; foreach ( $ this -> getServiceNamesByType ( $ type ) as $ name ) { if ( ! isset ( $ instances [ $ name ] [ 'instance' ] ) ) { continue ; } $ services [ ] = $ instances [ $ name ] [ 'instance' ] ; } return $ services ; } | Get multiple service instance by type . |
26,845 | public function getServiceInstanceByInterface ( $ interface ) { foreach ( $ this -> getServiceInstances ( ) as $ info ) { if ( ! isset ( $ info [ 'instance' ] ) ) { continue ; } $ instance = $ info [ 'instance' ] ; if ( $ instance instanceof $ interface ) { return $ instance ; } } return false ; } | Get single service instance by interface . |
26,846 | public static function loadService ( EngineTypeInterface $ engine , $ type , $ name = null ) { $ classname = static :: serviceClassname ( $ type ) ; if ( ! class_exists ( $ classname ) ) { throw new \ RuntimeException ( sprintf ( "Service class %s doesn't exist." , $ classname ) ) ; } return new $ classname ( $ engine , $ name ) ; } | Load engine service . |
26,847 | public static function serviceClassname ( $ name ) { $ services = static :: services ( ) ; if ( ! isset ( $ services [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The provided service %s does not exist.' , $ name ) ) ; } return $ services [ $ name ] ; } | Get engine service classname . |
26,848 | protected function getOptions ( ) { $ engine = $ this -> getConfigs ( ) -> getEngine ( ) ; $ options = $ this -> getConfigs ( ) -> getOptions ( ) ; return isset ( $ options [ $ engine ] ) ? $ options [ $ engine ] : [ ] ; } | Get engine options . |
26,849 | public function getFilePathContent ( ) { if ( $ this -> filePathContent === null ) { throw new InvalidArgumentException ( sprintf ( "The filePathContent must be setter." ) ) ; } $ path = $ this -> filePathContent ; if ( $ this -> container ) { $ path = $ this -> container -> get ( "kernel" ) -> locateResource ( $ this -> filePathContent ) ; } if ( ! $ this -> chainModel -> getExporterManager ( ) -> getFs ( ) -> exists ( $ path ) ) { throw new InvalidArgumentException ( sprintf ( "The filePathContent '%s' does not exist." , $ path ) ) ; } return $ path ; } | Busca la ruta del archivo que se usara como contenido |
26,850 | public function getFilePathHeader ( ) { if ( $ this -> filePathHeader === null ) { throw new InvalidArgumentException ( sprintf ( "The filePathContent must be setter." ) ) ; } $ path = $ this -> filePathHeader ; if ( $ this -> container ) { $ path = $ this -> container -> get ( "kernel" ) -> locateResource ( $ path ) ; } if ( ! $ this -> chainModel -> getExporterManager ( ) -> getFs ( ) -> exists ( $ path ) ) { throw new InvalidArgumentException ( sprintf ( "The filePathHeader '%s' does not exist." , $ path ) ) ; } return $ path ; } | Busca la ruta del archivo que se usara como encabezado |
26,851 | protected function getDocumentPath ( array $ parameters = [ ] ) { $ dirOut = $ this -> getDirOutput ( ) ; $ dirOut = $ dirOut . DIRECTORY_SEPARATOR . $ this -> getFileNameTranslate ( $ parameters ) . '.' . $ this -> getFormat ( ) ; return $ dirOut ; } | Retorna la ruta completa del archivo |
26,852 | protected function getTargetNode ( ) { if ( null === $ target = $ this -> getTarget ( ) ) { $ segments = explode ( '/' , $ this -> getPath ( ) ) ; $ target = '' ; while ( count ( $ segments ) > 0 ) { $ segment = array_pop ( $ segments ) ; $ target = $ segment . '/' . $ target ; if ( ! is_numeric ( $ segment ) ) { break ; } } return rtrim ( $ target , '/' ) ; } return $ target ; } | Returns a printable representation of the exception target . If no target has been explicitly passed in the last non - array segments of the path are returned . |
26,853 | public function isValid ( $ item ) { if ( ! $ item ) { $ item = new \ stdClass ( ) ; } $ validator = $ this -> getValidator ( ) ; return $ validator -> validate ( $ item ) ; } | Determine if the provided object is valid or not |
26,854 | private static function GetHTMLPurifierConfig ( ) { $ defaultConfig = \ HTMLPurifier_Config :: createDefault ( ) ; $ customConfig = Config :: inst ( ) -> get ( 'g4b0\HtmlPurifier\Purifier' , 'html_purifier_config' ) ; if ( is_array ( $ customConfig ) ) { foreach ( $ customConfig as $ key => $ value ) { $ defaultConfig -> set ( $ key , $ value ) ; } } return $ defaultConfig ; } | Get the HTML Purifier config |
26,855 | public static function Purify ( $ html = null , $ encoding = 'UTF-8' ) { $ config = self :: GetHTMLPurifierConfig ( ) ; $ config -> set ( 'Core.Encoding' , $ encoding ) ; $ config -> set ( 'HTML.Allowed' , 'span,p,br,a,h1,h2,h3,h4,h5,strong,em,u,ul,li,ol,hr,blockquote,sub,sup,p[class],img' ) ; $ config -> set ( 'HTML.AllowedElements' , array ( 'span' , 'p' , 'br' , 'a' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'strong' , 'em' , 'u' , 'ul' , 'li' , 'ol' , 'hr' , 'blockquote' , 'sub' , 'sup' , 'img' ) ) ; $ config -> set ( 'HTML.AllowedAttributes' , 'style,target,title,href,class,src,border,alt,width,height,title,name,id' ) ; $ config -> set ( 'CSS.AllowedProperties' , 'text-align,font-weight,text-decoration' ) ; $ config -> set ( 'AutoFormat.RemoveEmpty' , true ) ; $ config -> set ( 'Attr.ForbiddenClasses' , array ( 'MsoNormal' ) ) ; $ purifier = new \ HTMLPurifier ( $ config ) ; return $ cleanCode = $ purifier -> purify ( $ html ) ; } | Standard HTML purifier |
26,856 | public static function PurifyXHTML ( $ html = null , $ encoding = 'UTF-8' ) { $ config = self :: GetHTMLPurifierConfig ( ) ; $ config -> set ( 'Core.Encoding' , $ encoding ) ; $ config -> set ( 'HTML.Doctype' , 'XHTML 1.0 Strict' ) ; $ config -> set ( 'HTML.TidyLevel' , 'heavy' ) ; $ config -> set ( 'CSS.AllowedProperties' , array ( ) ) ; $ config -> set ( 'Attr.AllowedClasses' , array ( ) ) ; $ config -> set ( 'HTML.Allowed' , null ) ; $ config -> set ( 'AutoFormat.RemoveEmpty' , true ) ; $ config -> set ( 'AutoFormat.Linkify' , true ) ; $ config -> set ( 'AutoFormat.AutoParagraph' , true ) ; $ config -> set ( 'HTML.ForbiddenElements' , array ( 'span' , 'center' ) ) ; $ config -> set ( 'Core.EscapeNonASCIICharacters' , true ) ; $ config -> set ( 'Output.TidyFormat' , true ) ; $ purifier = new \ HTMLPurifier ( $ config ) ; $ html = $ purifier -> purify ( $ html ) ; $ html = str_ireplace ( "%5B" , "[" , $ html ) ; $ html = str_ireplace ( "%5D" , "]" , $ html ) ; return $ html ; } | XHTML 1 . 0 Strict purifier |
26,857 | public static function PurifyTXT ( $ html = null , $ encoding = 'UTF-8' ) { $ config = self :: GetHTMLPurifierConfig ( ) ; $ config -> set ( 'Core.Encoding' , $ encoding ) ; $ config -> set ( 'HTML.Allowed' , null ) ; $ config -> set ( 'HTML.AllowedElements' , array ( ) ) ; $ purifier = new \ HTMLPurifier ( $ config ) ; return $ purifier -> purify ( $ html ) ; } | Strip all HTML tags like strip_tags but encoding safe |
26,858 | public function toProtobuf ( ) : SignatureDeviceInfo { $ deviceInfo = new SignatureDeviceInfo ( ) ; if ( $ this -> deviceId !== null ) { $ deviceInfo -> setDeviceId ( $ this -> deviceId ) ; } $ deviceInfo -> setDeviceBrand ( $ this -> deviceBrand ) ; $ deviceInfo -> setDeviceModel ( $ this -> deviceModel ) ; $ deviceInfo -> setDeviceModelBoot ( $ this -> deviceModelBoot ) ; $ deviceInfo -> setFirmwareType ( $ this -> firmwareType ) ; $ deviceInfo -> setFirmwareBrand ( $ this -> firmwareBrand ) ; $ deviceInfo -> setHardwareModel ( $ this -> hardwareModel ) ; $ deviceInfo -> setHardwareManufacturer ( $ this -> hardwareManufacturer ) ; return $ deviceInfo ; } | Convert to protobuf message |
26,859 | protected function loadKeyValueStore ( $ config , $ container , $ loader ) { if ( empty ( $ config [ 'key_value_store' ] [ 'connection_name' ] ) ) { return ; } $ loader -> load ( 'keyvaluestore.xml' ) ; $ container -> setAlias ( 'windows_azure_distribution.key_value_store.storage_client' , 'windows_azure.table.' . $ config [ 'key_value_store' ] [ 'connection_name' ] ) ; } | Create the services for Doctrine KeyValueStore with Windows Azure |
26,860 | public function getNamedUrl ( $ name , $ params = array ( ) , $ version = null , $ locale = null ) { if ( $ version == null ) { $ version = Registry :: get ( 'version' ) ; } if ( $ locale == null ) { $ locale = Registry :: get ( 'locale' ) ; } $ foundRoute = false ; if ( isset ( $ this -> allRoutesByVersionAndLocale [ $ version ] [ $ locale ] [ $ name ] ) ) { $ url = $ this -> allRoutesByVersionAndLocale [ $ version ] [ $ locale ] [ $ name ] [ 'regexp' ] ; $ foundRoute = true ; } elseif ( isset ( $ this -> allRoutesByVersionAndLocale [ $ version ] [ '*' ] [ $ name ] ) ) { $ url = $ this -> allRoutesByVersionAndLocale [ $ version ] [ '*' ] [ $ name ] [ 'regexp' ] ; $ foundRoute = true ; } elseif ( isset ( $ this -> allRoutesByVersionAndLocale [ '*' ] [ '*' ] [ $ name ] ) ) { $ url = $ this -> allRoutesByVersionAndLocale [ '*' ] [ '*' ] [ $ name ] [ 'regexp' ] ; $ foundRoute = true ; } if ( $ foundRoute ) { preg_match_all ( '/\(([\w_]+):([^)]+)\)/im' , $ url , $ result , PREG_SET_ORDER ) ; for ( $ matchi = 0 ; $ matchi < count ( $ result ) ; $ matchi ++ ) { if ( isset ( $ params [ $ result [ $ matchi ] [ 1 ] ] ) ) { $ url = str_replace ( $ result [ $ matchi ] [ 0 ] , $ params [ $ result [ $ matchi ] [ 1 ] ] , $ url ) ; } } return $ url ; } else { throw new \ Exception ( 'Cannot find route named "' . $ name . '" (version=' . $ version . ', locale=' . $ locale . ')' ) ; } } | returns the url from the defined routes by its name |
26,861 | public function appendChildWithText ( NodeElement $ nodeElement , $ text , $ append = true ) { $ content = $ nodeElement -> render ( ) ; if ( $ append === true ) { $ content = $ content . $ text ; } else { $ content = $ text . $ content ; } $ this -> setText ( $ content ) ; return $ this ; } | Appends child element prepending or appending a text |
26,862 | public function setText ( $ text , $ finalize = true ) { if ( $ finalize && ! $ this -> isFinalized ( ) ) { $ this -> finalize ( ) ; } $ this -> append ( $ text ) ; return $ this ; } | Sets a text |
26,863 | public function finalize ( $ singular = false ) { $ this -> finalized = true ; if ( $ singular === true ) { $ text = ' />' ; } else { $ text = '>' ; } $ this -> append ( $ text ) ; return $ this ; } | Finalizes the opened tag |
26,864 | public function openTag ( $ tagName ) { $ this -> append ( sprintf ( '<%s' , $ tagName ) ) ; $ this -> tag = $ tagName ; return $ this ; } | Opens a tag |
26,865 | public function closeTag ( $ tag = null ) { if ( $ tag === null ) { $ tag = $ this -> tag ; } $ this -> append ( sprintf ( '</%s>' , $ tag ) ) ; return $ this ; } | Closes opened tag |
26,866 | public function addPropertyOnDemand ( $ property , $ value ) { if ( ( bool ) $ value === true ) { $ this -> addProperty ( $ property ) ; } return $ this ; } | Adds a property on demand |
26,867 | public function addAttribute ( $ attribute , $ value ) { $ value = Filter :: filterAttribute ( $ value ) ; if ( $ this -> isProperty ( $ attribute ) ) { $ this -> addPropertyOnDemand ( $ attribute , $ value ) ; } else { if ( $ this -> hasAttribute ( $ attribute ) ) { throw new LogicException ( sprintf ( 'The element already has "%s" attribute' , $ attribute ) ) ; } $ this -> append ( sprintf ( ' %s="%s"' , $ attribute , $ value ) ) ; $ this -> attributes [ $ attribute ] = $ value ; } return $ this ; } | Adds an attribute |
26,868 | public function addAttributes ( array $ attributes ) { foreach ( $ attributes as $ attribute => $ value ) { $ this -> addAttribute ( $ attribute , $ value ) ; } return $ this ; } | Adds attribute collection |
26,869 | public function hasClass ( $ class = null ) { if ( $ class !== null ) { $ classes = explode ( ' ' , $ this -> getClass ( ) ) ; return in_array ( $ class , $ classes ) ; } else { return $ this -> hasAttribute ( 'class' ) ; } } | Determines whether element has a class |
26,870 | public function isActiveDefaultPayment ( ) { return $ this -> scopeConfig -> isSetFlag ( self :: XML_PAYMENT_DEFAULT_ACTIVE_DEFAULT_PAYMENT , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; } | Is active default payment |
26,871 | public function getDefaultMethod ( ) { return $ this -> scopeConfig -> getValue ( self :: XML_PAYMENT_DEFAULT_METHOD , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; } | Get default payment method |
26,872 | public function isActiveGoogleAddress ( ) { $ flag = $ this -> scopeConfig -> isSetFlag ( self :: XML_GOOGLE_MAP_ADDRESS_ACTIVE_GOOGLE_ADDRESS , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; return $ flag && $ this -> getGoogleMapApiKey ( ) ; } | Is active Google Maps Address Search |
26,873 | public function isActiveBillingGoogleAddress ( ) { $ flag = $ this -> scopeConfig -> isSetFlag ( self :: XML_GOOGLE_MAP_ADDRESS_ACTIVE_GOOGLE_ADDRESS_BILLING , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; return $ flag && $ this -> getGoogleMapApiKey ( ) ; } | Is active Google Maps Address Search for billing address in Checkout |
26,874 | public function getGoogleMapApiKey ( ) { $ str = $ this -> scopeConfig -> getValue ( self :: XML_GOOGLE_MAP_API_KEY , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; $ str = trim ( $ str ) ; return $ str ; } | Get Google Maps API key |
26,875 | public function getGoogleMapAddressLibraries ( ) { return $ this -> scopeConfig -> getValue ( self :: XML_GOOGLE_MAP_ADDRESS_LIBRARIES , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; } | Get Google Maps API libraries |
26,876 | public function getGoogleMapAddressCountries ( ) { return explode ( ',' , ( string ) $ this -> scopeConfig -> getValue ( self :: XML_GOOGLE_MAP_ADDRESS_COUNTRY , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ) ; } | Get Google Maps API countries |
26,877 | public function getGoogleMapAddressLanguage ( ) { return $ this -> scopeConfig -> getValue ( self :: XML_GOOGLE_MAP_ADDRESS_LANGUAGE , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ) ; } | Get Google Maps API languages |
26,878 | public function checkChallenge ( ) { $ request = new CheckChallenge ( ) ; $ response = $ this -> service -> execute ( $ request , $ this -> position ) ; $ challengeUrl = trim ( $ response -> getChallengeUrl ( ) ) ; if ( $ response -> getShowChallenge ( ) || ! empty ( $ challengeUrl ) ) { if ( ! $ this -> captchaSolver instanceof Solver ) { $ this -> getLogger ( ) -> alert ( "Account has been flagged for CAPTCHA. No CAPTCHA-solver defined, returning challenge." ) ; return $ challengeUrl ; } $ this -> getLogger ( ) -> alert ( "Account has been flagged for CAPTCHA. Attempting to solve CAPTCHA with defined resolver." ) ; $ token = $ this -> captchaSolver -> solve ( $ challengeUrl ) ; $ this -> getLogger ( ) -> info ( "Received CAPTCHA solution. Verifying..." ) ; sleep ( 1 ) ; $ verify = $ this -> verifyChallenge ( $ token ) ; if ( $ verify -> hasSuccess ( ) ) { $ this -> getLogger ( ) -> info ( "Successfully solved CAPTCHA." ) ; return true ; } throw new FailedCaptchaException ( "Failed to resolve CAPTCHA." ) ; } return false ; } | Check if there is a CAPTCHA challenge . |
26,879 | public function acceptTerms ( ) : MarkTutorialCompleteResponse { $ request = new MarkTutorialComplete ( ) ; return $ this -> service -> execute ( $ request , $ this -> position ) ; } | Accept the terms |
26,880 | public function getPlayerData ( ) : GetPlayerResponse { $ request = new GetPlayer ( ) ; return $ this -> service -> execute ( $ request , $ this -> position ) ; } | Get player data |
26,881 | public function getInventory ( ) : GetInventoryResponse { $ request = new GetInventory ( ) ; return $ this -> service -> execute ( $ request , $ this -> position ) ; } | Get player inventory |
26,882 | public function getMapObjects ( ) : GetMapObjectsResponse { $ request = new GetMapObjects ( $ this -> position ) ; return $ this -> service -> execute ( $ request , $ this -> position ) ; } | Get map objects |
26,883 | private function appendInternal ( $ unit , array & $ stack ) { $ unit = $ this -> normalizeAssetPath ( $ unit ) ; array_push ( $ stack , $ unit ) ; return $ this ; } | Appends a unit |
26,884 | private function normalizeAssetPath ( $ path ) { $ pattern = '~@(\w+)~' ; $ replacement = sprintf ( '/%s/$1/%s' , ViewManager :: TEMPLATE_PARAM_MODULES_DIR , ViewManager :: TEMPLATE_PARAM_ASSETS_DIR ) ; return preg_replace ( $ pattern , $ replacement , $ path ) ; } | Replaces a module path inside provided path |
26,885 | public function register ( array $ collection ) { foreach ( $ collection as $ name => $ data ) { $ this -> plugins [ $ name ] = $ data ; } return $ this ; } | Registers plugin collection |
26,886 | public function load ( $ plugins ) { if ( ! is_array ( $ plugins ) ) { $ plugins = ( array ) $ plugins ; } foreach ( $ plugins as $ plugin ) { if ( ! isset ( $ this -> plugins [ $ plugin ] ) ) { trigger_error ( sprintf ( 'Attempted to load non-existing plugin %s' , $ plugin ) ) ; return false ; } if ( isset ( $ this -> plugins [ $ plugin ] [ 'scripts' ] ) ) { $ this -> appendScripts ( $ this -> plugins [ $ plugin ] [ 'scripts' ] ) ; } if ( isset ( $ this -> plugins [ $ plugin ] [ 'stylesheets' ] ) ) { $ this -> appendStylesheets ( $ this -> plugins [ $ plugin ] [ 'stylesheets' ] ) ; } } return $ this ; } | Loads plugins or a single plugin |
26,887 | public function reportLighthouse ( $ opts = [ 'hostname' => null , 'protocol' => 'http' ] ) { $ host = ProjectX :: getProjectConfig ( ) -> getHost ( ) ; $ protocol = $ opts [ 'protocol' ] ; $ hostname = isset ( $ opts [ 'hostname' ] ) ? $ opts [ 'hostname' ] : ( isset ( $ host [ 'name' ] ) ? $ host [ 'name' ] : 'localhost' ) ; $ path = $ this -> getReportsPath ( ) . "/lighthouse-report-$hostname.html" ; $ this -> taskGoogleLighthouse ( ) -> setUrl ( "$protocol://$hostname" ) -> setOutputPath ( $ path ) -> run ( ) ; } | Run Google lighthouse report . |
26,888 | protected function getReportsPath ( ) { $ project_root = ProjectX :: projectRoot ( ) ; $ reports_path = "$project_root/reports" ; if ( ! file_exists ( $ reports_path ) ) { mkdir ( $ reports_path ) ; } return $ reports_path ; } | Get project - x reports path . |
26,889 | public function engineUp ( $ opts = [ 'no-hostname' => false , 'no-browser' => false ] ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:up' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Startup engine environment . |
26,890 | public function engineRebuild ( ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:rebuild' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Rebuild engine configuration . |
26,891 | public function engineDown ( $ opts = [ 'include-network' => false ] ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:down' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Shutdown engine environment . |
26,892 | public function engineResume ( ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:resume' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Resume halted engine environment . |
26,893 | public function engineRestart ( ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:restart' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Restart engine environment . |
26,894 | public function engineReboot ( ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:reboot' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Reboot engine environment . |
26,895 | public function engineInstall ( ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> executeExistingCommand ( 'env:install' ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; return $ this ; } | Install engine configuration setup . |
26,896 | protected function executeExistingCommand ( $ command_name , InputInterface $ input = null , OutputInterface $ output = null ) { if ( ! isset ( $ command_name ) ) { return 1 ; } $ input = isset ( $ input ) ? $ input : $ this -> input ( ) ; $ output = isset ( $ output ) ? $ output : $ this -> output ( ) ; return $ this -> getApplication ( ) -> find ( $ command_name ) -> run ( $ input , $ output ) ; } | Execute existing command . |
26,897 | public function getDescriptionByStatusCode ( $ code ) { $ code = ( int ) $ code ; if ( isset ( $ this -> statuses [ $ code ] ) ) { return $ this -> statuses [ $ code ] ; } else { throw new OutOfRangeException ( sprintf ( 'The status code "%s" is out of allowed range' , $ code ) ) ; } } | Returns description by its associated code |
26,898 | public function generate ( $ code ) { if ( $ this -> isValid ( $ code ) ) { return sprintf ( 'HTTP/%s %s %s' , $ this -> version , $ code , $ this -> getDescriptionByStatusCode ( $ code ) ) ; } else { return false ; } } | Generates status header by associated code |
26,899 | public function discoverCommands ( ) { $ commands = ( new PhpClassDiscovery ( ) ) -> addSearchLocation ( APP_ROOT . '/src/Command' ) -> matchExtend ( 'Symfony\Component\Console\Command\Command' ) -> discover ( ) ; foreach ( $ commands as $ classname ) { $ this -> add ( new $ classname ( ) ) ; } return $ this ; } | Discover Project - X commands . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.