idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
13,600
public static function isDynamic ( string $ glob ) : bool { return strpos ( $ glob , '*' ) !== false || strpos ( $ glob , '?' ) !== false || strpos ( $ glob , '[' ) !== false ; }
Returns whether the glob is dynamic .
13,601
public static function toRegEx ( string $ glob ) : string { $ quoted = str_replace ( [ '?' , '*' ] , [ '.' , '.*' ] , $ glob ) ; $ regExp = '~^' . $ quoted . '$~' ; return $ regExp ; }
Converts the glob to a regular expression .
13,602
public function update ( $ table , $ data , $ keys , $ options = [ ] ) { return $ this -> object -> update ( $ table , $ data , $ keys , $ options ) ; }
Update table rows
13,603
public function when ( string $ type , array $ config = [ ] ) : self { if ( ! isset ( $ this -> data [ 'on' ] [ $ type ] ) ) { $ this -> data [ 'on' ] [ $ type ] = [ ] ; } $ this -> data [ 'on' ] [ $ type ] = \ array_merge ( $ this -> data [ 'on' ] [ $ type ] , $ config ) ; return $ this ; }
Setup on format configuration .
13,604
public function format ( ? string $ format = null , array $ config = [ ] ) : self { if ( ! \ is_null ( $ format ) && ! empty ( $ format ) ) { $ this -> setFormat ( $ format ) ; if ( ! empty ( $ config ) ) { $ this -> when ( $ format , $ config ) ; } } return $ this ; }
Get or set facile format .
13,605
public function delete ( $ dc ) { $ model = \ ContentModel :: findByPk ( $ dc -> id ) ; $ this -> objModel = new ContentWrapper \ Model ( $ model ) ; try { $ type = $ this -> objModel -> getType ( ) ; } catch ( \ Exception $ e ) { return ; } if ( $ this -> objModel -> getType ( ) == ContentWrapper \ Model :: TYPE_START...
handle content element deletion called by ondelete_callback
13,606
protected function createElement ( & $ sorting , $ type = ContentWrapper \ Model :: TYPE_SEPARATOR ) { $ model = new \ ContentModel ( ) ; if ( $ type == ContentWrapper \ Model :: TYPE_START ) { $ sorting = $ sorting - 2 ; } else { $ sorting = $ sorting + 2 ; $ model -> bootstrap_parentId = $ this -> objModel -> id ; } ...
Create a new wrapper element
13,607
protected function isTrigger ( $ trigger , $ target , $ action = Wrapper :: TRIGGER_CREATE ) { $ config = $ GLOBALS [ 'BOOTSTRAP' ] [ 'wrappers' ] [ $ this -> objModel -> getGroup ( ) ] ; $ key = $ action == static :: TRIGGER_DELETE ? 'triggerDelete' : 'triggerCreate' ; if ( isset ( $ config [ $ trigger ] [ $ key ] ) &...
check if action can be triggered
13,608
public function aroundGetBaseCurrencyCode ( \ Magento \ Store \ Model \ Store $ subject , \ Closure $ proceed ) { $ proceed ( ) ; $ storeId = $ subject -> getId ( ) ; $ stockId = $ this -> hlpStock -> getStockIdByStoreId ( $ storeId ) ; $ wrhsDo = $ this -> daoWrhs -> getById ( $ stockId ) ; $ curCode = $ wrhsDo -> get...
Replace Magento s base currency code by warehouse currency code .
13,609
static function getName ( \ Throwable $ exception ) : string { $ name = null ; if ( $ exception instanceof \ ErrorException ) { $ name = Error :: getName ( $ exception -> getSeverity ( ) ) ; } if ( $ name === null ) { $ name = get_class ( $ exception ) ; } if ( ( $ code = $ exception -> getCode ( ) ) !== 0 ) { $ name ....
Get name of the given exception
13,610
static function getChain ( \ Throwable $ node ) : array { $ chain = [ ] ; $ hashMap = [ ] ; while ( $ node !== null && ! isset ( $ hashMap [ $ hash = spl_object_hash ( $ node ) ] ) ) { $ chain [ ] = $ node ; $ hashMap [ $ hash ] = true ; $ node = $ node -> getPrevious ( ) ; } return $ chain ; }
List exceptions starting from the given exception
13,611
static function joinChains ( \ Throwable ... $ nodes ) : ? \ Throwable { $ lastNodeIndex = count ( $ nodes ) - 1 ; if ( $ lastNodeIndex > 0 ) { for ( $ i = 0 ; $ i < $ lastNodeIndex ; ++ $ i ) { $ initialNode = $ nodes [ $ i + 1 ] ; $ hashMap = [ ] ; while ( ( $ previousNode = $ initialNode -> getPrevious ( ) ) && ! is...
Join exception chains together
13,612
static function render ( \ Throwable $ exception , bool $ renderTrace = true , bool $ renderPrevious = false ) : string { $ exceptions = $ renderPrevious ? static :: getChain ( $ exception ) : [ $ exception ] ; $ totalExceptions = count ( $ exceptions ) ; $ lastException = $ totalExceptions - 1 ; $ output = '' ; for ( ...
Get textual information about an exception
13,613
protected function renderOutline ( $ parent , $ outline ) { $ outlineSub = $ parent -> addChild ( 'outline' ) ; $ textIsPresent = false ; foreach ( $ outline as $ key => $ value ) { if ( $ key === '@outlines' && is_array ( $ value ) ) { foreach ( $ value as $ outlineChild ) { $ this -> renderOutline ( $ outlineSub , $ ...
Create a XML outline object in a parent object .
13,614
public function getAll ( ) { $ response = $ this -> client -> sendRequest ( $ this -> getBase ( ) ) ; $ result = [ ] ; if ( ! is_array ( $ response ) ) { throw new UnexpectedValueException ( 'Array expected, but got ' . gettype ( $ response ) ) ; } foreach ( $ response as $ item ) { try { $ result [ ] = new Application...
Get list of all applications .
13,615
protected function addGridField ( string $ label , string $ db_field = null ) { if ( $ db_field === null ) { $ this -> sg_fields [ ] = $ label ; } else { $ this -> sg_fields [ $ db_field ] = $ label ; } return $ this ; }
Adiciona uma coluna ao grid de dados .
13,616
public function getComponents ( ) : array { if ( null === $ this -> components ) { $ this -> components = $ this -> loader -> loadComponents ( $ this ) ; } return $ this -> components ; }
Returns all components in this type
13,617
public function getComponent ( string $ key ) { $ components = $ this -> getComponents ( ) ; return array_key_exists ( $ key , $ components ) ? $ components [ $ key ] : null ; }
Returns a single component by key
13,618
public static function fromDirectory ( string $ directory ) : array { if ( ! \ is_dir ( $ directory ) ) { throw Exception \ DirectoryDoesNotExist :: fromDirectory ( $ directory ) ; } $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ directory , \ RecursiveDirectoryIterator :: FOLLOW_SY...
Returns an array of constructs defined in a directory .
13,619
public function addObservation ( $ x ) { $ this -> numObservations ++ ; if ( $ this -> numObservations <= 5 ) { $ this -> heights [ ] = $ x ; if ( $ this -> numObservations === 5 ) { sort ( $ this -> heights ) ; } return ; } if ( $ x < $ this -> heights [ 0 ] ) { $ this -> heights [ 0 ] = $ x ; $ k = 0 ; } elseif ( $ x...
Add an observation .
13,620
private function computeParabolic ( $ i , $ d ) { $ q = $ this -> heights [ $ i ] ; $ qPrev = $ this -> heights [ $ i - 1 ] ; $ qNext = $ this -> heights [ $ i + 1 ] ; $ n = $ this -> positions [ $ i ] ; $ nPrev = $ this -> positions [ $ i - 1 ] ; $ nNext = $ this -> positions [ $ i + 1 ] ; return ( $ q + $ d / ( $ nNe...
Use piecewise parabolic prediction to predict the ideal height of a marker .
13,621
private function computeLinear ( $ i , $ d ) { $ q = $ this -> heights [ $ i ] ; $ n = $ this -> positions [ $ i ] ; return ( $ q + $ d * ( $ this -> heights [ $ i + $ d ] - $ q ) / ( $ this -> positions [ $ i + $ d ] - $ n ) ) ; }
Linear formula to predict ideal position of a marker .
13,622
public function getValue ( ) { if ( $ this -> getCount ( ) <= 5 ) { sort ( $ this -> heights ) ; $ i = $ this -> p * count ( $ this -> heights ) ; if ( $ i === floor ( $ i ) ) { return ( $ this -> heights [ $ i - 1 ] + $ this -> heights [ $ i ] ) / 2 ; } else { return $ this -> heights [ floor ( $ i ) ] ; } } return $ ...
Get the estimated p - quantile value .
13,623
function toHtml ( ) { $ e = $ this -> e ; try { $ renderer = new RendererPhp ( ) ; return $ renderer -> capture ( __DIR__ . '/../.error.page.php' , array ( 'exception' => $ e ) ) ; } catch ( \ Exception $ ve ) { throw $ e ; } }
Print Exception Object Error Page
13,624
public static function get_image_sizes ( ) { global $ _wp_additional_image_sizes ; $ sizes = [ ] ; $ dynamic_sizes = Size_Manager :: get_dynamic_sizes ( ) ; foreach ( \ get_intermediate_image_sizes ( ) as $ size ) { if ( \ in_array ( $ size , [ 'thumbnail' , 'medium' , 'medium_large' , 'large' ] ) ) { $ sizes [ $ size ...
Get size information for all currently registered image sizes .
13,625
public static function get_image_size ( $ size ) { $ sizes = static :: get_image_sizes ( ) ; if ( \ is_string ( $ size ) && isset ( $ sizes [ $ size ] ) ) { return $ sizes [ $ size ] ; } return false ; }
Get size information for a specific image size .
13,626
public static function get_image_width ( $ size ) { $ size = static :: get_image_size ( $ size ) ; if ( $ size === false ) { return false ; } if ( isset ( $ size [ 'width' ] ) ) { return ( int ) $ size [ 'width' ] ; } return false ; }
Get the width of a specific image size .
13,627
public static function get_image_height ( $ size ) { $ size = static :: get_image_size ( $ size ) ; if ( $ size === false ) { return false ; } if ( isset ( $ size [ 'height' ] ) ) { return ( int ) $ size [ 'height' ] ; } return false ; }
Get the height of a specific image size .
13,628
public function runProcess ( $ output_file = '/dev/null' , $ append = false ) { switch ( PHP_OS ) { case 'Windows' : shell_exec ( sprintf ( '%s &' , $ this -> function_code , $ output_file ) ) ; break ; case 'Linux' : $ this -> pid = ( int ) shell_exec ( sprintf ( 'php -r "%s" %s %s 2>&1 & echo $!' , str_replace ( '"' ...
Runs the function in a background process .
13,629
public function stopProcess ( ) { $ this -> isCurrentOsSupported ( 'Only on *nix-based systems process cna be destroyed. You are running "%s".' ) ; try { $ result = shell_exec ( sprintf ( 'kill %d 2>&1' , $ this -> pid ) ) ; if ( ! preg_match ( '/No such process/' , $ result ) ) { return true ; } } catch ( Exception $ ...
Destroy the process .
13,630
public function toJSON ( $ options = 0 ) { if ( version_compare ( phpversion ( ) , '5.4.0' , '>=' ) === true ) { return json_encode ( $ this -> toArray ( ) , $ options | 64 ) ; } return str_replace ( '\\/' , '/' , json_encode ( $ this -> toArray ( ) , $ options ) ) ; }
Returns object JSON representation
13,631
public function actionSave ( $ id = null ) { if ( ! empty ( $ id ) ) { $ model = $ this -> findModel ( $ id ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'save' , 'id' => $ model -> id ] ) ; } } else { $ model = new FilterType ( ) ; if ( $ mode...
Creates a new FilterType model . If creation is successful the browser will be redirected to the view page .
13,632
public function setFactoryMode ( $ factory = true ) { $ this -> factoryMode = ( bool ) $ factory ; if ( $ this -> factoryMode ) { $ this -> reset ( ) ; } return $ this ; }
Set factory mode
13,633
protected function getServiceByFactory ( ) { if ( $ this -> arguments === null ) { return $ this -> initService ( ) ; } $ args = $ this -> normalizeArgs ( $ this -> arguments ) ; $ args = $ this -> processArgs ( $ args ) ; return $ this -> initService ( $ args ) ; }
Get service by factory
13,634
protected function getCommonService ( ) { if ( $ this -> service === null ) { if ( $ this -> arguments === null ) { $ this -> service = $ this -> initService ( ) ; } else { $ args = $ this -> normalizeArgs ( $ this -> arguments ) ; $ args = $ this -> processArgs ( $ args ) ; $ this -> service = $ this -> initService ( ...
Get service with common arguments
13,635
public function reset ( $ args = null ) { if ( $ args === null ) { $ this -> service = null ; return ; } $ args = $ this -> normalizeArgs ( $ args ) ; $ id = $ this -> getIdByArgs ( $ args ) ; unset ( $ this -> servicesByArgs [ $ id ] ) ; }
Reset instance of service
13,636
private function fetchTaxonomyDictionary ( ) : Collection { $ response = $ this -> client -> appData ( ) ; return new Collection ( array_get ( $ response , 'data.taxonomies' ) ) ?? new Collection ; }
Fetches taxonomy dictionary from the query
13,637
public function createView ( string $ class , string $ method ) : View { if ( false === method_exists ( $ class , $ method ) ) { throw new Exception ( 'Could not create view' ) ; } $ reflection = $ this -> container -> getFactory ( $ class ) -> getReflection ( ) ; if ( null === ( $ view = $ reflection -> getAnnotation ...
Initialize template or view from controller annotations
13,638
private function getRenderer ( string $ template ) : string { if ( is_readable ( $ template ) === false ) { throw new View \ Exception ( 'Could not open file "' . basename ( $ template ) . '"' ) ; } $ suffix = strtolower ( pathinfo ( $ template , PATHINFO_EXTENSION ) ) ; if ( isset ( $ this -> renderer [ $ suffix ] ) =...
Get appropriate renderer class name for a given template
13,639
public function enqueueStyles ( $ styles ) { if ( empty ( $ styles ) ) { return ; } $ defaults = [ 'src' => false , 'deps' => [ ] , 'ver' => false , 'media' => 'all' ] ; foreach ( $ styles as $ handle => $ opts ) { if ( ! is_array ( $ opts ) ) { continue ; } $ opts = array_merge ( $ defaults , $ opts ) ; wp_enqueue_sty...
Enqueue styles .
13,640
public function addBlockers ( $ ids ) : array { $ ids = $ this -> mergeBlcokedAt ( ( array ) $ ids ) ; return $ this -> blockerUsers ( ) -> syncWithoutDetaching ( $ ids ) ; }
Add blockers .
13,641
private function mergeBlcokedAt ( array $ ids ) : array { $ mergedIds = [ ] ; $ blockedAt = new Carbon ; foreach ( $ ids as $ id ) { $ mergedIds [ $ id ] = [ 'blocked_at' => $ blockedAt ] ; } return $ mergedIds ; }
Merge blocked_at to array for relationships table .
13,642
public function isBlocking ( $ id ) : bool { if ( is_array ( $ id ) ) { return count ( $ id ) === $ this -> blockingUsers ( ) -> whereIn ( 'blocked_by_id' , $ id ) -> count ( ) ; } return $ this -> blockingUsers ( ) -> where ( 'blocked_by_id' , $ id ) -> exists ( ) ; }
Check if it is blocking .
13,643
public function isBlockedBy ( $ id ) : bool { if ( is_array ( $ id ) ) { return count ( $ id ) === $ this -> blockerUsers ( ) -> whereIn ( 'blocker_id' , $ id ) -> count ( ) ; } return $ this -> blockerUsers ( ) -> where ( 'blocker_id' , $ id ) -> exists ( ) ; }
Check if it is being blocked .
13,644
public function blockerIds ( bool $ collection = false ) { $ ids = $ this -> blockerUsers ( ) -> pluck ( $ this -> getTable ( ) . '.id' ) ; if ( $ collection ) { return $ ids ; } return $ ids -> toArray ( ) ; }
Get blocker user IDs .
13,645
public function blockingIds ( bool $ collection = false ) { $ ids = $ this -> blockingUsers ( ) -> pluck ( $ this -> getTable ( ) . '.id' ) ; if ( $ collection ) { return $ ids ; } return $ ids -> toArray ( ) ; }
Get blocking user IDs .
13,646
public function rejectNotBlocker ( array $ ids ) : array { return BlockRelationship :: where ( 'blocked_by_id' , $ this -> id ) -> whereIn ( 'blocker_id' , $ ids ) -> pluck ( 'blocker_id' ) -> toArray ( ) ; }
Reject IDs that is not a blocker user from the given array .
13,647
public function log ( $ message , $ code = self :: INFO ) { $ this -> adapter -> log ( $ code , $ message ) ; }
Log the message
13,648
protected function isOrderLocked ( OrderEvent $ event ) { if ( ! $ event -> getForce ( ) && $ event -> getOrder ( ) -> getLocked ( ) ) { $ event -> addMessage ( new ResourceMessage ( 'ekyna_order.event.locked' , ResourceMessage :: TYPE_ERROR ) ) ; return true ; } return false ; }
Returns whether the order is locked or not and stop the event propagation if it s the case .
13,649
final public static function hasValue ( ... $ values ) : bool { foreach ( $ values as $ value ) : if ( is_array ( $ value ) ) : if ( ! ( isset ( $ value ) AND ( ! empty ( $ value ) ) ) ) : return FALSE ; break ; endif ; else : $ trimmedValue = trim ( $ value ) ; if ( ! ( isset ( $ trimmedValue ) AND ( $ trimmedValue !=...
Checks if an attribute has a value .
13,650
final public static function compareValues ( $ firstValue , $ secondValue ) : int { if ( ! self :: hasValue ( $ firstValue , $ secondValue ) ) new ErrorCode ( 1001 ) ; return $ firstValue <=> $ secondValue ; }
Validates if first parameter is less than equal to or greater than second parameter .
13,651
final public static function hasLength ( $ value , array $ options = [ ] ) : bool { $ valueLength = strlen ( $ value ) ; if ( ! self :: hasValue ( $ value ) ) new ErrorCode ( 1001 ) ; if ( isset ( $ options [ 'max' ] ) && ( $ valueLength > ( int ) $ options [ 'max' ] ) ) return FALSE ; if ( isset ( $ options [ 'min' ] ...
Checks for the maximum minimum or exact length of a value .
13,652
final public static function hasNumber ( $ value , array $ options = [ ] ) : bool { if ( ! self :: hasValue ( $ value ) ) new ErrorCode ( 1001 ) ; if ( ! is_numeric ( $ value ) ) return FALSE ; if ( ! empty ( $ options ) ) return static :: hasLength ( $ value , $ options ) ; return TRUE ; }
Validates if parameter is a number and if options aren t empty it checks the length .
13,653
final public static function formatMatch ( $ value = '' , $ regexFormat = '' ) : bool { if ( ! self :: hasValue ( $ value ) ) new ErrorCode ( 1001 ) ; if ( ! self :: hasValue ( $ regexFormat ) ) new ErrorCode ( 1001 ) ; return @ preg_match ( $ regexFormat , $ value ) ; }
Checks if parameter matches a certain format .
13,654
public function child ( ) { $ child = self :: i ( ) -> setParent ( $ this ) ; foreach ( $ this -> globalMiddleware as $ callback ) { $ child -> add ( $ callback ) ; } foreach ( $ this -> routeMiddleware as $ method => $ route ) { $ child -> route ( $ method , $ route [ 0 ] , $ route [ 1 ] ) ; } foreach ( $ this -> erro...
Returns a new instance with the same configuration
13,655
protected function getVariables ( $ matches ) { $ variables = array ( ) ; if ( ! is_array ( $ matches ) ) { return $ variables ; } array_shift ( $ matches ) ; foreach ( $ matches as $ path ) { $ variables = array_merge ( $ variables , explode ( '/' , $ path ) ) ; } foreach ( $ variables as $ i => $ variable ) { if ( ! ...
Returns a dynamic list of variables based on the given pattern and path
13,656
protected function handleErrors ( $ request , $ response ) { $ errorHandler = function ( ) use ( $ request , $ response ) { $ args = func_get_args ( ) ; $ response -> remove ( 'body' ) ; $ code = $ response -> get ( 'code' ) ; if ( ! $ code ) { $ response -> set ( 'code' , 500 ) ; } array_unshift ( $ args , $ request ,...
Listen and handle errors
13,657
protected function processGlobal ( $ request , $ response ) { $ args = array ( $ request , $ response ) ; foreach ( $ this -> globalMiddleware as $ callback ) { $ callback = $ callback -> bindTo ( $ this , get_class ( $ this ) ) ; if ( call_user_func_array ( $ callback , $ args ) === false ) { return false ; } } return...
Process global middleware
13,658
protected function processRoutes ( $ request , $ response ) { $ method = strtoupper ( $ request -> get ( 'method' ) ) ; if ( ! isset ( $ this -> routeMiddleware [ $ method ] ) || ! is_array ( $ this -> routeMiddleware [ $ method ] ) ) { return false ; } $ args = array ( $ request , $ response ) ; $ path = $ request -> ...
Process route middleware
13,659
public function load ( $ filename ) { if ( $ filename && file_exists ( $ filename ) ) { $ this -> doc -> load ( $ filename , LIBXML_NSCLEAN ) ; } else { $ this -> createBasicDocument ( ) ; } }
Load the file from disk .
13,660
protected function createBasicDocument ( ) { $ this -> doc -> loadXML ( '<?xml version="1.0" encoding="UTF-8"?>' . '<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"><file><body></body></file></xliff>' , LIBXML_NSCLEAN ) ; $ this -> setDataType ( 'plaintext' ) ; $ this -> setDate ( time ( ) ) ; $ this ...
Create the basic document structure .
13,661
protected function setAttribute ( \ DOMElement $ node , $ name , $ value ) { if ( $ this -> rootNSWorkaround ( ) ) { $ node -> setAttribute ( $ name , $ value ) ; } else { $ node -> setAttributeNS ( self :: NS , $ name , $ value ) ; } return $ node ; }
Set attribute workaround helper .
13,662
protected function getAttribute ( \ DOMElement $ node , $ name ) { if ( $ this -> rootNSWorkaround ( ) ) { return $ node -> getAttribute ( $ name ) ; } return $ node -> getAttributeNS ( self :: NS , $ name ) ; }
Get attribute workaround helper .
13,663
protected function setFileAttribute ( $ name , $ value ) { $ file = $ this -> getXPathFirstItem ( '/xliff:xliff/xliff:file' ) ; $ this -> setAttribute ( $ file , $ name , $ value ) ; }
Sets the given attribute in the XML element file to the given value .
13,664
public function setSource ( $ key , $ value ) { $ unit = $ this -> searchForId ( $ key , true ) ; $ source = $ this -> getXPathFirstItem ( 'xliff:source' , $ unit ) ; if ( $ source === null ) { $ source = $ unit -> appendChild ( $ this -> doc -> createElementNS ( self :: NS , 'source' ) ) ; } elseif ( $ source -> first...
Sets the source value for the given key to the given value .
13,665
public function getSource ( $ key ) { $ unit = $ this -> searchForId ( $ key ) ; $ source = $ this -> getXPathFirstItem ( 'xliff:source' , $ unit ) ; if ( $ source && $ source -> firstChild ) { return $ source -> firstChild -> nodeValue ; } return null ; }
Return the source value for a key .
13,666
public function setTarget ( $ key , $ value ) { $ unit = $ this -> searchForId ( $ key , true ) ; $ target = $ this -> getXPathFirstItem ( 'xliff:target' , $ unit ) ; if ( $ target === null ) { $ target = $ unit -> appendChild ( $ this -> doc -> createElementNS ( self :: NS , 'target' ) ) ; } elseif ( $ target -> first...
Sets the target value for the given key to the given value .
13,667
public function getTarget ( $ key ) { $ unit = $ this -> searchForId ( $ key ) ; $ target = $ this -> getXPathFirstItem ( 'xliff:target' , $ unit ) ; if ( $ target && $ target -> firstChild ) { return $ target -> firstChild -> nodeValue ; } return null ; }
Return the target value for a key .
13,668
public function remove ( $ key ) { $ unit = $ this -> searchForId ( $ key ) ; if ( $ unit ) { $ unit -> parentNode -> removeChild ( $ unit ) ; } return $ this ; }
Search for an entry with the given id and remove it if found .
13,669
public function getKeys ( ) { $ transUnits = $ this -> getXPath ( ) -> query ( '/xliff:xliff/xliff:file/xliff:body/xliff:trans-unit' ) ; $ result = array ( ) ; if ( $ transUnits -> length > 0 ) { foreach ( $ transUnits as $ element ) { if ( ! $ this -> getAttribute ( $ element , 'id' ) ) { throw new \ Exception ( 'Empt...
Retrieve all the keys .
13,670
public function setAll ( array $ values ) { foreach ( $ values as $ name => $ value ) { $ this -> set ( $ name , $ value ) ; } }
Appends all of the template variable to the end of the vars list
13,671
public function remove ( string $ name ) : self { if ( ! array_key_exists ( $ name , $ this -> routes ) ) { return $ this ; } $ route = $ this -> routes [ $ name ] ; $ node = $ this -> leaves [ $ route ] ; unset ( $ this -> routes [ $ name ] ) ; unset ( $ this -> leaves [ $ route ] ) ; $ node -> removeRoute ( $ route )...
Remove route .
13,672
public function addNamespace ( $ prefix , $ namespace ) { if ( empty ( $ namespace ) ) { throw new ArgumentOutOfRangeException ( "The $namespace parameter to addNamespace cannot be null or empty" ) ; } if ( substr ( $ prefix , 0 , 5 ) == "xmlns" ) { $ prefix = substr ( $ prefix , 5 ) ; } if ( strlen ( $ prefix ) > 0 &&...
Adds a namespace to the existing collection
13,673
public function registerSocialUser ( $ socialUser , $ provider ) { $ user = $ this -> user -> create ( $ this -> getUserFromSocial ( $ socialUser ) ) ; if ( ! $ user ) { return $ user ; } event ( new UserRegistering ( $ user , $ socialUser ) ) ; $ this -> userDetails -> create ( $ this -> getUserDetailsFromSocial ( $ s...
Register a new user from a social login .
13,674
private function getUserDetailsFromRequest ( User $ user ) { $ details = request ( ) -> only ( 'first_name' , 'middle_name' , 'last_name' , 'display_name' , 'timezone' , 'location' , 'url' ) ; $ details [ 'user_id' ] = $ user -> id ; return array_filter ( $ details ) ; }
Separate the user core information from the extra details .
13,675
private function getUserDetailsFromSocial ( $ socialUser , $ user ) { $ names = explode ( ' ' , $ socialUser -> getName ( ) ) ; $ username = is_null ( $ socialUser -> getNickname ( ) ) ? $ socialUser -> getEmail ( ) : $ socialUser -> getNickname ( ) ; $ details = [ 'user_id' => $ user -> id , 'first_name' => isset ( $ ...
Try to get as many details as possible from the social user object .
13,676
public function handleParseDate ( $ event ) { if ( $ event -> getResult ( ) === null ) { $ dateAdapter = $ this -> framework -> getAdapter ( Date :: class ) ; $ event -> setResult ( $ dateAdapter -> parse ( $ event -> getFormat ( ) , $ event -> getTimestamp ( ) ) ) ; } }
Handle the date parsing .
13,677
public function decrypt ( string $ response , string $ publicKey = null , string $ nonce = null ) : string { $ version = static :: getVersion ( $ response ) ; if ( $ version === 2 ) { if ( \ strlen ( $ response ) < 236 ) { throw new InvalidArgumentException ( sprintf ( "Message is %d bytes, however 236+ were expected" ...
Decrypts a payload using the response and an optional nonce Nonce is not required for v2 type signatures but is required for v1 signatures
13,678
private function decryptBody ( string $ response , string $ publicKey , string $ nonce ) : string { try { if ( \ strlen ( $ publicKey ) !== SODIUM_CRYPTO_BOX_PUBLICKEYBYTES ) { throw new InvalidArgumentException ( sprintf ( "Public key should be %d bytes." , SODIUM_CRYPTO_BOX_PUBLICKEYBYTES ) ) ; } if ( \ strlen ( $ no...
Decrypts a given response with a nonce This will return the decrypted string of decrypt was successful and false otherwise
13,679
public function isSignatureValid ( string $ response , string $ signature , string $ publicKey ) : bool { if ( \ strlen ( $ publicKey ) !== SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES ) { throw new InvalidArgumentException ( sprintf ( "Public key should be %d bytes." , SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES ) ) ; } if ( \ strlen ( $ ...
Returns true if the signature validates the response
13,680
public static function getPublicKeyFromResponse ( string $ response ) : string { $ version = static :: getVersion ( $ response ) ; if ( $ version === 2 ) { if ( \ strlen ( $ response ) < 236 ) { throw new InvalidArgumentException ; } return \ substr ( $ response , 28 , 32 ) ; } throw new InvalidArgumentException ( 'The...
Extracts the public key from a v2 response
13,681
public static function getSigningPublicKeyFromResponse ( string $ response ) : string { $ version = static :: getVersion ( $ response ) ; if ( $ version === 2 ) { if ( \ strlen ( $ response ) < 236 ) { throw new InvalidArgumentException ; } return \ substr ( $ response , - 160 , 32 ) ; } throw new InvalidArgumentExcept...
Extracts the signing public key from a v2 response
13,682
public static function getVersion ( string $ response ) : int { if ( \ strlen ( $ response ) < 16 ) { throw new DecryptionFailedException ( "Message length is too short to determine version." ) ; } $ header = \ substr ( $ response , 0 , 4 ) ; if ( \ strtoupper ( \ bin2hex ( $ header ) ) === 'DE259002' ) { return 2 ; } ...
Extracts the version from the response
13,683
public function setBlackTagList ( array $ tags ) { if ( ! $ this -> special_characters_allowed ) { throw new RuntimeException ( 'All special chars will be escaped. Set AllowHtml to use black list' ) ; } if ( $ this -> white_tag_list ) { throw new RuntimeException ( 'White list already added.' ) ; } $ this -> black_tag_...
Set list of tags that should be escaped
13,684
public function setHelpText ( string $ text = '' , string $ click_href = '' , bool $ href_new_window = false ) { $ this -> help_href_new_window = $ href_new_window ; $ text = trim ( $ text ) ; $ click_href = trim ( $ click_href ) ; if ( $ text === '' && $ click_href === '' ) { throw new RuntimeException ( 'Help must co...
Question sign near column title with help text showing on mouse hover
13,685
public function getCellView ( $ cell_data , array $ row_data = [ ] ) { if ( $ this -> tooltip_field && $ row_data ) { $ this -> requireTooltipJavascript ( ) ; $ tooltip = $ this -> replaceTemplateVars ( $ row_data , $ this -> tooltip_field ) ; if ( $ tooltip ) { return '<td' . $ this -> getAttributesView ( 0 , $ row_da...
Return html td
13,686
public function getAttributesView ( $ style_to_replace = '' , array $ row_data = [ ] ) { $ attr = [ ] ; if ( $ this -> width ) { $ attr [ 'width' ] = 'width="' . $ this -> width . '"' ; } if ( $ this -> align ) { $ attr [ 'align' ] = 'align="' . $ this -> align . '"' ; } if ( $ this -> nowrap ) { $ attr [ 'nowrap' ] = ...
Get td attributes
13,687
public function addProductionFilter ( FilterCollectionEvent $ event ) : void { $ now = new \ DateTime ( ) ; $ qb = $ event -> getQueryBuilder ( ) ; $ query = $ qb -> query ( ) -> bool ( ) -> addMust ( $ qb -> query ( ) -> term ( [ '_index' => 'production' ] ) ) -> addMust ( $ qb -> query ( ) -> term ( [ 'active' => tru...
Add the production filter to the main query .
13,688
protected function initCatalogsForSingleLocale ( $ locale , $ domain ) { if ( is_string ( $ domain ) ) { $ this -> initCatalog ( $ locale , $ domain ) ; return ; } if ( is_array ( $ domain ) ) { $ this -> initCatalogForManyDomains ( $ locale , $ domain ) ; return ; } throw new InvalidParameter ( 'Domain must be a strin...
Initialize the catalog for the exact locale and exact domain
13,689
protected function initCatalogsForManyLocales ( $ locales , $ domain ) { foreach ( $ locales as $ locale ) { $ this -> initCatalogsForSingleLocale ( $ locale , $ domain ) ; } }
Initialize the catalog for the many of the locales
13,690
protected function initCatalogForManyDomains ( $ locale , $ domains ) { foreach ( $ domains as $ domain ) { $ this -> initCatalog ( $ locale , $ domain ) ; } }
Initialize the catalog for the exact locale and many of the domains
13,691
protected function getCatalogContent ( $ locale , $ domain ) { $ path = $ this -> getCatalogPath ( $ locale , $ domain ) ; if ( ! is_file ( $ path ) ) { return false ; } if ( ! is_readable ( $ path ) ) { throw new ReadError ( 'Catalog file: "' . $ path . '" exists but can\'t be read' ) ; } $ result = file_get_contents ...
Get the catalog content
13,692
protected function getCatalogPath ( $ locale , $ domain ) { if ( $ this -> basePath === null ) { throw new NoPath ( 'Base path definition required' ) ; } $ pathParts = [ $ this -> basePath ] ; foreach ( $ this -> pathTemplate as $ part ) { if ( $ part === self :: TPL_LOCALE ) { $ pathParts [ ] = $ locale ; continue ; }...
Get the catalog path for the locale and domain
13,693
public static function save ( $ name , $ value , $ autoload = true , $ deprecated = '' ) { if ( false !== static :: get ( $ name ) ) { return update_option ( $ name , $ value , $ autoload ) ; } return add_option ( $ name , $ value , $ deprecated , $ autoload ) ; }
Save a new or update an option into the DB
13,694
public function start ( ) { if ( $ this -> _started === true ) { throw new Exception ( 'The event already been started' ) ; } $ this -> _startTime = microtime ( true ) ; $ this -> _startMemory = memory_get_usage ( ) ; $ this -> _started = true ; }
Start the event
13,695
public function stop ( $ type = self :: STATUS_SUCCESS ) { if ( $ this -> _started === false ) { throw new Exception ( 'Unable to stop the event which has not been started' ) ; } if ( $ this -> _ended === true ) { throw new Exception ( 'The event already been stopped' ) ; } $ this -> _stopTime = microtime ( true ) ; $ ...
Stop the event
13,696
public static function parse ( string $ csv , string $ delimiter = ',' , string $ enclosure = '"' , string $ escape = '\\' ) : Bag { $ row = str_getcsv ( $ csv , $ delimiter , $ enclosure , $ escape ) ; return Bag :: from ( array_map ( 'trim' , $ row ) ) ; }
Parse a CSV line into a Bag .
13,697
public static function dump ( iterable $ row , string $ delimiter = ',' , string $ enclosure = '"' , string $ escape = '\\' ) : string { $ row = Arr :: from ( $ row ) ; $ res = fopen ( 'php://temp' , 'r+' ) ; try { $ written = Thrower :: call ( 'fputcsv' , $ res , $ row , $ delimiter , $ enclosure , $ escape ) ; $ out ...
Dumps a row to a CSV line .
13,698
public function getRegExp ( $ event_key ) { $ pos = strpos ( $ event_key , '*' ) ; if ( $ pos === false ) { return null ; } $ buffer = '' ; $ reg_exp = '' ; $ length = strlen ( $ event_key ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ c = $ event_key [ $ i ] ; if ( strpos ( self :: PREG_METACHARS , $ c ) !== false ...
get event regular expression
13,699
function encodeURL ( $ method = null , array $ method_params = array ( ) ) { return Main :: encodeURL ( $ this -> parent -> parentClass ( ) , array ( $ this -> parent -> parentId ( ) ) , $ method , $ method_params , $ this -> parent -> dataName ( ) ) ; }
function encodeURL - overwrite parent function just to send 2 parameters