idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
54,000
public function isValidToken ( $ login , $ jwtWrapper , $ token ) { $ user = $ this -> getByLoginField ( $ login ) ; if ( is_null ( $ user ) ) { throw new UserNotFoundException ( 'User not found!' ) ; } if ( $ user -> get ( 'TOKEN_HASH' ) !== sha1 ( $ token ) ) { throw new NotAuthenticatedException ( 'Token does not ma...
Check if the Auth Token is valid
54,001
public function __async_save ( ) { if ( isset ( $ _POST ) ) { $ db_user = null ; if ( ! dbQuery ( 'user' ) -> UserID ( $ _POST [ 'UserID' ] ) -> Active ( 1 ) -> first ( $ db_user ) ) { $ db_user = new \ samson \ activerecord \ user ( false ) ; } $ db_user -> Created = ( $ _POST [ 'Created' ] == 0 ) ? date ( 'Y-m-d H:i:...
Save user data
54,002
public function __async_table ( ) { $ query = dbQuery ( 'user' ) -> Active ( 1 ) -> order_by ( 'UserID' ) ; $ table = new Table ( $ query ) ; return array ( 'status' => 1 , 'table' => $ table -> render ( ) ) ; }
Method for rendering table
54,003
public static function createTableColumnForSchemaColumn ( Column $ column , $ label ) { if ( $ column instanceof TimeColumn ) { new \ Rhubarb \ Leaf \ Table \ Leaves \ Columns \ TimeColumn ( $ column -> columnName , $ label ) ; } if ( $ column instanceof DateColumn || $ column instanceof MySqlDateTimeColumn ) { return ...
Creates the correct type of table column for the supplied model column .
54,004
function getOption ( string $ name , $ defaultValue = false ) { if ( ! $ this -> hasOption ( $ name ) ) { if ( \ is_null ( $ defaultValue ) ) { return $ defaultValue ; } $ this -> _options [ $ name ] = $ defaultValue ; } return $ this -> _options [ $ name ] ; }
Gets the option value of option with defined name or FALSE if the option is unknown .
54,005
public function getMethod ( $ allowOverride = true ) { if ( $ allowOverride && $ this -> methodOverride !== NULL && $ this -> method == Http :: METHOD_POST ) { return $ this -> methodOverride ; } return $ this -> method ; }
Get the HTTP request method .
54,006
public function setMethod ( $ method ) { $ method = strtoupper ( $ method ) ; if ( ! preg_match ( "'^[A-Z]{2,}$'" , $ method ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HTTP request method: "%s"' , $ method ) ) ; } $ this -> method = $ method ; return $ this ; }
Set the HTTP request method .
54,007
public function setMethodOverride ( $ method = NULL ) { if ( $ method === NULL ) { $ this -> methodOverride = NULL ; } else { $ method = strtoupper ( $ method ) ; if ( ! preg_match ( "'^[A-Z]{2,}$'" , $ method ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HTTP request method: "%s"' , $ method ) ) ; } ...
Set method override for a POST request .
54,008
public function setCookie ( $ name , $ value ) { if ( ! preg_match ( "'^[a-z_0-9\-\.]+$'i" , $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid cookie name: "%s"' , $ name ) ) ; } $ this -> cookies [ $ name ] = $ value ; return $ this ; }
Set a cookie value in the request .
54,009
public function setCookies ( array $ cookies ) { $ this -> cookies = [ ] ; foreach ( $ cookies as $ name => $ value ) { $ this -> setCookie ( $ name , $ value ) ; } return $ this ; }
Set all cookies found in the given array .
54,010
public static function merge ( array $ array1 , array $ array2 , $ overwrite = true ) { foreach ( $ array2 as $ key => $ value ) { if ( isset ( $ array1 [ $ key ] ) ) { if ( self :: isArray ( $ array1 [ $ key ] ) && self :: isArray ( $ value ) ) { $ array1 [ $ key ] = self :: merge ( $ array1 [ $ key ] , $ value , $ ov...
Merge two arrays recursively .
54,011
public function cmdGetOrder ( ) { $ result = $ this -> getListOrder ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableOrder ( $ result ) ; $ this -> output ( ) ; }
Callback for order - get command
54,012
public function cmdAddOrder ( ) { $ submitted = $ this -> getParam ( ) ; $ this -> setSubmitted ( null , $ submitted ) ; $ this -> setSubmittedJson ( 'data' ) ; $ this -> validateComponent ( 'order' ) ; if ( $ this -> isError ( ) ) { $ this -> output ( ) ; } $ id = $ this -> order -> add ( $ this -> getSubmitted ( ) ) ...
Callback for order - add command
54,013
public function cmdUpdateOrder ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this ->...
Callback for order - update command
54,014
public function set ( $ key , $ value ) { $ this -> validateValue ( $ value ) ; $ this -> variables [ $ key ] = $ value ; }
Set a given key to a view value
54,015
public function add ( $ key , $ value ) { $ this -> validateValue ( $ value ) ; if ( ! isset ( $ this -> variables [ $ key ] ) ) { $ this -> variables [ $ key ] = [ ] ; } if ( ! is_array ( $ this -> variables [ $ key ] ) ) { $ this -> variables [ $ key ] = [ $ this -> variables [ $ key ] ] ; } $ this -> variables [ $ k...
Adds a value to a collection collection will be created if it does not already exist
54,016
public function getMethodAnnotationsForMatchingTag ( $ tag , $ methodName = null ) { if ( $ methodName ) { return isset ( $ this -> methodAnnotations [ $ methodName ] [ $ tag ] ) ? $ this -> methodAnnotations [ $ methodName ] [ $ tag ] : array ( ) ; } else { $ matchingAnnotations = array ( ) ; foreach ( $ this -> getMe...
Get any method annotations with a matching tag . Return these indexed by field name .
54,017
public function getFieldAnnotationsForMatchingTag ( $ tag , $ fieldName = null ) { if ( $ fieldName ) { return isset ( $ this -> fieldAnnotations [ $ fieldName ] [ $ tag ] ) ? $ this -> fieldAnnotations [ $ fieldName ] [ $ tag ] : array ( ) ; } else { $ matchingAnnotations = array ( ) ; foreach ( $ this -> getFieldAnno...
Get any field annotations with a matching tag . Return these indexed by field name .
54,018
public function getFieldAnnotationsContainingMatchingTag ( $ tag ) { $ matchingAnnotations = array ( ) ; foreach ( $ this -> getFieldAnnotations ( ) as $ field => $ fieldAnnotations ) { if ( isset ( $ fieldAnnotations [ $ tag ] ) ) { $ matchingAnnotations [ $ field ] = $ fieldAnnotations ; } } return $ matchingAnnotati...
Get the full set of field annotations for any fields containing a tag .
54,019
public function getFieldAnnotationsNotContainingTags ( $ tags = array ( ) ) { $ matchingAnnotations = array ( ) ; foreach ( $ this -> getFieldAnnotations ( ) as $ field => $ fieldAnnotations ) { $ fieldAnnotationKeys = array_keys ( $ fieldAnnotations ) ; if ( ! array_intersect ( $ fieldAnnotationKeys , $ tags ) ) { $ m...
Get all field annotations not containing passed tags .
54,020
public static function invalidEntityType ( $ expected , $ actual ) { return new self ( sprintf ( 'Entity must be an instance of "%s"; got "%s".' , $ expected , is_object ( $ actual ) ? get_class ( $ actual ) : gettype ( $ actual ) ) ) ; }
Entity must be an instance of %s ; got %s .
54,021
public static function createDocumentFolderFromPostValues ( $ postValues ) { if ( isset ( $ postValues [ 'title' ] , $ postValues [ 'path' ] , $ postValues [ 'content' ] ) ) { $ documentFolderObject = new Document ( ) ; $ documentFolderObject -> title = $ postValues [ 'title' ] ; $ documentFolderObject -> slug = String...
Create folder from post values
54,022
final public function property ( $ name , $ value ) { $ this -> definition -> setProperty ( $ name , static :: processValue ( $ value , true ) ) ; return $ this ; }
Sets a specific property .
54,023
protected function assignValue ( FieldInterface $ field ) { $ value = $ this -> accessor -> getPropertyValue ( $ this -> instance , $ field -> name ( ) ) ; if ( $ value === null && $ field -> attribute ( 'autoincrement' ) ) { return ; } if ( $ value === null ) { $ this -> getValueFromReferencedEntity ( $ field ) ; } $ ...
Assigns value to query
54,024
public function execute ( IDS_Report $ data ) { if ( ! isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ _SERVER [ 'REQUEST_URI' ] = substr ( $ _SERVER [ 'PHP_SELF' ] , 1 ) ; if ( isset ( $ _SERVER [ 'QUERY_STRING' ] ) && $ _SERVER [ 'QUERY_STRING' ] ) { $ _SERVER [ 'REQUEST_URI' ] .= '?' . $ _SERVER [ 'QUERY_STRING' ] ; } }...
Iterates through registered loggers and executes them
54,025
public function addLogger ( ) { $ args = func_get_args ( ) ; foreach ( $ args as $ class ) { if ( ! in_array ( $ class , $ this -> loggers ) && ( $ class instanceof IDS_Log_Interface ) ) { $ this -> loggers [ ] = $ class ; } } }
Registers a new logging wrapper
54,026
public function removeLogger ( IDS_Log_Interface $ logger ) { $ key = array_search ( $ logger , $ this -> loggers ) ; if ( isset ( $ this -> loggers [ $ key ] ) ) { unset ( $ this -> loggers [ $ key ] ) ; return true ; } return false ; }
Removes a logger
54,027
public function parse ( $ rules ) : Rule \ Set { $ isArray = is_array ( $ rules ) ; $ isAssoc = $ isArray && self :: isAssociative ( $ rules ) ; $ set = null ; if ( is_string ( $ rules ) || is_object ( $ rules ) || $ isAssoc ) { $ set = $ this -> getRule ( $ rules ) ; } elseif ( $ isArray ) { foreach ( $ rules as $ v )...
Turns a number of rule definitions into an actual Rule Set .
54,028
public function getRule ( $ rule , $ arg = null ) : Rule \ Set { $ rules = new Rule \ Set ( ) ; if ( is_string ( $ rule ) ) { $ vrule = $ this -> registry -> factory ( $ rule , $ arg ) ; if ( $ vrule instanceof Draft ) { $ vrule = $ vrule -> finish ( $ this -> registry ) ; } $ rules -> add ( $ vrule ) ; } elseif ( is_o...
Parses rule definitions .
54,029
public function parseTemplateText ( $ viewText , & $ model ) { extract ( $ model ) ; $ preVariables = get_defined_vars ( ) ? get_defined_vars ( ) : array ( ) ; unset ( $ preVariables [ "model" ] ) ; ob_start ( ) ; include $ viewText ; $ result = ob_get_contents ( ) ; ob_end_clean ( ) ; $ postVariables = get_defined_var...
Parse the view as PHP . This also allows for new variables to be defined within a view and as such these will be merged into the model for use in a parent view if required .
54,030
public static function random ( int $ length = 10 , string $ keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) : string { $ pieces = [ ] ; $ max = mb_strlen ( $ keyspace , '8bit' ) - 1 ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ pieces [ ] = $ keyspace [ random_int ( 0 , $ max ) ] ; } re...
Creating a random string
54,031
public static function safe ( string $ string ) : string { $ split = str_split ( $ string ) ; foreach ( $ split as $ k => $ char ) { if ( str_contains ( '~!@#$%^&*()_-=+<>/\?;:{}[]|,.' , $ char ) ) { unset ( $ split [ $ k ] ) ; } } return implode ( '' , $ split ) ; }
Remove special char s from string
54,032
public static function range ( $ max , $ start = 1 , $ step = 1 ) { if ( $ step < 1 ) { return [ ] ; } $ array = [ ] ; for ( $ i = $ start ; $ i <= $ max ; $ i += $ step ) { $ array [ ] = $ i ; } return $ array ; }
Fill an array with a range of numbers .
54,033
public static function fetch ( $ array , $ path , $ default = null ) { if ( ! is_array ( $ array ) ) { return $ default ; } if ( $ path === '' ) { return $ array ; } $ path = is_array ( $ path ) ? $ path : explode ( '.' , $ path ) ; $ levels = count ( $ path ) ; if ( $ levels === 0 ) { return $ array ; } $ ret = $ defa...
Fetch nested array value by dot notation path .
54,034
public function setTranslatable ( TranslatableInterface $ translatable = null ) { if ( $ translatable === $ this -> translatable ) { return $ this ; } $ previousTranslatable = $ this -> translatable ; $ this -> translatable = $ translatable ; if ( null !== $ previousTranslatable ) { $ previousTranslatable -> removeTran...
Sets the translatable .
54,035
protected function escapeParameters ( ) { $ parameters = $ this -> parameters ; foreach ( $ parameters as $ k => $ v ) { switch ( gettype ( $ v ) ) { case 'string' : $ parameters [ $ k ] = $ this -> stringEscape ( $ v ) ; break ; case 'boolean' : $ parameters [ $ k ] = ( $ v === true ) ? 1 : 0 ; break ; case 'object' :...
Escape the parameters and return them .
54,036
protected function compileQuery ( ) { $ query = $ this -> sql ; if ( strncasecmp ( $ query , 'INSERT' , 6 ) === 0 || strncasecmp ( $ query , 'UPDATE' , 6 ) === 0 ) { $ query = str_replace ( '%s' , '%p' , $ query ) ; } $ chunks = preg_split ( "/('[^']*')/" , $ query , - 1 , ( PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMP...
Compile the query into a string .
54,037
public function matches ( $ sqlQuery ) { if ( empty ( $ this -> compiledQuery ) ) { $ this -> compileQuery ( ) ; } return $ sqlQuery === $ this -> compiledQuery ; }
Check if the query matches against the query and parameters .
54,038
public function receive_message ( $ client , $ timeout ) { $ decodedClient = is_object ( $ client ) ? $ client : json_decode ( $ client ) ; $ queue = $ decodedClient -> { 'queues' } -> { 'output' } ; if ( $ this -> debug ) $ this -> log_out ( "DEBUG" , "Polling from '$queue' ..." ) ; $ result = $ this -> sqs -> receive...
Poll for incoming SQS messages using this method .
54,039
public function delete_message ( $ client , $ msg ) { $ decodedClient = is_object ( $ client ) ? $ client : json_decode ( $ client ) ; $ this -> sqs -> deleteMessage ( array ( 'QueueUrl' => $ decodedClient -> { 'queues' } -> { 'output' } , 'ReceiptHandle' => $ msg [ 'ReceiptHandle' ] ) ) ; return true ; }
Delete the provided message from the SQS queue
54,040
public function start_job ( $ client , $ input , $ jobId = null ) { $ decodedClient = is_object ( $ client ) ? $ client : json_decode ( $ client ) ; $ decodedInput = is_object ( $ input ) ? $ input : json_decode ( $ input ) ; if ( ! $ decodedClient ) { throw new \ InvalidArgumentException ( "Invalid JSON 'client' to st...
Send a start_job command to CPE
54,041
private function craft_new_msg ( $ type , $ jobId , $ client , $ data ) { $ data -> { 'client' } = $ client ; $ msg = array ( 'time' => microtime ( true ) , 'type' => $ type , 'jobId' => $ jobId , 'data' => $ data ) ; return $ msg ; }
Craft the object to be sent out to SQS
54,042
private function validate_client ( $ client ) { if ( ! isset ( $ client -> { "name" } ) ) throw new \ Exception ( "'client' has no 'name'!" ) ; if ( ! isset ( $ client -> { "queues" } ) ) throw new \ Exception ( "'client' has no 'queues'!" ) ; if ( ! isset ( $ client -> { "queues" } -> { 'input' } ) ) throw new \ Excep...
Validate Client object structure
54,043
public static function Color2Rgb ( $ colorDefinition ) { if ( \ is_array ( $ colorDefinition ) ) { if ( \ count ( $ colorDefinition ) > 2 && \ count ( $ colorDefinition ) < 5 ) { return $ colorDefinition ; } throw new ArgumentError ( 'colorDefinition' , $ colorDefinition , 'Drawing' , 'A (a)rgb(a) array with 3-4 Elemen...
Converts the defined color into a RGB color definition ( a numeric indicated array 0 = R 1 = G 2 = B
54,044
public static function Color2Hex ( $ colorDefinition ) { if ( \ is_array ( $ colorDefinition ) ) { if ( \ count ( $ colorDefinition ) != 3 ) { throw new ArgumentError ( 'colorDefinition' , $ colorDefinition , 'Drawing' , 'A rgb array with 3 Elements is required!' ) ; } return static :: Rgb2Hex ( $ colorDefinition ) ; }...
Converts the defined Color definition into hexadecimal representation .
54,045
public static function Hex2Rgb ( string $ color ) { if ( $ color [ 0 ] == '#' ) { $ color = \ substr ( $ color , 1 ) ; } if ( \ strlen ( $ color ) == 8 ) { $ color = \ substr ( $ color , 2 ) ; } if ( \ strlen ( $ color ) == 6 ) { $ r = $ color [ 0 ] . $ color [ 1 ] ; $ g = $ color [ 2 ] . $ color [ 3 ] ; $ b = $ color ...
Convert a color from hexadecimal notation to RGB array .
54,046
public static function Rgb2Hex ( $ r , int $ g = - 1 , int $ b = - 1 ) { if ( \ is_array ( $ r ) ) { if ( \ count ( $ r ) != 3 ) { return false ; } \ array_change_key_case ( $ r , \ CASE_LOWER ) ; if ( isset ( $ r [ 'r' ] ) && isset ( $ r [ 'g' ] ) && isset ( $ r [ 'b' ] ) ) { $ g = $ r [ 'g' ] ; $ b = $ r [ 'b' ] ; $ ...
Converts a RGB array or the 3 r g b values into a hexadecimal color representation .
54,047
public function onKernelController ( ) { $ themeContext = $ this -> container -> get ( 'theme.context.front' ) ; $ themeContext -> setCurrentTheme ( $ this -> getShopStorage ( ) -> getCurrentShop ( ) -> getTheme ( ) ) ; }
Sets shop context related session variables
54,048
public function getStateOnDate ( $ datestamp , $ addCountryCode = false ) { $ result = [ ] ; $ bind = [ ] ; $ bind [ QBldMax :: BND_ON_DATE ] = $ datestamp ; $ query = $ this -> qbuildSnapOnDate -> build ( ) ; if ( $ addCountryCode ) { $ as = self :: AS_TBL_DWNL ; $ tbl = $ this -> resource -> getTableName ( ECustomer ...
Select downline tree state on the given datestamp .
54,049
protected static function sortByOrder ( $ a , $ b ) { if ( ! isset ( $ a [ 'link_order' ] ) && isset ( $ b [ 'link_order' ] ) ) { $ a [ 'link_order' ] = ( $ b [ 'link_order' ] + 1 ) ; } if ( ! isset ( $ b [ 'link_order' ] ) && isset ( $ a [ 'link_order' ] ) ) { $ b [ 'link_order' ] = ( $ a [ 'link_order' ] + 1 ) ; } if...
Comparison for the uasort method
54,050
protected static function sortChildElements ( $ array ) { foreach ( $ array as $ i => $ item ) { if ( isset ( $ item [ 'children' ] ) && is_array ( $ item [ 'children' ] ) ) { uasort ( $ array [ $ i ] [ 'children' ] , 'self::sortByOrder' ) ; $ array [ $ i ] [ 'children' ] = array_values ( self :: sortChildElements ( $ ...
Sort child elements from the menu array
54,051
public function setAction ( $ action ) { if ( false === is_string ( $ action ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ action ) ) , E_USER_ERROR ) ; } $ this -> action = $ action ; }
Set the action
54,052
public function bindParameters ( ContainerBuilder $ container , $ name , $ config ) { $ container -> setParameter ( 'alpixel_user.role_descriptions' , $ config [ 'role_descriptions' ] ) ; $ container -> setParameter ( 'alpixel_user.firewall_templates' , $ config [ 'firewall_templates' ] ) ; $ container -> setParameter ...
Binds the params from config .
54,053
public function addConfigVars ( $ path = 'config.ini' ) { if ( $ path === 'config.php' ) { $ arrayIniParams = parse_ini_file ( dirname ( __FILE__ ) . '/' . $ path , true ) ; } else { $ arrayIniParams = parse_ini_file ( $ path , true ) ; } foreach ( $ arrayIniParams as $ key => $ iniParam ) { $ this -> storage [ $ key ]...
Add Config Vars from a new . ini file
54,054
public function dispatchEvent ( $ eventName , Event $ event = null ) { if ( $ this -> eventDispatcher instanceof EventDispatcherInterface ) { $ this -> eventDispatcher -> dispatch ( $ eventName , $ event ) ; } }
Dispatches an event to the event dispatcher if one has been configured .
54,055
public function quartile ( int $ index ) : Quartile { switch ( $ index ) { case 0 : return $ this -> min ; case 1 : return $ this -> firstQuartile ; case 2 : return $ this -> median ; case 3 : return $ this -> thirdQuartile ; case 4 : return $ this -> max ; } throw new OutOfRangeException ; }
Return the quartile at the wished index
54,056
private function buildMin ( Dataset $ dataset ) : self { $ this -> min = new Quartile ( min ( ... $ dataset -> ordinates ( ) ) ) ; return $ this ; }
Extract the minimum value from the dataset
54,057
private function buildMax ( Dataset $ dataset ) : self { $ this -> max = new Quartile ( max ( ... $ dataset -> ordinates ( ) ) ) ; return $ this ; }
Extract the maximum value from the dataset
54,058
private function buildMean ( Dataset $ dataset ) : self { $ this -> mean = mean ( ... $ dataset -> ordinates ( ) ) ; return $ this ; }
Build the mean value from the dataset
54,059
private function buildMedian ( Dataset $ dataset ) : self { $ this -> median = new Quartile ( median ( ... $ dataset -> ordinates ( ) ) ) ; return $ this ; }
Extract the median from the dataset
54,060
private function buildQuartile ( Number $ percentage , ColumnVector $ dataset ) : Number { $ dimension = $ dataset -> dimension ( ) ; if ( $ dimension -> value ( ) === 2 ) { return divide ( add ( $ dataset -> get ( 0 ) , $ dataset -> get ( 1 ) ) , 2 ) ; } else if ( $ dimension -> value ( ) === 1 ) { return $ dataset ->...
Return the value describing the the quartile at the given percentage
54,061
public function routeParams ( $ params = '' ) { if ( ! empty ( $ params ) ) { if ( is_a ( $ params , 'stdClass' ) ) { $ this -> routeParams = $ params ; } else { return false ; } } else { return $ this -> routeParams ; } }
Get or set the routeParams property .
54,062
protected function checkBlank ( $ object , string $ fieldName ) { if ( $ object === null || strlen ( trim ( $ object ) ) === 0 ) { throw new \ InvalidArgumentException ( "The \"$fieldName\" argument is required; it cannot be null, empty, nor containing only whitespace" ) ; } return $ object ; }
Checks that a string argument isn t null empty or just whitespace .
54,063
protected function ensure ( array & $ source , string $ key ) { if ( ! isset ( $ source [ $ key ] ) || ! $ source [ $ key ] ) { throw new \ Caridea \ Auth \ Exception \ MissingCredentials ( ) ; } return $ source [ $ key ] ; }
Throws a MissingCredentials if the value is empty .
54,064
protected function verify ( string $ input , string $ hash ) { if ( ! password_verify ( $ input , $ hash ) ) { throw new \ Caridea \ Auth \ Exception \ InvalidPassword ( ) ; } }
Verifies a user - provided password against a hash .
54,065
public function register ( $ command ) { $ classexp = explode ( '/' , $ command ) ; for ( $ i = 0 ; $ i < count ( $ classexp ) ; $ i ++ ) { $ classexp [ $ i ] = ucwords ( $ classexp [ $ i ] ) ; } $ class = __NAMESPACE__ . '\\' . implode ( '\\' , $ classexp ) ; return new $ class ( ) ; }
Register console command class .
54,066
public function getCurrent ( ) { if ( ! $ this -> iterationStarted || is_null ( $ this -> current ) ) throw new InvalidOperationException ( ) ; return $ this -> current -> Current ; }
Get the current value of the iterator
54,067
protected function getValidExecProfiles ( string $ profileName = null ) { $ validProfs = [ 'production' => 'production' , 'dev' => 'dev' , 'staging' => 'staging' , 'sandbox' => 'sandbox' , 'demo' => 'demo' , 'debug' => 'debug' ] ; if ( $ profileName ) { if ( ! isset ( $ validProfs [ $ profileName ] ) ) { throw new \ Ru...
Get this config s list of known profiles .
54,068
protected function get ( string $ key ) { if ( ! array_key_exists ( $ key , $ this -> config ) ) throw new InvalidConfigException ( "Your configuration doesn't have a value for the key `$key`" ) ; return $ this -> config [ $ key ] ; }
An internal method that ensures an error is thrown if the given key is not found in the configuration .
54,069
public static function link ( $ name , $ url , array $ attributes = [ ] ) { return static :: openTag ( 'link' , array_merge ( $ attributes , [ 'href' => $ url ] ) ) . $ name . static :: closeTag ( 'link' ) ; }
Render link tag
54,070
public static function script ( $ text , array $ attributes = [ ] , $ type = 'text/javascript' ) { return static :: openTag ( 'script' , array_merge ( $ attributes , [ 'type' => $ type ] ) ) . ' /*<![CDATA[*/ ' . $ text . ' /*]]>*/ ' . static :: closeTag ( 'script' ) ; }
Render script source
54,071
protected function generateDependencyData ( $ cache ) { $ timestamps = $ this -> getTimestamps ( $ cache , ( array ) $ this -> tags ) ; $ newKeys = [ ] ; foreach ( $ timestamps as $ key => $ timestamp ) { if ( $ timestamp === false ) { $ newKeys [ ] = $ key ; } } if ( ! empty ( $ newKeys ) ) { $ timestamps = array_merg...
Generates the data needed to determine if dependency has been changed . This method does nothing in this class .
54,072
public function getHasChanged ( $ cache ) { $ timestamps = $ this -> getTimestamps ( $ cache , ( array ) $ this -> tags ) ; return $ timestamps !== $ this -> data ; }
Performs the actual dependency checking .
54,073
protected function CreateSubLevel ( NavigationItem $ parent ) { $ navigation = new self ( ) ; $ navigation -> isSubLevel = true ; $ navigation -> naviParent = $ parent ; $ navigation -> SetTreeItem ( $ this -> tree , $ this -> item ) ; return $ navigation ; }
Creates a navigation renderer for a sub level
54,074
private function IsActive ( ) { $ pageItem = $ this -> naviItem -> GetPageItem ( ) ; if ( ! $ pageItem ) { return false ; } return $ pageItem -> GetPage ( ) -> Equals ( PageRenderer :: Page ( ) ) ; }
Returns true if the current item points to the current page
54,075
private function IsTrail ( ) { $ pageItem = $ this -> naviItem -> GetPageItem ( ) ; if ( ! $ pageItem ) { return false ; } $ parent = PageRenderer :: Page ( ) -> GetParent ( ) ; $ itemPage = $ pageItem -> GetPage ( ) ; while ( $ parent ) { if ( $ itemPage -> Equals ( $ parent ) ) { return true ; } $ parent = $ parent -...
Checks if the current navigation item points to a parent of the current page
54,076
public function validateTimestamps ( ) { if ( $ this -> encrypted ) { $ document = $ this -> decryptedDocument ; } else { $ document = $ this -> document ; } $ timestampNodes = $ document -> getElementsByTagName ( 'Conditions' ) ; for ( $ i = 0 ; $ i < $ timestampNodes -> length ; $ i ++ ) { $ nbAttribute = $ timestamp...
Verifies that the document is still valid according Conditions Element .
54,077
public function execute ( ) { $ this -> doAction ( self :: ON_BEFORE_MIGRATE_CMD_EXECUTE_ACTION ) ; if ( NULL === $ this -> migrator ) { throw new MigrationException ( 'You must set the migrator before executing this command.' ) ; } $ verbose = self :: getOption ( $ this , 'verbose' ) -> value ; $ direction = self :: g...
Executes the command action .
54,078
public function addPClass ( $ pclass ) { if ( ! $ pclass instanceof KlarnaPClass ) { throw new Klarna_InvalidTypeException ( 'pclass' , 'KlarnaPClass' ) ; } if ( ! isset ( $ this -> pclasses ) || ! is_array ( $ this -> pclasses ) ) { $ this -> pclasses = array ( ) ; } if ( $ pclass -> getDescription ( ) === null || $ p...
Adds a PClass to the storage .
54,079
public function getPClass ( $ id , $ eid , $ country ) { if ( ! is_int ( $ id ) ) { throw new InvalidArgumentException ( 'Supplied ID is not an integer!' ) ; } if ( ! is_array ( $ this -> pclasses ) ) { throw new Klarna_PClassException ( 'No match for that eid!' ) ; } if ( ! isset ( $ this -> pclasses [ $ eid ] ) || ! ...
Gets the PClass by ID .
54,080
public function getPClasses ( $ eid , $ country , $ type = null ) { if ( ! is_int ( $ country ) ) { throw new Klarna_ArgumentNotSetException ( 'country' ) ; } $ tmp = false ; if ( ! is_array ( $ this -> pclasses ) ) { return ; } $ tmp = array ( ) ; foreach ( $ this -> pclasses as $ eid => $ pclasses ) { $ tmp [ $ eid ]...
Returns an array of KlarnaPClasses keyed with pclass ID . If type is specified only that type will be returned .
54,081
public function render ( $ templateFile , array $ vars = [ ] ) { $ this -> getService ( 'retriever' ) -> setLocalVars ( $ vars ) ; return $ this -> getService ( 'template' ) -> render ( $ templateFile , $ vars ) ; }
renders a template . uses template service .
54,082
public function retrieve ( $ key , $ default = '' ) { $ retriever = $ this -> getService ( 'retriever' ) ; if ( $ retriever -> has ( $ key ) ) { return $ retriever -> get ( $ key ) ; } return $ default ; }
retrieves a param from - the matches of the uri - the request - the flash
54,083
static function ModuleClass ( $ type , ModuleLocation $ location ) { $ parts = \ explode ( self :: $ bundleModuleSeparator , $ type ) ; if ( count ( $ parts ) != 2 ) { throw new \ InvalidArgumentException ( 'Module type string must be in the format <bundle>-<module>' ) ; } $ bundle = $ parts [ 0 ] ; $ module = $ parts ...
Gets the class name by type string and module loation
54,084
static function CreateModule ( $ type , ModuleLocation $ location ) { $ class = self :: ModuleClass ( $ type , $ location ) ; if ( ! class_exists ( $ class ) ) { return null ; } return new $ class ( ) ; }
Finds the module associated with the given type and returns an instance
54,085
static function BackendNavModules ( ) { $ result = array ( ) ; $ allBundles = PathUtil :: Bundles ( ) ; $ coreKey = array_search ( 'Core' , $ allBundles ) ; unset ( $ allBundles [ $ coreKey ] ) ; array_unshift ( $ allBundles , 'Core' ) ; $ bundles = array_values ( $ allBundles ) ; foreach ( $ bundles as $ bundle ) { $ ...
The modules for the backend navigation
54,086
private static function SortByNavIndex ( array & $ result ) { $ sorted = array ( ) ; foreach ( $ result as $ bundle => $ modules ) { ksort ( $ modules ) ; $ sorted [ $ bundle ] = $ modules ; } return $ sorted ; }
Sorts the the navigation items by index
54,087
private static function AddBackendNavModule ( array & $ result , BackendModule $ module ) { $ bundle = $ module -> MyBundle ( ) ; if ( ! isset ( $ result [ $ bundle ] ) ) { $ result [ $ bundle ] = array ( ) ; } $ result [ $ bundle ] [ $ module -> SideNavIndex ( ) ] = $ module ; }
Adds the module to the side navigation
54,088
public function run ( ) { if ( false === function_exists ( 'exec' ) ) { return trigger_error ( 'Function "exec" is not enabled' , E_USER_ERROR ) ; } if ( false === is_readable ( Path :: get ( 'schedule' ) ) ) { return trigger_error ( printf ( 'Could not read schedule folder "%s"' , Path :: get ( 'schedule' ) ) ) ; } if...
Iterate over all schedule files and execute tasks
54,089
public function task ( $ script ) { if ( false === is_string ( $ script ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ script ) ) , E_USER_ERROR ) ; } $ script = sprintf ( '%s%s%s.php' , Path :: get ( 'schedule' ) , Application :: get...
Execute individual task of schedule file
54,090
private function exec ( $ command , $ background = false ) { exec ( escapeshellcmd ( $ command ) . ( $ background === true ? ' > /dev/null &' : '' ) , $ output ) ; return $ output ; }
Runs system command
54,091
private function checkRun ( $ crontab ) { $ time = explode ( ' ' , date ( 'i G j n w' ) ) ; $ crontab = explode ( ' ' , $ crontab ) ; foreach ( $ crontab as $ k => & $ v ) { $ time [ $ k ] = preg_replace ( '/^0+(?=\d)/' , '' , $ time [ $ k ] ) ; $ v = explode ( ',' , $ v ) ; foreach ( $ v as & $ v1 ) { $ v1 = preg_repl...
Checks if script should run
54,092
private function bootstrap ( ) { include ( dirname ( dirname ( dirname ( dirname ( dirname ( dirname ( __FILE__ ) ) ) ) ) ) . DIRECTORY_SEPARATOR . 'bootstrap.php' ) ; new \ Bootstrap ( false ) ; }
Load the bootstrap
54,093
protected function verifySchema ( array $ schema ) { $ customTypes = isset ( $ schema [ 'customTypes' ] ) ? $ schema [ 'customTypes' ] : [ ] ; if ( ! is_array ( $ customTypes ) ) { throw new Exception ( "Given value for key 'customTypes' is not an array." ) ; } $ properties = isset ( $ schema [ 'properties' ] ) ? $ sch...
Ensures that the given schema has valid values . Will yield defaults where available .
54,094
protected function validateMappedValues ( array $ data ) { $ errors = [ ] ; foreach ( array_diff_key ( $ this -> properties , [ ':any_name:' => 1 ] ) as $ key => $ property ) { $ result = $ this -> selectValue ( $ property , $ data ) ; if ( $ result instanceof Ok ) { $ value = $ result -> unwrap ( ) ; if ( $ value === ...
Validates the values of all explicitly defined schema properties .
54,095
protected function selectValue ( PropertyInterface $ property , array $ data ) { $ errors = [ ] ; $ key = $ property -> getName ( ) ; $ value = array_key_exists ( $ key , $ data ) ? $ data [ $ key ] : null ; if ( $ value === null && $ property -> isRequired ( ) ) { if ( ! array_key_exists ( $ key , $ data ) ) { $ error...
Returns the property s corresponding value from the given data array .
54,096
public function renderNodeTreeFunction ( \ Twig_Environment $ twig , NodeInterface $ node , array $ options = array ( ) ) { return $ twig -> render ( 'MMCmfContentBundle:Form/NodeTree:list.html.twig' , array ( 'node' => $ node , 'icon' => $ this -> getIcon ( get_class ( $ node ) ) , 'options' => $ options ) ) ; }
renders the menu
54,097
protected function pretty ( ) { $ xml = $ this -> getParameter ( 'value' ) ; $ level = $ this -> getParameter ( 'level' ) != null ? intval ( $ this -> getParameter ( 'level' ) ) : 6 ; $ xml = explode ( "\n" , preg_replace ( '/>\s*</' , ">\n<" , $ xml ) ) ; $ indent = 0 ; $ pretty = array ( ) ; if ( count ( $ xml ) && p...
Formats an XML string
54,098
public function getAllActive ( ) { $ dto = new DTO ( ) ; $ dto -> setParameter ( "Status" , "enabled" ) ; $ dto -> setParameter ( "Installed" , "1" ) ; $ dto -> setOrderBy ( "Priority" ) ; $ dto = $ this -> findAll ( $ dto ) ; return $ dto -> getResults ( ) ; }
Returns an array of all active plugins
54,099
public static function isAbsoluteUrl ( $ _path ) { $ url = parse_url ( $ _path ) ; return $ url !== false && isset ( $ url [ 'scheme' ] ) && $ url [ 'scheme' ] != '' ; }
Check is url absolute