idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
56,600
protected function getContents ( $ searchCriterias ) { $ searchCriterias = array_merge ( array ( 'contentType' => '' , 'choiceType' => ReadContentRepositoryInterface :: CHOICE_AND , 'keywords' => null , ) , $ searchCriterias ) ; $ language = $ this -> currentSiteManager -> getSiteLanguage ( ) ; $ siteId = $ this -> currentSiteManager -> getSiteId ( ) ; return $ this -> contentRepository -> findByContentTypeAndCondition ( $ language , $ searchCriterias [ 'contentType' ] , $ searchCriterias [ 'choiceType' ] , $ searchCriterias [ 'keywords' ] , $ siteId ) ; }
Return block contents
56,601
public function format ( $ how , $ class_name = "stdClass" , $ ctor_args = [ ] ) { switch ( $ how ) { case PDO :: FETCH_ASSOC : $ data = $ this -> formatAssoc ( ) ; break ; case PDO :: FETCH_BOTH : $ data = $ this -> formatBoth ( ) ; break ; case PDO :: FETCH_CLASS : $ data = $ this -> formatClass ( $ class_name , $ ctor_args ) ; break ; case PDO :: FETCH_OBJ : $ data = $ this -> formatObj ( ) ; break ; default : throw new Exception ( "Need to implement formatter for $how" ) ; } return $ data ; }
Formats and returns the row s data according to the formatting options specified
56,602
protected function formatBoth ( ) { $ data = [ ] ; $ index = 0 ; foreach ( $ this -> getData ( ) as $ key => $ value ) { $ data [ $ key ] = $ value ; $ data [ $ index ] = $ value ; $ index ++ ; } return $ data ; }
Formats and returns the row s data as a single array with each column repeated - once with a string key describing the column name and once with an integer key representing the column s numerical position .
56,603
protected function fetchAvailableShippingMethods ( ) { if ( ! $ this -> methods ) { $ activeCarriers = $ this -> getShippingConfig ( ) -> getActiveCarriers ( ) ; foreach ( $ activeCarriers as $ carrierCode => $ carrierModel ) { $ this -> addShippingMethodsFromCarrier ( $ carrierCode , $ carrierModel ) ; } } return $ this -> methods ; }
collect all available shipping methods that are mapped to a ROM shipping method
56,604
protected function addShippingMethodsFromCarrier ( $ carrierCode , Mage_Shipping_Model_Carrier_Abstract $ model ) { $ carrierTitle = $ this -> getCarrierTitle ( $ model ) ; foreach ( ( array ) $ model -> getAllowedMethods ( ) as $ methodCode => $ method ) { $ this -> storeShippingMethodInfo ( $ carrierCode . '_' . $ methodCode , $ this -> buildNameString ( $ carrierTitle , $ method ) ) ; } }
add valid shipping methods from the carrier to the list .
56,605
protected function storeShippingMethodInfo ( $ shippingMethod , $ displayString ) { $ sdkId = $ this -> lookupShipMethod ( $ shippingMethod ) ; if ( ! $ sdkId ) { $ this -> logger -> warning ( 'Encountered active shipping method with no ROM mapping.' , $ this -> logContext -> getMetaData ( __CLASS__ , [ 'shipping_method' => $ shippingMethod , 'display_string' => $ displayString ] ) ) ; return ; } $ this -> methods [ $ shippingMethod ] = [ 'sdk_id' => $ sdkId , 'display_text' => $ displayString , ] ; }
add the shipping method to the the list if it is a valid ROM shipping method
56,606
protected function getFirstAvailable ( ) { if ( $ this -> methods ) { reset ( $ this -> methods ) ; return key ( $ this -> methods ) ; } return null ; }
get the first available magento shipping method code
56,607
public function getRandomBytesString ( $ byteCount ) { $ chars = '' ; if ( $ this -> mcrypt ) { $ chars = mcrypt_create_iv ( $ byteCount , MCRYPT_DEV_URANDOM ) ; } if ( ! $ chars && $ this -> openssl ) { $ chars = openssl_random_pseudo_bytes ( $ byteCount ) ; } if ( ! $ chars && $ this -> urandom ) { while ( ( $ len = strlen ( $ chars ) ) < $ byteCount ) { $ chars .= fread ( $ this -> urandomFileHandler , $ byteCount - $ len ) ; } } if ( $ len = strlen ( $ chars ) < $ byteCount ) { throw new Exception ( 'Cannot use a cryptographically secure PRNG.' ) ; } return $ chars ; }
generates crypto safe bytes and puts them into a string of chars
56,608
public function rand ( $ min = 0 , $ max = null ) { if ( $ max === null ) { $ max = $ this -> defaultMax ; } if ( ! is_int ( $ min ) || ! is_int ( $ max ) ) { throw new Exception ( '$min and $max must be integers' ) ; } if ( $ min > $ max ) { throw new Exception ( '$min must be <= $max' ) ; } $ maxSafe = ( int ) floor ( ( ( pow ( 2 , 8 * $ this -> intByteCount - 2 ) - 1 ) + pow ( 2 , 8 * $ this -> intByteCount - 2 ) ) / ( $ max - $ min ) ) * ( $ max - $ min ) ; do { $ chars = $ this -> getRandomBytesString ( $ this -> intByteCount ) ; $ n = 0 ; for ( $ i = 0 ; $ i < $ this -> intByteCount ; $ i ++ ) { $ n |= ( ord ( $ chars [ $ i ] ) << ( 8 * ( $ this -> intByteCount - $ i - 1 ) ) ) ; } } while ( abs ( $ n ) > $ maxSafe ) ; return ( abs ( $ n ) % ( $ max - $ min + 1 ) ) + $ min ; }
generates crypto safe ints inside a given range
56,609
public function open ( String $ name = NULL , Array $ _attributes = [ ] ) { $ this -> clearValidationSessions ( ) ; $ this -> setFormName ( $ name , $ _attributes ) ; $ this -> isEnctypeAttribute ( $ _attributes ) ; $ this -> isWhereAttribute ( $ name ) ; $ this -> isQueryAttribute ( ) ; $ this -> isPreventAttribute ( ) ; $ this -> setMethodType ( $ _attributes ) ; $ this -> createFormElementByAttributes ( $ _attributes , $ return ) ; $ this -> isDatabaseProcessWithName ( $ name , $ return ) ; $ this -> isCSRFAttribute ( $ return ) ; $ this -> _unsetopen ( ) ; $ this -> outputElement .= $ return ; return $ this ; }
Open form tag .
56,610
public function close ( ) { unset ( $ this -> settings [ 'getrow' ] ) ; if ( isset ( $ this -> getJavascriptValidationFunction ) ) { $ this -> outputElement .= Inclusion \ View :: use ( 'JavascriptValidationFunctions' , $ this -> getJavascriptValidationFunction , true , __DIR__ . '/' ) ; $ this -> getJavascriptValidationFunction = NULL ; } $ this -> outputElement .= '</form>' . EOL ; return $ this ; }
Closes form object .
56,611
public function datetimeLocal ( String $ name = NULL , String $ value = NULL , Array $ _attributes = [ ] ) { return $ this -> _input ( $ name , $ value , $ _attributes , 'datetime-local' ) ; }
datetime - local form object .
56,612
public function textarea ( String $ name = NULL , String $ value = NULL , Array $ _attributes = [ ] ) { $ this -> setNameAttribute ( $ name ) ; $ this -> setValueAttribute ( $ value ) ; if ( ! empty ( $ this -> settings [ 'attr' ] [ 'name' ] ) ) { $ this -> _postback ( $ this -> settings [ 'attr' ] [ 'name' ] , $ value ) ; $ this -> getVMethodMessages ( ) ; $ this -> _validate ( $ this -> settings [ 'attr' ] [ 'name' ] , $ this -> settings [ 'attr' ] [ 'name' ] ) ; $ value = $ this -> _getrow ( 'textarea' , $ value , $ this -> settings [ 'attr' ] ) ; } $ this -> commonMethodsForInputElements ( 'textarea' ) ; $ this -> getPermAttribute ( $ perm ) ; $ this -> createTextareaElementByValueAndAttributes ( $ value , $ _attributes , $ return ) ; $ this -> createBootstrapFormInputElementByType ( 'textarea' , $ return , $ _attributes , $ return ) ; $ this -> outputElement .= $ this -> _perm ( $ perm , $ return ) ; return $ this ; }
textarea form object .
56,613
public function select ( String $ name = NULL , Array $ options = [ ] , $ selected = NULL , Array $ _attributes = [ ] , Bool $ multiple = false ) { $ this -> isTableOrQueryData ( $ options ) ; $ this -> setOptionAttribute ( $ options ) ; $ this -> isExcludeAttribute ( $ options ) ; $ this -> isIncludeAttribute ( $ options ) ; $ this -> isOrderAttribute ( $ options ) ; $ this -> setSelectedAttribute ( $ selected , $ options ) ; $ this -> setMultipleAttribute ( $ multiple , $ _attributes ) ; $ this -> setNameAttributeWithReference ( $ name , $ _attributes ) ; if ( ! empty ( $ _attributes [ 'name' ] ) ) { $ this -> _postback ( $ _attributes [ 'name' ] , $ selected ) ; $ this -> getVMethodMessages ( ) ; $ this -> _validate ( $ _attributes [ 'name' ] , $ _attributes [ 'name' ] ) ; $ selected = $ this -> _getrow ( 'select' , $ selected , $ _attributes ) ; } $ this -> commonMethodsForInputElements ( 'select' ) ; $ this -> getPermAttribute ( $ perm ) ; $ this -> createSelectElement ( $ options , $ selected , $ _attributes , $ return ) ; $ this -> createBootstrapFormInputElementByType ( 'select' , $ return , $ _attributes , $ return ) ; $ this -> _unsetselect ( ) ; $ this -> outputElement .= $ this -> _perm ( $ perm , $ return ) ; return $ this ; }
select form object .
56,614
public function multiselect ( String $ name = NULL , Array $ options = [ ] , $ selected = NULL , Array $ _attributes = [ ] ) { return $ this -> select ( $ name , $ options , $ selected , $ _attributes , true ) ; }
select type multiselect form object .
56,615
public function hidden ( $ name = NULL , String $ value = NULL ) { $ name = $ this -> settings [ 'attr' ] [ 'name' ] ?? $ name ; $ value = $ this -> settings [ 'attr' ] [ 'value' ] ?? $ value ; $ this -> settings [ 'attr' ] = [ ] ; $ hiddens = NULL ; if ( is_array ( $ name ) ) foreach ( $ name as $ key => $ val ) { $ hiddens .= $ this -> createHiddenElement ( $ key , $ val ) ; } else { $ hiddens = $ this -> createHiddenElement ( $ name , $ value ) ; } $ this -> outputElement .= $ hiddens ; return $ this ; }
hidden form object .
56,616
public function file ( String $ name = NULL , Bool $ multiple = false , Array $ _attributes = [ ] ) { if ( ! empty ( $ this -> settings [ 'attr' ] [ 'multiple' ] ) ) { $ multiple = true ; } $ name = $ this -> settings [ 'attr' ] [ 'name' ] ?? $ name ; if ( $ multiple === true ) { $ this -> settings [ 'attr' ] [ 'multiple' ] = 'multiple' ; $ name = Base :: suffix ( $ name , '[]' ) ; } $ this -> commonMethodsForInputElements ( 'file' ) ; return $ this -> _input ( $ name , '' , $ _attributes , 'file' ) ; }
file form object .
56,617
public function group ( $ code = '' , String $ class = '' ) { if ( is_string ( $ code ) ) { $ this -> settings [ 'group' ] [ 'class' ] = $ this -> bootstrapClassResolution ( 'form-group' , $ code ) ; return $ this ; } elseif ( is_callable ( $ code ) ) { $ this -> callableGroup = true ; $ result = $ this -> getHTMLClass ( ) -> class ( 'form-group row' . Base :: prefix ( $ class , ' ' ) ) -> div ( EOL . Buffering \ Callback :: do ( $ code ) ) ; unset ( $ this -> callableGroup ) ; return $ result ; } }
Use of bootstrap group
56,618
public function label ( String $ for = NULL , String $ value = NULL , String $ class = NULL ) { $ this -> settings [ 'label' ] [ 'for' ] = $ for ; $ this -> settings [ 'label' ] [ 'value' ] = $ value ; $ this -> settings [ 'label' ] [ 'class' ] = $ class ; return $ this ; }
Use of bootstrap label
56,619
protected function createSelectElement ( $ options , $ selected , $ _attributes , & $ return ) { $ return = '<select' . $ this -> attributes ( $ _attributes ) . '>' ; if ( is_array ( $ options ) ) foreach ( $ options as $ key => $ value ) { if ( is_array ( $ selected ) ) { if ( in_array ( $ key , $ selected ) ) { $ select = ' selected="selected"' ; } else { $ select = "" ; } } else { if ( $ selected == $ key ) { $ select = ' selected="selected"' ; } else { $ select = "" ; } } $ return .= '<option value="' . $ key . '"' . $ select . '>' . $ value . '</option>' . EOL ; } $ return .= '</select>' . EOL ; }
Protected create select element
56,620
protected function setSelectedAttribute ( & $ selected , $ options ) { $ selected = $ this -> settings [ 'selectedKey' ] ?? $ selected ; if ( isset ( $ this -> settings [ 'selectedValue' ] ) ) { $ flip = array_flip ( $ options ) ; $ selected = $ flip [ $ this -> settings [ 'selectedValue' ] ] ; } }
Protected set selected attribute
56,621
protected function isOrderAttribute ( & $ options ) { if ( isset ( $ this -> settings [ 'order' ] [ 'type' ] ) ) { $ options = Arrays \ Sort :: order ( $ options , $ this -> settings [ 'order' ] [ 'type' ] , $ this -> settings [ 'order' ] [ 'flags' ] ) ; } }
Protected is order attribute
56,622
protected function isExcludeAttribute ( & $ options ) { if ( isset ( $ this -> settings [ 'exclude' ] ) ) { $ options = Arrays \ Excluding :: use ( $ options , $ this -> settings [ 'exclude' ] ) ; } }
Protected is exclude attribute
56,623
protected function isIncludeAttribute ( & $ options ) { if ( isset ( $ this -> settings [ 'include' ] ) ) { $ options = Arrays \ Including :: use ( $ options , $ this -> settings [ 'include' ] ) ; } }
Protected is include attribute
56,624
protected function isTableOrQueryData ( & $ options ) { if ( ! empty ( $ this -> settings [ 'table' ] ) || ! empty ( $ this -> settings [ 'query' ] ) ) { $ key = key ( $ options ) ; $ current = current ( $ options ) ; array_shift ( $ options ) ; $ dbClass = Singleton :: class ( 'ZN\Database\DB' ) ; if ( ! empty ( $ this -> settings [ 'table' ] ) ) { $ table = $ this -> settings [ 'table' ] ; if ( strstr ( $ table , ':' ) ) { $ tableEx = explode ( ':' , $ tableEx ) ; $ table = $ tableEx [ 1 ] ; $ db = $ tableEx [ 0 ] ; $ db = $ dbClass -> differentConnection ( $ db ) ; $ result = $ db -> select ( $ current , $ key ) -> get ( $ table ) -> result ( ) ; } else { $ result = $ dbClass -> select ( $ current , $ key ) -> get ( $ table ) -> result ( ) ; } } else { $ result = $ dbClass -> query ( $ this -> settings [ 'query' ] ) -> result ( ) ; } foreach ( $ result as $ row ) { $ options [ $ row -> $ key ] = $ row -> $ current ; } } }
Protected is table or query data
56,625
protected function setNameAttribute ( $ name ) { if ( ! isset ( $ this -> settings [ 'attr' ] [ 'name' ] ) && ! empty ( $ name ) ) { $ this -> settings [ 'attr' ] [ 'name' ] = $ name ; } }
Protected set textarea name attribute
56,626
protected function isEnctypeAttribute ( & $ _attributes ) { if ( isset ( $ _attributes [ 'enctype' ] ) ) { $ enctype = $ _attributes [ 'enctype' ] ; if ( isset ( $ this -> enctypes [ $ enctype ] ) ) { $ _attributes [ 'enctype' ] = $ this -> enctypes [ $ enctype ] ; } } }
Protected is enctype attribute
56,627
protected function isWhereAttribute ( $ name ) { if ( isset ( $ this -> settings [ 'where' ] ) ) { $ this -> settings [ 'getrow' ] = Singleton :: class ( 'ZN\Database\DB' ) -> get ( $ name ) -> row ( ) ; } }
Protected is where attribute
56,628
protected function isQueryAttribute ( ) { if ( $ query = ( $ this -> settings [ 'query' ] ?? NULL ) ) { $ this -> settings [ 'getrow' ] = Singleton :: class ( 'ZN\Database\DB' ) -> query ( $ query ) -> row ( ) ; } }
Protected is query attribute
56,629
protected function _unsetselect ( ) { unset ( $ this -> settings [ 'table' ] ) ; unset ( $ this -> settings [ 'query' ] ) ; unset ( $ this -> settings [ 'option' ] ) ; unset ( $ this -> settings [ 'exclude' ] ) ; unset ( $ this -> settings [ 'include' ] ) ; unset ( $ this -> settings [ 'order' ] ) ; unset ( $ this -> settings [ 'selectedKey' ] ) ; unset ( $ this -> settings [ 'selectedValue' ] ) ; }
protected unset select variables
56,630
protected function _unsetopen ( ) { unset ( $ this -> settings [ 'where' ] ) ; unset ( $ this -> settings [ 'whereValue' ] ) ; unset ( $ this -> settings [ 'whereColumn' ] ) ; unset ( $ this -> settings [ 'query' ] ) ; unset ( $ this -> settings [ 'token' ] ) ; unset ( $ this -> settings [ 'process' ] ) ; unset ( $ this -> settings [ 'duplicateCheck' ] ) ; }
protected unset open variables
56,631
public function send ( $ opt = null ) { $ http = new $ this -> request_class ( ) ; $ response = $ http -> send_multi_request ( $ this -> queue , array ( 'limit' => $ this -> limit ) ) ; return $ response ; }
Executes the batch request queue .
56,632
public function many ( array $ keys ) { $ results = [ ] ; foreach ( $ keys as $ key ) { $ results [ $ key ] = $ this -> get ( $ key ) ; } return $ results ; }
Retrieve multiple items from the cache by key . Items not found in the cache will have a null value .
56,633
public function getPrefix ( ) { $ uuid = uniqid ( static :: CACHE_CHECK_PREFIX , true ) ; $ prefix = wp_cache_get ( $ this -> prefix , static :: CACHE_GROUP_KEY , false , $ uuid ) ; if ( $ prefix !== $ uuid ) { return $ prefix ; } $ this -> setPrefix ( $ this -> prefix ) ; return $ this -> getPrefix ( ) ; }
Get the cache key prefix .
56,634
public function setPrefix ( $ prefix ) { global $ wpdb ; $ this -> prefix = ! empty ( $ prefix ) ? $ prefix : $ wpdb -> prefix ; wp_cache_set ( $ prefix , uniqid ( $ prefix , true ) , static :: CACHE_GROUP_KEY , 0 ) ; }
Set the cache key prefix .
56,635
public function tags ( $ names ) { return new WordPressTaggedCache ( $ this , new TagSet ( $ this , is_array ( $ names ) ? $ names : func_get_args ( ) ) ) ; }
begin executing a new tags operation
56,636
public static function updateNginx ( $ srcFilename , $ dstFilename , $ backupDir = null ) { return self :: updateFile ( $ srcFilename , $ dstFilename , 'nginx' , $ backupDir ) ; }
Update nginx config
56,637
public static function updateCrontab ( $ sourceFilename , $ backupDir = null ) { if ( empty ( $ sourceFilename ) ) { throw new \ InvalidArgumentException ( 'Invalid argument $srcFilename, must be not empty' ) ; } if ( ! FileHelper :: fileExists ( $ sourceFilename ) ) { throw new \ RuntimeException ( sprintf ( 'File crontab_filename:"%s" not found' , $ sourceFilename ) ) ; } $ backupDir = $ backupDir ? : '{{deploy_path}}/backup/crontab' ; if ( ! FileHelper :: dirExists ( $ backupDir ) ) { run ( 'mkdir -p ' . $ backupDir ) ; ! isVerbose ( ) ? : writeln ( sprintf ( 'Backup dir "%s" created' , $ backupDir ) ) ; } $ backupFilename = sprintf ( '%s/crontab.%s' , $ backupDir , date ( 'Y-m-d_H:i:s' ) ) ; if ( ( bool ) run ( 'if crontab -l > /dev/null 2>&1; then echo 1; else echo 0; fi' ) ) { run ( sprintf ( 'crontab -l > %s' , $ backupFilename ) ) ; } else { run ( sprintf ( 'touch %s' , $ backupFilename ) ) ; } $ diff = ( bool ) run ( sprintf ( 'if ! diff -q %s %s > /dev/null 2>&1; then echo 1; fi' , $ backupFilename , $ sourceFilename ) ) ; $ result = false ; if ( $ diff ) { run ( sprintf ( 'crontab "%s"' , $ sourceFilename ) ) ; ! isVerbose ( ) ? : writeln ( run ( 'crontab -l' ) ) ; $ result = true ; } else { ! isVerbose ( ) ? : writeln ( 'Crontab has no diff' ) ; run ( 'rm ' . $ backupFilename ) ; } return $ result ; }
Update user crontab
56,638
public function deliverMessage ( UserEventInterface $ event , EventQueueInterface $ queue ) { if ( $ event -> getNick ( ) != $ event -> getConnection ( ) -> getNickname ( ) ) { $ messages = $ this -> database -> retrieveMessages ( $ event -> getNick ( ) ) ; foreach ( $ messages as $ row ) { $ message = sprintf ( '(%s) %s: %s' , ( new \ DateTime ( $ row [ 'timestamp' ] ) ) -> format ( 'm/d h:ia' ) , $ row [ 'sender' ] , $ row [ 'message' ] ) ; $ queue -> ircNotice ( $ event -> getNick ( ) , $ message ) ; } } }
Listen for an user activity and send all stored messages .
56,639
public function handleCommand ( CommandEventInterface $ event , EventQueueInterface $ queue ) { $ params = $ event -> getCustomParams ( ) ; if ( count ( $ params ) < 2 ) { $ queue -> ircNotice ( $ event -> getNick ( ) , 'Can\'t identify nickname or message.' ) ; $ this -> helpMessages ( [ $ queue , 'ircNotice' ] , $ event -> getNick ( ) , $ event -> getCustomCommand ( ) ) ; } else { $ message = implode ( ' ' , array_slice ( $ params , 1 ) ) ; if ( $ this -> database -> postMessage ( $ event -> getNick ( ) , $ params [ 0 ] , $ message ) ) { $ queue -> ircNotice ( $ event -> getNick ( ) , 'Ok, I\'ll tell him/her.' ) ; } else { $ queue -> ircNotice ( $ event -> getNick ( ) , 'Sry, There\'s so many things to tell him/her.' ) ; } } }
Handles command calls
56,640
public function helpCommand ( CommandEventInterface $ event , EventQueueInterface $ queue ) { $ command = strpos ( $ event -> getCustomCommand ( ) , '.help' ) !== false ? substr ( $ event -> getCustomCommand ( ) , 0 , - 5 ) : $ event -> getCustomParams ( ) [ 0 ] ; $ this -> helpMessages ( [ $ queue , 'irc' . $ event -> getCommand ( ) ] , $ event -> getSource ( ) , $ command ) ; }
Handles help command calls
56,641
private function helpMessages ( callable $ callback , $ target , $ command ) { call_user_func ( $ callback , $ target , 'Usage: ' . $ command . ' <nickname> <message>' ) ; call_user_func ( $ callback , $ target , 'Stores a <message> to be send next time the <nickname> is seen.' ) ; }
Reply with usage help messages
56,642
public function start ( ) { $ whoops = new Run ( ) ; $ handler = new PrettyPageHandler ( ) ; $ handler -> addResourcePath ( __DIR__ . '/Resources' ) ; $ handler -> setEditor ( 'sublime' ) ; $ whoops -> pushHandler ( $ handler ) ; $ whoops -> register ( ) ; $ this -> whoops = $ whoops ; }
Register the Whoops! Exception Handler
56,643
public function run ( ) { $ this -> runCompilationByArrangedPriority ( ) ; foreach ( $ this -> components as $ name => $ classes ) { $ this -> compileGroupClasses ( $ name , $ classes ) ; } $ original = $ this -> config -> get ( 'compile.files' , [ ] ) ; foreach ( $ original as $ class ) { $ this -> collection [ 'added' ] [ ] = $ class ; } $ this -> config -> set ( 'compile.files' , $ this -> collection [ 'added' ] ) ; return new Fluent ( [ 'added' => $ this -> collection [ 'added' ] , 'missing' => $ this -> collection [ 'missing' ] , ] ) ; }
Run compile optimization list .
56,644
protected function runCompilationByArrangedPriority ( ) { foreach ( $ this -> arrange as $ name ) { if ( ! isset ( $ this -> components [ $ name ] ) ) { continue ; } $ classes = $ this -> components [ $ name ] ; $ this -> compileGroupClasses ( $ name , $ classes ) ; unset ( $ this -> components [ $ name ] ) ; } }
Compilation should be appended by priority to avoid class redeclared issue .
56,645
protected function compileGroupClasses ( $ name , array $ classes ) { $ path = "{$this->path}/{$name}" ; if ( ! $ this -> files -> isDirectory ( $ path ) ) { return ; } foreach ( $ classes as $ class ) { $ file = "{$path}/{$class}.php" ; if ( $ this -> files -> exists ( $ file ) ) { $ this -> collection [ 'added' ] [ ] = $ file ; } else { $ this -> collection [ 'missing' ] [ ] = $ file ; } } }
Compile classes by group .
56,646
public function addPaths ( $ paths ) { if ( is_string ( $ paths ) ) { $ paths = array ( $ paths ) ; } foreach ( $ paths as $ path ) { $ this -> searchPaths [ ] = $ path ; } }
Adds paths to the default search array .
56,647
public static function make ( array $ config = [ ] , $ name = '' ) { if ( ! \ is_array ( $ config ) ) { throw new \ InvalidArgumentException ( 'Logger config is must be an array and not allow empty.' ) ; } $ name = $ name ? : ( $ config [ 'name' ] ?? '' ) ; if ( ! $ name ) { throw new \ InvalidArgumentException ( 'Logger name is required.' ) ; } if ( ! isset ( self :: $ loggers [ $ name ] ) ) { self :: $ loggers [ $ name ] = new static ( $ config , $ name ) ; } if ( ! self :: $ shutdownRegistered ) { register_shutdown_function ( function ( ) { self :: flushAll ( ) ; register_shutdown_function ( [ self :: class , 'flushAll' ] , true ) ; } ) ; self :: $ shutdownRegistered = true ; } return self :: $ loggers [ $ name ] ; }
create new instance or get exists instance
56,648
public static function arrayRemove ( $ arr , $ key , $ default = null ) { if ( isset ( $ arr [ $ key ] ) ) { $ value = $ arr [ $ key ] ; unset ( $ arr [ $ key ] ) ; return $ value ; } return $ default ; }
get value and unset it
56,649
public function instance ( $ name = null ) { if ( empty ( $ instance ) ) { throw new Exception ( "A cart name is mandatory." ) ; } $ this -> instance = $ name ; return $ this ; }
Set the current cart instance
56,650
public function add ( $ id , $ name = null , $ qty = null , $ price = null , Array $ options = array ( ) ) { if ( Arrays :: is ( $ id ) ) { if ( $ this -> isMulti ( $ id ) ) { foreach ( $ id as $ item ) { $ options = Arrays :: exists ( 'options' , $ item ) ? $ item [ 'options' ] : array ( ) ; $ this -> addRow ( $ item [ 'id' ] , $ item [ 'name' ] , $ item [ 'qty' ] , $ item [ 'price' ] , $ options ) ; } return ; } $ options = Arrays :: exists ( 'options' , $ id ) ? $ id [ 'options' ] : array ( ) ; return $ this -> addRow ( $ id [ 'id' ] , $ id [ 'name' ] , $ id [ 'qty' ] , $ id [ 'price' ] , $ options ) ; } return $ this -> addRow ( $ id , $ name , $ qty , $ price , $ options ) ; }
Add a row to the cart
56,651
public function update ( $ rowId , $ attribute ) { if ( ! $ this -> hasRowId ( $ rowId ) ) { throw new Exception ( 'This cart does not contain this row.' ) ; } if ( Arrays :: isArray ( $ attribute ) ) { return $ this -> updateAttribute ( $ rowId , $ attribute ) ; } return $ this -> updateQty ( $ rowId , $ attribute ) ; }
Update the quantity of one row of the cart
56,652
public function remove ( $ rowId ) { if ( ! $ this -> hasRowId ( $ rowId ) ) { throw new Exception ( 'This cart does not contain this row.' ) ; } $ cart = $ this -> getContent ( ) ; $ cart -> forget ( $ rowId ) ; return $ this -> updateCart ( $ cart ) ; }
Remove a row from the cart
56,653
public function get ( $ rowId ) { $ cart = $ this -> getContent ( ) ; $ rows = $ cart -> _fields ; return ( Arrays :: inArray ( $ rowId , $ rows ) ) ? $ cart -> $ rowId : null ; }
Get a row of the cart by its ID
56,654
public function content ( ) { $ cart = $ this -> getContent ( ) ; $ rows = $ cart -> _fields ; if ( ! count ( $ rows ) ) { return null ; } $ content = array ( ) ; foreach ( $ rows as $ rowId ) { $ content [ $ rowId ] = $ cart -> $ rowId ; } return $ content ; }
Get the cart content
56,655
public function total ( ) { $ total = 0 ; $ cart = $ this -> getContent ( ) ; if ( empty ( $ cart -> _fields ) ) { return $ total ; } foreach ( $ cart -> _fields as $ rowId ) { $ row = $ cart -> $ rowId ; $ total += $ row -> subtotal ; } return $ total ; }
Get the price total
56,656
public function count ( $ totalItems = true ) { $ cart = $ this -> getContent ( ) ; if ( false === $ totalItems ) { return count ( $ cart -> _fields ) ; } $ count = 0 ; foreach ( $ cart -> _fields as $ rowId ) { $ row = $ cart -> $ rowId ; $ count += $ row -> qty ; } return $ count ; }
Get the number of items in the cart
56,657
public function search ( array $ search ) { $ results = array ( ) ; $ cart = $ this -> getContent ( ) ; $ rows = $ cart -> _fields ; foreach ( $ rows as $ rowId ) { $ item = $ cart -> $ rowId ; $ found = $ item -> search ( $ search ) ; if ( true === $ found ) { $ results [ ] = $ item ; } } return ( empty ( $ results ) ) ? false : $ results ; }
Search if the cart has a item
56,658
protected function addRow ( $ id , $ name , $ qty , $ price , array $ options = array ( ) ) { if ( empty ( $ id ) || empty ( $ name ) || empty ( $ qty ) || empty ( $ price ) ) { throw new Exception ( 'Some mandatory info are missing' ) ; } if ( ! is_numeric ( $ qty ) ) { throw new Exception ( 'Quantity must be numeric.' ) ; } if ( ! is_numeric ( $ price ) ) { throw new Exception ( 'Price must be numeric.' ) ; } $ cart = $ this -> getContent ( ) ; $ rowId = $ this -> generateRowId ( $ id , $ options ) ; if ( Arrays :: in ( $ rowId , $ cart -> _fields ) ) { $ row = $ cart -> $ rowId ; $ cart = $ this -> updateRow ( $ rowId , array ( 'qty' => $ row -> qty + $ qty ) ) ; } else { $ cart = $ this -> createRow ( $ rowId , $ id , $ name , $ qty , $ price , $ options ) ; } return $ this -> updateCart ( $ cart ) ; }
Add row to the cart
56,659
protected function hasRowId ( $ rowId ) { $ cart = $ this -> getContent ( ) ; $ rows = $ cart -> _fields ; return Arrays :: in ( $ rowId , $ rows ) ; }
Check if a rowid exists in the current cart instance
56,660
protected function updateRow ( $ rowId , $ attributes ) { $ cart = $ this -> getContent ( ) ; $ row = $ cart -> $ rowId ; $ row -> populate ( $ attributes ) ; if ( ! is_null ( array_keys ( $ attributes , array ( 'qty' , 'price' ) ) ) ) { $ row -> put ( 'subtotal' , $ row -> qty * $ row -> price ) ; } $ cart -> put ( $ rowId , $ row ) ; return $ cart ; }
Update a row if the rowId already exists
56,661
protected function createRow ( $ rowId , $ id , $ name , $ qty , $ price , $ options ) { $ cart = $ this -> getContent ( ) ; $ newRow = new Container ( ) ; $ values = array ( 'rowid' => $ rowId , 'id' => $ id , 'name' => $ name , 'qty' => $ qty , 'price' => $ price , 'options' => new Container ( $ options ) , 'subtotal' => $ qty * $ price ) ; $ newRow -> populate ( $ values ) ; $ cart -> put ( $ rowId , $ newRow ) ; return $ cart ; }
Create a new row Object
56,662
protected function updateQty ( $ rowId , $ qty ) { if ( 1 > $ qty ) { return $ this -> remove ( $ rowId ) ; } return $ this -> updateRow ( $ rowId , array ( 'qty' => $ qty ) ) ; }
Update the quantity of a row
56,663
private function getLength ( string $ string ) : ? int { if ( extension_loaded ( 'mbstring' ) && ! defined ( 'NO_PHP_EXTENSIONS' ) ) { if ( ! mb_check_encoding ( $ string , 'UTF-8' ) ) { return null ; } return mb_strlen ( $ string , 'UTF-8' ) ; } $ charLength = 0 ; $ length = strlen ( $ string ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ charLength ++ ; $ char = ord ( $ string [ $ i ] ) ; if ( $ char < 0x80 ) { continue ; } if ( ( $ char & 0xE0 ) === 0xC0 ) { $ n = 1 ; } elseif ( ( $ char & 0xF0 ) === 0xE0 ) { $ n = 2 ; } elseif ( ( $ char & 0xF0 ) === 0xF0 ) { $ n = 3 ; } else { return null ; } for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( ++ $ i === $ length ) { return null ; } if ( ( ord ( $ string [ $ i ] ) & 0xC0 ) !== 0x80 ) { return null ; } } } return $ charLength ; }
Returns the length of the given string or null if not a valid UTF - 8 string .
56,664
protected function checkServerAndAbort ( $ server = null ) { $ server = $ server ? $ server : fp_env ( 'ACACHA_FORGE_SERVER' ) ; if ( ! $ this -> checkServer ( $ server ) ) { $ this -> error ( 'Server ' . $ server . ' not valid' ) ; die ( ) ; } }
Check server and abort .
56,665
protected function checkValue ( $ env_var , $ field , $ value = null , $ servers = null ) { $ value = $ value ? $ value : fp_env ( $ env_var ) ; $ servers = $ servers ? $ servers : $ this -> obtainServers ( ) ; return in_array ( $ value , collect ( $ servers ) -> pluck ( $ field ) -> toArray ( ) ) ; }
Check value in servers .
56,666
public function render ( ) { if ( ! $ this -> checkAnsiAwareSystem ( ) ) { return $ this -> str ; } if ( $ this -> has_tags ) { return $ this -> tag_format -> parse ( $ this -> str ) ; } elseif ( ! empty ( $ this -> str ) ) { $ this -> output -> useEffect ( $ this -> format ) ; return $ this -> output -> build ( ) ; } return $ this -> str ; }
Renders the text with color and effet applied .
56,667
public static function authorize ( $ code ) { $ config = self :: config ( ) ; if ( ! $ config ) { return false ; } $ url = self :: $ clef_base_url . "authorize" ; $ postdata = http_build_query ( array ( 'code' => $ code , 'app_id' => $ config [ 'app_id' ] , 'app_secret' => $ config [ 'app_secret' ] ) ) ; $ opts = array ( 'http' => array ( 'method' => 'POST' , 'header' => 'Content-type: application/x-www-form-urlencoded' , 'content' => $ postdata ) ) ; $ context = stream_context_create ( $ opts ) ; $ response = file_get_contents ( $ url , false , $ context ) ; if ( $ response ) { $ response = json_decode ( $ response , true ) ; return $ response ; } return false ; }
Return authorization from Clef . io for an account
56,668
public static function info ( $ access_token ) { $ opts = array ( 'http' => array ( 'method' => 'GET' ) ) ; $ url = self :: $ clef_base_url . "info?access_token=" . $ access_token ; $ context = stream_context_create ( $ opts ) ; $ response = file_get_contents ( $ url , false , $ context ) ; if ( ! $ response ) { $ response = json_decode ( $ response , true ) ; return $ response ; } return false ; }
Get info about member by access_token
56,669
public static function authentication ( $ code = '' ) { if ( empty ( $ code ) ) { return false ; } $ authorize = self :: authorize ( $ code ) ; if ( ! $ authorize ) { return false ; } if ( isset ( $ authorize [ 'error' ] ) ) { return $ authorize ; } return self :: info ( $ authorize [ 'access_token' ] ) ; }
Get authentication of a Clef account
56,670
public static function button ( $ url , $ params = array ( ) ) { $ config = self :: config ( ) ; if ( ! $ config ) { return null ; } $ color = ( isset ( $ params [ 'color' ] ) && $ params [ 'color' ] == "white" ) ? "white" : "blue" ; $ style = ( isset ( $ params [ 'style' ] ) && $ params [ 'style' ] == "button" ) ? "button" : "flat" ; return '<script type="text/javascript" src="https://clef.io/v3/clef.js" class="clef-button" data-app-id="' . $ config [ 'app_id' ] . '" data-color="' . $ color . '" data-style="' . $ style . '" data-redirect-url="' . $ url . '"></script>' ; }
Display button for Login
56,671
public static function customButton ( $ title , $ url , $ attributes = array ( ) ) { $ config = self :: config ( ) ; if ( ! $ config ) { return null ; } $ attributes = Helpers :: addClass ( $ attributes , "clef" ) ; return '<a href="https://clef.io/iframes/qr?app_id=' . $ config [ 'app_id' ] . '&amp;redirect_url=' . $ url . '" ' . \ HTML :: attributes ( $ attributes ) . '>' . $ title . '</a>' ; }
Display custom button for Login
56,672
private function makeMigration ( $ option ) { if ( $ option ) { $ table = Str :: plural ( Str :: snake ( class_basename ( $ this -> argument ( 'name' ) ) ) ) ; $ this -> call ( 'make:migration' , [ 'name' => "create_{$table}_table" , '--create' => $ table ] ) ; } }
Create migration file if not null
56,673
private function makeResourceController ( $ option ) { if ( $ option ) { $ controllerName = Str :: studly ( class_basename ( $ this -> argument ( 'name' ) ) ) ; $ controllerNameFile = $ controllerName . 'Controller.php' ; try { $ controllerPath = __DIR__ . '/controller.stub' ; $ controllerAppPath = app_path ( 'Http/Controllers/' . $ controllerNameFile ) ; $ this -> helper -> replaceAndSave ( $ controllerPath , '{{name}}' , $ controllerName , $ controllerAppPath ) ; } catch ( \ Exception $ e ) { return $ this -> error ( $ e -> getMessage ( ) ) ; } } }
Create resource controller if not null
56,674
private function createObjectFiles ( $ name , $ newObject , $ newContract , $ newConcrete ) { try { $ objectPath = __DIR__ . '/object.stub' ; $ objectAppPath = app_path ( 'Models/Objects/' . $ newObject ) ; $ this -> helper -> replaceAndSave ( $ objectPath , '{{name}}' , $ name , $ objectAppPath ) ; } catch ( \ Exception $ e ) { return $ this -> error ( $ e -> getMessage ( ) ) ; } try { $ contractPath = __DIR__ . '/contract.stub' ; $ contractAppPath = app_path ( 'Models/Contracts/Repositories/' . $ newContract ) ; $ this -> helper -> replaceAndSave ( $ contractPath , '{{name}}' , $ name , $ contractAppPath ) ; } catch ( \ Exception $ e ) { return $ this -> error ( $ e -> getMessage ( ) ) ; } try { $ concretePath = __DIR__ . '/concrete.stub' ; $ concreteAppPath = app_path ( 'Models/Concrete/Eloquent/' . $ newConcrete ) ; $ this -> helper -> replaceAndSave ( $ concretePath , '{{name}}' , $ name , $ concreteAppPath ) ; } catch ( \ Exception $ e ) { return $ this -> error ( $ e -> getMessage ( ) ) ; } }
Create oject repository files
56,675
private function makeBindings ( $ newContract , $ newConcrete ) { $ appBindContract = substr ( 'App\Models\Contracts\Repositories\\' . $ newContract , 0 , - 4 ) ; $ appBindConcrete = substr ( 'App\Models\Concrete\Eloquent\\' . $ newConcrete , 0 , - 4 ) ; $ bindImplementation = "public function register() { \$this->app->bind( '$appBindContract', // Repository (Interface) '$appBindConcrete' // Eloquent (Class) ); " ; $ search = 'public function register() {' ; try { $ this -> helper -> replaceAndSave ( getcwd ( ) . '/app/providers/AppServiceProvider.php' , $ search , $ bindImplementation ) ; } catch ( \ Exception $ e ) { $ this -> error ( $ e -> getMessage ( ) ) ; } }
Make the necessary bindings for the repository
56,676
public function run ( $ handler , $ data = null , array $ options = [ ] ) { $ this -> _handler = Handlers :: get ( $ handler ) ; $ this -> _data = $ data === null ? $ this -> _data : $ data ; $ options += $ this -> _handler -> options ( ) + [ 'queue' => 'default' , 'priority' => static :: PRIORITY_NORMAL , 'wait' => false , 'fallback' => false , 'ttr' => 600 ] ; if ( ! $ this -> _connection -> online ( ) ) { if ( ! $ options [ 'fallback' ] ) { throw new Exception ( 'Connection offline; not allowed to fallback.' ) ; } $ this -> _log -> notice ( "Connection offline; performing job `{$this}` inline." ) ; $ this -> perform ( ) ; return ; } $ body = $ this -> _serialize ( [ 'handler' => $ this -> _handler -> name ( ) , 'data' => $ data ] ) ; $ this -> _id = $ this -> _connection -> enqueue ( $ options [ 'queue' ] , $ body , [ 'priority' => $ options [ 'priority' ] , 'ttr' => $ options [ 'ttr' ] , 'delay' => 0 ] ) ; if ( $ options [ 'wait' ] ) { $ this -> _connection -> wait ( [ $ this -> _id ] , $ options [ 'ttr' ] ) ; } }
Enqueues a job .
56,677
public function accionarEvento ( $ nombre ) { if ( isset ( $ this -> eventos [ $ nombre ] ) ) { $ argumentos = func_get_args ( ) ; array_shift ( $ argumentos ) ; if ( count ( $ this -> eventos [ $ nombre ] ) > 1 ) { $ resultado = [ ] ; foreach ( $ this -> eventos [ $ nombre ] as $ definicion ) { $ resultado [ ] = call_user_func_array ( $ definicion , $ argumentos ) ; } return $ resultado ; } return call_user_func_array ( $ this -> eventos [ $ nombre ] [ 0 ] , $ argumentos ) ; } return null ; }
Dispara un evento pasando argumentos de forma opcional .
56,678
private function setCustomizersPosition ( ) { if ( ! preg_match ( '/^\s*return[\n\s]+(?:\[|array[\s\n]*\()/ims' , $ this -> contents , $ m ) ) { throw new Exception ( 'Failed to determine the start of the return array' ) ; } $ this -> customizersPosition = strpos ( $ this -> contents , $ m [ 0 ] ) ; }
Set the position inside the read content where we can add custom code .
56,679
public function authenticate ( TokenInterface $ token = null ) { $ token = $ token ? : $ this -> authenticator -> present ( ) ; if ( ! $ token instanceof TokenInterface ) { return new Result ( Result :: FAILURE_NO_TOKEN ) ; } $ result = new Result ( ) ; try { $ token = $ this -> authenticator -> authenticate ( $ token ) ; } catch ( AuthenticationException $ e ) { $ result -> setCode ( $ e -> getCode ( ) ) ; $ result -> setException ( $ e ) ; $ result -> setToken ( $ e -> getToken ( ) ) ; return $ result ; } $ result -> setCode ( Result :: SUCCESS ) ; $ result -> setToken ( $ token ) ; if ( ! $ token instanceof StatelessTokenInterface ) { $ this -> storage -> write ( $ token ) ; } $ this -> setToken ( $ token ) ; return $ result ; }
Authenticate a token or ask providers to provide a token to authenticate
56,680
public function isGranted ( $ attributes , $ object = null ) { if ( ! is_array ( $ attributes ) ) { $ attributes = [ $ attributes ] ; } return $ this -> authorizationManager -> decide ( $ this -> getToken ( ) , $ attributes , $ object ) ; }
Check if the current token is granted permissions .
56,681
public function initialize ( ) { if ( ! isset ( $ this -> authenticator ) ) { throw new \ RuntimeException ( 'Aegis is missing an authentication authenticator.' ) ; } if ( ! isset ( $ this -> storage ) ) { throw new \ RuntimeException ( 'Aegis is missing a persistent storage engine.' ) ; } $ this -> setToken ( new AnonymousToken ( ) ) ; $ token = $ this -> storage -> read ( ) ; if ( $ token instanceof TokenInterface ) { $ result = $ this -> authenticate ( $ token ) ; } $ this -> initialized = true ; return $ this ; }
Initialize Aegis .
56,682
public function SetServiceName ( $ sServiceName ) { $ bRet = false ; if ( CLib :: IsExistingString ( $ sServiceName ) ) { $ bRet = true ; $ this -> m_sServiceName = $ sServiceName ; } return $ bRet ; }
set service name and url
56,683
public function GetResponseVData ( $ arrResponse ) { if ( CLib :: IsArrayWithKeys ( $ arrResponse , 'vdata' ) || CLib :: IsObjectWithProperties ( $ arrResponse , 'vdata' ) ) { return $ arrResponse [ 'vdata' ] ; } else { return null ; } }
get error id from response VData array
56,684
public function GetVDataArray ( $ nErrorId , $ sErrorDesc = '' , $ arrVData = [ ] , $ sVersion = '1.0' , $ bCached = null , $ arrExtra = [ ] ) { $ arrHeader = [ ] ; $ arrRet = [ ] ; if ( is_numeric ( $ nErrorId ) ) { $ nErrorId = intval ( $ nErrorId ) ; $ sErrorDesc = ( ( is_string ( $ sErrorDesc ) || is_numeric ( $ sErrorDesc ) ) ? strval ( $ sErrorDesc ) : '' ) ; $ arrRet = [ 'errorid' => $ nErrorId , 'errordesc' => $ sErrorDesc , 'vdata' => ( ( is_array ( $ arrVData ) || is_object ( $ arrVData ) ) ? $ arrVData : [ ] ) , ] ; } else { $ arrRet = $ this -> GetDefaultVDataJson ( ) ; } $ arrRet [ 'version' ] = ( is_string ( $ sVersion ) && strlen ( $ sVersion ) > 0 ) ? $ sVersion : self :: SERVICE_DEFAULT_VERSION ; if ( is_bool ( $ bCached ) ) { $ arrRet [ 'cache' ] = intval ( $ bCached ? 1 : 0 ) ; } if ( CLib :: IsArrayWithKeys ( $ arrExtra ) ) { foreach ( $ arrExtra as $ sKey => $ vValue ) { if ( CLib :: IsExistingString ( $ sKey , true ) ) { $ sKey = strtolower ( trim ( $ sKey ) ) ; if ( ! $ this -> IsReservedKey ( $ sKey ) && ! array_key_exists ( $ sKey , $ arrRet ) ) { $ arrRet [ $ sKey ] = $ vValue ; } } } } if ( CLib :: IsExistingString ( $ this -> m_sServiceName , true ) || CLib :: IsExistingString ( $ this -> m_sServiceUrl , true ) ) { $ arrRet = array_merge ( [ 'name' => $ this -> m_sServiceName , 'url' => $ this -> m_sServiceUrl , ] , $ arrRet ) ; } return $ arrRet ; }
get json in virtual data format
56,685
public function GetVDataString ( $ nErrorId , $ sErrorDesc = '' , $ arrVData = [ ] , $ sVersion = '1.0' , $ bCached = null , $ arrExtra = [ ] ) { $ sRet = '' ; $ arrJson = $ this -> GetVDataArray ( $ nErrorId , $ sErrorDesc , $ arrVData , $ sVersion , $ bCached , $ arrExtra ) ; if ( $ this -> IsValidVData ( $ arrJson ) ) { $ sRet = @ json_encode ( $ arrJson ) ; } else { $ sRet = @ json_encode ( $ this -> GetDefaultVDataJson ( ) ) ; } return $ sRet ; }
get json encoded string in virtual data format
56,686
public function GetVDataResponse ( $ nErrorId , $ sErrorDesc = '' , $ arrVData = [ ] , $ sVersion = self :: SERVICE_DEFAULT_VERSION , $ bCached = null , $ arrExtra = [ ] , $ nHttpStatus = Response :: HTTP_OK ) { $ cResponse = new Response ( ) ; $ sContentJson = '' ; $ sContentType = '' ; if ( ! is_numeric ( $ nHttpStatus ) ) { $ nHttpStatus = Response :: HTTP_OK ; } $ sContentJson = $ this -> GetVDataString ( $ nErrorId , $ sErrorDesc , $ arrVData , $ sVersion , $ bCached , $ arrExtra ) ; $ sContentType = $ this -> GetContentTypeWithVersion ( $ sVersion ) ; $ cResponse -> setContent ( $ sContentJson ) ; $ cResponse -> setStatusCode ( $ nHttpStatus ) ; $ cResponse -> headers -> set ( 'Content-Type' , $ sContentType ) ; if ( $ this -> IsAllowedCorsRequest ( ) ) { $ cResponse -> headers -> set ( 'Access-Control-Allow-Origin' , $ this -> m_cCors -> GetRefererHost ( true ) ) ; $ cResponse -> headers -> set ( 'Access-Control-Allow-Credentials' , 'true' ) ; $ cResponse -> headers -> set ( 'Access-Control-Allow-Headers' , 'Content-Type,Accept' ) ; $ cResponse -> headers -> set ( 'Access-Control-Allow-Methods' , 'POST,GET,OPTIONS,PUT,DELETE' ) ; } return $ cResponse ; }
get response object instance contains json encoded string in virtual data format
56,687
public function IsValidVData ( $ arrJson ) { return ( is_array ( $ arrJson ) && array_key_exists ( 'errorid' , $ arrJson ) && array_key_exists ( 'errordesc' , $ arrJson ) && array_key_exists ( 'vdata' , $ arrJson ) && is_numeric ( $ arrJson [ 'errorid' ] ) && is_string ( $ arrJson [ 'errordesc' ] ) && is_array ( $ arrJson [ 'vdata' ] ) ) ; }
if the variable being evaluated is a valid json in virtual data format ?
56,688
public function IsReservedKey ( $ sKey ) { $ bRet = false ; if ( CLib :: IsExistingString ( $ sKey , true ) ) { $ sKey = strtolower ( trim ( $ sKey ) ) ; $ bRet = in_array ( $ sKey , self :: ARR_RESERVED_KEYS ) ; } return $ bRet ; }
if the variable being evaluated is the reserved key
56,689
public function GetContentTypeWithVersion ( $ sVersion ) { return sprintf ( "%s%s" , CConst :: HTTP_HEADER_VERSION_CONTENT_TYPE , ( is_string ( $ sVersion ) && strlen ( $ sVersion ) > 0 ) ? $ sVersion : self :: SERVICE_DEFAULT_VERSION ) ; }
get content type of HTTP header
56,690
public function authorize ( Application $ app ) { $ server = $ this -> getAuthorizationServer ( $ app ) ; $ grant = $ server -> getGrantType ( 'password' ) ; try { $ result = $ grant -> completeFlow ( ) ; return new JsonResponse ( $ result ) ; } catch ( OAuthException $ e ) { return new JsonResponse ( [ 'error' => $ e -> errorType , 'message' => $ e -> getMessage ( ) , ] , $ e -> httpStatusCode ? : 500 , $ e -> getHttpHeaders ( ) ) ; } }
For password grant type
56,691
public function create ( $ url ) { if ( ! preg_match ( '!^\w+://! i' , $ url ) ) { $ url = url ( $ url ) ; } $ this -> url = $ url ; $ this -> session = curl_init ( $ this -> url ) ; return $ this ; }
Start a session from a URL
56,692
public function upload ( UploadedFile $ file ) { self :: $ generic_file -> moveUploadedFile ( new File ( $ file , $ file -> getClientOriginalName ( ) ) , null , $ this ) ; return $ this ; }
Store uploaded file by configured path pattern and fill data to this model .
56,693
public function delete ( ) { if ( self :: $ generic_file -> canRemoveFiles ( ) ) { $ file_usage_count = 0 ; if ( method_exists ( $ this , 'getFileUsageCount' ) ) { $ file_usage_count = $ this -> getFileUsageCount ( $ this ) ; } if ( $ file_usage_count <= 1 ) { self :: $ generic_file -> delete ( $ this ) ; } } return parent :: delete ( ) ; }
Delete file if not use in other models .
56,694
private function parseTokens ( ) { $ this -> tokens = $ this -> tokenStore -> getTokens ( $ this -> tokenMask ) ; $ this -> keys = array_keys ( $ this -> tokens ) ; $ this -> keyLengths = array_unique ( array_map ( 'strlen' , $ this -> keys ) ) ; arsort ( $ this -> keyLengths ) ; $ this -> maxLen = reset ( $ this -> keyLengths ) ; }
Parse the current set ok tokens and cache some metadata about them for speed
56,695
public function loadConfig ( $ parsedConfig ) { $ this -> _footerController = $ parsedConfig [ 'moduleConf' ] [ 'automatic_controller_footer' ] ; $ this -> _footerGlobal = $ parsedConfig [ 'moduleConf' ] [ 'automatic_global_footer' ] ; $ this -> _headerController = $ parsedConfig [ 'moduleConf' ] [ 'automatic_controller_header' ] ; $ this -> _headerGlobal = $ parsedConfig [ 'moduleConf' ] [ 'automatic_global_header' ] ; }
Initializes the module with defined configuration
56,696
public function doBeforeView ( $ context = null ) { if ( $ this -> _headerController ) { $ viewPath = ROOT . DS . 'app' . DS . 'views' . DS . strtolower ( $ this -> _controller -> getControllerName ( ) ) . DS . strtolower ( $ this -> _controller -> getAction ( ) ) . DS . 'header.php' ; if ( file_exists ( $ viewPath ) ) { $ this -> _controller -> addViewPre ( FView :: create ( strtolower ( $ this -> _controller -> getControllerName ( ) ) . DS . strtolower ( $ this -> _controller -> getAction ( ) ) . DS . 'header.php' , $ this -> getController ( ) -> getApp ( ) ) ) ; } elseif ( $ this -> _headerGlobal ) { $ viewPath = ROOT . DS . 'app' . DS . 'views' . DS . 'header.php' ; if ( file_exists ( $ viewPath ) ) { $ this -> _controller -> addViewPre ( FView :: create ( 'header.php' , $ this -> getController ( ) -> getApp ( ) ) ) ; } } } }
Adds the header as the first view to be rendered . The controller based - header has always the precedence on the global header
56,697
public function doAfter ( ) { if ( $ this -> _footerController ) { $ viewPath = ROOT . DS . 'app' . DS . 'views' . DS . strtolower ( $ this -> _controller -> getControllerName ( ) ) . DS . strtolower ( $ this -> _controller -> getAction ( ) ) . DS . 'footer.php' ; if ( file_exists ( $ viewPath ) ) { $ this -> _controller -> addView ( FView :: create ( strtolower ( $ this -> _controller -> getControllerName ( ) ) . DS . strtolower ( $ this -> _controller -> getAction ( ) ) . DS . 'footer.php' , $ this -> getController ( ) -> getApp ( ) ) ) ; } elseif ( $ this -> _footerGlobal ) { $ viewPath = ROOT . DS . 'app' . DS . 'views' . DS . 'footer.php' ; if ( file_exists ( $ viewPath ) ) { $ this -> _controller -> addView ( FView :: create ( 'footer.php' , $ this -> getController ( ) -> getApp ( ) ) ) ; } } } }
Executes actions after the views are rendered
56,698
public function staticRoleTitle ( $ roleKey ) { $ role = $ this -> roleCollection -> getRoleByKey ( $ roleKey ) ; return null !== $ role ? $ role -> getTitle ( ) : null ; }
Returns the static role name
56,699
public static function getAll ( ) : array { return [ self :: GET , self :: HEAD , self :: POST , self :: PUT , self :: DELETE , self :: CONNECT , self :: OPTIONS , self :: TRACE , self :: PATCH , ] ; }
Returns list of all valid HTTP request methods .