idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
5,200 | public function stripSpecialChars ( $ replacement ) { $ this -> returnValue = preg_replace ( '/[^A-Za-z0-9]/' , $ replacement , $ this -> returnValue ) ; $ this -> returnValue = preg_replace ( '/ +/' , $ replacement , $ this -> returnValue ) ; return $ this ; } | Removes all non alpha numberical characters |
5,201 | public function split ( $ delimiter , $ limit = null ) { return is_null ( $ limit ) ? explode ( $ delimiter , $ this -> returnValue ) : explode ( $ delimiter , $ this -> returnValue , $ limit ) ; } | Split a string by string |
5,202 | public function toBool ( ) { return ( ! is_null ( $ this -> returnValue ) ) && ( ! empty ( $ this -> returnValue ) ) && ( ! in_array ( strtolower ( $ this -> returnValue ) , $ this -> falseStrings ) ) ; } | Converts this string to a boolean . |
5,203 | public function toComment ( $ mime ) { $ commentStart = "<!--" ; $ commentEnd = " ; switch ( $ mime ) { case "text/javascript" : case "text/css" : case "application/x-javascript" : $ commentStart = "/**" ; $ commentEnd = "**/" ; break ; default : break ; } $ this -> returnValue = $ commentStart . " " . $ this -> return... | Wrap this string in a comment block |
5,204 | public static function createRandomAlphaNumeric ( $ length = 8 ) { $ chars = array ( "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" , "123456789" ) ; $ count = array ( ( strlen ( $ chars [ 0 ] ) - 1 ) , ( strlen ( $ chars [ 1 ] ) - 1 ) ) ; $ prefix = "" ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ type = mt_r... | Generatesa random string |
5,205 | public function register ( ) { set_exception_handler ( new ExceptionHandler ( $ this -> request , $ this -> factory ) ) ; register_shutdown_function ( new ShutdownHandler ( $ this -> request , $ this -> factory ) ) ; } | Register the exception handler and the shutdown handler . |
5,206 | public function clear ( ) { $ loops = $ this -> getLoops ( ) ; if ( $ loops -> getService ( "cache" ) -> flushAll ( ) ) { $ loops -> getService ( "logger" ) -> info ( "Clearing cache was successful." ) ; return 0 ; } else { $ loops -> getService ( "logger" ) -> err ( "Clearing cache failed." ) ; return 1 ; } } | Calls flushAll on cache |
5,207 | public static function setUseMultiByte ( $ use_mbstring ) { if ( $ use_mbstring ) { if ( ! extension_loaded ( self :: $ __mbstring_extension_name ) ) { self :: toss ( "RuntimeException" , "The '{0}' extension must be enabled." , self :: $ __mbstring_extension_name ) ; } self :: $ use_mbstring = true ; if ( ! self :: $ ... | Sets whether to use the mbstring extension for string operations |
5,208 | public static function setCharacterSet ( $ char_set ) { $ default = self :: getDefaultCharacterSet ( ) ; $ char_set = $ char_set ? strtoupper ( $ char_set ) : $ default ; $ available = array_map ( "strtoupper" , mb_list_encodings ( ) ) ; $ is_valid = false ; foreach ( $ available as $ a ) { if ( $ a === $ char_set ) { ... | Sets the character set this class uses for string operations |
5,209 | public static function camelCaseToUnderscore ( $ str ) { $ under = "" ; $ chars = self :: chars ( $ str ) ; $ lower = false ; $ upper = false ; foreach ( $ chars as $ char ) { if ( "_" !== $ char && "-" !== $ char ) { if ( self :: startsUpper ( $ char ) ) { $ under .= ( $ lower || $ upper ) ? "_{$char}" : $ char ; $ lo... | Transforms a string with CamelCaseText into a string with underscore_text |
5,210 | public static function underscoreToCamelCase ( $ str ) { $ str = self :: replace ( $ str , "_" , " " ) ; $ str = self :: replace ( $ str , "-" , " " ) ; $ str = self :: title ( $ str ) ; return self :: replace ( $ str , " " , "" ) ; } | Transforms a string with underscore_text into a string with CamelCaseText |
5,211 | public static function startsWith ( $ str , $ find , $ match_case = true ) { if ( $ match_case ) { return self :: $ use_mbstring ? mb_strpos ( $ str , $ find ) === 0 : strpos ( $ str , $ find ) === 0 ; } else { return self :: $ use_mbstring ? mb_stripos ( $ str , $ find ) === 0 : stripos ( $ str , $ find ) === 0 ; } } | Returns whether the string starts with another string |
5,212 | public static function endsWith ( $ str , $ find , $ match_case = true ) { if ( ! $ match_case ) { $ str = self :: toLower ( $ str ) ; $ find = self :: toLower ( $ find ) ; } if ( self :: $ use_mbstring ) { $ len = mb_strlen ( $ find ) ; $ is_ends = mb_substr ( $ str , "-{$len}" ) === $ find ; } else { $ len = strlen (... | Returns whether the string ends with another string |
5,213 | public static function startsUpper ( $ str ) { $ char = self :: sub ( $ str , 0 , 1 ) ; return self :: toUpper ( $ char ) === $ char ; } | Returns whether the string starts with an upper case character |
5,214 | public static function startsLower ( $ str ) { $ char = self :: sub ( $ str , 0 , 1 ) ; return self :: toLower ( $ char ) === $ char ; } | Returns whether the string starts with a lower case character |
5,215 | public static function replace ( $ str , $ search , $ replace ) { if ( self :: $ use_mbstring ) { $ search_len = mb_strlen ( $ search ) ; $ replace_len = mb_strlen ( $ replace ) ; $ search_pos = mb_strpos ( $ str , $ search ) ; while ( $ search_pos !== false ) { $ str = mb_substr ( $ str , 0 , $ search_pos ) . $ replac... | Replaces characters in a string |
5,216 | public static function length ( $ str ) { return self :: $ use_mbstring ? mb_strlen ( $ str , self :: $ char_set ) : strlen ( $ str ) ; } | Returns the number of characters in the string |
5,217 | public static function chars ( $ str ) { if ( self :: $ use_mbstring ) { $ chars = [ ] ; for ( $ i = 0 , $ l = self :: length ( $ str ) ; $ i < $ l ; $ i ++ ) { $ chars [ ] = mb_substr ( $ str , $ i , 1 , self :: $ char_set ) ; } } else { $ chars = str_split ( $ str ) ; } return $ chars ; } | Splits a string into individual characters |
5,218 | public static function toUpper ( $ str ) { return self :: $ use_mbstring ? mb_strtoupper ( $ str , self :: $ char_set ) : strtoupper ( $ str ) ; } | Transforms a string to upper case |
5,219 | public static function toLower ( $ str ) { return self :: $ use_mbstring ? mb_strtolower ( $ str , self :: $ char_set ) : strtolower ( $ str ) ; } | Transforms a string to lower case |
5,220 | public static function ucFirst ( $ str ) { if ( self :: $ use_mbstring ) { $ first = self :: toUpper ( self :: sub ( $ str , 0 , 1 ) ) ; $ str = $ first . self :: sub ( $ str , 1 ) ; } else { $ str = ucfirst ( $ str ) ; } return $ str ; } | Transforms the first letter of a string to upper case |
5,221 | public static function lcFirst ( $ str ) { if ( self :: $ use_mbstring ) { $ first = self :: toLower ( self :: sub ( $ str , 0 , 1 ) ) ; $ str = $ first . self :: sub ( $ str , 1 ) ; } else { $ str = lcfirst ( $ str ) ; } return $ str ; } | Transforms the first letter of a string to lower case |
5,222 | public static function title ( $ str ) { return self :: $ use_mbstring ? mb_convert_case ( $ str , MB_CASE_TITLE , self :: $ char_set ) : ucwords ( strtolower ( $ str ) ) ; } | Upper cases the first letter of each word in the string |
5,223 | public static function sub ( $ str , $ start , $ end = null ) { if ( null !== $ end ) { return self :: $ use_mbstring ? mb_substr ( $ str , $ start , $ end ) : substr ( $ str , $ start , $ end ) ; } else { return self :: $ use_mbstring ? mb_substr ( $ str , $ start ) : substr ( $ str , $ start ) ; } } | Returns a portion of the string |
5,224 | public static function truncate ( $ str , $ max_len , $ pos = self :: TRUNC_END , $ ellipsis = "..." ) { if ( self :: length ( $ str ) > $ max_len ) { $ ellipsis_len = self :: length ( $ ellipsis ) ; switch ( $ pos ) { case self :: TRUNC_START : $ max_len -= $ ellipsis_len ; $ str = $ ellipsis . self :: sub ( $ str , "... | Truncates strings which exceed a maximum length |
5,225 | public static function transform ( & $ str , $ transformation = self :: TR_LOWER ) { switch ( $ transformation ) { case self :: TR_LOWER : $ str = self :: toLower ( $ str ) ; break ; case self :: TR_UPPER : $ str = self :: toUpper ( $ str ) ; break ; case self :: TR_TITLE : $ str = self :: title ( $ str ) ; break ; cas... | Transform a string |
5,226 | public static function generateButtonForm ( $ label , $ postfields , $ postUrl = '' ) { $ html = '<form method="POST" action="' . $ postUrl . '">' . self :: generateHiddenInputFields ( $ postfields ) . self :: generateSubmitButton ( $ label ) . '</form>' ; return $ html ; } | Generates what appears to be just a button but is actually a submittable form that will post itself or the specified postUrl . |
5,227 | public static function generateInputField ( $ name , $ type , $ currentValue = "" , $ placeholder = "" ) { $ type = strtolower ( $ type ) ; if ( $ type === 'button' ) { $ msg = 'Developer error: please use the generateButton function ' . 'instead to create buttons.' ; throw new \ Exception ( $ msg ) ; } if ( $ type == ... | Generates a html input field |
5,228 | public static function generateTextArea ( $ name , $ currentValue = "" , $ placeholder = "" , $ class = "" , $ rows = "" , $ cols = "" , $ id = "" , $ disabled = false ) { $ idAttribute = '' ; $ rowAttribute = '' ; $ colsAttribute = '' ; $ disabledAttribute = '' ; if ( $ rows != "" ) { $ rowAttribute = ' rows="' . $ ro... | Generates a textaread form element |
5,229 | public static function generateDropDownMenu ( $ name , $ currentValue , $ options , $ rowSize = 1 , $ multipleSelect = false , $ onChange = "" , $ id = "" ) { $ isAssoc = self :: isAssoc ( $ options ) ; $ optionsHtml = "" ; foreach ( $ options as $ key => $ option ) { $ optionValue = $ option ; $ optionLabel = $ option... | Generates an html drop down menu for forms . If the array of drop down options passed in is an array then the value posted will be the key and the display label for the option will be the value . |
5,230 | public static function generateSubmitButton ( $ label = "Submit" , $ offscreen = false ) { $ styleAttribute = '' ; if ( $ offscreen ) { $ styleAttribute = ' style="position: absolute; left: -9999px" ' ; } $ html = '<input ' . 'type="submit" ' . 'value="' . $ label . '" ' . $ styleAttribute . '/>' ; return $ html ; } | Generates a submit button for a form . |
5,231 | public function copy ( string $ templateFolder , string $ targetFolder , array $ context ) { $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ templateFolder , \ FilesystemIterator :: KEY_AS_PATHNAME | \ FilesystemIterator :: CURRENT_AS_FILEINFO | \ FilesystemIterator :: SKIP_DOTS ) , ... | Recursivly iterates over the contents in the given templateFolder building the targetPath while replaceing variables in the path . |
5,232 | public function getTargetPath ( string $ templateFolder , string $ targetFolder , string $ currentPath ) : string { $ trimPath = function ( $ path ) { return rtrim ( $ path , DIRECTORY_SEPARATOR . ' ' ) ; } ; return str_replace ( $ trimPath ( $ templateFolder ) , $ trimPath ( $ targetFolder ) , $ trimPath ( $ currentPa... | Replaces the part of the templateFolder in the currentPath with the part of the target folder . The currentPath should be the absolute path to the template file . |
5,233 | public function apply ( QueryBuilder $ builder ) { $ builder -> where ( $ this -> name , $ this -> operation , $ this -> value ) ; } | It returns query builder that can be pass further to read repository |
5,234 | protected function checkValue ( ) : void { if ( ! ctype_digit ( $ this -> value ) && ! is_numeric ( $ this -> value ) && ! empty ( $ this -> value ) ) { throw new InvalidArgumentException ( 'NumericParser: Value must be of type numeric' ) ; } } | Check if value is not a number . |
5,235 | public function findMatchingFiles ( string $ path ) : array { $ path = $ this -> validatePath ( $ path ) ; if ( is_dir ( $ path ) ) { $ pathCollection = $ this -> findMatchingFilesInDirectory ( $ path ) ; } elseif ( is_file ( $ path ) ) { $ pathCollection = [ $ path ] ; } else { throw new FileException ( sprintf ( 'Cou... | Returns the matching files containing the test doc comment |
5,236 | public function create ( $ email ) { $ store = $ this -> getCacheStorage ( ) ; do { $ hash = String :: generateRandom ( self :: HASH_LENGTH , null , true ) ; } while ( $ store -> hasItem ( $ hash ) ) ; $ store -> setItem ( $ hash , $ email ) ; return $ hash ; } | Request a password - change |
5,237 | public static function getTemplateConfig ( ) { if ( self :: $ _templateConfig === 0 ) { $ request = Agl :: getRequest ( ) ; $ module = $ request -> getModule ( ) ; $ view = $ request -> getView ( ) ; $ action = $ request -> getAction ( ) ; self :: $ _templateConfig = Agl :: app ( ) -> getConfig ( 'core-layout/modules/'... | Get the template configuration . |
5,238 | public function render ( ) { $ this -> _path = $ this -> getPath ( ) ; if ( ! is_readable ( $ this -> _path ) ) { Request :: setHttpHeader ( Request :: HEADER_404 ) ; $ this -> setFile ( static :: ERROR_404 ) ; $ this -> _path = $ this -> getPath ( ) ; if ( ! is_readable ( $ this -> _path ) ) { throw new Exception ( "V... | Include the template in the current page . |
5,239 | public function getBlock ( $ pBlock , array $ pVars = array ( ) ) { if ( ! preg_match ( '#^([a-z0-9]+)/([a-z0-9_-]+)$#' , $ pBlock , $ blockPathInfos ) or ! isset ( $ blockPathInfos [ 1 ] ) or ! isset ( $ blockPathInfos [ 2 ] ) ) { throw new Exception ( "Block identifier '$pBlock' is not correct" ) ; } $ this -> _block... | Create a block and include it into the view . |
5,240 | public function validate ( $ record ) { $ record -> errors ( ) -> clear ( ) ; foreach ( $ this -> validations as $ attribute => $ validators ) { if ( $ attribute === 'validateWith' ) { foreach ( $ validators as $ validatorClass => $ options ) { if ( is_int ( $ validatorClass ) ) { $ validatorClass = $ options ; $ optio... | Returns true if all validations passed false otherwise . |
5,241 | public function equals ( $ value , bool $ strict = false ) : bool { if ( null === $ value ) { return false ; } if ( $ value instanceof MailAddress ) { return ( $ value -> _userPart === $ this -> _userPart ) && ( ( ( string ) $ value -> _domainPart ) === ( ( string ) $ this -> _domainPart ) ) ; } if ( $ strict ) { retur... | Checks if the defined value is equal to current mail address value . |
5,242 | public function import ( $ data ) { if ( ! is_array ( $ data ) ) { $ data = is_callable ( array ( $ data , 'toArray' ) ) ? $ data -> toArray ( ) : ( array ) $ data ; } foreach ( $ data as $ key => $ value ) { $ this [ $ key ] = $ value ; } return $ this ; } | Implements \ xpl \ Common \ Importable |
5,243 | public function post ( $ uri , $ body , array $ headers = [ ] ) { $ defaultHeaders = [ 'Authorization' => "Bearer {$this->token}" , 'Content-Type' => 'application/json' , 'Accept' => 'application/json' ] ; $ headers = array_merge ( $ headers , $ defaultHeaders ) ; return $ this -> client -> post ( $ uri , [ 'headers' =... | Execute a POST request with the given parameters . |
5,244 | protected function getCompiler ( ) { if ( $ this -> compiler === null ) { $ this -> compiler = new Compiler ( ) ; $ this -> compiler -> setFormatter ( $ this -> formatter ) ; } return $ this -> compiler ; } | Get the SCSS compiler . |
5,245 | public static function bootEloquentUuid ( ) { static :: creating ( function ( $ model ) { $ model -> incrementing = false ; $ model -> { $ model -> getKeyName ( ) } = ( string ) Uuid :: uuid4 ( ) ; } ) ; } | Boot EloquentUuid trait for the model . |
5,246 | public function onBootstrap ( MvcEvent $ e ) { $ config = $ e -> getApplication ( ) -> getServiceManager ( ) -> get ( 'Config' ) ; if ( ! empty ( $ config [ $ this -> configKey ] ) ) { $ phpSettings = ( array ) $ config [ $ this -> configKey ] ; foreach ( $ phpSettings as $ key => $ value ) { @ ini_set ( $ key , $ valu... | Event callback to be triggered on bootstrap |
5,247 | public static function __callstatic ( $ method , $ arguments ) { $ content = count ( $ arguments ) ? $ arguments [ 0 ] : null ; return self :: createSub ( $ method , $ content ) ; } | Generates the markup for an XML element . |
5,248 | public function timerAdd ( array $ tags , $ value ) { if ( $ this -> isEnabled ( ) ) { $ tags = array_merge ( $ tags , $ this -> getPinboardTags ( ) ) ; return pinba_timer_add ( $ tags , $ value ) ; } else { return null ; } } | Creates new timer . This timer is already stopped and have specified time value . |
5,249 | public function editorAction ( Request $ request , Template $ template ) { $ form = $ this -> createForm ( new PageManagerType , $ template ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ this -> get ( 'opifer.content.block_manager' ) -> save ( $ template ) ; } $ parameters = [ 'subject' =>... | Graphical Template editor |
5,250 | private function _setRequest ( ) { if ( $ this -> _requestUri !== NULL ) { $ this -> _request = preg_replace ( '#(^/)|(^' . ROOT . ')|(/$)#' , '' , $ this -> _requestUri ) ; if ( ! $ this -> _request ) { $ this -> _request = self :: DEFAULT_MODULE . '/' . self :: DEFAULT_VIEW ; } $ this -> _requestVars = explode ( '/' ... | Save the request string and an equivalent as array . |
5,251 | private function _setModule ( ) { if ( preg_match ( '/^[a-z0-9_-]+$/' , $ this -> _requestVars [ 0 ] ) ) { $ this -> _module = $ this -> _requestVars [ 0 ] ; } else { $ this -> _module = $ this -> _requestVars [ 0 ] = self :: DEFAULT_MODULE ; } return $ this ; } | Check the module syntax and save it . |
5,252 | private function _setView ( ) { if ( preg_match ( '/^[a-z0-9_-]+$/' , $ this -> _requestVars [ 1 ] ) ) { $ this -> _view = $ this -> _requestVars [ 1 ] ; } else { $ this -> _view = $ this -> _requestVars [ 1 ] = self :: DEFAULT_VIEW ; } return $ this ; } | Check the view syntax and save it . |
5,253 | private function _setParams ( ) { foreach ( $ _GET as $ key => $ value ) { $ this -> _params [ $ key ] = $ this -> _sanitize ( $ value ) ; } foreach ( $ _POST as $ key => $ value ) { $ _POST [ $ key ] = $ this -> _sanitize ( $ value ) ; } $ nbElements = count ( $ this -> _requestVars ) ; if ( $ nbElements > 3 ) { $ i =... | Save the URL params and sanitize POST and GET values . |
5,254 | private function _sanitize ( $ pValue ) { $ value = trim ( $ pValue ) ; $ value = htmlspecialchars ( $ value , ENT_QUOTES , 'UTF-8' ) ; $ value = ( string ) $ value ; return $ value ; } | Sanitize the given value . |
5,255 | public function getAction ( ) { $ action = strtolower ( $ this -> getParam ( self :: ACTION_PARAM ) ) ; if ( $ action === '' or ! preg_match ( '/^[a-z0-9_-]+$/' , $ action ) ) { return Controller :: DEFAULT_ACTION ; } return $ action ; } | Return the requested action or the default action . |
5,256 | public function addItem ( $ title ) { if ( is_object ( $ title ) && $ title instanceof Item ) { $ item = $ title ; } else { $ item = new Item ( $ this , $ title ) ; } $ this -> item_collection -> push ( $ item ) ; return $ item ; } | Add item to the menu . |
5,257 | public function filter ( $ property_name , $ value , $ include_children = false ) { $ filter_result = new Collection ( ) ; $ this -> item_collection -> filter ( function ( $ item ) use ( $ property_name , $ value , $ include_children , & $ filter_result ) { if ( ! isset ( $ item -> $ property_name ) ) { return false ; ... | Filter items by property . |
5,258 | public function setAttribute ( $ name , ... $ value ) { $ value = is_array ( array_get ( $ value , 0 , '' ) ) ? array_get ( $ value , 0 ) : $ value ; $ this -> updateAttribute ( $ name , $ value , $ this -> getAttributeValueSeparator ( $ name ) ) ; return $ this ; } | Set attribute by name . |
5,259 | public function addAttribute ( $ name , ... $ value ) { $ value = is_array ( array_get ( $ value , 0 , '' ) ) ? array_get ( $ value , 0 ) : $ value ; list ( $ current_value , $ separator ) = $ this -> manipulateAttribute ( $ name , $ value ) ; foreach ( $ value as $ attribute_value ) { $ current_value [ ] = $ attribute... | Add attribute by name . |
5,260 | public function removeAttribute ( $ name , $ value ) { list ( $ current_value , $ separator ) = $ this -> manipulateAttribute ( $ name , $ value ) ; $ this -> updateAttribute ( $ name , $ current_value , $ separator ) ; return $ this ; } | Remove attribute by name . |
5,261 | public function appendAttribute ( $ name , ... $ value ) { list ( $ current_value , $ separator ) = $ this -> manipulateAttribute ( $ name , $ value ) ; foreach ( $ value as $ attribute_value ) { $ current_value [ ] = $ attribute_value ; } $ this -> updateAttribute ( $ name , $ current_value , $ separator ) ; return $ ... | Append to attribute by name . |
5,262 | public function prependAttribute ( $ name , ... $ value ) { list ( $ current_value , $ separator ) = $ this -> manipulateAttribute ( $ name , $ value ) ; foreach ( $ value as $ attribute_value ) { array_unshift ( $ current_value , $ attribute_value ) ; } $ this -> updateAttribute ( $ name , $ current_value , $ separato... | Prepend to attribute by name . |
5,263 | private function manipulateAttribute ( $ name , $ value ) { $ current_value = array_get ( $ this -> attribute , $ name , '' ) ; $ separator = ( strlen ( trim ( $ current_value ) ) > 0 ) ? $ this -> getAttributeValueSeparator ( $ name ) : '' ; $ current_value = $ separator !== '' ? explode ( $ separator , $ current_valu... | Clean attribute value before required change . |
5,264 | private function updateAttribute ( $ name , $ value , $ separator ) { array_set ( $ this -> attribute , $ name , implode ( $ separator , $ value ) ) ; return $ this ; } | Update attribute by name . |
5,265 | public function render ( $ parent_id = false ) { $ container_tag = array_get ( $ this -> option , 'tag' , 'ul' ) ; $ item_tag = array_get ( $ this -> option , 'item_tag' , 'li' ) ; $ item_callback = array_get ( $ this -> option , 'item_callback' , null ) ; $ text_only = array_get ( $ this -> option , 'text_only' , fals... | Render this menu and it s children . |
5,266 | public function processForm ( FormInterface $ form , $ andFlush = true ) { $ data = $ form -> getData ( ) ; $ this -> save ( $ data ) ; return $ data ; } | Process the Form and return the persisted MediaProvider |
5,267 | public function save ( MediaProviderInterface $ mediaProvider , $ andFlush = true ) { $ context = $ mediaProvider -> getMedia ( ) -> getContext ( ) ; $ provider = $ this -> providerService -> getProviderManager ( $ context ) ; if ( null !== $ mediaProvider -> getMedia ( ) -> getFile ( ) ) { $ this -> uploadProcess ( $ ... | Execute the full process for upload and persist MediaProvider |
5,268 | public function createAction ( ) { $ request = $ this -> getRequest ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\Paragraph\Model\Snippet\Model' ) ; $ snippet = $ model -> create ( ) ; $ form = $ locator -> get ( 'Form' ) -> create ( 'Grid\Paragraph\Snippet\Create' ) ; $ form ->... | Create a snippet |
5,269 | public function uploadAction ( ) { $ request = $ this -> getRequest ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\Paragraph\Model\Snippet\Model' ) ; $ snippet = $ model -> create ( ) ; $ form = $ locator -> get ( 'Form' ) -> create ( 'Grid\Paragraph\Snippet\Upload' ) ; $ form ->... | Upload a snippet |
5,270 | public function editAction ( ) { static $ typeToMime = array ( 'css' => 'text/css' , 'js' => 'text/javascript' , ) ; $ params = $ this -> params ( ) ; $ request = $ this -> getRequest ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\Paragraph\Model\Snippet\Model' ) ; $ snippet = $ ... | Edit a snippet |
5,271 | public function setLogLevelFile ( $ level , $ filename ) { $ dir = dirname ( $ this -> defaultFile ) ; if ( ! is_array ( $ level ) ) { $ level = array ( $ level ) ; } foreach ( $ level as $ loglevel ) { $ this -> filenameLevels [ $ loglevel ] = $ dir . DIRECTORY_SEPARATOR . $ filename ; } } | Assign a file for specific log levels |
5,272 | public function separateLogFiles ( $ ext = '.txt' ) { foreach ( $ this -> filenameLevels as $ level => $ filename ) { $ this -> setLogLevelFile ( $ level , $ level . $ ext ) ; } } | Convenience function to make each log level go to a separate file . It uses the directory name of the current default file . |
5,273 | public function write ( $ level , $ message , array $ context = array ( ) ) { $ filename = $ this -> filenameLevels [ $ level ] ? : $ this -> defaultFile ; $ context = array ( '__context' => $ context ) ; $ log = $ this -> format ( $ level , $ message , $ context ) ; $ logDir = dirname ( $ filename ) ; if ( ! is_dir ( ... | Write the logs to a file |
5,274 | public function getParam ( string $ param ) { $ result = $ this -> getConfig ( ) -> get ( $ param ) ; return $ result ?? null ; } | Get some parameter from config by keyname |
5,275 | function getBasename ( ) { $ filename = $ this -> getFilename ( ) ; $ extension = $ this -> getExtension ( ) ; return ( $ extension === '' || $ extension === null ) ? $ filename : $ filename . '.' . $ extension ; } | Get Filename Include File Extension |
5,276 | public function beforePrepare ( Event $ event ) { $ command = $ event [ 'command' ] ; if ( $ command -> getName ( ) !== 'createEntity' ) return ; if ( ! $ command [ '_id' ] ) return ; $ operation = $ command -> getOperation ( ) ; $ operation -> setHttpMethod ( 'PUT' ) ; } | If an entity create request is made with an ID parameter change the HTTP method from POST to PUT . This allows adding entities with custom IDs . |
5,277 | public function reverseTransform ( $ image ) { if ( null === $ image ) { return null ; } $ filename = $ image -> getFilename ( ) ; if ( empty ( $ filename ) ) { return null ; } if ( $ this -> preFilename && ( $ this -> preFilename !== $ filename ) ) { $ this -> imageManager -> remove ( $ image ) ; } $ image = $ this ->... | Reverse transform . |
5,278 | public function fonts ( WP_Customize_Manager $ wp_customize ) { if ( ! $ this -> fonts || ! $ this -> font_types ) { return ; } $ wp_customize -> add_section ( 'fonts' , array ( 'title' => esc_html__ ( 'Fonts' , 'rock' ) , 'priority' => 40 , ) ) ; foreach ( $ this -> font_types as $ name => $ args ) { if ( empty ( $ na... | Register fonts section and settings . |
5,279 | public function get_default_font ( $ font_type ) { $ defaults = array_combine ( array_keys ( $ this -> font_types ) , wp_list_pluck ( $ this -> font_types , 'default' ) ) ; $ default = isset ( $ defaults [ $ font_type ] ) ? $ defaults [ $ font_type ] : $ this -> fonts [ 0 ] ; return $ this -> sanitize_font ( $ default ... | Return the default font for a given font type . |
5,280 | public function get_font_weights ( $ font , $ font_type ) { $ weights = ( array ) apply_filters ( 'rock_font_weights' , array ( 300 , 400 , 700 ) , $ font , $ font_type ) ; $ weights = array_filter ( array_map ( 'absint' , $ weights ) ) ; sort ( $ weights ) ; return $ weights ; } | Return an array of weights for a font . |
5,281 | public function enqueue_google_fonts ( ) { $ font_families = array ( ) ; foreach ( $ this -> font_types as $ name => $ args ) { if ( empty ( $ name ) ) { continue ; } $ font = $ this -> get_font ( $ name ) ; $ weights = $ this -> get_font_weights ( $ font , $ name ) ; $ font_families [ $ font ] = isset ( $ font_familie... | Enqueue Google Fonts . |
5,282 | public function enqueue_inline_css ( ) { foreach ( $ this -> font_types as $ name => $ args ) { if ( empty ( $ name ) || empty ( $ args [ 'css' ] ) ) { continue ; } $ css = sprintf ( Rock_Customizer :: parse_css_rules ( $ args [ 'css' ] ) , $ this -> get_font ( $ name ) ) ; wp_add_inline_style ( Rock_Customizer :: $ st... | Add inline CSS for the font customizations . |
5,283 | public function ttl ( $ key , $ db = - 1 ) { if ( - 1 != $ db ) { $ this -> execute ( 'select' , array ( $ db ) ) ; } return $ this -> execute ( 'ttl' , array ( $ key ) ) ; } | Get time to live |
5,284 | public function setInstance ( Instance $ instance ) { $ this -> instance = $ instance ; $ this -> exception = null ; $ this -> connect ( ) ; return $ this ; } | Set current instance |
5,285 | protected function connect ( ) { $ this -> client = new Client ( array ( 'host' => $ this -> instance -> getHost ( ) , 'port' => $ this -> instance -> getPort ( ) , ) ) ; } | Connect redis client to the server |
5,286 | public function parse ( $ file ) { $ this -> reader -> open ( $ file ) ; $ parsed = $ this -> reader -> parse ( ) ; $ data = $ this -> parseElements ( $ parsed [ 'value' ] ) ; return $ this -> collection ; } | Parse a . gim file |
5,287 | public function parseElements ( array $ elements , ElementInterface $ parent = null ) { foreach ( $ elements as $ element ) { try { $ object = $ this -> elementFactory -> make ( $ element [ 'name' ] ) ; } catch ( InvalidElementException $ e ) { $ object = $ this -> getReservation ( $ element [ 'name' ] ) ; } $ object -... | Parse the elements retrieved from a parsed . gim file |
5,288 | public function getReservation ( $ name ) { if ( array_key_exists ( $ name , $ this -> reservations ) ) { return $ this -> reservations [ $ name ] ; } throw new InvalidElementException ( "Element '{$name}' does not exist" ) ; } | Get a reservation by name |
5,289 | public function findOpenForBuyer ( Profile $ seller ) { $ qb = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) ; $ orderStatuses = array_merge ( Order :: getOpenStatusCodes ( ) , array ( Order :: STATUS_PICKED_UP_FROM_HUB , Order :: STATUS_COMPLETED , ) ) ; $ qb -> from ( 'HarvestCloudCoreBundle:Order' , 'o' )... | Get open orders for Buyer |
5,290 | public function findForBuyer ( Profile $ buyer ) { $ qb = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) ; $ qb -> from ( 'HarvestCloudCoreBundle:Order' , 'o' ) -> select ( 'o' ) -> where ( 'o.buyer = :buyer' ) -> andWhere ( 'o.status_code != :cart' ) -> orderBy ( 'o.id' , 'DESC' ) -> setParameter ( 'buyer' ,... | Get orders for Buyer |
5,291 | public function findOpenForSeller ( Profile $ seller ) { $ qb = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) ; $ qb -> from ( 'HarvestCloudCoreBundle:Order' , 'o' ) -> select ( 'o' ) -> join ( 'o.seller' , 's' ) -> orderBy ( 'o.id' , 'DESC' ) -> where ( $ qb -> expr ( ) -> in ( 'o.status_code' , Order :: ge... | Get open orders for Seller |
5,292 | public function findOpenForHub ( Profile $ hub ) { $ qb = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) -> from ( 'HarvestCloudCoreBundle:Order' , 'o' ) -> select ( 'o' ) ; $ q = $ qb -> getQuery ( ) ; return $ q -> execute ( ) ; } | Get open orders for Hub |
5,293 | public function filterFields ( FieldBag $ fields ) { $ allFields = $ this -> getModule ( ) -> getOption ( 'model_fields' ) ; $ filteredFields = new FieldBag ( ) ; foreach ( $ fields as $ name => $ field ) { if ( ! $ allFields -> has ( $ name ) ) { throw new \ RuntimeException ( sprintf ( 'The field "%s" does not exist.... | Filters the global fields . |
5,294 | public function init ( ) { $ this -> routes = $ this -> routes -> getRouteCollections ( ) ; $ this -> dispatcher = $ this -> createDispatcher ( ) ; $ this -> currentURL = $ this -> request -> getPathInfo ( ) ; $ this -> dispatch ( ) ; } | Init the router . |
5,295 | protected function createDispatcher ( ) { $ options = array ( ) ; $ options += [ 'routeParser' => 'FastRoute\\RouteParser\\Std' , 'dataGenerator' => 'FastRoute\\DataGenerator\\GroupCountBased' , 'dispatcher' => 'FastRoute\\Dispatcher\\GroupCountBased' , ] ; $ routeCollector = new RouteCollector ( new $ options [ 'route... | Create dispatcher for router . |
5,296 | protected function dispatch ( ) { $ routeInfo = $ this -> dispatcher -> dispatch ( $ _SERVER [ 'REQUEST_METHOD' ] , $ this -> currentURL ) ; switch ( $ routeInfo [ 0 ] ) { case Dispatcher :: NOT_FOUND : break ; case Dispatcher :: METHOD_NOT_ALLOWED : $ allowedMethods = $ routeInfo [ 1 ] ; break ; case Dispatcher :: FOU... | Run the router try to match current request path with registered route . |
5,297 | protected function handle ( $ handler , $ vars ) { if ( is_callable ( $ handler ) ) { return call_user_func_array ( $ handler , $ vars ) ; } elseif ( is_string ( $ handler ) ) { if ( ! strpos ( $ handler , '@' ) ) { $ handler = $ handler . '@index' ; } list ( $ controller , $ method ) = explode ( '@' , $ handler ) ; $ ... | Handle routeHandler Callable . |
5,298 | private function overrideMethods ( array $ mockedMethods = null ) { foreach ( $ this -> extends as $ className ) { $ reflectedClass = new ReflectionClass ( $ className ) ; foreach ( $ reflectedClass -> getMethods ( ) as $ reflectedMethod ) { if ( $ mockedMethods !== null && ! in_array ( $ reflectedMethod -> getName ( )... | Override the already - defined methods in the class unless mockedMethods is provided in which case only those methods are overridden . |
5,299 | public function buildMethods ( ) { $ methods = "" ; foreach ( $ this -> methods as $ method ) { $ methods .= "\n" . $ method -> build ( ) ; } $ call = "" ; if ( ! array_key_exists ( '__call' , $ this -> methods ) ) { $ call = "public function __call(\$method, \$args) { try { return \$t... | Build a string containing method bodies required to create a mocked version of the class |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.