idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
4,700
protected function registerVerifyEmailBroker ( ) { $ this -> app -> singleton ( 'auth.verify_emails' , function ( $ app ) { return new VerifyEmailBrokerManager ( $ app ) ; } ) ; $ this -> app -> bind ( 'auth.verify_emails.broker' , function ( $ app ) { return $ app -> make ( 'auth.verify_emails' ) -> broker ( ) ; } ) ; }
Register the verify email broker instance .
4,701
public function render ( ) { $ render = '' ; try { $ render = $ this -> getRenderer ( ) -> render ( 'form' , $ this ) ; } catch ( \ Exception $ e ) { dd ( $ e -> getMessage ( ) ) ; } return $ render ; }
Render the polliwog
4,702
public function getValues ( ) { $ values = [ ] ; foreach ( $ this -> getElements ( ) as $ name => $ e ) { if ( $ e -> isDiscreet ( ) ) { continue ; } $ values [ $ name ] = $ e -> getValue ( ) ; } return $ values ; }
Return all values from all elements
4,703
public function getFilteredValues ( ) { $ values = [ ] ; foreach ( $ this -> getElements ( ) as $ name => $ e ) { if ( $ e -> isDiscreet ( ) ) { continue ; } $ values [ $ name ] = $ e -> getFilteredValue ( ) ; } return $ values ; }
Return all filtered values from all elements
4,704
public function valid ( array $ values , $ populate = true ) { foreach ( $ this -> getElements ( ) as $ index => & $ element ) { if ( ! array_key_exists ( $ index , $ values ) ) { if ( is_a ( $ element , 'FrenchFrogs\Form\Element\Boolean' ) ) { $ values [ $ index ] = 0 ; } else { $ values [ $ index ] = '' ; } } $ element -> valid ( $ values [ $ index ] ) ; if ( ! $ element -> isValid ( ) ) { $ this -> getValidator ( ) -> addError ( $ index , $ element -> getErrorAsString ( ) ) ; } } return $ this ; }
Valid all the form elements
4,705
public function getErrorAsString ( ) { $ errors = [ ] ; foreach ( $ this -> getValidator ( ) -> getErrors ( ) as $ index => $ message ) { $ errors [ ] = sprintf ( '%s:%s %s' , $ index , PHP_EOL , $ message ) ; } return implode ( PHP_EOL , $ errors ) ; }
Return string formated error from the form validation
4,706
protected function getObjectReferences ( ObjectManager $ objectManager , $ className ) { $ identifier = $ objectManager -> getClassMetadata ( $ className ) -> getIdentifier ( ) ; $ idField = reset ( $ identifier ) ; $ objectRepository = $ objectManager -> getRepository ( $ className ) ; $ idsResult = $ objectRepository -> createQueryBuilder ( 't' ) -> select ( 't.' . $ idField ) -> getQuery ( ) -> getArrayResult ( ) ; $ ids = [ ] ; foreach ( $ idsResult as $ result ) { $ ids [ ] = $ result [ $ idField ] ; } return $ this -> getObjectReferencesByIds ( $ objectManager , $ className , $ ids ) ; }
Returns array of object references .
4,707
protected function getObjectReferencesByIds ( ObjectManager $ objectManager , $ className , array $ ids ) { $ entities = [ ] ; foreach ( $ ids as $ id ) { $ entities [ ] = $ objectManager -> getReference ( $ className , $ id ) ; } return $ entities ; }
Returns array of object references by their ids . It s useful when ids are known and objects are used as other entities relation .
4,708
private function applyFilter ( Builder $ query , $ field , $ filter , $ or = false ) { $ filter = explode ( ':' , $ filter ) ; if ( count ( $ filter ) > 1 ) { $ operator = $ this -> getFilterOperator ( $ filter [ 0 ] ) ; $ value = $ this -> replaceWildcards ( $ filter [ 1 ] ) ; } else { $ operator = '=' ; $ value = $ this -> replaceWildcards ( $ filter [ 0 ] ) ; } $ fields = explode ( '.' , $ field ) ; if ( count ( $ fields ) > 1 ) { return $ this -> applyNestedFilter ( $ query , $ fields , $ operator , $ value , $ or ) ; } else { return $ this -> applyWhereClause ( $ query , $ field , $ operator , $ value , $ or ) ; } }
Applies a single filter to the query
4,709
private function applyNestedFilter ( Builder $ query , array $ fields , $ operator , $ value , $ or = false ) { $ relation_name = implode ( '.' , array_slice ( $ fields , 0 , count ( $ fields ) - 1 ) ) ; $ relation_field = end ( $ fields ) ; if ( $ relation_name [ 0 ] == '!' ) { $ relation_name = substr ( $ relation_name , 1 , strlen ( $ relation_name ) ) ; $ that = $ this ; return $ query -> whereHas ( $ relation_name , function ( $ query ) use ( $ relation_field , $ operator , $ value , $ that , $ or ) { $ query = $ that -> applyWhereClause ( $ query , $ relation_field , $ operator , $ value , $ or ) ; } , '=' , 0 ) ; } $ that = $ this ; return $ query -> whereHas ( $ relation_name , function ( $ query ) use ( $ relation_field , $ operator , $ value , $ that , $ or ) { $ query = $ that -> applyWhereClause ( $ query , $ relation_field , $ operator , $ value , $ or ) ; } ) ; }
Applies a nested filter . Nested filters are filters on field on related models .
4,710
private function applyWhereClause ( Builder $ query , $ field , $ operator , $ value , $ or = false ) { $ verb = $ or ? 'orWhere' : 'where' ; $ null_verb = $ or ? 'orWhereNull' : 'whereNull' ; $ not_null_verb = $ or ? 'orWhereNotNull' : 'whereNotNull' ; $ value = $ this -> base64decodeIfNecessary ( $ value ) ; switch ( $ value ) { case 'today' : return $ query -> $ verb ( $ field , 'like' , Carbon :: now ( ) -> format ( 'Y-m-d' ) . '%' ) ; case 'nottoday' : return $ query -> $ verb ( function ( $ q ) use ( $ field ) { $ q -> where ( $ field , 'not like' , Carbon :: now ( ) -> format ( 'Y-m-d' ) . '%' ) -> orWhereNull ( $ field ) ; } ) ; case 'null' : return $ query -> $ null_verb ( $ field ) ; case 'notnull' : return $ query -> $ not_null_verb ( $ field ) ; default : return $ query -> $ verb ( $ field , $ operator , $ value ) ; } }
Applies a where clause . Is used by applyFilter and applyNestedFilter to apply the clause to the query .
4,711
private function getFilterOperator ( $ filter ) { $ operator = str_replace ( 'notlike' , 'not like' , $ filter ) ; $ operator = str_replace ( 'gt' , '>' , $ operator ) ; $ operator = str_replace ( 'ge' , '>=' , $ operator ) ; $ operator = str_replace ( 'lt' , '<' , $ operator ) ; $ operator = str_replace ( 'le' , '<=' , $ operator ) ; $ operator = str_replace ( 'eq' , '=' , $ operator ) ; $ operator = str_replace ( 'ne' , '!=' , $ operator ) ; return $ operator ; }
Translates operators to SQL
4,712
public function resource ( $ controller , array $ options = array ( ) ) { $ name = isset ( $ options [ "prefix" ] ) ? $ options [ "prefix" ] : "" ; $ name .= $ this -> getResourceName ( $ controller , $ options ) ; $ actions = $ this -> getResourceActions ( $ options ) ; $ resource = new RouteResource ; foreach ( $ actions as $ action => $ map ) { $ resource -> set ( $ this -> set ( $ map [ 0 ] , $ this -> getResourcePath ( $ action , $ map [ 1 ] , $ name , $ options ) , [ $ controller , $ action ] ) -> setName ( "$name.$action" ) ) ; } return $ resource ; }
Resource routing allows you to quickly declare all of the common routes for a given resourceful controller . Instead of declaring separate routes for your index show new edit create update and destroy actions a resourceful route declares them in a single line of code .
4,713
public function resources ( array $ controllers ) { $ resource = new RouteResource ; foreach ( $ controllers as $ controller ) $ resource -> set ( $ this -> resource ( $ controller ) ) ; return $ resource ; }
Collect several resources at same time .
4,714
public static function setCookie ( ResponseInterface $ response , $ name , $ value = null , $ ttl = null , $ path = null , $ domain = null , $ secure = false , $ httponly = true ) { $ cookie = urlencode ( $ name ) . '=' . urlencode ( $ value ) ; self :: addExpire ( $ cookie , $ ttl ) ; self :: addDomain ( $ cookie , $ domain ) ; self :: addPath ( $ cookie , $ path ) ; self :: addSecure ( $ cookie , $ secure ) ; self :: addHttpOnly ( $ cookie , $ httponly ) ; return $ response -> withAddedHeader ( 'Set-Cookie' , $ cookie ) ; }
Set a cookie in the response
4,715
public static function unsetCookie ( ResponseInterface $ response , $ name , $ path = null ) { return self :: setCookie ( $ response , $ name , '' , time ( ) - 86400 , $ path ) ; }
Unset a cookie
4,716
public static function publicCache ( ResponseInterface $ response , $ cacheTime = 120 ) { $ maxAge = $ cacheTime * 60 ; return $ response -> withAddedHeader ( 'Expires' , self :: timeStamp ( $ maxAge ) ) -> withAddedHeader ( 'Cache-Control' , "public, max-age={$maxAge}" ) -> withAddedHeader ( 'Last-Modified' , self :: timeStamp ( ) ) ; }
Set public cache header
4,717
public static function privateNoExpireCache ( ResponseInterface $ response , $ cacheTime = 120 ) { $ maxAge = $ cacheTime * 60 ; return $ response -> withAddedHeader ( 'Cache-Control' , "private, max-age={$maxAge}, pre-check={$maxAge}" ) -> withAddedHeader ( 'Last-Modified' , self :: timeStamp ( ) ) ; }
Set private_no_expire cache header
4,718
public function getErrorMessage ( ) { if ( is_string ( $ this -> jsonError ) ) { return $ this -> jsonError ; } elseif ( isset ( $ this -> jsonError [ 'message' ] ) ) { return $ this -> jsonError [ 'message' ] ; } return '' ; }
The error message specified in the API or an empty string if not available .
4,719
public function reset ( ) { return $ this -> collector -> set ( $ this -> method , $ this -> pattern , $ this -> action ) -> nth ( 0 ) -> setStrategy ( $ this -> strategy ) -> setParams ( $ this -> params ) -> setDefaults ( $ this -> defaults ) -> setMetadataArray ( $ this -> metadata ) ; }
Clone this route and set it into the collector .
4,720
public function call ( callable $ container = null ) { $ this -> action = $ this -> buildCallable ( $ this -> action , $ container ) ; if ( $ this -> strategy === null ) { return call_user_func_array ( $ this -> action , array_merge ( $ this -> defaults , $ this -> params ) ) ; } if ( ! is_object ( $ this -> strategy ) ) { if ( $ container === null ) { $ this -> strategy = new $ this -> strategy ; } else $ this -> strategy = $ container ( $ this -> strategy ) ; } return $ this -> callWithStrategy ( ) ; }
Execute the route action if no strategy was provided the action will be executed by the call_user_func PHP function .
4,721
private function parseCallableController ( $ controller , $ container ) { $ controller = rtrim ( $ this -> namespace , "\\" ) . "\\" . $ this -> parseCallablePlaceholders ( $ controller ) ; if ( $ container === null ) { return new $ controller ; } else return $ container ( $ controller ) ; }
Get the controller object .
4,722
private function parseCallablePlaceholders ( $ fragment ) { if ( strpos ( $ fragment , "{" ) !== false ) { foreach ( $ this -> params as $ placeholder => $ value ) { if ( strpos ( $ fragment , "{" . $ placeholder . "}" ) !== false ) { $ fragment = str_replace ( "{" . $ placeholder . "}" , ucwords ( str_replace ( "-" , " " , $ value ) ) , $ fragment ) ; } } } return $ fragment ; }
Parse and replace dynamic content on route action .
4,723
private function callWithStrategy ( ) { if ( $ this -> strategy instanceof StrategyInterface ) { if ( $ this -> strategy instanceof MatcherAwareInterface ) { $ this -> strategy -> setMatcher ( $ this -> matcher ) ; } return $ this -> strategy -> call ( $ this ) ; } throw new BadRouteException ( str_replace ( "%s" , get_class ( $ this -> strategy ) , BadRouteException :: BAD_STRATEGY ) ) ; }
Execute the route action with the given strategy .
4,724
public function setConstraint ( $ token , $ regex ) { $ initPos = strpos ( $ this -> pattern , "{" . $ token ) ; if ( $ initPos !== false ) { $ endPos = strpos ( $ this -> pattern , "}" , $ initPos ) ; $ newPattern = substr_replace ( $ this -> pattern , "{" . "$token:$regex" . "}" , $ initPos , $ endPos - $ initPos + 1 ) ; $ wildcards = $ this -> collector -> getParser ( ) -> getWildcardTokens ( ) ; $ newPattern = str_replace ( array_keys ( $ wildcards ) , $ wildcards , $ newPattern ) ; $ this -> setPatternWithoutReset ( $ newPattern ) ; } return $ this ; }
Set a constraint to a token in the route pattern .
4,725
public function addDataTypeClass ( $ dataTypeFQCN , $ classContent , $ replace = false ) { if ( strpos ( $ dataTypeFQCN , "Prooph\\Link\\Application\\DataType\\" ) !== 0 ) { throw new \ InvalidArgumentException ( "Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $ dataTypeFQCN ) ; } $ nsDirs = explode ( "\\" , str_replace ( "Prooph\\Link\\Application\\DataType\\" , "" , $ dataTypeFQCN ) ) ; $ className = array_pop ( $ nsDirs ) ; if ( empty ( $ className ) ) { throw new \ InvalidArgumentException ( "Provided data type FQCN contains no class name: " . $ dataTypeFQCN ) ; } $ currentPath = $ this -> toString ( ) ; if ( ! empty ( $ nsDirs ) ) { foreach ( $ nsDirs as $ nsDir ) { $ currentPath .= DIRECTORY_SEPARATOR . $ nsDir ; if ( ! is_dir ( $ currentPath ) ) mkdir ( $ currentPath ) ; } } $ filename = $ currentPath . DIRECTORY_SEPARATOR . $ className . ".php" ; if ( ! $ replace && file_exists ( $ filename ) ) return ; file_put_contents ( $ filename , $ classContent ) ; }
Writes the given class content to a class file named after the class . The root directory is defined by the path of ApplicationDataTypeLocation . The namespace of the class should start with Application \ DataType \ If more sub namespaces are defined the method creates a directory for each namespace part if not already exists .
4,726
protected function checkForDuplicateNames ( ) { $ normalized = [ ] ; foreach ( $ this -> data -> rawData [ 'modules' ] as $ moduleId => $ module ) { $ normalized [ $ moduleId ] = $ this -> normalizeName ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] ) ; } return $ this -> getKeysForDuplicates ( $ normalized ) ; }
Checks all modules for conflicting module names and returns modules per duplicate set .
4,727
protected function addOrInjectSectionNamePrefix ( $ moduleId ) { $ module = $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] ; $ prefix = $ module [ 'parent_names' ] [ 'section' ] ; $ this -> modulePrefixedSection [ $ moduleId ] = true ; if ( ! $ this -> prefixGroup && ! $ this -> prefixMenu ) { $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ prefix ) ; } $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ module [ 'parent_names' ] [ 'section' ] ) ; if ( $ this -> prefixGroup ) { $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ module [ 'parent_names' ] [ 'group' ] ) ; } if ( $ this -> prefixMenu ) { $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ module [ 'parent_names' ] [ 'menu' ] ) ; } }
Prefixes module name with section name keeping into account whether other higher - level prefixes have been applied
4,728
protected function addOrInjectGroupNamePrefix ( $ moduleId ) { $ module = $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] ; $ prefix = $ module [ 'parent_names' ] [ 'group' ] ; $ this -> modulePrefixedGroup [ $ moduleId ] = true ; if ( ! $ this -> prefixMenu ) { $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ prefix ) ; } $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ module [ 'parent_names' ] [ 'section' ] ) ; $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ module [ 'parent_names' ] [ 'group' ] ) ; if ( $ this -> prefixMenu ) { $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ module [ 'parent_names' ] [ 'menu' ] ) ; } }
Prefixes module name with group name keeping into account whether other higher - level prefixes have been applied
4,729
protected function addOrInjectMenuNamePrefix ( $ moduleId ) { $ module = $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] ; $ prefix = $ module [ 'parent_names' ] [ 'menu' ] ; $ this -> modulePrefixedMenu [ $ moduleId ] = true ; $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = $ this -> addPrefix ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] , $ prefix ) ; }
Prefixes module name with menu name keeping into account whether other higher - level prefixes have been applied
4,730
protected function addModuleIdPostFix ( $ moduleId ) { $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = null ; $ this -> prefixModuleName ( $ moduleId ) ; $ module = $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] ; $ this -> data -> rawData [ 'modules' ] [ $ moduleId ] [ 'prefixed_name' ] = trim ( array_get ( $ module , 'prefixed_name' ) ? : $ module [ 'name' ] ) . ' ' . $ moduleId ; }
Postfixes the module name with the module ID as a last resort to making a unique module name .
4,731
function getKeysForDuplicates ( array $ array ) { $ duplicates = $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { if ( ! isset ( $ newArray [ $ value ] ) ) { $ newArray [ $ value ] = $ key ; continue ; } if ( isset ( $ duplicates [ $ value ] ) ) { $ duplicates [ $ value ] [ ] = $ key ; } else { $ duplicates [ $ value ] = [ $ newArray [ $ value ] , $ key ] ; } } return $ duplicates ; }
Returns the keys for values that occur more than once in an array
4,732
public function getPageUrl ( $ page ) { $ qs = '' ; if ( $ _SERVER [ 'QUERY_STRING' ] ) { $ qs = '?' . $ _SERVER [ 'QUERY_STRING' ] ; } return str_replace ( $ this -> fromFormat ( $ this -> currentPage ) , $ this -> fromFormat ( $ page ) , $ this -> uri ) . $ qs ; }
Get the url for a specified page number .
4,733
public function getPrevUrls ( $ floor = null ) { if ( $ floor ) { $ floor = $ this -> currentPage - $ floor ; } else { $ floor = 1 ; } return $ this -> getRangeUrls ( $ floor , $ this -> currentPage - 1 ) ; }
Get paginated urls that come before the current page .
4,734
public function getNextUrls ( $ max = null ) { if ( $ max ) { $ max = $ this -> currentPage + $ max ; } else { $ max = $ this -> totalPages ; } return $ this -> getRangeUrls ( $ this -> currentPage + 1 , $ max ) ; }
Get paginated urls that come after the current page .
4,735
public function getEasyMarkup ( ) { $ markup = '' ; if ( $ this -> prevUrl ) { $ markup .= "<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>" ; } $ pages = $ this -> getPrevUrls ( 5 ) ; foreach ( $ pages as $ i => $ page ) { $ markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>" ; } if ( $ this -> totalPages ) { $ markup .= "<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>" ; } $ pages = $ this -> getNextUrls ( 5 ) ; foreach ( $ pages as $ i => $ page ) { $ markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>" ; } if ( $ this -> nextUrl ) { $ markup .= "<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>" ; } return "<ul class='pagination'>{$markup}</ul>" ; }
Get a simple markup for a pagination feed .
4,736
public function process ( $ identifier , \ Controller $ controller , $ result = null ) { if ( $ this -> hasProcessor ( $ identifier ) ) { return $ this -> processors [ $ identifier ] -> process ( $ controller , $ result ) ; } else { return false ; } }
Process an output processor by identifier if it exists
4,737
protected function getFulfillmentMethodsByType ( $ type ) { if ( ! $ this -> fulfillmentMethodsByType ) { $ this -> loadFulfillmentMethods ( ) ; } return $ this -> fulfillmentMethodsByType -> get ( $ type ) ; }
Retrieve a collection of fulfillment methods by type eg . give back all fulfillment methods for type shipment
4,738
protected function loadFulfillmentMethods ( ) { $ this -> fulfillmentMethodsByType = new ArrayCollection ( ) ; foreach ( $ this -> configuration as $ type => $ configurationFulfillmentMethods ) { foreach ( $ configurationFulfillmentMethods as $ configurationFulfillmentMethod ) { if ( array_key_exists ( 'class' , $ configurationFulfillmentMethod ) ) { $ class = $ configurationFulfillmentMethod [ 'class' ] ; $ fulfillmentMethod = new $ class ( ) ; $ fulfillmentMethodsInType = $ this -> fulfillmentMethodsByType -> get ( $ type ) ; if ( ! $ fulfillmentMethodsInType ) { $ fulfillmentMethodsInType = new ArrayCollection ( ) ; $ this -> fulfillmentMethodsByType -> set ( $ type , $ fulfillmentMethodsInType ) ; } $ fulfillmentMethodsInType -> add ( $ fulfillmentMethod ) ; } } } }
Load fulfillment methods from the configuration
4,739
public function unserialize ( $ serialized ) { $ unserialized = unserialize ( $ serialized ) ; $ this -> amount = $ unserialized [ 'amount' ] ; $ this -> currency = unserialize ( $ unserialized [ 'currency' ] ) ; }
Unserializing Money value object
4,740
public function multiply ( $ operand , $ roundingMode = self :: ROUND_HALF_UP , $ useGaapPrecision = false ) { $ this -> assertOperand ( $ operand ) ; $ validatedOperand = $ this -> normalizeOperand ( $ operand ) ; if ( $ useGaapPrecision ) { $ amount = Math :: bcround ( bcmul ( $ this -> amount , $ validatedOperand , self :: GAAP_PRECISION + 1 ) , self :: GAAP_PRECISION , $ roundingMode ) ; } else { $ amount = Math :: bcround ( bcmul ( $ this -> amount , $ validatedOperand , self :: GAAP_PRECISION + 1 ) , self :: BASIC_PRECISION , $ roundingMode ) ; } return new Money ( $ amount , $ this -> currency ) ; }
Multiplying compatible with Verraes Money To use GAAP precision rounding pass true as third argument
4,741
public function divide ( $ operand , $ roundingMode = self :: ROUND_HALF_UP , $ useGaapPrecision = false ) { $ this -> assertOperand ( $ operand , true ) ; $ validatedOperand = $ this -> normalizeOperand ( $ operand ) ; if ( $ useGaapPrecision ) { $ amount = Math :: bcround ( bcdiv ( $ this -> amount , $ validatedOperand , self :: GAAP_PRECISION + 1 ) , self :: GAAP_PRECISION , $ roundingMode ) ; } else { $ amount = Math :: bcround ( bcdiv ( $ this -> amount , $ validatedOperand , self :: GAAP_PRECISION + 1 ) , self :: BASIC_PRECISION , $ roundingMode ) ; } return new Money ( $ amount , $ this -> currency ) ; }
Division compatible with Verraes Money To use GAAP precision rounding pass true as third argument
4,742
public function allocate ( array $ ratios , $ useGaapPrecision = false ) { $ useGaapPrecision ? $ precision = self :: GAAP_PRECISION : $ precision = self :: BASIC_PRECISION ; $ remainder = $ this -> amount ; $ results = [ ] ; $ total = array_sum ( $ ratios ) ; foreach ( $ ratios as $ ratio ) { $ share = bcdiv ( bcmul ( $ this -> amount , ( string ) $ ratio , $ precision ) , ( string ) $ total , $ precision ) ; $ results [ ] = new Money ( $ share , $ this -> currency ) ; $ remainder = bcsub ( $ remainder , $ share , $ precision ) ; } $ count = count ( $ results ) - 1 ; $ index = 0 ; $ minValue = '0.' . str_repeat ( '0' , $ precision - 1 ) . '1' ; while ( bccomp ( $ remainder , '0' . str_repeat ( '0' , $ precision ) , $ precision ) !== 0 ) { $ remainder = bcsub ( $ remainder , $ minValue , $ precision ) ; $ results [ $ index ] = $ results [ $ index ] -> add ( new Money ( $ minValue , $ this -> currency ) ) ; if ( $ index !== $ count ) { $ index ++ ; } else { $ index = 0 ; } } return $ results ; }
Allocate the money according to a list of ratio s Allocation is compatible with Verraes Money To use GAAP precision rounding pass true as second argument
4,743
public function bulkUpdate ( $ values ) { foreach ( $ values as $ property => $ value ) { $ this -> update ( $ property , $ value ) ; } return $ this ; }
Updates the object with multiple values
4,744
public function update ( $ using = 'hex' , $ value = false ) { if ( 'hex' == $ using || 'alpha' == $ using ) { $ this -> $ using = $ value ; } $ this -> hex = $ this -> formats -> update ( $ using , $ value , $ this -> hex ) ; return $ this ; }
Updates the object with a value
4,745
public function fetch ( ) { $ data = Base :: query ( 'bf2cc si' ) ; $ spl = explode ( "\t" , $ data ) ; $ result = array ( 'name' => $ spl [ 7 ] , 'map' => $ spl [ 5 ] , 'playersCurrent' => $ spl [ 3 ] , 'playersMax' => $ spl [ 2 ] , 'playersJoining' => $ spl [ 4 ] , 'tickets' => array ( $ spl [ 10 ] - $ spl [ 11 ] , $ spl [ 10 ] - $ spl [ 16 ] ) , 'ticketsMax' => $ spl [ 10 ] , 'timeElapsed' => $ spl [ 18 ] , 'timeRemaining' => $ spl [ 19 ] ) ; return ( object ) $ result ; }
Fetches Server Info
4,746
public function validator ( $ type , $ validator ) { $ this -> validators [ $ type ] = $ validator ; $ this -> resolver ( $ type , function ( $ data , $ resourceId ) use ( $ type ) { $ validators = Arr :: wrap ( $ this -> validators [ $ type ] ) ; foreach ( $ validators as $ validator ) { $ data [ 'id' ] = $ resourceId ; $ validator -> with ( $ data ) ; $ result = $ validator -> passes ( ) ; if ( ! $ result ) { $ errors = $ validator -> errors ( ) ; $ types = explode ( '.' , $ type ) ; $ key = end ( $ types ) ; if ( $ resourceId !== null ) { $ key .= '_' . $ resourceId ; } $ this -> errors [ $ key ] = array_merge ( Arr :: get ( $ this -> errors , $ key , [ ] ) , $ errors ) ; } } } ) ; return $ this ; }
Add a validator to be ran when the type is found .
4,747
public function validate ( array $ input ) { $ result = $ this -> parse ( $ input ) ; if ( $ result === null ) { throw new InvalidJsonException ( 'Parser was unable to process the JSON due to there not being a data key.' ) ; } if ( count ( $ this -> seenTypes ) > 0 ) { array_walk ( $ this -> presenceCheckers , function ( callable $ callback = null , $ type ) { if ( $ callback !== null ) { try { $ isRequired = $ callback ( $ this -> seenTypes ) ; } catch ( FailedValidationException $ exception ) { $ this -> errors = array_merge ( $ this -> errors , [ $ type => $ exception -> getMessages ( ) ] ) ; return ; } if ( $ isRequired === false ) { return ; } } elseif ( $ this -> seenTypes -> has ( $ type ) ) { return ; } $ this -> errors [ $ type ] = 'Missing api resource from the request.' ; } ) ; } if ( count ( $ this -> errors ) > 0 ) { throw new FailedValidationException ( $ this -> errors ) ; } return true ; }
Validate input .
4,748
public static function register ( $ code , $ frequency , $ callback , array $ args = array ( ) ) { if ( ! is_callable ( $ callback ) ) { throw new \ RuntimeException ( 'The callback must be callable' ) ; } $ instance = self :: getInstance ( ) ; $ cronRegistry = $ instance -> getCronRegistry ( ) ; $ cronRegistry [ $ code ] = array ( 'frequency' => $ frequency , 'callback' => $ callback , 'args' => $ args , ) ; $ instance -> setCronRegistry ( $ cronRegistry ) ; return $ instance ; }
register a cron job
4,749
public function jsonResponse ( ) { $ user = Auth :: getUser ( ) ; $ ssoUser = new SSOUser ( ) ; $ ssoUser -> id = $ user -> id ; $ ssoUser -> name = $ user -> username ; $ ssoUser -> email = $ user -> email ; $ ssoUser -> roles = $ user -> roles ; $ ssoUser -> profilepicture = "" ; $ userInfo = $ ssoUser -> toArray ( ) ; return VanillaSSO :: WriteJsConnect ( $ userInfo , $ _GET , true ) ; }
Produces jsonResponse .
4,750
public static function create ( $ class , EntityManager $ entityManager ) { $ rc = new \ ReflectionClass ( $ class ) ; $ interface = 'Blast\CoreBundle\CodeGenerator\CodeGeneratorInterface' ; if ( ! $ rc -> implementsInterface ( $ interface ) ) { throw new \ RuntimeException ( "Class $class should implement $interface" ) ; } $ codeGenerator = new $ class ( ) ; $ codeGenerator :: setEntityManager ( $ entityManager ) ; return $ codeGenerator ; }
Creates an entity code generator service .
4,751
public function pathPart ( $ i ) { if ( isset ( $ this -> pathParts [ $ i ] ) ) { return $ this -> pathParts [ $ i ] ; } return null ; }
Get a part of the path by index .
4,752
public static function images ( $ file = null , $ secure = false ) { return asset ( self :: appendToPath ( config ( 'pxlcms.paths.images' ) , $ file ) , $ secure ) ; }
External path to CMS images
4,753
public static function imagesInternal ( $ file = null ) { return base_path ( self :: appendToPath ( self :: appendToPath ( config ( 'pxlcms.paths.base_internal' ) , config ( 'pxlcms.paths.images' ) ) , $ file ) ) ; }
Internal path to CMS images
4,754
protected static function appendToPath ( $ path , $ file ) { if ( empty ( $ file ) ) return $ path ; return rtrim ( $ path , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . $ file ; }
Append a subpath or file to a path
4,755
public static function get ( $ arr , $ key , $ default = null ) { return self :: exists ( $ arr , $ key ) ? $ arr [ $ key ] : $ default ; }
Return the value of a key or a default value .
4,756
public static function exists ( $ arr , $ key ) { if ( is_object ( $ arr ) ) { return $ arr -> offsetExists ( $ key ) ; } if ( is_array ( $ arr ) ) { return array_key_exists ( $ key , $ arr ) ; } return false ; }
Determines whether an array contains a certain key .
4,757
public static function pluck ( $ arr , $ path ) { $ ret = [ ] ; $ path = ( array ) $ path ; foreach ( $ arr as $ v ) { $ node = & $ v ; $ ok = true ; foreach ( $ path as $ part ) { if ( ! is_array ( $ node ) || ! array_key_exists ( $ part , $ node ) ) { $ ok = false ; break ; } $ node = & $ node [ $ part ] ; } if ( $ ok ) { $ ret [ ] = $ node ; } } return $ ret ; }
Extract values from an array with the given path .
4,758
public function Charset ( ) { return ( $ this -> owner -> config ( ) -> Charset ) ? $ this -> owner -> config ( ) -> Charset : self :: $ Charset ; }
Character set .
4,759
public function getTitleFields ( ) { return array ( LabelField :: create ( 'FaviconDescription' , 'A title tag is the main text that describes an online document. Title elements have long been considered one of the most important on-page SEO elements (the most important being overall content), and appear in three key places: browsers, search engine results pages, and external websites.<br />@ <a href="https://moz.com/learn/seo/title-tag" target="_blank">Title Tag - Learn SEO - Mozilla</a>' ) -> addExtraClass ( 'information' ) , DropdownField :: create ( 'TitleOrder' , 'Page Title Order' , self :: $ TitleOrderOptions ) , TextField :: create ( 'TitleSeparator' , 'Page Title Separator' ) -> setAttribute ( 'placeholder' , self :: $ TitleSeparatorDefault ) -> setAttribute ( 'size' , 1 ) -> setMaxLength ( 1 ) -> setDescription ( 'max 1 character' ) , TextField :: create ( 'Title' , 'Website Name' ) , TextField :: create ( 'TaglineSeparator' , 'Tagline Separator' ) -> setAttribute ( 'placeholder' , self :: $ TaglineSeparatorDefault ) -> setAttribute ( 'size' , 1 ) -> setMaxLength ( 1 ) -> setDescription ( 'max 1 character' ) , TextField :: create ( 'Tagline' , 'Tagline' ) -> setDescription ( 'optional' ) ) ; }
Gets the title fields .
4,760
public function load ( ) { $ this -> checkSource ( ) ; $ this -> spammers = $ this -> cacheSpammers ( function ( ) { return SpammerCollection :: load ( file ( $ this -> source , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ) ; } ) ; return $ this ; }
Load spammers .
4,761
public function isBlocked ( $ host ) { $ host = parse_url ( $ host , PHP_URL_HOST ) ; $ host = utf8_encode ( trim ( $ host ) ) ; if ( empty ( $ host ) ) return false ; $ fullDomain = $ this -> getFullDomain ( $ host ) ; $ rootDomain = $ this -> getRootDomain ( $ fullDomain ) ; return $ this -> spammers ( ) -> whereHostIn ( [ $ fullDomain , $ rootDomain ] ) -> whereBlocked ( ) -> count ( ) > 0 ; }
Check if the given host is blocked .
4,762
private function getRootDomain ( $ domain ) { $ domainParts = explode ( '.' , $ domain ) ; $ count = count ( $ domainParts ) ; return $ count > 1 ? $ domainParts [ $ count - 2 ] . '.' . $ domainParts [ $ count - 1 ] : $ domainParts [ 0 ] ; }
Get the root domain .
4,763
private function cacheSpammers ( Closure $ callback ) { return cache ( ) -> remember ( $ this -> cacheKey , $ this -> cacheExpires , $ callback ) ; }
Cache the spammers .
4,764
public static function create ( User $ user , string $ salt ) : self { return new self ( md5 ( $ salt . serialize ( [ $ user -> name ( ) , $ user -> firstName ( ) , $ user -> lastName ( ) , $ user -> mailAddress ( ) , self :: createRandomContent ( ) ] ) ) ) ; }
creates token for given user
4,765
public function process ( RequestInterface $ request , ResponseInterface $ response , DelegateInterface $ next = null ) { $ response = $ this -> before ( $ request , $ response ) ; if ( $ next ) { $ response = $ next -> next ( $ request , $ response ) ; } return $ this -> after ( $ request , $ response ) ; }
Make process logic clear !
4,766
protected function createProcessBuilder ( array $ arguments = array ( ) ) { $ pb = new Process ( implode ( ' ' , $ arguments ) ) ; if ( null !== $ this -> timeout ) { $ pb -> setTimeout ( $ this -> timeout ) ; } return $ pb ; }
Creates a new process builder .
4,767
protected function setPrefix ( $ prefix ) { if ( is_string ( $ prefix ) ) { $ this -> prefix = $ prefix ; return $ this ; } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ prefix ) . "' for argument 'prefix' given." ) ; } }
Sets the namespace prefix .
4,768
protected function parseRuleString ( $ ruleString ) { if ( is_string ( $ ruleString ) ) { $ charset = $ this -> getCharset ( ) ; $ ruleString = preg_replace ( '/^[ \r\n\t\f]*@namespace[ \r\n\t\f]+/i' , '' , $ ruleString ) ; $ ruleString = trim ( $ ruleString , " \r\n\t\f" ) ; $ ruleString = rtrim ( $ ruleString , ";" ) ; $ isEscaped = false ; $ inFunction = false ; $ parts = [ ] ; $ currentPart = "" ; for ( $ i = 0 , $ j = mb_strlen ( $ ruleString , $ charset ) ; $ i < $ j ; $ i ++ ) { $ char = mb_substr ( $ ruleString , $ i , 1 , $ charset ) ; if ( $ char === "\\" ) { if ( $ isEscaped === false ) { $ isEscaped = true ; } else { $ isEscaped = false ; } } else { if ( $ char === " " ) { if ( $ isEscaped === false ) { if ( $ inFunction == false ) { $ currentPart = trim ( $ currentPart , " \r\n\t\f" ) ; if ( $ currentPart !== "" ) { $ parts [ ] = trim ( $ currentPart , " \r\n\t\f" ) ; $ currentPart = "" ; } } } else { $ currentPart .= $ char ; } } elseif ( $ isEscaped === false && $ char === "(" ) { $ inFunction = true ; $ currentPart .= $ char ; } elseif ( $ isEscaped === false && $ char === ")" ) { $ inFunction = false ; $ currentPart .= $ char ; } else { $ currentPart .= $ char ; } } if ( $ isEscaped === true && $ char !== "\\" ) { $ isEscaped = false ; } } if ( $ currentPart !== "" ) { $ currentPart = trim ( $ currentPart , " \r\n\t\f" ) ; if ( $ currentPart !== "" ) { $ parts [ ] = trim ( $ currentPart , " \r\n\t\f" ) ; } } foreach ( $ parts as $ key => $ value ) { $ parts [ $ key ] = Placeholder :: replaceStringPlaceholders ( $ value ) ; } $ countParts = count ( $ parts ) ; if ( $ countParts === 2 ) { $ this -> setPrefix ( $ parts [ 0 ] ) ; $ name = Url :: extractUrl ( $ parts [ 1 ] ) ; $ this -> setName ( $ name ) ; } elseif ( $ countParts === 1 ) { $ name = Url :: extractUrl ( $ parts [ 0 ] ) ; $ this -> setName ( $ name ) ; } else { } } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ ruleString ) . "' for argument 'ruleString' given." ) ; } }
Parses the namespace rule .
4,769
public function duplicate ( ) { $ this -> isNewRecord = true ; foreach ( $ this -> primaryKey ( ) as $ key ) { $ this -> $ key = null ; } if ( $ this -> save ( ) ) { return $ this ; } return null ; }
Duplicate entries in the table .
4,770
private function setDefaultPreferredProfileAdapters ( $ flags , $ options ) { $ this -> preferredProfilerAdapters = array ( new ProfilerAdapter \ UprofilerAdapter ( $ flags , $ options ) , new ProfilerAdapter \ XhprofAdapter ( $ flags , $ options ) , new ProfilerAdapter \ NullAdapter ( $ flags , $ options ) , ) ; }
Sets default preferred profile adapters
4,771
private function addInternalIgnoreFunctions ( $ options ) { if ( isset ( $ options [ 'ignored_functions' ] ) === false ) { $ options [ 'ignored_functions' ] = array ( ) ; } $ options [ 'ignored_functions' ] = array_merge ( $ options [ 'ignored_functions' ] , array ( 'xhprof_disable' , 'Link0\Profiler\ProfilerAdapter\XhprofAdapter::stop' , 'Link0\Profiler\ProfilerAdapter\UprofilerAdapter::stop' , 'Link0\Profiler\ProfilerAdapter\NullAdapter::stop' , 'Link0\Profiler\ProfilerAdapter::stop' , 'Link0\Profiler\ProfilerAdapter::isRunning' , 'Link0\Profiler\Profiler::getProfilerAdapter' , 'Link0\Profiler\Profiler::getProfileFactory' , 'Link0\Profiler\Profiler::stop' , 'Link0\Profiler\Profiler::isRunning' , 'Link0\Profiler\Profiler::__destruct' , ) ) ; return $ options ; }
Adds internal methods for ignored_functions
4,772
public function stop ( ) { $ profile = $ this -> getProfileFactory ( ) -> create ( $ this -> getProfilerAdapter ( ) -> stop ( ) , $ this -> getApplicationData ( ) , $ _SERVER ) ; $ this -> getPersistenceService ( ) -> persist ( $ profile ) ; return $ profile ; }
Stops profiling and persists and returns the Profile object
4,773
public function build ( ) { if ( $ this -> updateRequired ) { $ this -> updateRequired = false ; foreach ( $ this -> nodes as $ node ) { if ( $ node -> parent ( ) ) { $ node -> unlock ( ) -> detach ( ) ; } } $ this -> root -> addChildren ( $ this -> builder -> build ( $ this -> hierarchy , $ this -> nodes -> toArray ( ) ) ) ; foreach ( $ this -> nodes as $ node ) { if ( $ node -> parent ( ) === $ this -> root || $ this -> nodes -> contains ( $ node -> parent ( ) ) ) { $ node -> lock ( ) ; } } } }
Builds tree based on its nodes registry and hierarchy configuration if structure update required .
4,774
public function replace ( $ nodeName , ChildNodeInterface $ node ) { $ this -> removeNodeFromList ( $ nodeName ) ; $ this -> nodes -> set ( $ nodeName , $ node ) ; $ this -> updateRequired = true ; return $ this ; }
Replaces named tree node to new one .
4,775
public function addMany ( $ parentName , array $ namedItems , $ prepend = false ) { foreach ( $ namedItems as $ name => $ item ) { $ this -> add ( $ parentName , $ name , $ item , $ prepend ) ; } return $ this ; }
Adds multiple nodes to tree .
4,776
public function move ( $ nodeName , $ newParentName , $ prepend = false ) { if ( ! $ this -> nodes -> hasKey ( $ nodeName ) ) { throw new NodeNotFoundException ( ) ; } $ node = $ this -> nodes -> get ( $ nodeName ) ; $ this -> remove ( $ nodeName ) ; $ this -> add ( $ newParentName , $ nodeName , $ node , $ prepend ) ; return $ this ; }
Moves node to another parent .
4,777
public function remove ( $ nodeName ) { $ children = self :: removeTreeNode ( $ this -> hierarchy , $ nodeName ) ; $ this -> removeNodeFromList ( $ nodeName ) ; $ this -> updateRequired = true ; return $ this ; }
Removes node by its name .
4,778
protected function add ( $ parentName = null , $ nodeName , ChildNodeInterface $ node , $ prepend = false ) { if ( ! self :: addTreeNode ( $ this -> hierarchy , $ parentName , $ nodeName , $ prepend ) ) { throw new NodeNotFoundException ( "Can't add '$nodeName' node to '$parentName': '$parentName' node not found." ) ; } $ this -> removeNodeFromList ( $ nodeName ) ; $ this -> nodes -> set ( $ nodeName , $ node ) ; $ this -> updateRequired = true ; return $ this ; }
Adds new tree node . If node exists replaces it .
4,779
public static function abs ( $ int ) { if ( ! static :: is ( $ int ) ) { throw new \ InvalidArgumentException ( "The \$int parameter must be of type int (or string representing a big int)." ) ; } if ( Int :: is ( $ int ) ) { return Int :: abs ( $ int ) ; } else { return Str :: replace ( $ int , '-' , '' ) ; } }
Gets the absolute value of the given integer .
4,780
protected function validator ( $ varInput ) { if ( is_array ( $ varInput ) ) { return parent :: validator ( $ varInput ) ; } $ varInput = \ Idna :: encodeUrl ( $ varInput ) ; return parent :: validator ( trim ( $ varInput ) ) ; }
Trim the values
4,781
private function getRepository ( ) { $ c = $ this -> repository ; if ( $ c instanceof \ Closure ) { $ this -> repository = $ c ( ) ; } return $ this -> repository ; }
Return the wrapped PHPCR Repository
4,782
public function getQuery ( ) { $ queryParts = array_map ( function ( $ value ) { return ( $ value instanceof Operator ) ? $ value -> expression ( ) : $ value ; } , $ this -> queryParts ) ; return implode ( '' , $ queryParts ) ; }
builds the query and returns it as a string
4,783
public function getDateTimePickerOptions ( ) { if ( ! isset ( $ this -> dateTimePickerOptions [ 'language' ] ) ) $ this -> dateTimePickerOptions [ 'language' ] = config ( 'app.locale' ) ; $ available = [ 'en' , 'pl' , 'sv' , 'de' ] ; $ this -> dateTimePickerOptions [ 'language' ] = in_array ( $ this -> dateTimePickerOptions [ 'language' ] , $ available ) ? $ this -> dateTimePickerOptions [ 'language' ] : 'en' ; return $ this -> dateTimePickerOptions ; }
Gets the Model datetimepickerOptions .
4,784
public function setDateTimePickerOptions ( $ attr , $ option = null ) { $ options = is_array ( $ attr ) ? $ attr : [ $ attr => $ option ] ; foreach ( $ options as $ key => $ value ) $ this -> dateTimePickerOptions [ $ key ] = $ value ; return $ this ; }
Sets the Model datetimepickerOptions .
4,785
public static function difference ( int $ stamp1 , int $ stamp2 = null ) : int { if ( ! is_int ( $ stamp2 ) ) { $ stamp2 = time ( ) ; } return $ stamp2 > $ stamp1 ? $ stamp2 - $ stamp1 : $ stamp1 - $ stamp2 ; }
Number of seconds elapsed between 2 timestamps
4,786
public function toString ( ) { if ( ! $ this -> getPath ( ) ) { return '' ; } $ path = preg_replace ( '/^\\\/' , '' , $ this -> getPath ( ) ) ; $ namespace = $ this -> getDocBlock ( ) -> setTabulation ( $ this -> getTabulation ( ) ) -> toString ( ) . $ this -> getTabulationFormatted ( ) . 'namespace ' . $ path . ';' . PHP_EOL ; return $ namespace ; }
Parse the namespace string ;
4,787
public function process ( array $ statementlist , SymbolTable $ table = null ) { if ( is_null ( $ table ) ) { $ table = new SymbolTable ; } $ statementlist = $ this -> optimize ( $ statementlist ) ; $ results = [ ] ; foreach ( $ statementlist as $ statement ) { $ results = array_merge ( $ results , ( array ) $ statement -> process ( $ table ) ) ; } return $ results ; }
Main entrypoint .
4,788
public function checkValue ( & $ value ) { if ( parent :: checkValue ( $ value ) ) { $ value = trim ( $ value , " \r\n\t\f;" ) ; if ( strpos ( $ value , "!" ) !== false ) { $ charset = $ this -> getStyleSheet ( ) -> getCharset ( ) ; if ( mb_strtolower ( mb_substr ( $ value , - 10 , null , $ charset ) , $ charset ) === "!important" ) { $ this -> setIsImportant ( true ) ; $ value = rtrim ( mb_substr ( $ value , 0 , - 10 , $ charset ) ) ; } } $ value = Optimizer :: optimizeDeclarationValue ( $ value ) ; return true ; } return false ; }
Checks the value .
4,789
public function setIsImportant ( $ isImportant ) { if ( is_bool ( $ isImportant ) ) { $ this -> isImportant = $ isImportant ; } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ isImportant ) . "' for argument 'isImportant' given." ) ; } }
Sets the importance status of the declaration .
4,790
public function postAction ( Request $ request ) { try { $ data = $ request -> request -> all ( ) ; $ this -> validatePostData ( $ data ) ; $ locale = $ this -> getLocale ( $ request ) ; $ price = $ this -> getPriceCalculationManager ( ) -> retrieveItemPrices ( $ data [ 'items' ] , $ data [ 'currency' ] , $ locale ) ; $ view = $ this -> view ( $ price , 200 ) ; } catch ( PriceCalculationException $ pce ) { $ view = $ this -> view ( $ pce -> getMessage ( ) , 400 ) ; } return $ this -> handleView ( $ view ) ; }
Calculates total prices of all given items .
4,791
private function validatePostData ( $ data ) { $ required = [ 'items' , 'currency' ] ; foreach ( $ required as $ field ) { if ( ! isset ( $ data [ $ field ] ) && ! is_null ( $ data [ $ field ] ) ) { throw new PriceCalculationException ( $ field . ' is required but not set properly' ) ; } } }
Checks if all necessary data for post request is set .
4,792
protected function compile ( ) { $ attributes = new Attributes ( ) ; $ this -> setLinkTitle ( $ attributes ) ; $ this -> setHref ( $ attributes ) ; $ this -> setCssClass ( $ attributes ) ; $ this -> enableLightbox ( $ attributes ) ; $ this -> setDataAttributes ( $ attributes ) ; if ( $ this -> target ) { $ attributes -> setAttribute ( 'target' , '_blank' ) ; } if ( $ this -> bootstrap_icon ) { $ this -> Template -> icon = Bootstrap :: generateIcon ( $ this -> bootstrap_icon ) ; } $ this -> Template -> attributes = $ attributes ; $ this -> Template -> link = $ this -> linkTitle ; }
Compile button element inspired by ContentHyperlink .
4,793
protected function setLinkTitle ( Attributes $ attributes ) { if ( $ this -> linkTitle == '' ) { $ this -> linkTitle = $ this -> url ; } if ( TL_MODE !== 'BE' ) { $ attributes -> setAttribute ( 'title' , $ this -> titleText ? : $ this -> linkTitle ) ; } }
Set title link .
4,794
protected function setHref ( Attributes $ attributes ) { if ( substr ( $ this -> url , 0 , 7 ) == 'mailto:' ) { if ( version_compare ( VERSION . '.' . BUILD , '3.5.5' , '>=' ) ) { $ url = \ StringUtil :: encodeEmail ( $ this -> url ) ; } else { $ url = \ String :: encodeEmail ( $ this -> url ) ; } $ attributes -> setAttribute ( 'href' , $ url ) ; } else { $ attributes -> setAttribute ( 'href' , ampersand ( $ this -> url ) ) ; } }
Set Link href .
4,795
protected function setCssClass ( Attributes $ attributes ) { $ attributes -> addClass ( 'btn' ) ; if ( $ this -> cssID [ 1 ] == '' ) { $ attributes -> addClass ( 'btn-default' ) ; } else { $ attributes -> addClass ( $ this -> cssID [ 1 ] ) ; } }
Set css classes .
4,796
protected function enableLightbox ( Attributes $ attributes ) { if ( ! $ this -> rel ) { return ; } if ( strncmp ( $ this -> rel , 'lightbox' , 8 ) !== 0 ) { $ attributes -> setAttribute ( 'rel' , $ this -> rel ) ; } else { $ attributes -> setAttribute ( 'data-lightbox' , substr ( $ this -> rel , 9 , - 1 ) ) ; } }
Enable lightbox .
4,797
protected function setDataAttributes ( Attributes $ attributes ) { $ this -> bootstrap_dataAttributes = deserialize ( $ this -> bootstrap_dataAttributes , true ) ; if ( empty ( $ this -> bootstrap_dataAttributes ) ) { return ; } foreach ( $ this -> bootstrap_dataAttributes as $ attribute ) { if ( trim ( $ attribute [ 'value' ] ) != '' && $ attribute [ 'name' ] != '' ) { $ attributes -> setAttribute ( 'data-' . $ attribute [ 'name' ] , $ attribute [ 'value' ] ) ; } } }
Set data attributes .
4,798
public static function setObjectACL ( $ key , $ bucket , $ acl = 'public-read' ) { $ s3c = self :: getS3C ( ) ; if ( $ s3c -> doesObjectExist ( $ bucket , $ key ) ) { $ result = $ s3c -> putObjectAcl ( array ( 'ACL' => $ acl , 'Bucket' => $ bucket , 'Key' => $ key , ) ) ; if ( $ result ) { return true ; } } return false ; }
setObjectACL Change the access level of an object on S3 .
4,799
public function getString ( $ value ) { if ( $ this -> startsWith ( $ value , '\'' ) && $ this -> endsWith ( $ value , '\'' ) ) { return ltrim ( rtrim ( $ value , '\'' ) , '\'' ) ; } if ( $ this -> startsWith ( $ value , '"' ) && $ this -> endsWith ( $ value , '"' ) ) { return ltrim ( rtrim ( $ value , '"' ) , '"' ) ; } return $ value ; }
Removes or from string