idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
19,300 | protected function prepareForeignConstraint ( DOMElement $ table , DOMXPath $ xpath , Table $ schemaTable ) { $ foreignKeys = $ xpath -> query ( sprintf ( '/database/table[@name="%s"]/foreign' , $ table -> getAttribute ( 'name' ) ) ) ; foreach ( $ foreignKeys as $ foreignKey ) { $ foreignTable = $ foreignKey -> getAttr... | Prepare foreign key constraint |
19,301 | protected function prepareUniqueConstraint ( DOMElement $ table , DOMXPath $ xpath , Table $ schemaTable ) { $ uniqueTags = $ xpath -> query ( sprintf ( '/database/table[@name="%s"]/unique' , $ table -> getAttribute ( 'name' ) ) ) ; foreach ( $ uniqueTags as $ uniqueTag ) { $ uniqueColumns = $ uniqueTag -> getElementsB... | Prepare unique constraint |
19,302 | protected function preparePrimaryConstraint ( DOMElement $ table , DOMXPath $ xpath , Table $ schemaTable ) { $ primaryTags = $ xpath -> query ( sprintf ( '/database/table[@name="%s"]/primary' , $ table -> getAttribute ( 'name' ) ) ) ; foreach ( $ primaryTags as $ primaryTag ) { $ primaryColumns = $ primaryTag -> getEl... | Prepare primary constraint |
19,303 | protected function getBootstrapSassJavascripts ( ) { $ process = new Process ( "gem which bootstrap-sass" ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { throw new WatcherCompileException ( "`bootstrap-sass` gem was not found\n\n" . $ process -> getOutput ( ) ) ; } $ gemPath = trim ( $ process -> ge... | Get a list of js files |
19,304 | public static function addListener ( string $ event , $ function , int $ priority = 10 , array $ args = null ) : void { Event :: $ listeners [ $ event ] [ $ priority ] [ ] = [ 'function' => $ function , 'args' => $ args ] ; } | Add new listener |
19,305 | public static function removeAllListeners ( string $ event ) : void { if ( Event :: hasListeners ( $ event ) ) { unset ( Event :: $ listeners [ $ event ] ) ; } } | Remove all listeners for current event . |
19,306 | public static function hasListeners ( string $ event ) : bool { if ( ! isset ( Event :: $ listeners [ $ event ] ) || count ( Event :: $ listeners [ $ event ] ) === 0 ) { return false ; } return true ; } | Check is listeners exists for current event . |
19,307 | public static function dispatch ( string $ event , array $ args = [ ] , bool $ return = false ) { if ( isset ( Event :: $ listeners [ $ event ] ) && count ( Event :: $ listeners [ $ event ] ) > 0 ) { $ listeners = Event :: $ listeners [ $ event ] ; krsort ( $ listeners ) ; foreach ( $ listeners as $ listener ) { foreac... | Dispatch all listeners of the given event . |
19,308 | public function setErrorHandle ( $ err , $ message , $ file , $ line ) { $ oJsonRpc = JsonRpc :: getInstance ( ) ; $ content = explode ( "\n" , file_get_contents ( $ file ) ) ; header ( 'Content-Type: application/json' ) ; $ id = $ oJsonRpc -> extractId ( ) ; $ error = array ( "code" => 100 , "message" => "Server error... | set error handler |
19,309 | public function response ( $ result , $ id , $ error ) { if ( $ error ) { $ error [ 'name' ] = 'JSONRPCError' ; } return json_encode ( array ( "jsonrpc" => "2.0" , 'result' => $ result , 'id' => $ id , 'error' => $ error ) ) ; } | make the response |
19,310 | public function extractId ( ) { $ regex = '/[\'"]id[\'"] *: *([0-9]*)/' ; $ rawData = $ this -> getRawPostData ( ) ; if ( preg_match ( $ regex , $ rawData , $ m ) ) { return intval ( $ m [ 1 ] ) ; } else { return null ; } } | try to extract id from broken json |
19,311 | private function currentURL ( ) { $ pageURL = 'http' ; if ( isset ( $ _SERVER [ "HTTPS" ] ) && $ _SERVER [ "HTTPS" ] == "on" ) { $ pageURL .= "s" ; } $ pageURL .= "://" ; if ( $ _SERVER [ "SERVER_PORT" ] != "80" ) { $ pageURL .= $ _SERVER [ "SERVER_NAME" ] . ":" . $ _SERVER [ "SERVER_PORT" ] . $ _SERVER [ "REQUEST_URI"... | get the current URL |
19,312 | private function serviceDescription ( $ object ) { $ class_name = get_class ( $ object ) ; $ methods = get_class_methods ( $ class_name ) ; $ service = [ "sdversion" => "1.0" , "name" => "DemoService" , "address" => $ this -> currentURL ( ) , "id" => "urn:md5:" . md5 ( $ this -> currentURL ( ) ) ] ; $ static = get_clas... | get service description of the class |
19,313 | private function getJsonRequest ( ) { $ request = $ this -> getRawPostData ( ) ; if ( $ request == "" ) { throw new JsonRpcExeption ( 101 , "Parse Error: no data" ) ; } $ encoding = mb_detect_encoding ( $ request , 'auto' ) ; if ( $ encoding != 'UTF-8' ) { $ request = iconv ( $ encoding , 'UTF-8' , $ request ) ; } $ re... | get the json request |
19,314 | protected function setFirewallsAndAccessRules ( Application $ app ) { $ app -> extend ( 'security.firewalls' , function ( $ firewalls , $ app ) { $ createUser = new RequestMatcher ( '^/users$' , null , [ 'POST' ] ) ; $ verifyRegistration = new RequestMatcher ( '^/users/[0-9]+/verify-registration$' , null , [ 'POST' ] )... | Set user related firewalls |
19,315 | protected function driverAction ( $ action , $ item ) { if ( is_null ( $ item ) ) { return $ this -> getDriver ( ) -> { $ action } ( ) ; } else { return $ this -> getDriver ( ) -> { $ action } ( $ item ) ; } } | Execute an action with the driver |
19,316 | public function merge ( $ data ) { if ( ! is_array ( $ data ) ) { $ data = $ this -> makeArray ( $ data ) ; } $ this -> _data = array_merge ( $ this -> _data , $ data ) ; } | Merges the given items into the collection . |
19,317 | public function replace ( $ data ) { if ( ! is_array ( $ data ) ) { $ data = $ this -> makeArray ( $ data ) ; } $ this -> _data = array_replace ( $ this -> _data , $ data ) ; } | Replaces items in the collection with those given . |
19,318 | public function intersect ( $ data ) { if ( ! is_array ( $ data ) ) { $ data = $ this -> makeArray ( $ data ) ; } return new static ( array_intersect_assoc ( $ this -> _data , $ data ) ) ; } | Computes the intersection with the given array and returns a new collection . |
19,319 | public function keyFilter ( $ func ) { $ filtered = array_filter ( $ this -> keys ( ) , $ func ) ; return new static ( array_intersect_key ( $ this -> _data , array_flip ( $ filtered ) ) ) ; } | Filters the items by key and returns a new collection . |
19,320 | public function addJob ( $ job = [ ] ) { if ( ! isset ( $ job [ 'msg' ] ) ) throw new RuntimeException ( 'Job without a message' ) ; if ( ! isset ( $ job [ 'schedule' ] ) ) throw new RuntimeException ( 'Job without a CRON expression' ) ; if ( ! isset ( $ job [ 'function' ] ) ) throw new RuntimeException ( 'Job without ... | Load the cron jobs that should be runned and register them into the jobs array . |
19,321 | public function getJob ( $ msg ) { $ found = false ; foreach ( $ this -> jobs as $ job ) { if ( $ job [ 'msg' ] === $ msg ) { $ found = $ job ; break ; } } return $ found ; } | Get a particular job by msg |
19,322 | public function output ( $ args = null ) { $ i = 0 ; foreach ( $ this -> jobs as $ job ) if ( $ job [ 'function' ] ( $ job [ 'msg' ] ) === TRUE ) $ i ++ ; $ this -> jobs = [ ] ; return $ i ; } | Load the cron jobs to run and execute them . |
19,323 | public function removeListener ( string $ event , callable $ listener ) { if ( $ this -> _events [ $ event ] ?? false ) { $ key = array_search ( $ listener , $ this -> _events [ $ event ] , true ) ; if ( $ key !== false ) { array_splice ( $ this -> _events [ $ event ] , $ key , 1 ) ; } } return $ this ; } | Remove specific listener of an event . |
19,324 | public function setResponseCode ( $ code ) { if ( ! ResponseCode :: isValid ( $ code ) ) { throw new \ InvalidArgumentException ( 'setResponseCode(): Invalid HTTP response code given of value ' . strval ( $ code ) ) ; } $ this -> statusCode = $ code ; return $ this ; } | Sets the HTTP response code . |
19,325 | public function doRedirect ( $ url , $ permanent = false ) { $ this -> setResponseCode ( $ permanent ? ResponseCode :: HTTP_MOVED_PERMANENTLY : ResponseCode :: HTTP_FOUND ) ; $ this -> setHeader ( 'Location' , $ url ) ; return $ this ; } | Redirect the user to a specific URL . Performs a HTTP 301 or HTTP 302 redirect . |
19,326 | public function setHeader ( $ key , $ value ) { $ this -> headers [ strval ( $ key ) ] = strval ( $ value ) ; return $ this ; } | Sets a HTTP header to a certain value . |
19,327 | public function setCookie ( $ name , $ value , $ expire = 0 , $ path = null , $ domain = null , $ secure = false , $ httpOnly = false ) { return $ this -> addCookie ( ( new Cookie ( ) ) -> setName ( $ name ) -> setValue ( $ value ) -> setExpireTimestamp ( $ expire ) -> setPath ( $ path ) -> setDomain ( $ domain ) -> se... | Creates or updates a cookie . |
19,328 | protected function sendCookies ( ) { foreach ( $ this -> cookies as $ cookie ) { setcookie ( $ cookie -> getName ( ) , $ cookie -> getValue ( ) , $ cookie -> getExpireTimestamp ( ) , $ cookie -> getPath ( ) , $ cookie -> getDomain ( ) , $ cookie -> isSecure ( ) , $ cookie -> isHttpOnly ( ) ) ; } } | Sends the HTTP cookies to the client . Causes output! |
19,329 | protected function sendHeaders ( ) { header ( sprintf ( '%s %s' , self :: PROTOCOL_VERSION , ResponseCode :: getMessageForCode ( $ this -> statusCode ) ) ) ; foreach ( $ this -> headers as $ name => $ value ) { header ( sprintf ( "%s: %s" , $ name , $ value ) ) ; } } | Sends the HTTP headers to the client . Causes output! |
19,330 | public function send ( ) { $ this -> sendHeaders ( ) ; $ this -> sendCookies ( ) ; if ( ResponseCode :: canHaveBody ( $ this -> statusCode ) ) { $ this -> sendBody ( ) ; } } | Sends the HTTP response to the client . Causes output! |
19,331 | private function applyIdentifier ( Siteroot $ siteroot ) { $ reflectionClass = new \ ReflectionClass ( get_class ( $ siteroot ) ) ; $ reflectionProperty = $ reflectionClass -> getProperty ( 'id' ) ; $ reflectionProperty -> setAccessible ( true ) ; $ reflectionProperty -> setValue ( $ siteroot , UuidUtil :: generate ( )... | Apply UUID as identifier when entity doesn t have one yet . |
19,332 | public function filter ( $ request ) { foreach ( $ this -> _filters as $ filter ) { if ( ! $ request = $ filter -> filter ( $ request ) ) { throw new Exception ( "Filter returned a null request" ) ; } } return $ request ; } | Filter a request fail if a null result is returned |
19,333 | protected function getCorrespondingSaucelabsJob ( ) { $ jobs = $ this -> sauceApi ( ) -> getJobs ( $ from = 0 , $ to = null , $ limit = 1 , $ skip = null , $ username = null ) ; return $ jobs [ 'jobs' ] [ 0 ] ; } | We currently assume that the firstmost job is the current test for which we should update metadata . This is not always true but at the moment there seems to be little to be done in this matter . |
19,334 | protected function gatherMetaData ( $ test ) { $ metadata = array ( 'tags' => isset ( $ this -> config [ 'tags' ] ) ? explode ( "," , $ this -> config [ 'tags' ] ) : array ( ) , 'custom-data' => array ( ) , ) ; $ metadata [ 'tags' ] [ ] = "test:" . $ test -> toString ( ) ; $ metadata [ 'custom-data' ] [ 'options' ] = $... | Gather metadata about the current test to send to saucelabs making it easier to filter tests |
19,335 | public function initConfig ( $ force = false ) { $ pluginName = $ this -> _getPluginName ( ) ; $ checkPath = $ this -> _getCheckPath ( ) ; $ configFile = $ this -> _getConfigFile ( ) ; $ language = ( string ) Configure :: read ( 'Config.language' ) ; if ( ! $ force && ! empty ( $ checkPath ) && Configure :: check ( $ c... | Initializes configuration for plugin . |
19,336 | public static function fromInt ( $ int ) { if ( ! \ is_int ( $ int ) ) { throw new \ InvalidArgumentException ( '$int must be an integer' ) ; } $ flags = new static ( ) ; foreach ( static :: getEnumValues ( ) as $ const ) { if ( ( $ int & $ const ) === $ const ) { $ flags -> addFlag ( $ const ) ; } } return $ flags ; } | Converts an integer value to an enum of this type |
19,337 | public function getNames ( ) { $ isSet = PHPArray :: filter ( static :: getConstants ( ) , function ( $ value ) { return $ this -> hasFlag ( $ value ) ; } ) ; return \ array_keys ( $ isSet ) ; } | Returns an array of this class constant names which are defined in this instance |
19,338 | protected function _filterAsset ( CakeEvent $ event ) { $ url = $ event -> data [ 'request' ] -> url ; $ response = $ event -> data [ 'response' ] ; $ filters = Configure :: read ( 'Asset.filter' ) ; $ isCss = ( strpos ( $ url , 'ccss/' ) === 0 || preg_match ( '#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i' , $ url... | Checks if the client is requesting a filtered asset and runs the corresponding filter if any is configured |
19,339 | public function setRoutes ( ) : void { if ( is_null ( $ this -> routes ) ) { $ this -> routes = [ ] ; $ routesConfig = $ this -> config -> getParam ( 'routes' ) ?? [ ] ; foreach ( $ routesConfig as $ routeName => $ routeArr ) { $ route = new Route ( $ routeName , $ routeArr [ 'methods' ] , $ routeArr [ 'path' ] , $ rou... | Sets \ Duktig \ Core \ Route \ Route objects from config values |
19,340 | protected function get ( ) { $ url = '' ; if ( $ this -> scheme ) { $ url = $ this -> scheme . ':' ; } if ( $ this -> host ) { $ url .= '//' . $ this -> authority ( ) ; } if ( $ this -> path ) { $ url .= '/' . ltrim ( $ this -> path , '/' ) ; } if ( $ this -> query ) { $ url .= '?' . $ this -> query ; } if ( $ this -> ... | Get URL as string |
19,341 | protected function set ( $ url ) { $ parts = parse_url ( $ url ) ; if ( ! $ parts ) { throw new \ InvalidArgumentException ( 'URL malformed' ) ; } $ this -> scheme = isset ( $ parts [ 'scheme' ] ) ? strtolower ( $ parts [ 'scheme' ] ) : '' ; $ this -> username = $ parts [ 'user' ] ?? '' ; $ this -> password = $ parts [... | Set URL as string |
19,342 | public function authority ( ) { $ userInfo = $ this -> username ; if ( $ this -> password ) { $ userInfo .= ':' . $ this -> password ; } $ port = $ this -> port ( ) ; $ authority = $ this -> host ; if ( $ authority && $ userInfo ) { $ authority = $ userInfo . '@' . $ authority ; } if ( $ authority && $ port ) { $ autho... | Get authority component of the URL |
19,343 | public static function capture ( array $ server = null ) { if ( ! $ server ) { $ server = $ _SERVER ; } $ source = 'http:' ; if ( isset ( $ server [ 'HTTPS' ] ) && $ server [ 'HTTPS' ] && $ server [ 'HTTPS' ] != 'off' ) { $ source = 'https:' ; } if ( isset ( $ server [ 'HTTP_HOST' ] ) ) { $ source .= '//' . $ server [ ... | Capture the URL from the SERVER super global |
19,344 | public function create_taxonomy ( $ options ) { if ( ! $ options instanceof WP_Taxonomy_Options ) { trigger_error ( 'Options must be passed as a WP_Taxonomy_Options.' ) ; return ; } if ( ! $ options -> has_required_properties ( ) ) { trigger_error ( 'WP_Taxonomy_Options are missing required properties.' ) ; return ; } ... | Creates a custom taxonomy . |
19,345 | public function getTitle ( ) { $ title = '' ; if ( trim ( $ this -> title ) != '' ) { $ title = trim ( $ this -> title ) ; } if ( trim ( $ this -> name ) != '' ) { if ( trim ( $ title ) != '' ) { $ title .= $ this -> delimiter ; } $ title .= trim ( $ this -> name ) ; } if ( trim ( $ title ) == '' ) { $ title = 'zepi Tu... | Returns the title for the request |
19,346 | protected function addConfigListeners ( $ id , $ event ) { if ( isset ( $ this -> configuredEvents [ $ id ] [ $ event ] ) || ! $ this -> canAddConfig || ! $ this -> config ) { return $ this ; } $ this -> canAddConfig = false ; $ this -> config -> configureEventManager ( $ this , $ id , $ event ) ; $ this -> configuredE... | Add config events |
19,347 | public function close ( Line $ closerLine ) : string { if ( isset ( $ this -> config [ 'close_by' ] ) && $ closerLine -> indentLevel == $ this -> line -> indentLevel ) { foreach ( $ this -> config [ 'close_by' ] as $ key => $ value ) { if ( $ closerLine -> pregMatch ( $ key ) ) { return $ this -> withParam ( $ value ) ... | Close this control node and returning node closer . |
19,348 | private function withParam ( string $ input ) { return str_replace ( '$_FLAG_$' , "__HTSL_CTRL_FLAG_{$this->id}__" , preg_replace_callback ( '/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/' , function ( array $ matches ) { $ param = $ this -> param ; if ( isset ( $ matches [ 1 ] ) ) { array_map ( ... [ function ( ... | Parse opener or closer with parameters . |
19,349 | protected function dispatchCommandFrom ( $ command , ArrayAccess $ source , array $ extras = [ ] ) { return app ( 'tactician.dispatcher' ) -> dispatchFrom ( $ command , $ source , $ extras ) ; } | Marshal a command and dispatch it to its respective handler . |
19,350 | public function remove ( $ key ) { if ( array_key_exists ( $ key , $ this -> map ) ) { $ tmp = $ this -> map [ $ key ] ; unset ( $ this -> map [ $ key ] ) ; return $ tmp ; } else return NULL ; } | Remove a name and its value if present . |
19,351 | public static function stringToValue ( $ string ) { if ( $ string == '' ) { return $ string ; } if ( is_float ( $ string ) ) { return ( float ) $ string ; } if ( is_int ( $ string ) ) { return ( int ) $ string ; } if ( strtolower ( $ string ) == 'true' ) { return true ; } if ( strtolower ( $ string ) == 'false' ) { ret... | Try to convert a string into a number boolean or null . If the string can t be converted return the string . |
19,352 | private static function isAssoc ( $ value ) { if ( ! is_array ( $ value ) ) return false ; return array_keys ( $ value ) !== range ( 0 , count ( $ value ) - 1 ) ; } | Determines if an value is an associative array |
19,353 | public static function numberToString ( $ number = NULL ) { if ( $ number === NULL ) { throw new JSONException ( 'Null pointer' ) ; } self :: testValidity ( $ number ) ; $ number = ( string ) $ number ; if ( strpos ( $ number , '.' ) > 0 && strpos ( $ number , 'e' ) < 0 && strpos ( $ number , 'E' ) < 0 ) { while ( subs... | Produce a string from a number . |
19,354 | public function toJSONArray ( $ names = NULL ) { if ( $ names == NULL || count ( $ names ) == 0 ) { return NULL ; } $ ja = new JSONArray ( ) ; foreach ( $ this -> map as $ key => $ value ) { $ ja -> put ( $ this -> opt ( $ key ) ) ; } return $ ja ; } | Produce a JSONArray containing the values of the members of this JSONObject . |
19,355 | public function write ( ) { $ returnstring = '{' ; foreach ( $ this -> map as $ key => $ value ) { $ returnstring .= '"' . $ key . '":' ; if ( $ value instanceof JSONObject || $ value instanceof JSONArray ) $ returnstring .= $ value -> write ( ) ; elseif ( gettype ( $ value ) == 'integer' || gettype ( $ value ) == 'dou... | Returns the contents of the JSONObject as a JSONString . For compactness no whitespace is added . |
19,356 | public function render ( ) { $ this -> latte -> setLoader ( $ this -> file ? new FileLoader ( ) : new StringLoader ( ) ) ; $ this -> latte -> render ( $ this -> file ? : $ this -> source , $ this -> params ) ; } | Renders template to output . |
19,357 | public static function fromXml ( \ DOMDocument $ xml ) { $ static = new static ( ) ; $ loans = $ xml -> getElementsByTagName ( 'loan' ) ; $ static -> loans = LoanCollection :: fromXml ( $ loans ) ; $ loanHistory = $ xml -> getElementsByTagName ( 'loanHistory' ) ; $ static -> loanHistory = LoanCollection :: fromXml ( $ ... | Builds a UserActivities object from XML . |
19,358 | function givePdo ( \ PDO $ conn ) { if ( $ this -> pdo ) throw new exImmutable ; $ this -> pdo = $ conn ; return $ this ; } | Set PDO Instance |
19,359 | public static function createFromGlobals ( array $ globals ) { $ env = new \ Sofi \ Base \ Collection ( $ globals ) ; if ( is_array ( $ env [ 'slim.files' ] ) && $ env -> has ( 'slim.files' ) ) { return $ env [ 'slim.files' ] ; } elseif ( isset ( $ _FILES ) ) { return static :: parseUploadedFiles ( $ _FILES ) ; } retur... | Create a normalized tree of UploadedFile instances from global server variables . |
19,360 | public function getConfig ( ) { if ( $ this -> cache instanceof Cache \ CacheInterface && ! empty ( $ configs = $ this -> cache -> getConfig ( ) ) ) { return $ configs ; } $ configs = $ this -> moduleHandler -> getModulesConfig ( ) ; foreach ( $ this -> files as $ file ) { $ config = require $ file ; if ( ! is_array ( ... | Get entire configurations in application and modules |
19,361 | protected function filterViewPath ( $ configViewPaths ) { if ( ! ArrayUtils :: isHashTable ( $ configViewPaths ) ) { throw new Exception \ InvalidArgumentException ( 'Config view path is not valid' ) ; } foreach ( $ configViewPaths as $ moduleName => $ viewPath ) { $ viewPath = realpath ( $ viewPath ) ; if ( ! $ viewPa... | Get real path for view path configs |
19,362 | protected function filterVoltPath ( $ configVolt ) { foreach ( $ configVolt as $ moduleName => $ config ) { $ path = false ; if ( isset ( $ config [ 'path' ] ) ) { unset ( $ configVolt [ $ moduleName ] [ 'path' ] ) ; $ path = realpath ( $ config [ 'path' ] ) ; } if ( $ path ) { $ configVolt [ $ moduleName ] [ 'path' ] ... | Filter config volt template engine |
19,363 | protected function cleanUp ( array $ configs ) { $ configs [ 'view' ] = ! isset ( $ configs [ 'view' ] ) ? [ ] : $ this -> filterViewPath ( $ configs [ 'view' ] ) ; $ configs [ 'volt' ] = ! isset ( $ configs [ 'volt' ] ) ? [ ] : $ this -> filterVoltPath ( $ configs [ 'volt' ] ) ; if ( $ this -> cache instanceof Cache \... | Clean up entire application config |
19,364 | public function regexp ( $ value , string $ expression ) : bool { return is_string ( $ value ) && preg_match ( $ expression , $ value ) ; } | Check string using regexp . |
19,365 | public function shorter ( $ value , int $ length ) : bool { return is_string ( $ value ) && mb_strlen ( trim ( $ value ) ) <= $ length ; } | Check if string length is shorter or equal that specified value . |
19,366 | public function range ( $ value , int $ min , int $ max ) : bool { return is_string ( $ value ) && ( mb_strlen ( $ trimmed = trim ( $ value ) ) >= $ min ) && ( mb_strlen ( $ trimmed ) <= $ max ) ; } | Check if string length are fits in specified range . |
19,367 | public function _getByPath ( $ path ) { $ result = null ; $ steps = $ this -> _pathAsArray ( $ path ) ; $ depth = count ( $ steps ) ; if ( $ depth == 0 ) { $ result = $ this -> data ; } else { $ pointer = $ this -> data ; $ level = 0 ; foreach ( $ steps as $ step ) { if ( is_array ( $ pointer ) ) { if ( isset ( $ point... | Recursive method to get some attribute of the DataObject by path . |
19,368 | public function getData ( ) { $ this -> validate ( 'amount' , 'currency' ) ; $ data = array ( ) ; $ data [ 'timestamp' ] = $ this -> getTimestamp ( ) ; $ data [ 'transaction[amount]' ] = $ this -> getAmountInteger ( ) ; $ data [ 'transaction[cancel_url]' ] = $ this -> getCancelUrl ( ) ; $ data [ 'transaction[currency]'... | Assemble the data to send with the request . |
19,369 | protected function GetResourceNamespace ( $ prefix , $ resourceKey ) { $ resourceNamespace = $ prefix . ucfirst ( strtolower ( $ resourceKey ) ) . "Resx_" . $ this -> CultureValue ; return $ resourceNamespace ; } | Computes the resource namespace from the context . |
19,370 | public function executeAction ( ) { $ moduleClass = $ this -> get ( 'request' ) -> get ( '_module.module' ) ; $ actionName = $ this -> get ( 'request' ) -> get ( '_module.action' ) ; $ module = $ this -> get ( 'module_manager' ) -> get ( $ moduleClass ) ; foreach ( $ module -> getControllerPreExecutes ( ) as $ controll... | Executes an action . |
19,371 | public function offsetGet ( $ key ) { $ result = array_get ( $ this -> items , $ key ) ; if ( is_array ( $ result ) ) return new static ( $ result ) ; return $ result ; } | Get an item at a given offset using Dot - notation . |
19,372 | public function get ( $ key , $ default = null ) { if ( $ this -> offsetExists ( $ key ) ) { return $ this -> offsetGet ( $ key ) ; } return value ( $ default ) ; } | Get an item from the collection by key using Dot - notation . |
19,373 | public function setName ( $ name ) { if ( ! is_string ( $ name ) || strlen ( trim ( $ name ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid name, must be a non empty string' ) ; $ this -> name = $ name ; } | Set name of this Provider |
19,374 | public function setType ( $ type ) { if ( ! is_string ( $ type ) || strlen ( trim ( $ type ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid type, must be a non empty string' ) ; $ this -> type = $ type ; } | Set type of this Provider |
19,375 | public function log ( $ level , $ message , array $ context = [ ] ) { if ( ! is_string ( $ level ) || ! is_string ( $ message ) ) { throw new \ InvalidArgumentException ( 'Level or message must be a string' ) ; } $ file = $ this -> logPath . '/' . $ level . '.log' ; $ stream = $ this -> streamFactory -> createStreamFro... | Write log . |
19,376 | public static function loadThemes ( ) { $ themesFolder = new Folder ( ROOT . DS . 'themes' ) ; $ themes = $ themesFolder -> read ( ) [ 0 ] ; $ loader = require ROOT . DS . 'vendor' . DS . 'autoload.php' ; foreach ( $ themes as $ theme ) { $ loader -> addPsr4 ( 'WasabiTheme\\' . $ theme . '\\' , [ $ themesFolder -> path... | Register all available themes in the composer classloader and load them as plugin . |
19,377 | public static function init ( ) { foreach ( self :: $ _registeredThemes as $ registeredTheme ) { $ theme = self :: _initializeTheme ( $ registeredTheme ) ; self :: $ _themes [ $ theme -> id ( ) ] = $ theme ; } self :: $ _initialized = true ; } | Initialize all available themes . |
19,378 | public static function theme ( $ theme = null ) { if ( ! self :: $ _initialized ) { self :: init ( ) ; } if ( $ theme !== null ) { if ( ! isset ( self :: $ _themes [ $ theme ] ) ) { throw new Exception ( __d ( 'wasabi_cms' , 'Theme "{0}" does not exist.' , $ theme ) ) ; } self :: $ _theme = self :: $ _themes [ $ theme ... | Get or set the currently active theme . |
19,379 | public static function getThemesForSelect ( ) { if ( ! self :: $ _initialized ) { self :: init ( ) ; } $ results = [ ] ; foreach ( self :: $ _themes as $ theme ) { $ results [ $ theme -> id ( ) ] = $ theme -> name ( ) ; } return $ results ; } | Get all themes for a form select input . |
19,380 | protected static function _initializeTheme ( $ registeredTheme ) { list ( $ theme , $ themeName ) = pluginSplit ( $ registeredTheme ) ; $ themeNamespace = preg_replace ( '/\\//' , '\\' , $ theme ) ; $ themeClass = $ themeNamespace . '\\' . $ themeName ; try { $ theme = new $ themeClass ( ) ; } catch ( Exception $ e ) {... | Initialize a single registered theme . |
19,381 | private function loadServiceProvider ( ) { \ Tiga \ Framework \ Facade \ Facade :: setFacadeContainer ( $ this ) ; $ providers = $ this [ 'config' ] -> get ( 'provider' ) ; $ providers = array_unique ( $ providers ) ; foreach ( $ providers as $ provider ) { $ instance = new $ provider ( $ this ) ; $ instance -> registe... | Load registered service provider in the main plugin and child plugin . |
19,382 | private function removeLogs ( Schedule $ scheduler ) { $ scheduler -> call ( function ( ) { $ searchDir = Config :: $ root . 'storage' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR ; $ prefix = config ( 'app.logger.name' ) ; $ logs = glob ( $ searchDir . $ prefix . '-*-*-*.log' ) ; if ( count ( $ logs ) < 1 ) re... | Remove application logs |
19,383 | public static function getExceptionNameHierarchy ( \ Exception $ e , $ separator = ' >> ' ) { $ names = array ( ) ; do { $ names [ ] = get_class ( $ e ) ; } while ( ( $ e = $ e -> getPrevious ( ) ) !== null ) ; $ names = implode ( $ separator , $ names ) ; return $ names ; } | Returns a formatted string containing the class names of the exeptions thrown . |
19,384 | public static function getFormattedExceptionMessage ( \ Exception $ e ) { $ name = static :: getExceptionNameHierarchy ( $ e ) ; list ( $ file , $ line , $ stackTrace ) = static :: getOriginalExceptionFileAndLineNumber ( $ e ) ; $ message = "{$name}: {$e->getMessage()} ({$e->getcode()})\n{$file} {$line}\n{$stackTrace}"... | Returns the formatted message of a passed in exception . |
19,385 | public static function getOriginalExceptionFileAndLineNumber ( \ Exception $ e ) { $ names = array ( ) ; do { $ p = $ e ; $ names [ ] = get_class ( $ e ) ; } while ( ( $ e = $ e -> getPrevious ( ) ) !== null ) ; return array ( $ p -> getFile ( ) , $ p -> getLine ( ) , $ p -> getTraceAsString ( ) ) ; } | Returns the file name line number and stack trace where the original exception was thrown . |
19,386 | public function transform ( $ data ) : File { $ file = file_exists ( $ data ) ? $ data : null ; $ file = is_null ( $ file ) ? new File ( '' , false ) : new File ( $ file , true ) ; return $ file ; } | Transforms an string to File |
19,387 | private function getJSONVersionOfSchema ( ) { $ cacheFile = dirname ( dirname ( __DIR__ ) ) . '/data/schemaorg.cache' ; if ( ! file_exists ( $ cacheFile ) ) { if ( ! file_exists ( dirname ( $ cacheFile ) ) ) { mkdir ( dirname ( $ cacheFile ) , 0777 , true ) ; } $ graph = new \ EasyRdf_Graph ( self :: RDFA_SCHEMA ) ; $ ... | Retrieve the latest RDFA version of schema . org and converts it to JSON - LD . |
19,388 | public function migrate ( $ direction = 'up' ) { if ( ! $ this -> tableExists ( 'schema_migrations' ) ) { $ this -> createMigrationsTable ( ) ; } foreach ( get_declared_classes ( ) as $ declaredClass ) { if ( is_subclass_of ( $ declaredClass , "Avalon\\Database\\Migration" ) ) { if ( $ direction === 'up' ) { $ this -> ... | Handles the execution of migrations . |
19,389 | protected function up ( $ className ) { if ( $ fileName = $ this -> migrated ( $ className ) ) { $ migration = new $ className ; $ migration -> up ( ) ; $ migration -> execute ( ) ; $ this -> connection -> insert ( "schema_migrations" , [ 'version' => $ fileName , 'date' => date ( "Y-m-d" ) ] ) ; } } | Migrates the database forward . |
19,390 | protected function migrated ( $ className ) { $ classInfo = new ReflectionClass ( $ className ) ; $ fileName = str_replace ( '.php' , '' , basename ( $ classInfo -> getFileName ( ) ) ) ; $ result = $ this -> connection -> createQueryBuilder ( ) -> select ( 'version' ) -> from ( 'schema_migrations' ) -> where ( 'version... | Checks if the migration has been executed and returns the migrations base file name . |
19,391 | protected function createMigrationsTable ( ) { $ schema = new Schema ; $ table = $ schema -> createTable ( "schema_migrations" ) ; $ table -> addColumn ( "version" , "string" ) ; $ table -> addColumn ( "date" , "date" ) ; $ queries = $ schema -> toSql ( $ this -> connection -> getDatabasePlatform ( ) ) ; foreach ( $ qu... | Creates the migration log table . |
19,392 | public static function toXML ( $ data , $ rootNodeName = 'entity' , & $ xml = null ) { if ( ini_get ( 'zend.ze1_compatibility_mode' ) == 1 ) ini_set ( 'zend.ze1_compatibility_mode' , 0 ) ; if ( is_null ( $ xml ) ) $ xml = simplexml_load_string ( "<?xml version='1.0' encoding='utf-8'?><$rootNodeName />" ) ; foreach ( $ ... | Converts a multidimensional associative array to an XML document . |
19,393 | public function to ( $ destination , array $ defaults = [ ] ) { if ( $ this -> name === null ) { $ this -> name = strtolower ( str_replace ( [ '\\' , '::' ] , '_' , $ destination ) ) ; } $ this -> destination = $ destination ; $ this -> defaults = $ defaults ; return $ this ; } | Destination class and method of route . |
19,394 | public function method ( $ method ) { if ( ! is_array ( $ method ) ) { $ method = [ $ method ] ; } $ this -> method = $ method ; return $ this ; } | HTTP methods to accept . |
19,395 | public function generateUrl ( array $ tokens = [ ] ) { $ path = $ this -> path ; foreach ( $ tokens as $ key => $ value ) { $ path = str_replace ( ":{$key}" , $ value , $ path ) ; } return $ path ; } | Generates the path replacing tokens with specified values . |
19,396 | public function & SetForm ( \ MvcCore \ Ext \ Forms \ IForm & $ form ) { $ this -> form = & $ form ; return $ this ; } | Set form instance to render . |
19,397 | public function & SetField ( \ MvcCore \ Ext \ Forms \ IField & $ field ) { $ this -> __protected [ 'fieldRendering' ] = TRUE ; $ this -> field = & $ field ; return $ this ; } | Set rendered field . |
19,398 | public function RenderTemplate ( ) { $ formViewScript = $ this -> form -> GetViewScript ( ) ; return $ this -> Render ( static :: $ formsDir , is_bool ( $ formViewScript ) ? $ this -> form -> GetId ( ) : $ formViewScript ) ; } | Render configured form template . |
19,399 | public function RenderErrors ( ) { $ this -> form -> PreDispatch ( ) ; $ result = '' ; $ errors = & $ this -> form -> GetErrors ( ) ; if ( $ errors && $ this -> form -> GetErrorsRenderMode ( ) == \ MvcCore \ Ext \ Forms \ IForm :: ERROR_RENDER_MODE_ALL_TOGETHER ) { $ result .= '<div class="errors">' ; foreach ( $ error... | Render form errors . If form is configured to render all errors together at form beginning this function completes all form errors into div . errors with div . error elements inside containing each single errors message . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.