idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
15,000 | public static function isIpInCidr ( string $ ip , string $ cidr ) : bool { if ( ! filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { throw new \ UnexpectedValueException ( "invalid value for ip; expecting an IPv4 address" ) ; } list ( $ range , $ netmask ) = static :: parseCidr ( $ cidr ) ; $ netmask = ~ (... | Determine whether an ip address is within a given CIDR |
15,001 | public static function isPrivateIp ( string $ ip ) : bool { foreach ( self :: PRIVATE_IPV4_RANGES as $ range ) { if ( self :: isIpInCidr ( $ ip , $ range ) ) { return true ; } } return false ; } | Determine whether a given ip is in one of the private network ranges |
15,002 | public function render ( $ html = null ) { if ( $ html === null && $ this -> getHtml ( ) === '' ) { $ html = $ this -> getLink ( ) ; } return parent :: render ( $ html ) ; } | Render an anchor |
15,003 | public function getNextCallable ( ) { if ( ! $ this -> initiated ) { reset ( $ this -> callables ) ; $ this -> initiated = true ; return current ( $ this -> callables ) ; } return next ( $ this -> callables ) ; } | Get the next call and move the pointer If movement hasn t initiated get current |
15,004 | public function next ( ) { if ( ! $ this -> initiated ) { reset ( $ this -> callables ) ; $ this -> initiated = true ; return call_user_func_array ( current ( $ this -> callables ) , func_get_args ( ) ) ; } return call_user_func_array ( next ( $ this -> callables ) , func_get_args ( ) ) ; } | Call the current stack and point to the next stack |
15,005 | private function getProvider ( $ subjectOrOrderItem ) { foreach ( $ this -> registry -> getProviders ( ) as $ provider ) { if ( $ provider -> supports ( $ subjectOrOrderItem ) ) { return $ provider ; } } throw new InvalidArgumentException ( 'Unsupported subject.' ) ; } | Returns the provider supporting the subject or item . |
15,006 | public function loadMembership ( Production $ production , UserInterface $ user ) : ? ProductionMembershipInterface { return $ this -> membership_provider -> loadMembership ( $ production , $ user ) ; } | Load a membership using available membership provider . |
15,007 | public function onManagerStart ( Server $ server ) : void { $ this -> fire ( ServerEvent :: MANAGER_STARTED , $ server ) ; ServerUtil :: createPidFile ( $ server -> manager_pid , $ this -> pidFile ) ; ProcessUtil :: setTitle ( "{$this->name}: manager" ) ; $ this -> log ( "The <comment>manager</comment> process success ... | on Manager Start |
15,008 | public function onManagerStop ( Server $ server ) : void { $ this -> fire ( ServerEvent :: MANAGER_STOPPED , $ server ) ; $ this -> log ( "The manager process stopped. (PID {$server->manager_pid})" ) ; ServerUtil :: removePidFile ( $ this -> pidFile ) ; } | on Manager Stop |
15,009 | public function onStart ( Server $ server ) : void { $ this -> fire ( ServerEvent :: STARTED , $ server ) ; $ this -> masterPid = $ masterPid = $ server -> master_pid ; $ rootPath = $ this -> config ( 'rootPath' ) ; $ rootPath = $ rootPath ? " (at $rootPath)" : '' ; ProcessUtil :: setTitle ( sprintf ( '%s: master%s' , ... | on Master Start |
15,010 | public function onShutdown ( Server $ server ) : void { $ this -> fire ( ServerEvent :: SHUTDOWN , $ server ) ; $ this -> log ( "The swoole master process(PID: <info>{$server->master_pid})</info> stopped." ) ; } | on Master Stop |
15,011 | public static function change ( $ what , $ how ) { switch ( $ what ) { case 'layout' : self :: $ settings [ 'mvc' ] [ 'controller_layout' ] = $ how ; break ; case 'view' : self :: $ settings [ 'mvc' ] [ 'controller_view' ] = $ how ; break ; } } | Changing view or layout |
15,012 | public static function processMagicVariables ( ) { $ variables_object = new \ Object \ Magic \ Variables ( ) ; $ variables = $ variables_object -> get ( ) ; $ input = \ Request :: input ( null , true , true ) ; foreach ( $ variables as $ k => $ v ) { if ( ! array_key_exists ( $ k , $ input ) ) { self :: $ settings [ 'f... | Process magic variables |
15,013 | protected function loadThemer ( ) { $ app = app ( ) ; $ this -> styles = $ app -> make ( Styles :: class ) ; $ this -> scripts = $ app -> make ( Scripts :: class ) ; if ( method_exists ( $ this , 'share' ) ) { $ this -> share ( [ 'styles' => $ this -> styles , 'scripts' => $ this -> scripts , 'images' => $ app -> make ... | Initialise and load themer components |
15,014 | protected function loadStylesheet ( $ settings ) { if ( $ this -> styles !== null ) { $ this -> styles -> add ( $ settings ) ; } return $ this ; } | Add a stylesheet |
15,015 | protected function loadStylesheets ( ... $ styles ) { $ files = $ this -> getFilePayload ( $ styles ?? null ) ; if ( empty ( $ files ) ) { return ; } foreach ( $ files as $ style ) { $ this -> loadStylesheet ( $ style ) ; } } | Add multiple stylesheets |
15,016 | protected function loadScript ( $ settings ) { if ( $ this -> scripts !== null ) { $ this -> scripts -> add ( $ settings ) ; } return $ this ; } | Add a script |
15,017 | protected function loadScripts ( ... $ scripts ) { $ files = $ this -> getFilePayload ( $ scripts ?? null ) ; if ( empty ( $ files ) ) { return ; } foreach ( $ files as $ script ) { $ this -> loadScript ( $ script ) ; } } | Add multiple scripts |
15,018 | protected function getFilePayload ( ? array $ files ) : ? array { if ( empty ( $ files ) ) { return null ; } $ files = array_filter ( $ files , function ( $ file ) { return $ file instanceof ResourceSettings || ( isset ( $ file [ 'key' ] ) && isset ( $ file [ 'filename' ] ) ) ; } ) ; return $ files ; } | Get the file payload |
15,019 | public static function factory ( $ config = array ( ) ) { $ default = array ( 'compute_type' => 'compute' , 'identity_type' => 'identity' , 'storage_type' => 'storage' , 'region' => 'RegionOne' ) ; $ required = array ( 'auth_url' ) ; $ config = Inspector :: prepareConfig ( $ config , $ default , $ required ) ; $ client... | Factory method to create a new OpenstackClient |
15,020 | public function getEndpoints ( $ serviceType ) { if ( is_null ( $ this -> token ) ) { throw new OpenstackException ( 'Unauthenticated' ) ; } $ serviceEndpoints = array ( ) ; foreach ( $ this -> serviceCatalog as $ value ) { if ( $ value [ 'type' ] == $ serviceType ) { $ serviceEndpoints = $ value [ 'endpoints' ] ; } } ... | Get endpoints for the service type for all regions |
15,021 | public function getEndpoint ( $ serviceType , $ region , $ endpointType = 'public' ) { $ serviceEndpoints = $ this -> getEndpoints ( $ serviceType ) ; foreach ( $ serviceEndpoints as $ endpointsRegion => $ endpoints ) { if ( $ endpointsRegion == $ region ) { return $ endpoints [ $ endpointType . 'URL' ] ; } } } | Get an endpoint for a specific service and region |
15,022 | public function generateToken ( $ userId ) { $ user = $ this -> users -> find ( $ userId ) ; if ( ! is_null ( $ user ) ) { $ user -> generateActivationToken ( ) ; $ user -> setStatus ( Status :: INACTIVE ) ; } } | Generate an activation token for a user . |
15,023 | public function resend ( $ tokenString ) { $ token = $ this -> findToken ( $ tokenString ) ; if ( ! is_null ( $ token ) ) { session ( ) -> forget ( 'inactive_email' ) ; $ token -> extend ( ) ; $ token -> notifyUser ( ) ; } } | Find the activation token extend it s expire time and resend the email . |
15,024 | public function findTokenByEmail ( $ email ) { $ user = $ this -> users -> where ( 'email' , $ email ) -> first ( ) ; if ( ! is_null ( $ user ) ) { return $ user -> getActivationToken ( ) ; } return null ; } | Find a Token object by the token string . |
15,025 | public function request ( $ inputs ) { $ result = $ this -> restCall ( 'PaymentRequest.json' , $ inputs ) ; if ( $ result [ 'Status' ] == 100 || $ result [ 'Status' ] == 101 ) { return [ 'Authority' => $ result [ 'Authority' ] ] ; } else { return [ 'error' => $ result [ 'Status' ] ] ; } } | request driver . |
15,026 | public function refreshAuthority ( $ inputs ) { $ result = $ this -> restCall ( 'RefreshAuthority.json' , $ inputs ) ; if ( $ result [ 'Status' ] == 100 || $ result [ 'Status' ] == 101 ) { return [ 'Status' => 'success' , 'refreshed' => true ] ; } else { return [ 'Status' => 'error' , 'error' => $ result [ 'Status' ] ]... | refreshAuthority driver . |
15,027 | public function optional ( $ type ) { foreach ( $ this -> arguments as $ index => $ argument ) { if ( gettype ( $ argument ) === $ type || is_a ( $ argument , $ type , true ) ) { array_splice ( $ this -> arguments , $ index , 1 ) ; return $ argument ; } } } | Ask for an optional argument by type then pop and return the first found from the list . |
15,028 | public function required ( $ type ) { $ count = count ( $ this -> arguments ) ; $ argument = $ this -> optional ( $ type ) ; if ( $ count === count ( $ this -> arguments ) ) { throw new InvalidArgumentException ( 'Arguments miss one of the ' . $ type . ' type' ) ; } return $ argument ; } | Ask for an required argument by type then pop and return the first found from the list . If not found throw an exception . |
15,029 | public function noMoreDefinedArguments ( ) { $ definedArguments = array_filter ( $ this -> arguments , function ( $ argument ) { return ! is_null ( $ argument ) ; } ) ; if ( $ count = count ( $ definedArguments ) ) { throw new InvalidArgumentException ( 'You pass ' . $ count . ' unexpected not null arguments' ) ; } } | Throw an exception if all the arguments except null ones have not yet been taken . |
15,030 | public function setIcon ( $ source , $ type = self :: ICON_ASSET ) { $ this -> iconType = ( string ) $ type ; $ this -> iconSource = ( string ) $ source ; return $ this ; } | Set the icon source and type |
15,031 | public static function add ( $ message , $ page = P , $ action = P_DO , $ time = NOW , $ user_id = USER_ID , $ url = SELF ) { $ log_check = new AppLogEntityRepository ( ) ; $ app_log = new AppLogEntity ( ) ; $ app_log -> loadDataFromArray ( [ 'ts' => $ time , 'user_id' => $ user_id , 'url' => $ url , 'msg' => $ message... | Create one log message |
15,032 | public static function flushLog ( ) { $ last_flush_time = Settings :: get ( 'cms_tools_application_log_flush' ) ; if ( NOW - $ last_flush_time < 453600 ) { return ; } self :: sendInformation ( ) ; $ app_log = new AppLogEntityRepository ( ) ; $ app_log -> addSimpleSelectFields ( [ 'id' , 'ts' , 'user_id' , 'url' , 'msg'... | Save log into file and try to send via email to Developers |
15,033 | private static function sendInformation ( ) { $ url = CMS_SITE . 'ping.php?site=' . urlencode ( Configuration :: getInstance ( ) -> get ( 'site' ) [ 'name' ] ) . '&host=' . urlencode ( HOST ) . '&ip=' . urlencode ( IP ) . '&server=' . urlencode ( SERVER_IP ) . '&key=' . urlencode ( Configuration :: getInstance ( ) -> g... | Report to stats server of the existing domain |
15,034 | public static function validate ( $ argument , $ argumentName = null ) { if ( trim ( $ argument ) != null && ! is_numeric ( $ argument ) ) { throw new \ InvalidArgumentException ( "$argumentName is not a valid numeric value" ) ; } return true ; } | Helper method for validating an argument if it is numeric |
15,035 | public function beforeLoad ( $ collection , $ printQuery = false , $ logQuery = false ) { if ( ! $ collection -> isLoaded ( ) ) { $ select = $ collection -> getSelect ( ) ; $ connection = $ select -> getConnection ( ) ; $ select -> joinLeft ( [ 'sale_flag' => $ collection -> getTable ( 'faonni_catalog_product_index_sal... | Load collection data into object items |
15,036 | protected function parseOutline ( SimpleXMLElement $ outlineXML ) { $ outline = [ ] ; foreach ( $ outlineXML -> attributes ( ) as $ key => $ value ) { $ outline [ $ key ] = ( string ) $ value ; } if ( empty ( $ outline [ 'text' ] ) && isset ( $ outline [ 'title' ] ) ) { $ outline [ 'text' ] = $ outline [ 'title' ] ; } ... | Parse an XML object as an outline object and return corresponding array |
15,037 | protected function makeConsoleLogger ( OutputInterface $ output ) : ConsoleLogger { return new ConsoleLogger ( $ output , [ LogLevel :: DEBUG => OutputInterface :: VERBOSITY_VERY_VERBOSE , LogLevel :: INFO => OutputInterface :: VERBOSITY_VERBOSE , LogLevel :: NOTICE => OutputInterface :: VERBOSITY_NORMAL ] , [ LogLevel... | Creates a PSR logger instance which prints messages to the command output |
15,038 | protected function writeError ( OutputInterface $ output , string $ message ) { if ( $ output instanceof ConsoleOutputInterface ) { $ output = $ output -> getErrorOutput ( ) ; } $ output -> writeln ( $ this -> getHelper ( 'formatter' ) -> formatBlock ( $ message , 'error' ) ) ; } | Prints an error to an output |
15,039 | protected function findGApiOAuthSecretFileValue ( InputInterface $ input , OutputInterface $ output ) : ? string { $ needToParseConfigFile = false ; $ gApiOAuthSecretFile = $ this -> getGApiOAuthSecretFileOption ( $ input ) ; if ( $ gApiOAuthSecretFile === null ) { $ needToParseConfigFile = true ; if ( $ output -> isVe... | Attempts to find GApiOAuthSecretFile from option or config . |
15,040 | protected function findGApiAccessTokenFileValue ( InputInterface $ input , OutputInterface $ output ) : ? string { $ needToParseConfigFile = false ; $ gApiAccessTokenFile = $ this -> getGApiAccessTokenFileOption ( $ input ) ; if ( $ gApiAccessTokenFile === null ) { $ needToParseConfigFile = true ; if ( $ output -> isVe... | Attempts to find GApiAccessTokenFile from option or config . |
15,041 | protected function extractGApiAuthConfigSettings ( array $ configData , OutputInterface $ output ) { $ options = [ ] ; foreach ( array ( 'gApiOAuthSecretFile' , 'gApiAccessTokenFile' ) as $ option ) { if ( ! isset ( $ configData [ self :: ROOT_CONFIG_G_API_ACCESS_KEY ] [ $ option ] ) ) { continue ; } if ( ! is_string (... | Extract GApiAuth settings from array of config data . |
15,042 | protected function getDataFromConfigFile ( OutputInterface $ output ) : ? array { if ( $ this -> findConfigFile ( $ output ) === null ) { if ( $ output -> isVerbose ( ) ) { $ output -> writeln ( 'A configuration file `' . $ this -> getCommandStaticConfigFilename ( ) . '`' . ' exists neither in the current directory nor... | Gets options values from a configuration file |
15,043 | protected function findConfigFile ( OutputInterface $ output ) : ? string { $ directory = @ getcwd ( ) ; if ( $ directory === false ) { throw new \ RuntimeException ( 'Can\'t get the working directory path. Make sure the working directory is readable.' ) ; } for ( $ i = 0 ; $ i < 10000 ; ++ $ i ) { $ file = $ directory... | Finds a configuration file within the current working directory and its parents |
15,044 | protected function getFullPath ( $ contextPath , $ targetPath ) : string { if ( $ this -> filesystem -> isAbsolutePath ( $ targetPath ) ) { return $ targetPath ; } return rtrim ( $ contextPath , '/\\' ) . DIRECTORY_SEPARATOR . $ targetPath ; } | Converts a relative file path to a full path |
15,045 | public function onPaymentStateChange ( PaymentEvent $ event ) { $ payment = $ event -> getPayment ( ) ; if ( ! $ payment instanceof OrderPayment ) { return ; } $ order = $ payment -> getOrder ( ) ; $ this -> stateResolver -> resolve ( $ order , $ event ) ; $ this -> updateOrder ( $ order , $ event , true ) ; } | Payment state change event handler . |
15,046 | public function onPaymentNotify ( PaymentEvent $ event ) { $ payment = $ event -> getPayment ( ) ; if ( ! $ payment instanceof OrderPayment ) { return ; } $ order = $ payment -> getOrder ( ) ; if ( $ order -> getLocked ( ) ) { $ order -> setLocked ( false ) ; $ this -> updateOrder ( $ order , $ event ) ; } } | Payment notify event handler . |
15,047 | public function onPaymentDone ( PaymentEvent $ event ) { $ payment = $ event -> getPayment ( ) ; if ( ! $ payment instanceof OrderPayment ) { return ; } $ order = $ payment -> getOrder ( ) ; if ( $ order -> getLocked ( ) ) { $ order -> setLocked ( false ) ; $ this -> updateOrder ( $ order , $ event ) ; } $ returnPath =... | Payment done event handler . |
15,048 | private function updateOrder ( OrderInterface $ order , PaymentEvent $ event , $ force = false ) { $ orderEvent = new OrderEvent ( $ order ) ; $ orderEvent -> setForce ( $ force ) ; $ this -> operator -> update ( $ orderEvent ) ; if ( $ orderEvent -> hasMessages ( ) ) { $ event -> addMessages ( $ orderEvent -> getMessa... | Updates the order . |
15,049 | public function getAllModules ( ) { $ arrModules = array ( ) ; $ strQuery = 'SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id' ; if ( \ Input :: get ( 'table' ) == 'tl_module' && \ Input :: get ( 'act' ) == 'edit' ) { $ strQuery .= ' WHERE m.id != ?' ; } $ strQuery .= ' ORDER BY ... | Get all modules prepared for select wizard |
15,050 | public function getTemplates ( $ dc ) { $ prefix = '' ; if ( $ dc instanceof \ MultiColumnWizard ) { $ dc -> field = $ dc -> strField ; $ dc -> table = $ dc -> strTable ; } if ( isset ( $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ $ dc -> field ] [ 'eval' ] [ 'templatePrefix' ] ) ) { $ prefix = $ GLOBALS [ '... | get all templates . A templatePrefix can be defined using eval . templatePrefix |
15,051 | public function set_model ( $ model ) { foreach ( $ this -> required_arguments ( ) as $ key ) { if ( ! isset ( $ model [ $ key ] ) ) { throw new \ RuntimeException ( 'The required argument "' . $ key . '" was not provided for ' . get_called_class ( ) ) ; } } if ( ! isset ( $ model [ 'id' ] ) && isset ( $ model [ 'name'... | Set the model data for this component . |
15,052 | public function remove_html_class ( $ class ) { $ i = 0 ; foreach ( $ this -> html_classes as $ c ) { if ( $ c === $ class ) { array_splice ( $ this -> html_classes , $ i , 1 ) ; break ; } $ i ++ ; } } | Remove an HTML class to the list of HTML classes to be printed when the component is rendered . |
15,053 | public function render ( $ echo = false ) { $ this -> enqueue_scripts ( ) ; ob_start ( ) ; include dirname ( __FILE__ ) . '/AbstractComponent.phtml' ; $ html = ob_get_clean ( ) ; if ( ! $ echo ) { return $ html ; } echo $ html ; } | Enqueue component s script and render it . |
15,054 | public function replaceContent ( & $ parameters , TypoScriptFrontendController $ parentObject ) { if ( TYPO3_MODE === 'FE' ) { $ configuration = $ parentObject -> config [ 'config' ] [ 'tx_replacecontent.' ] ; if ( ! is_array ( $ configuration [ 'search.' ] ) || ! is_array ( $ configuration [ 'replace.' ] ) ) { return ... | Search for a string and replace it with something else . |
15,055 | private static function generateSalt ( int $ length ) : string { $ uniqueRandomString = md5 ( uniqid ( mt_rand ( ) , true ) ) ; $ base64String = base64_encode ( $ uniqueRandomString ) ; $ modifiedBase64String = str_replace ( '+' , '.' , $ base64String ) ; return substr ( $ modifiedBase64String , 0 , $ length ) ; } | Generates salt for hashing . |
15,056 | public static function passwordEncrypt ( string $ password = NULL ) : string { $ hashFormat = "$2y$10$" ; $ saltLength = 22 ; $ salt = static :: generateSalt ( $ saltLength ) ; $ formatAndSalt = $ hashFormat . $ salt ; return crypt ( $ password , $ formatAndSalt ) ; } | Encrypts password using blowfish . |
15,057 | public static function passwordCheck ( string $ password , string $ existingHash ) : bool { $ hash = crypt ( $ password , $ existingHash ) ; return ( $ hash == $ existingHash ) ? TRUE : FALSE ; } | Check password with existing hashed password . |
15,058 | public static function blazeEncrypt ( string $ string ) : string { $ cryptKey = 'qJB0rGtIn5UB1xG03efyCp' ; return base64_encode ( mcrypt_encrypt ( MCRYPT_RIJNDAEL_256 , md5 ( $ cryptKey ) , $ string , MCRYPT_MODE_CBC , md5 ( md5 ( $ cryptKey ) ) ) ) ; } | Two way hash algorithm to encrypt the given string |
15,059 | public static function blazeDecrypt ( string $ encodedString ) : string { $ cryptKey = 'qJB0rGtIn5UB1xG03efyCp' ; return rtrim ( mcrypt_decrypt ( MCRYPT_RIJNDAEL_256 , md5 ( $ cryptKey ) , base64_decode ( $ encodedString ) , MCRYPT_MODE_CBC , md5 ( md5 ( $ cryptKey ) ) ) , "\0" ) ; } | Two way hash algorithm to dencrypt the given string |
15,060 | public function addServiceCatalog ( $ type , $ name , array $ endpoints ) { if ( ! array_key_exists ( $ type , $ this -> catalogs ) ) { $ this -> catalogs [ $ type ] = [ ] ; } foreach ( $ endpoints as $ index => $ endpoint ) { if ( ! is_array ( $ endpoint ) ) { throw new TokenException ( 'Expecting an array for an endp... | Adds a service catalog using the array output of a token - call . |
15,061 | public static function create ( array $ content ) { $ access = static :: arrayGet ( $ content , 'access' ) ; $ token = static :: arrayGet ( $ access , 'token' ) ; $ tokenid = static :: arrayGet ( $ token , 'id' ) ; $ expires = static :: arrayGet ( $ token , 'expires' ) ; try { $ expireDate = new \ DateTime ( $ expires ... | Factory method to use with Keystone token responses or a json_encoded Token instance . |
15,062 | public function readAction ( string $ production_slug , AuthorizationCheckerInterface $ auth ) : RedirectResponse { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'slug' => $ production_slug ] ) ) { throw new NotFoundHttpExcept... | Read a production simply redirects to the overview . |
15,063 | public function overviewAction ( string $ production_slug , AuthorizationCheckerInterface $ auth ) : Response { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'slug' => $ production_slug ] ) ) { throw new NotFoundHttpException ... | Shows the production image and description with block for timeline . |
15,064 | public function settingsAction ( string $ production_slug , Request $ request , AuthorizationCheckerInterface $ auth ) : Response { if ( null === $ production = $ this -> em -> getRepository ( Production :: class ) -> findOneBy ( [ 'slug' => $ production_slug ] ) ) { throw new NotFoundHttpException ( ) ; } if ( ! $ aut... | Provide a generic settings form for admins . |
15,065 | protected function getOrCreate ( string $ id , callable $ creator ) { if ( ! $ this -> getHelperSet ( ) -> has ( 'container' ) ) { return $ creator ( ) ; } $ container = $ this -> getContainer ( ) ; if ( $ container -> has ( $ id ) ) { return $ container -> get ( $ id ) ; } return $ creator ( ) ; } | Get a service by ID from the container if it exists or create it with the callable . |
15,066 | protected function createTitle ( Infoset $ info ) { if ( php_sapi_name ( ) === 'cli' ) { $ info -> setTitle ( '[success]CLI[/success]' ) ; return ; } $ code = http_response_code ( ) ; $ title = ( $ code < 400 ) ? '[success]' . $ code . '[/success]' : '[alert]' . $ code . '[/alert]' ; if ( ob_get_level ( ) > 0 ) { $ tit... | Create the title information |
15,067 | public static function initialize ( array $ defaults , Options $ options , $ options_key ) { $ controls = [ ] ; $ groups = [ ] ; foreach ( $ defaults as $ control_id => $ control_info ) { $ controls [ $ control_id ] = $ control_info [ 'ui' ] :: create ( $ options , $ options_key , $ control_id , $ control_info ) ; if (... | Initialize controls for a plugin settings page . |
15,068 | public function get ( $ modified = true ) { Argument :: i ( ) -> test ( 1 , 'bool' ) ; $ array = array ( ) ; foreach ( $ this -> list as $ i => $ row ) { $ array [ $ i ] = $ row -> get ( $ modified ) ; } return $ array ; } | Returns the row array |
15,069 | public function part ( $ offset ) { if ( ! isset ( $ this -> identifierParts [ $ offset ] ) ) { return null ; } return $ this -> identifierParts [ $ offset ] ; } | Get the value of the identifier part at the specified offset |
15,070 | public function keys ( $ search = null , $ caseSensitive = false ) { if ( $ search === null ) { return array_keys ( $ this -> identifierParts ) ; } if ( $ caseSensitive === true ) { return array_keys ( $ this -> identifierParts , $ search ) ; } $ search = strtolower ( $ search ) ; $ keys = array_keys ( $ this -> identi... | Get the keys of the identifier parts that match the specified string or the keys of all parts if no string provided |
15,071 | public function startsWith ( $ startsWith , $ caseSensitive = false ) { if ( ! $ caseSensitive ) { return strtolower ( $ this -> first ( ) ) === strtolower ( $ startsWith ) ; } return $ this -> first ( ) === $ startsWith ; } | Determine if the identifier starts with the specified part string |
15,072 | public function endsWith ( $ endsWith , $ caseSensitive = false ) { if ( ! $ caseSensitive ) { return strtolower ( $ this -> last ( ) ) === strtolower ( $ endsWith ) ; } return $ this -> last ( ) === $ endsWith ; } | Determine if the identifier ends with the specified part string |
15,073 | public function mergeRange ( $ start , $ end = null ) { if ( $ end === null ) { $ end = $ this -> getNumParts ( ) - 1 ; } if ( $ end <= $ start ) { return $ this ; } $ mergedParts = implode ( array_slice ( $ this -> identifierParts , $ start , $ end ) ) ; array_splice ( $ this -> identifierParts , $ start , $ end , $ m... | Merge a range of identifier parts into one part |
15,074 | public function replace ( $ offset , $ replacement ) { if ( ! array_key_exists ( $ offset , $ this -> identifierParts ) ) { throw new OutOfBoundsException ( 'No identifier part exists at the specified position: ' . $ offset ) ; } $ this -> identifierParts [ $ offset ] = $ replacement ; return $ this ; } | Replace an identifier part at the specified position |
15,075 | public function offsetSet ( $ offset , $ part ) { if ( $ offset === null ) { $ this -> append ( $ part ) ; } $ this -> replace ( $ offset , $ part ) ; } | Using array access set the identifier part at the specified position |
15,076 | protected function applyOutputFormat ( DynamicIdentifier $ identifier ) { if ( $ this -> outputFormat !== null ) { $ identifier -> setOutputFormat ( $ this -> outputFormat ) ; } return $ identifier ; } | Applies the current output case to a DynamicIdentifier if already set explicitly |
15,077 | static public function iteratorToArray ( Traversable $ iterator ) { $ array = [ ] ; foreach ( $ iterator as $ key => $ value ) { if ( $ value instanceof Traversable ) { $ value = self :: iteratorToArray ( $ value ) ; } $ array [ $ key ] = $ value ; } return $ array ; } | Recursively iterator to array converter |
15,078 | static public function objectMerge ( ) { $ result = new stdClass ( ) ; foreach ( func_get_args ( ) as $ object ) { foreach ( $ object as $ key => $ value ) { $ result -> $ key = $ value ; } } return $ result ; } | Merge abjects into one |
15,079 | static public function parseValue ( $ value ) { $ value = trim ( $ value ) ; if ( is_numeric ( $ value ) ) { $ valueOrigin = $ value ; if ( strpos ( $ value , '.' ) === false ) { $ value = ( int ) $ value ; } else { $ value = ( float ) $ value ; } if ( $ valueOrigin !== ( string ) $ value ) { $ value = $ valueOrigin ; ... | Parse value convert to integer or float if value is numeric |
15,080 | public function setBars ( $ bars ) { if ( is_string ( $ bars ) && strlen ( $ bars ) > 1 ) { $ this -> bars = $ bars ; } return $ this ; } | Sets the handlebars characters |
15,081 | protected function setup_validation ( $ data ) { $ this -> validation = new Validation ( $ data , $ this -> rules ( ) , $ this -> messages ( ) ) ; if ( ! empty ( $ this -> aliases ( ) ) ) { $ this -> set_aliases ( $ this -> aliases ( ) ) ; } } | Sets up the Snap \ Http \ Validation \ Validation instance . |
15,082 | public function renderizate ( $ path , $ file , $ data = null ) { $ file = $ path . $ file . '.php' ; if ( $ data ) { self :: $ data [ self :: setHash ( $ file ) ] = $ data ; } require_once $ file ; return true ; } | Render screen view . |
15,083 | private static function setHash ( $ filePath ) { if ( stristr ( php_uname ( 's' ) , 'WIN' ) ) { $ filePath = str_replace ( [ '/' , '\\' ] , DIRECTORY_SEPARATOR , $ filePath ) ; } return md5 ( $ filePath ) ; } | Set file path hash . |
15,084 | private function renderHiddenInputs ( ) { $ items = $ this -> form -> field ( $ this -> cartForm , 'productId' ) -> hiddenInput ( [ 'value' => $ this -> product -> id ] ) -> label ( false ) ; $ items .= $ this -> form -> field ( $ this -> cartForm , 'count' ) -> hiddenInput ( [ 'value' => self :: DEFAULT_PRODUCT_COUNT ... | Renders hidden inputs . |
15,085 | public function renderPrice ( ) { if ( empty ( $ this -> product ) ) { return false ; } $ items = '' ; if ( ! empty ( $ this -> priceContainerOptions ) ) { $ items = Html :: beginTag ( 'div' , $ this -> priceContainerOptions ) ; } if ( ! empty ( $ this -> product -> defaultCombination ) ) { $ items .= $ this -> renderC... | Renders prices block . |
15,086 | private function renderCombinationPriceItem ( ) { $ item = Html :: tag ( 'strong' , Yii :: $ app -> formatter -> asCurrency ( $ this -> product -> defaultCombination -> price -> discountPrice ) , $ this -> discountPriceOptions ) ; if ( empty ( $ this -> product -> defaultCombination -> price -> discount_type_id ) || em... | Renders price item using product price from default combination . |
15,087 | private function renderDefaultPriceItem ( ) { $ item = Html :: tag ( 'strong' , Yii :: $ app -> formatter -> asCurrency ( $ this -> product -> getDiscountPrice ( ) ) , $ this -> discountPriceOptions ) ; if ( ! empty ( $ this -> product -> price -> discount_type_id ) ) { $ item .= Html :: tag ( 'strike' , Yii :: $ app -... | Renders price item using default product price . |
15,088 | public function addRemovePostTypeSupport ( $ props ) { if ( empty ( $ props ) ) { return ; } add_action ( 'init' , function ( ) use ( $ props ) { $ available = [ 'title' , 'editor' , 'author' , 'thumbnail' , 'excerpt' , 'trackbacks' , 'custom-fields' , 'comments' , 'revisions' , 'page-attributes' , 'post-formats' ] ; f... | Add or Remove post type supports to WP . |
15,089 | public function addRemoveThemeSupport ( $ key , $ props = [ ] ) { add_action ( 'after_setup_theme' , function ( ) use ( $ key , $ props ) { if ( is_bool ( $ props ) && ! $ props ) { remove_theme_support ( $ key ) ; } else if ( empty ( $ props ) ) { add_theme_support ( $ key ) ; } else { add_theme_support ( $ key , $ pr... | Add theme supports to WP . |
15,090 | public static function extractParamsFromHeaderString ( string $ hmacHeader = null ) { if ( $ hmacHeader !== null && preg_match ( '/^HMAC\s+(.*?)$/' , $ hmacHeader , $ matches ) ) { if ( \ strpos ( $ matches [ 1 ] , ',' ) !== false ) { $ params = explode ( ',' , trim ( $ matches [ 1 ] ) ) ; if ( count ( $ params ) !== 3... | Extracts the HMAC parameters from a header string |
15,091 | public function getHeader ( ) : string { $ salt = $ this -> getEncodedSalt ( ) ; $ hmac = $ this -> getEncodedHMAC ( ) ; if ( $ this -> version === 2 ) { $ data = \ base64_encode ( \ json_encode ( [ 'access_token' => $ this -> token -> accessToken , 'date' => $ this -> date , 'hmac' => $ hmac , 'salt' => $ salt , 'v' =... | Generates the versions HMAC header |
15,092 | public function verify ( string $ hmac , self $ auth , int $ driftAllowance = 90 ) : bool { $ drift = $ this -> getTimeDrift ( $ auth -> getDate ( ) ) ; if ( $ drift === null || $ drift >= $ driftAllowance ) { return false ; } try { if ( \ sodium_memcmp ( $ hmac , $ auth -> getHMAC ( ) ) === 0 ) { return true ; } } cat... | Validates a provided HMAC against an auth object and a drift |
15,093 | private function getTimeDrift ( string $ date ) : ? int { $ now = new \ DateTime ( ) ; $ now -> format ( \ DateTime :: RFC1123 ) ; try { $ realDate = new DateTime ( $ date ) ; } catch ( \ Exception $ e ) { return null ; } return ( int ) \ abs ( $ now -> getTimestamp ( ) - $ realDate -> getTimestamp ( ) ) ; } | Calculates the time difference between now and the provided date |
15,094 | protected function shouldExecute ( $ request , bool $ before = true ) : bool { return ! in_array ( $ request -> path ( ) , $ before ? $ this -> beforeExcept : $ this -> afterExcept ) ; } | Determine if request has a URI that should fire the after middleware |
15,095 | protected function shouldAutoPrepareForResponse ( ) : bool { $ request = request ( ) ; return $ request -> isMethod ( 'get' ) && ! in_array ( $ request -> path ( ) ?? '' , $ this -> autoPrepareResponseExcept ) ; } | Determine if we automatically prepare for a response from a request |
15,096 | protected function prepareForResponse ( ) { if ( $ this -> preparedForResponse ) { return ; } $ this -> loadView ( ) ; $ this -> loadThemer ( ) ; $ this -> loadThemerDefaultFiles ( $ this -> config ) ; $ this -> loadGlobalViewVariables ( $ this -> config ) ; if ( method_exists ( $ this , 'prepareExtraForResponse' ) ) {... | Prepare for a request response |
15,097 | protected function prepareForFormResponse ( bool $ withRecaptcha = true , ... $ scripts ) { $ app = app ( ) ; if ( $ withRecaptcha ) { $ recaptcha = $ app -> make ( Recaptcha :: class ) ; $ app -> make ( 'session' ) -> put ( '__recaptcha_active' , true ) ; } $ this -> share ( [ 'sequence' => $ app -> make ( Sequence ::... | Add parts required for rendering a form |
15,098 | public function isGSheetFileNameIgnored ( $ fullName ) : bool { $ nameWithoutExtension = explode ( '.' , $ fullName ) [ 0 ] ; if ( '_' === substr ( $ fullName , - 1 ) || '_' === substr ( $ nameWithoutExtension , - 1 ) ) { return true ; } return false ; } | If a file is called foo_ then it is assumed to be private and should be explicitly ignored |
15,099 | protected function isAllHeadingValuesPresentInRow ( ? array $ row ) { if ( true === empty ( $ row ) ) { return false ; } foreach ( $ this -> targettedHeadingValues as $ headerValue ) { if ( false === in_array ( trim ( $ headerValue ) , $ row ) ) { return false ; } } return true ; } | Allows additional columns in the spreadsheet as long as all the targetted columns are present . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.