idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
3,700 | public function setHour ( $ hour ) { if ( ! in_array ( $ hour , range ( 0 , 23 ) ) ) { throw new InvalidArgumentException ( 'Hour must be between 0 and 23' ) ; } $ this -> hour = $ hour ; return $ this ; } | Sets hour of repetition |
3,701 | protected function processModuleSorting ( ) { $ this -> model [ 'is_listified' ] = false ; $ this -> model [ 'ordered_by' ] = [ ] ; if ( $ this -> module [ 'max_entries' ] == 1 ) { return ; } if ( $ this -> module [ 'sort_entries_manually' ] ) { $ this -> model [ 'is_listified' ] = true ; return ; } $ this -> model [ '... | Determines and stores information about the sorting configuration found for entries of the module |
3,702 | protected function prepareModelOverrides ( ) { $ this -> overrides = $ this -> getOverrideConfigForModel ( $ this -> moduleId ) ; if ( array_key_exists ( 'name' , $ this -> overrides ) ) { $ name = $ this -> overrides [ 'name' ] ; } else { $ name = array_get ( $ this -> module , 'prefixed_name' ) ? : $ this -> model [ ... | Prepares override cache for current model being assembled |
3,703 | protected function applyOverridesForRelationships ( ) { $ overrides = array_get ( $ this -> overrides , 'relationships' ) ; if ( empty ( $ overrides ) ) return ; $ removeRelations = [ ] ; foreach ( $ overrides as $ overrideName => $ override ) { foreach ( [ 'normal' , 'image' , 'file' , 'checkbox' ] as $ type ) { forea... | Applies overrides set in the config for analyzed relationships |
3,704 | protected function multipleBelongsToRelationsBetweenModels ( $ fromModuleId , $ toModuleId ) { $ count = 0 ; foreach ( $ this -> context -> output [ 'models' ] [ $ fromModuleId ] [ 'relationships' ] [ 'normal' ] as $ relationship ) { if ( $ relationship [ 'model' ] == $ toModuleId && $ relationship [ 'type' ] == Genera... | Returns whether there are multiple relationships from one model to the other |
3,705 | protected function getImageResizesForField ( $ fieldId ) { if ( ! array_key_exists ( 'resizes' , $ this -> data -> rawData [ 'fields' ] [ $ fieldId ] ) || ! count ( $ this -> data -> rawData [ 'fields' ] [ $ fieldId ] [ 'resizes' ] ) ) { return [ ] ; } $ resizes = [ ] ; foreach ( $ this -> data -> rawData [ 'fields' ] ... | Returns data about resizes for an image field |
3,706 | protected function checkForReservedClassName ( $ name ) { $ name = trim ( strtolower ( $ name ) ) ; if ( in_array ( $ name , config ( 'pxlcms.generator.reserved' , [ ] ) ) ) { throw new \ InvalidArgumentException ( "Cannot use {$name} as a module name, it is reserved!" ) ; } } | Checks whether a given name is on the reserved list |
3,707 | private function extended ( callable $ previous = null , callable $ current ) : callable { return is_null ( $ previous ) ? $ current : new Extension ( $ current , $ previous ) ; } | Return the previous service factory extended with the current service factory . |
3,708 | final public static function get_header_string ( int $ code ) { if ( ! isset ( self :: $ header_string [ $ code ] ) ) $ code = 404 ; return [ 'code' => $ code , 'msg' => self :: $ header_string [ $ code ] , ] ; } | Get HTTP code . |
3,709 | public static function start_header ( int $ code = 200 , int $ cache = 0 , array $ headers = [ ] ) { $ msg = 'OK' ; extract ( self :: get_header_string ( $ code ) ) ; $ proto = isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ? $ _SERVER [ 'SERVER_PROTOCOL' ] : 'HTTP/1.1' ; static :: header ( "$proto $code $msg" ) ; if ( $ ca... | Start sending response headers . |
3,710 | public static function send_file ( string $ fpath , $ disposition = null , int $ code = 200 , int $ cache = 0 , array $ headers = [ ] , bool $ xsendfile = null , callable $ callback_notfound = null ) { if ( ! file_exists ( $ fpath ) || is_dir ( $ fpath ) ) { static :: start_header ( 404 , 0 , $ headers ) ; if ( is_call... | Send file . |
3,711 | final public static function print_json ( int $ errno = 0 , $ data = null , int $ http_code = 200 , int $ cache = 0 ) { $ json = json_encode ( compact ( 'errno' , 'data' ) ) ; self :: start_header ( $ http_code , $ cache , [ 'Content-Length: ' . strlen ( $ json ) , 'Content-Type: application/json' , ] ) ; static :: hal... | Convenience method for JSON response . |
3,712 | final public static function pj ( $ retval , int $ forbidden_code = null , int $ cache = 0 ) { $ http_code = 200 ; if ( ! is_array ( $ retval ) ) { $ retval = [ - 1 , null ] ; $ forbidden_code = 500 ; } if ( $ retval [ 0 ] !== 0 ) { $ http_code = 401 ; if ( $ forbidden_code ) $ http_code = $ forbidden_code ; } if ( ! i... | Even shorter JSON response formatter . |
3,713 | public function all ( ) { $ pluggables = [ ] ; $ allPlugs = $ this -> getAllBaseNames ( ) ; foreach ( $ allPlugs as $ plug ) { $ pluggables [ ] = $ this -> getJsonContents ( $ plug ) ; } return new Collection ( $ this -> sortByOrder ( $ pluggables ) ) ; } | Get all the pluggables . |
3,714 | protected function getAllBaseNames ( ) { $ pluggables = [ ] ; $ path = $ this -> getPath ( ) ; if ( ! is_dir ( $ path ) ) { return $ pluggables ; } $ folders = $ this -> files -> directories ( $ path ) ; foreach ( $ folders as $ plug ) { $ pluggables [ ] = basename ( $ plug ) ; } return $ pluggables ; } | Get all pluggable basenames . |
3,715 | protected function getAllSlugs ( ) { $ pluggables = $ this -> all ( ) ; $ slugs = [ ] ; foreach ( $ pluggables as $ plug ) { $ slugs [ ] = $ plug [ 'slug' ] ; } return $ slugs ; } | Get all pluggable slugs . |
3,716 | protected function pathExists ( $ folder ) { $ folder = Str :: studly ( $ folder ) ; return in_array ( $ folder , $ this -> getAllBaseNames ( ) ) ; } | Check if given pluggable path exists . |
3,717 | public function getPluggablePath ( $ slug , $ allowNotExists = false ) { $ pluggable = Str :: studly ( $ slug ) ; if ( ! $ this -> pathExists ( $ pluggable ) && $ allowNotExists === false ) { return ; } return $ this -> getPath ( ) . "/{$pluggable}/" ; } | Get path for the specified pluggable . |
3,718 | public function getProperty ( $ property , $ default = null ) { list ( $ pluggable , $ key ) = explode ( '::' , $ property ) ; return array_get ( $ this -> getJsonContents ( $ pluggable ) , $ key , $ default ) ; } | Get a pluggable property value . |
3,719 | public function setProperty ( $ property , $ value ) { list ( $ pluggable , $ key ) = explode ( '::' , $ property ) ; $ content = $ this -> getJsonContents ( $ pluggable ) ; if ( count ( $ content ) ) { if ( isset ( $ content [ $ key ] ) ) { unset ( $ content [ $ key ] ) ; } $ content [ $ key ] = $ value ; $ this -> se... | Set a pluggale property value . |
3,720 | public function getByEnabled ( $ enabled = true ) { $ disabledPluggables = [ ] ; $ enabledPluggables = [ ] ; $ pluggables = $ this -> all ( ) ; foreach ( $ pluggables as $ pluggable ) { if ( $ this -> isEnabled ( $ pluggable [ 'slug' ] ) ) { $ enabledPluggables [ ] = $ pluggable ; } else { $ disabledPluggables [ ] = $ ... | Find a pluggable with enabled status given . |
3,721 | protected function getJsonContents ( $ pluggable ) { $ pluggable = Str :: studly ( $ pluggable ) ; $ default = [ ] ; if ( ! $ this -> pathExists ( $ pluggable ) ) { return $ default ; } $ path = $ this -> getJsonPath ( $ pluggable ) ; if ( $ this -> files -> exists ( $ path ) ) { $ contents = $ this -> files -> get ( $... | Get pluggable JSON content as an array . |
3,722 | public function sortByOrder ( $ pluggables ) { $ orderedPluggables = [ ] ; foreach ( $ pluggables as $ pluggable ) { if ( ! isset ( $ pluggable [ 'order' ] ) ) { $ pluggable [ 'order' ] = 9001 ; } $ orderedPluggables [ ] = $ pluggable ; } if ( count ( $ orderedPluggables ) > 0 ) { $ orderedPluggables = $ this -> arrayO... | Sort pluggables by order . |
3,723 | protected function arrayOrderBy ( ) { $ arguments = func_get_args ( ) ; $ data = array_shift ( $ arguments ) ; foreach ( $ arguments as $ argument => $ field ) { if ( is_string ( $ field ) ) { $ temp = [ ] ; foreach ( $ data as $ key => $ row ) { $ temp [ $ key ] = $ row [ $ field ] ; } $ arguments [ $ argument ] = $ t... | Helper method to order multiple values easily . |
3,724 | public function listPayments ( $ userId , $ monetaryAccountId ) { $ payments = $ this -> client -> get ( $ this -> getResourceEndpoint ( $ userId , $ monetaryAccountId ) ) ; foreach ( $ payments [ 'Response' ] as $ key => $ payment ) { $ payments [ 'Response' ] [ $ key ] [ 'Payment' ] [ 'amount' ] [ 'value' ] = $ this ... | Lists all payments . |
3,725 | public function getPayment ( $ userId , $ monetaryAccountId , $ id ) { $ paymentResponse = $ this -> client -> get ( $ this -> getResourceEndpoint ( $ userId , $ monetaryAccountId ) . '/' . ( int ) $ id ) ; $ payment = $ paymentResponse [ 'Response' ] [ 0 ] [ 'Payment' ] ; $ payment [ 'amount' ] [ 'value' ] = $ this ->... | Gets a user its payment information . |
3,726 | public function changeNodeNameAction ( ) { $ nodeName = $ this -> bodyParam ( 'node_name' ) ; if ( ! is_string ( $ nodeName ) || strlen ( $ nodeName ) < 3 ) { return new ApiProblemResponse ( new ApiProblem ( 422 , $ this -> translator -> translate ( 'The node name must be at least 3 characters long' ) ) ) ; } $ this ->... | Handles a POST request that want to change the node name |
3,727 | public function configureJavascriptTickerAction ( ) { $ tickerEnabled = $ this -> bodyParam ( 'enabled' ) ; $ tickerInterval = $ this -> bodyParam ( 'interval' ) ; if ( ! is_bool ( $ tickerEnabled ) ) { return new ApiProblemResponse ( new ApiProblem ( 422 , $ this -> translator -> translate ( 'The enabled flag should b... | Handles a POST request to configure the javascript ticker |
3,728 | public function configureWorkflowProcessorMessageQueueAction ( ) { $ queueEnabled = $ this -> bodyParam ( 'enabled' ) ; if ( ! is_bool ( $ queueEnabled ) ) { return new ApiProblemResponse ( new ApiProblem ( 422 , $ this -> translator -> translate ( 'The enabled flag should be a boolean value' ) ) ) ; } if ( $ queueEnab... | Handles a POST request to enable or disable the workflow processor message queue |
3,729 | public static function log ( $ message , $ args = null ) { if ( getenv ( 'DEBUG' ) || getenv ( 'OPENCART_INSTALLER_DEBUG' ) ) { if ( $ args ) { if ( ! is_array ( $ args ) ) { $ args = array ( $ args ) ; } $ message = vsprintf ( $ message , $ args ) ; } echo 'OpencartInstaller: ' . $ message . PHP_EOL ; } } | Writes debug message to stdout . |
3,730 | function submitFoundationForm ( $ data , $ form ) { if ( isset ( $ data [ 'SecurityID' ] ) ) { unset ( $ data [ 'SecurityID' ] ) ; } Session :: set ( 'FoundationForm' . $ this -> ID , $ data ) ; return $ this -> redirect ( $ this -> Link ( ) ) ; } | submit the form and redirect back to the form |
3,731 | protected function parseRuleString ( $ ruleString ) { $ charset = $ this -> getCharset ( ) ; $ ruleString = preg_replace ( '/^[ \r\n\t\f]*@import[ \r\n\t\f]+/i' , '' , $ ruleString ) ; $ ruleString = trim ( $ ruleString , " \r\n\t\f" ) ; $ ruleString = rtrim ( $ ruleString , ";" ) ; $ isEscaped = false ; $ inFunction =... | Parses the import rule . |
3,732 | public function markdown ( $ markdown , $ page = null ) { $ file = $ markdown . '.md' ; if ( isset ( $ page ) ) { $ file = $ page . '/' . $ markdown . '.md' ; } if ( ! Storage :: disk ( 'markdown' ) -> exists ( $ file ) ) { return false ; } $ array = $ this -> markdownToArray ( $ file ) ; return $ array ; } | Parses and output a markdown file |
3,733 | public function markdownLink ( $ file_path , $ type = '' ) { $ array = explode ( '/' , $ file_path ) ; $ dir = $ array [ 0 ] ; $ replace = array ( '-' , '_' ) ; $ url = trim ( $ dir , '.md' ) ; $ display_name = str_replace ( $ replace , ' ' , trim ( $ dir , '.md' ) ) ; if ( count ( $ array ) > 1 ) { $ name = trim ( $ a... | Converts a give md file path to a link |
3,734 | public function markdownMenu ( $ dir = null ) { $ md_files = $ this -> markdownFiles ( $ dir ) ; $ links = [ ] ; foreach ( $ md_files as $ file ) { $ links [ ] = $ this -> markdownLink ( $ file , $ this -> type ) ; } return $ links ; } | Returns an list or directory of array of markdown files |
3,735 | public function markdownPosts ( $ dir = null ) { $ source = collect ( $ this -> markdownFiles ( $ dir ) ) ; if ( empty ( $ source ) ) { return false ; } $ files = $ source -> map ( function ( $ file ) { $ array = $ this -> markdownToArray ( $ file ) ; $ arr [ 'url' ] = $ array [ 'url' ] ; $ arr [ 'last_modified' ] = $ ... | Return and array of markdown |
3,736 | public function markdownToArray ( $ file ) { $ markdown = $ this -> markdown -> transform ( Storage :: disk ( 'markdown' ) -> get ( $ file ) ) ; $ array = explode ( "\n" , $ markdown ) ; $ data [ 'url' ] = $ this -> markdownLink ( $ file , 'url' ) ; $ data [ 'last_modified' ] = date ( 'Y-m-d' , Storage :: disk ( 'markd... | Takes a markdown and converts it to array |
3,737 | public function setFilters ( $ filters ) { if ( ! is_array ( $ filters ) ) { $ this -> clearFilters ( ) ; foreach ( explode ( '|' , $ filters ) as $ filter ) { $ params = [ ] ; if ( strpos ( $ filter , ':' ) ) { list ( $ filter , $ params ) = explode ( ':' , $ filter ) ; $ params = ( array ) explode ( ',' , $ params ) ... | Set all filter as an array |
3,738 | public function addFilter ( $ index , $ method = null , ... $ params ) { $ this -> filters [ $ index ] = [ $ method , $ params ] ; return $ this ; } | Add a single filter to the filters container |
3,739 | public function getFilter ( $ index ) { if ( ! $ this -> hasFilter ( $ index ) ) { throw new \ Exception ( 'Impossible de trouver le filtre : ' . $ index ) ; } return $ this -> filters [ $ index ] ; } | Return the filter from the filters container from the filter container |
3,740 | public function filter ( $ value ) { foreach ( $ this -> getFilters ( ) as $ index => $ filter ) { list ( $ method , $ params ) = $ filter ; $ method = is_null ( $ method ) ? $ index : $ method ; array_unshift ( $ params , $ value ) ; if ( ! is_string ( $ method ) && is_callable ( $ method ) ) { $ value = call_user_fun... | Filter de value |
3,741 | public function dateFormat ( $ value , $ format = 'd/m/Y' ) { if ( ! empty ( $ value ) ) { if ( strlen ( $ value ) == 10 ) { $ value .= ' 00:00:00' ; } if ( $ value == '0000-00-00 00:00:00' ) { $ value = '' ; } else { $ date = \ DateTime :: createFromFormat ( 'Y-m-d H:i:s' , $ value ) ; if ( $ date !== false && ! array... | Format a date |
3,742 | public function addServer ( int $ engine , string $ host = "127.0.0.1" , int $ port = 0 ) : Server { $ this -> servers [ ] = new Server ( $ engine , $ host , $ port ) ; return end ( $ this -> servers ) ; } | Add a server to connection queue |
3,743 | public function isConnected ( ) : bool { if ( $ this -> engine ) { $ connected = $ this -> engine -> isConnected ( ) ; if ( ! $ connected ) { $ this -> engine = null ; } return $ connected ; } return false ; } | Check connection status |
3,744 | public function ping ( bool $ reconnect = false ) : bool { if ( $ this -> engine ) { $ ping = $ this -> engine -> ping ( ) ; if ( ! $ ping ) { $ this -> engine = null ; if ( $ reconnect ) { $ this -> connect ( ) ; } } return $ ping ; } return false ; } | Ping Cache Server |
3,745 | public function has ( string $ key ) : bool { $ this -> checkConnection ( __METHOD__ ) ; return $ this -> engine -> has ( $ key ) ; } | Checks if a data exists on cache server corresponding to provided key |
3,746 | public function delete ( string $ key ) : bool { $ this -> checkConnection ( __METHOD__ ) ; $ delete = $ this -> engine -> delete ( $ key ) ; if ( $ delete && $ this -> index ) { $ this -> index -> events ( ) -> trigger ( Indexing :: EVENT_ON_DELETE ) -> params ( $ key ) -> fire ( ) ; } return $ delete ; } | Delete an stored item with provided key on cache server |
3,747 | public function flush ( ) : bool { $ this -> checkConnection ( __METHOD__ ) ; $ flush = $ this -> engine -> flush ( ) ; if ( $ flush && $ this -> index ) { $ this -> index -> events ( ) -> trigger ( Indexing :: EVENT_ON_FLUSH ) -> fire ( ) ; } return $ flush ; } | Flushes all stored data from cache server |
3,748 | public function countUp ( string $ key , int $ inc = 1 ) : int { $ this -> checkConnection ( __METHOD__ ) ; return $ this -> engine -> countUp ( $ key , $ inc ) ; } | Increase stored integer value If key doesn t already exist a new key will be created with value 0 before increment |
3,749 | public function countDown ( string $ key , int $ dec = 1 ) : int { $ this -> checkConnection ( __METHOD__ ) ; return $ this -> engine -> countDown ( $ key , $ dec ) ; } | Decrease stored integer value If key doesn t already exist a new key will be created with value 0 before decrement |
3,750 | public function setCacheableIdentifier ( string $ id = null , int $ length = null ) : self { if ( $ id ) { if ( ! preg_match ( '/^[a-zA-Z0-9\_\-\~\.]{8,32}$/' , $ id ) ) { throw new CacheException ( 'Invalid value passed to "setCacheableIdentifier" method' ) ; } $ this -> cacheableId = $ id ; $ this -> cacheableIdLengt... | Set custom identifier for objects extending CacheableInterface |
3,751 | private function setObject ( array $ data ) { $ identifierAttribute = $ this -> configuration -> getIdentifierAttribute ( ) ; if ( $ identifierAttribute === null ) { throw new UndefinedIdentifierAttribute ( ) ; } if ( isset ( $ data [ $ identifierAttribute ] ) === true ) { return $ this -> setObjectForObjectData ( $ id... | Create class object with data |
3,752 | public function icon ( $ icon , $ is_icon_only = true ) { $ this -> setIcon ( $ icon ) ; ( $ is_icon_only ) ? $ this -> enableIconOnly ( ) : $ this -> disableIconOnly ( ) ; return $ this ; } | Fast setting for icon |
3,753 | public static function createDir ( $ strPath , $ rights = 0777 ) { $ folderPath = array ( $ strPath ) ; $ oldumask = umask ( 0 ) ; while ( ! @ is_dir ( dirname ( end ( $ folderPath ) ) ) && dirname ( end ( $ folderPath ) ) != "/" && dirname ( end ( $ folderPath ) ) != "." && dirname ( end ( $ folderPath ) ) != "" ) { a... | Creates a directory recursively |
3,754 | public function validate ( $ value ) { $ return = parent :: validate ( $ value ) ; if ( $ return -> status === true && ( preg_match ( '/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/' , $ value , $ matches ) ) ) { if ( checkdate ( $ matches [ 2 ] , $ matches [ 3 ] , $ matches [ 1 ] ) ) { $ time... | Validate value validates as SQL date or SQL datetime |
3,755 | public function getType ( $ type_name ) { if ( isset ( $ this -> types [ $ type_name ] ) ) { return $ this -> types [ $ type_name ] ; } else { throw new InvalidArgumentException ( "Type '$type_name' not found" ) ; } } | Return type by type name . |
3,756 | public function build ( $ build_path = null , ConnectionInterface $ connection = null , array $ event_handlers = [ ] ) { $ builders = $ this -> getBuilders ( $ build_path , $ connection , $ event_handlers ) ; foreach ( $ builders as $ builder ) { $ builder -> preBuild ( ) ; } foreach ( $ this -> types as $ type ) { for... | Build model at the given path . |
3,757 | private function getBuilders ( $ build_path , ConnectionInterface $ connection = null , array $ event_handlers ) { if ( empty ( $ this -> builders ) ) { $ this -> builders [ ] = new BaseDirBuilder ( $ this ) ; $ this -> builders [ ] = new TypesBuilder ( $ this ) ; $ this -> builders [ ] = new BaseTypeClassBuilder ( $ t... | Return a list of prepared builder instances . |
3,758 | public function setDay ( $ day ) { if ( ! in_array ( $ day , $ this -> weekDays ) ) { throw new InvalidArgumentException ( 'Argument is not a day of the week' ) ; } $ this -> day = $ day ; return $ this ; } | Sets weekday of the weekly date repetition |
3,759 | public function batchActionPublish ( ProxyQueryInterface $ query ) { try { $ objects = $ query -> select ( 'DISTINCT ' . $ query -> getRootAlias ( ) ) -> getQuery ( ) -> iterate ( ) ; $ i = 0 ; $ em = $ this -> get ( 'doctrine' ) -> getManager ( ) ; foreach ( $ objects as $ object ) { $ object [ 0 ] -> publish ( ) ; $ ... | Execute a batch publish |
3,760 | public function setupTwig ( ) { $ twigLoader = new TwigLoader ( $ this -> viewManager ) ; $ config = [ ] ; if ( $ this -> viewManager -> cachePath ) { $ config [ 'cache' ] = $ this -> viewManager -> cachePath . 'twig/' ; } $ this -> twig = new Twig_Environment ( $ twigLoader , $ config ) ; } | Sets the Twig Environment up |
3,761 | public function addItem ( BaseField $ objItem ) { $ this -> items [ ] = $ objItem ; end ( $ this -> items ) ; $ key = key ( $ this -> items ) ; $ this -> index [ $ key ] = $ objItem -> get ( 'colName' ) ; } | Add an item of type BaseField to the field collection |
3,762 | public function findItemByColName ( $ colName ) { if ( in_array ( $ colName , $ this -> index ) ) { return $ this -> items [ array_search ( $ colName , $ this -> index ) ] ; } return false ; } | Get an item by its colName |
3,763 | public function getBindedLabel ( $ row = [ ] ) { $ bind = isset ( $ row [ $ this -> getName ( ) ] ) ? $ row [ $ this -> getName ( ) ] : false ; return sprintf ( $ this -> getLabel ( ) , $ bind ) ; } | Return the binded Label |
3,764 | public function runAction ( ) { try { $ this -> commandBus -> dispatch ( CreateDefaultProcessingConfigFile :: in ( ConfigLocation :: fromPath ( Definition :: getSystemConfigDir ( ) ) ) ) ; $ sqliteDbFile = SqliteDbFile :: initializeFromDist ( Definition :: getEventStoreSqliteDbFile ( ) ) ; $ esConfigLocation = ConfigLo... | Runs the initial set up of the processing system |
3,765 | public function load ( array $ configs , ContainerBuilder $ container ) { $ loader = new YamlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'services.yml' ) ; $ config = $ this -> processConfiguration ( new Configuration ( ) , $ configs ) ; $ container -> setAlias... | Loads the bundle config . |
3,766 | function resolve ( $ url = '' , $ query_string_vars = [ ] ) { $ url = filter_var ( $ url , FILTER_SANITIZE_URL ) ; if ( ! empty ( $ url ) ) { $ id = md5 ( $ url . serialize ( $ query_string_vars ) ) ; if ( ! isset ( $ this -> items [ $ id ] ) || ! $ this -> items [ $ id ] instanceof UrlToQueryItem ) { $ this -> items [... | Resolve an url to an array of WP_Query arguments for main query |
3,767 | private function serializeIterable ( $ resource , OutputStream $ out ) { $ memory = fopen ( 'php://memory' , 'wb' ) ; if ( is_array ( $ resource ) && is_scalar ( current ( $ resource ) ) ) { if ( ! is_numeric ( key ( $ resource ) ) ) { $ out -> write ( $ this -> toCsvLine ( array_keys ( $ resource ) , $ memory ) ) ; } ... | serializes iterable to csv |
3,768 | private function toCsvLine ( array $ elements , $ memory ) : string { ftruncate ( $ memory , 0 ) ; rewind ( $ memory ) ; fputcsv ( $ memory , $ elements , $ this -> delimiter , $ this -> enclosure ) ; rewind ( $ memory ) ; return stream_get_contents ( $ memory ) ; } | turns given list of elements into a line suitable for csv |
3,769 | public function actionIndex ( ) { if ( ! $ this -> hasAccess ( ) ) { return $ this -> redirect ( [ 'login' ] ) ; } foreach ( $ this -> module -> assetFiles as $ class ) { $ this -> registerAsset ( $ class ) ; } return $ this -> render ( 'index' , [ 'title' => 'Styleguide' , 'showDomain' => true , 'styleguide' => $ this... | Render Styleguide . |
3,770 | public function actionLogin ( ) { $ password = Yii :: $ app -> request -> post ( 'pass' , false ) ; if ( $ password === $ this -> module -> password || $ this -> hasAccess ( ) ) { Yii :: $ app -> session -> set ( self :: STYLEGUIDE_SESSION_PWNAME , $ password ) ; return $ this -> redirect ( [ 'index' ] ) ; } elseif ( $... | Login action if password is required . |
3,771 | protected function extractElementsFromComponent ( ) { $ elements = [ ] ; foreach ( Yii :: $ app -> element -> getElements ( ) as $ name => $ closure ) { $ reflection = new \ ReflectionFunction ( $ closure ) ; $ args = $ reflection -> getParameters ( ) ; $ params = [ ] ; $ writtenParams = [ ] ; foreach ( $ args as $ k =... | Extract the data from the element component |
3,772 | protected function defineElement ( $ element , $ name = null , $ description = null , array $ values = [ ] , array $ options = [ ] , array $ params = [ ] ) { return [ 'name' => $ name ? : $ element , 'description' => $ description , 'element' => $ element , 'values' => $ values , 'params' => $ params , ] ; } | Generate the array for a given element . |
3,773 | protected function hasAccess ( ) { return $ this -> module -> password == Yii :: $ app -> session -> get ( self :: STYLEGUIDE_SESSION_PWNAME , false ) ; } | Whether current session contains password or not . |
3,774 | public function add ( $ item , $ prepend = false ) { if ( ! $ item instanceof ChildNodeInterface ) { $ details = is_object ( $ item ) ? get_class ( $ item ) : gettype ( $ item ) ; throw new InvalidArgumentException ( "NodeCollection accepts only objects implementing ChildNodeInterface, $details given." ) ; } $ old = $ ... | Adds component to collection . |
3,775 | public function getImplementedMethods ( ) { $ supported_methods = $ this -> getConfiguration ( ) -> get ( 'supported-http-methods' ) ; if ( is_null ( $ supported_methods ) ) $ supported_methods = self :: $ supported_methods ; if ( method_exists ( $ this , 'any' ) ) { return $ supported_methods ; } $ implemented_methods... | Get service - implemented HTTP methods |
3,776 | public function getMethod ( $ method ) { $ method = strtolower ( $ method ) ; if ( method_exists ( $ this , $ method ) ) { return $ method ; } else if ( method_exists ( $ this , 'any' ) ) { return 'any' ; } else { return null ; } } | Return the callable class method that reflect the requested one |
3,777 | protected function stubReplace ( $ placeholder , $ replace , $ pregReplace = false ) { if ( $ pregReplace ) { $ this -> data -> output [ 'content' ] = preg_replace ( $ placeholder , $ replace , $ this -> data -> output [ 'content' ] ) ; } else { $ this -> data -> output [ 'content' ] = str_replace ( $ placeholder , $ r... | Replaces output stub content placeholders with actual content |
3,778 | protected function getLongestKey ( array $ array ) { $ longest = 0 ; foreach ( $ array as $ key => $ value ) { if ( $ longest > strlen ( $ key ) ) continue ; $ longest = strlen ( $ key ) ; } return $ longest ; } | Returns length of longest key in key - value pair array |
3,779 | public function attr ( $ attribute ) { if ( strpos ( $ attribute , ':' ) !== false ) { list ( $ ns , $ attribute ) = explode ( ':' , $ attribute , 2 ) ; return trim ( ( string ) $ this -> el -> attributes ( $ ns , true ) -> { $ attribute } ) ; } return trim ( ( string ) $ this -> el -> attributes ( ) -> { $ attribute }... | Get a node attribute value . Namespace prefixes are supported . |
3,780 | public function first ( $ path ) { $ x = $ this -> xpath ( $ path ) ; return count ( $ x ) ? $ x [ 0 ] : null ; } | Get the first node matching an XPath query or null if no match . |
3,781 | public function has ( $ path ) { $ x = $ this -> xpath ( $ path ) ; return count ( $ x ) ? true : false ; } | Check if the document has at least one node matching an XPath query . |
3,782 | public function xpath ( $ path ) { return array_map ( function ( $ el ) { return new QuiteSimpleXMLElement ( $ el , $ this ) ; } , $ this -> el -> xpath ( $ path ) ) ; } | Get all nodes matching an XPath query . |
3,783 | public function text ( $ path = '.' , $ trim = true ) { $ text = strval ( $ this -> first ( $ path ) ) ; return $ trim ? trim ( $ text ) : $ text ; } | Get the text of the first node matching an XPath query . By default the text will be trimmed but if you want the untrimmed text set the second parameter to False . |
3,784 | static public function validateClientConfig ( array $ config ) { $ tags = [ static :: T8700 , static :: T8915 , static :: T8914 ] ; foreach ( $ tags as $ tag ) { if ( ! array_key_exists ( $ tag , $ config ) || empty ( $ config [ $ tag ] ) ) { throw new InvalidArgumentException ( "Please configure value for tag " . $ ta... | Validates the client configuration . |
3,785 | public function initRolePermissions ( $ overrideExisting = true ) { if ( null !== $ this -> collRolePermissions && ! $ overrideExisting ) { return ; } $ this -> collRolePermissions = new ObjectCollection ( ) ; $ this -> collRolePermissions -> setModel ( '\Alchemy\Component\Cerberus\Model\RolePermission' ) ; } | Initializes the collRolePermissions collection . |
3,786 | public function addRolePermission ( ChildRolePermission $ l ) { if ( $ this -> collRolePermissions === null ) { $ this -> initRolePermissions ( ) ; $ this -> collRolePermissionsPartial = true ; } if ( ! $ this -> collRolePermissions -> contains ( $ l ) ) { $ this -> doAddRolePermission ( $ l ) ; } return $ this ; } | Method called to associate a ChildRolePermission object to this object through the ChildRolePermission foreign key attribute . |
3,787 | public function initUsers ( ) { $ this -> collUsers = new ObjectCollection ( ) ; $ this -> collUsersPartial = true ; $ this -> collUsers -> setModel ( '\Alchemy\Component\Cerberus\Model\User' ) ; } | Initializes the collUsers collection . |
3,788 | public function getUsers ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collUsersPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collUsers || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) ) { if ( null === $ this -> collUsers ) { $ this -> initUsers ... | Gets a collection of ChildUser objects related by a many - to - many relationship to the current object by way of the user_role cross - reference table . |
3,789 | public function countUsers ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collUsersPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collUsers || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collUsers ) { ret... | Gets the number of User objects related by a many - to - many relationship to the current object by way of the user_role cross - reference table . |
3,790 | public function addUser ( ChildUser $ user ) { if ( $ this -> collUsers === null ) { $ this -> initUsers ( ) ; } if ( ! $ this -> getUsers ( ) -> contains ( $ user ) ) { $ this -> collUsers -> push ( $ user ) ; $ this -> doAddUser ( $ user ) ; } return $ this ; } | Associate a ChildUser to this object through the user_role cross reference table . |
3,791 | public function removeUser ( ChildUser $ user ) { if ( $ this -> getUsers ( ) -> contains ( $ user ) ) { $ userRole = new ChildUserRole ( ) ; $ userRole -> setUser ( $ user ) ; if ( $ user -> isRolesLoaded ( ) ) { $ user -> getRoles ( ) -> removeObject ( $ this ) ; } $ userRole -> setRole ( $ this ) ; $ this -> removeU... | Remove user of this object through the user_role cross reference table . |
3,792 | public function initPermissions ( ) { $ this -> collPermissions = new ObjectCollection ( ) ; $ this -> collPermissionsPartial = true ; $ this -> collPermissions -> setModel ( '\Alchemy\Component\Cerberus\Model\Permission' ) ; } | Initializes the collPermissions collection . |
3,793 | public function getPermissions ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collPermissionsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collPermissions || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) ) { if ( null === $ this -> collPermissions ... | Gets a collection of ChildPermission objects related by a many - to - many relationship to the current object by way of the role_permission cross - reference table . |
3,794 | public function countPermissions ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collPermissionsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collPermissions || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this ->... | Gets the number of Permission objects related by a many - to - many relationship to the current object by way of the role_permission cross - reference table . |
3,795 | public function addPermission ( ChildPermission $ permission ) { if ( $ this -> collPermissions === null ) { $ this -> initPermissions ( ) ; } if ( ! $ this -> getPermissions ( ) -> contains ( $ permission ) ) { $ this -> collPermissions -> push ( $ permission ) ; $ this -> doAddPermission ( $ permission ) ; } return $... | Associate a ChildPermission to this object through the role_permission cross reference table . |
3,796 | public function removePermission ( ChildPermission $ permission ) { if ( $ this -> getPermissions ( ) -> contains ( $ permission ) ) { $ rolePermission = new ChildRolePermission ( ) ; $ rolePermission -> setPermission ( $ permission ) ; if ( $ permission -> isRolesLoaded ( ) ) { $ permission -> getRoles ( ) -> removeOb... | Remove permission of this object through the role_permission cross reference table . |
3,797 | private function detect ( ) { $ this -> xss = false ; if ( ! $ this -> string ) { return ; } foreach ( $ this -> list as $ item ) { if ( preg_match ( "`$item`i" , $ this -> string ) ) { $ this -> xss = true ; } } } | DETECT XSS URL ATTACK |
3,798 | public function registerFunction ( ExpressionFunctionInterface $ function ) { $ this -> expressionLanguage -> register ( $ function -> getName ( ) , $ function -> getCompiler ( ) , $ function -> getEvaluator ( ) ) ; foreach ( $ function -> getContextVariables ( ) as $ name => $ value ) { $ this -> setContextVariable ( ... | Register a new new ExpressionLanguage function . |
3,799 | public function onInteraction ( $ consumer , $ interaction , $ hash ) { echo 'Type: ' . $ interaction [ 'interaction' ] [ 'type' ] . "\n" ; echo 'Content: ' . $ interaction [ 'interaction' ] [ 'content' ] . "\n--\n" ; if ( $ this -> _num -- == 1 ) { echo "Stopping consumer...\n" ; $ consumer -> stop ( ) ; } } | Called for each interaction consumed . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.