idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
29,000
public function setCountMethod ( int $ method ) : int { if ( ! in_array ( $ method , [ self :: COUNT_METHOD_SELECT , self :: COUNT_METHOD_RECORDCOUNT ] ) ) { throw new \ InvalidArgumentException ( 'Invalid count method' ) ; } $ previous = $ this -> countMethod ; $ this -> countMethod = $ method ; return $ previous ; }
Change the count method the only possible values are COUNT_METHOD_SELECT and COUNT_METHOD_RECORDCOUNT Return the previous count method set
29,001
public function set ( string $ version ) : VersionInterface { $ matches = [ ] ; $ numbers = [ ] ; if ( preg_match ( $ this -> regex , $ version , $ matches ) ) { $ numbers = $ this -> mapMatches ( $ matches ) ; } if ( empty ( $ numbers ) ) { return new Version ( '0' ) ; } $ major = ( array_key_exists ( 'major' , $ numbers ) ? $ numbers [ 'major' ] : '0' ) ; $ minor = ( array_key_exists ( 'minor' , $ numbers ) ? $ numbers [ 'minor' ] : '0' ) ; if ( array_key_exists ( 'micro' , $ numbers ) ) { $ micro = $ numbers [ 'micro' ] ; $ patch = ( array_key_exists ( 'patch' , $ numbers ) ? $ numbers [ 'patch' ] : null ) ; $ micropatch = ( array_key_exists ( 'micropatch' , $ numbers ) ? $ numbers [ 'micropatch' ] : null ) ; } else { $ micro = '0' ; $ patch = null ; $ micropatch = null ; } $ stability = ( array_key_exists ( 'stability' , $ numbers ) ) ? $ numbers [ 'stability' ] : null ; if ( null === $ stability || 0 === mb_strlen ( $ stability ) ) { $ stability = 'stable' ; } $ stability = mb_strtolower ( $ stability ) ; switch ( $ stability ) { case 'rc' : $ stability = 'RC' ; break ; case 'patch' : case 'pl' : case 'p' : $ stability = 'patch' ; break ; case 'beta' : case 'b' : $ stability = 'beta' ; break ; case 'alpha' : case 'a' : $ stability = 'alpha' ; break ; case 'dev' : case 'd' : $ stability = 'dev' ; break ; } $ build = ( array_key_exists ( 'build' , $ numbers ) ) ? $ numbers [ 'build' ] : null ; return new Version ( $ major , $ minor , $ micro , $ patch , $ micropatch , $ stability , $ build ) ; }
sets the detected version
29,002
public function detectVersion ( string $ useragent , array $ searches = [ ] , string $ default = '0' ) : VersionInterface { $ modifiers = [ [ '\/' , '' ] , [ '\(' , '\)' ] , [ ' ' , ';' ] , [ ' ' , '' ] , [ '' , '' ] , [ ' \(' , ';' ] , ] ; $ version = $ default ; if ( false !== mb_strpos ( $ useragent , '%' ) ) { $ useragent = urldecode ( $ useragent ) ; } foreach ( $ searches as $ search ) { if ( ! is_string ( $ search ) ) { continue ; } if ( false !== mb_strpos ( $ search , '%' ) ) { $ search = urldecode ( $ search ) ; } foreach ( $ modifiers as $ modifier ) { $ compareString = '/' . $ search . $ modifier [ 0 ] . '(\d+[\d._\-+ abcdehlprstv]*)' . $ modifier [ 1 ] . '/i' ; $ matches = [ ] ; $ doMatch = preg_match ( $ compareString , $ useragent , $ matches ) ; if ( $ doMatch ) { $ version = mb_strtolower ( str_replace ( '_' , '.' , $ matches [ 1 ] ) ) ; break 2 ; } } } return $ this -> set ( $ version ) ; }
detects the bit count by this browser from the given user agent
29,003
protected function prepareAttributes ( array $ attributes ) { $ attributesCollected = '' ; foreach ( $ attributes as $ attribute => $ value ) { if ( $ value === null ) { $ attributesCollected .= ' ' . $ attribute ; } else { $ value = ( is_array ( $ value ) ) ? $ value [ 0 ] : $ value ; $ attributesCollected .= ' ' . $ attribute . '="' . $ value . '"' ; } } return $ attributesCollected ; }
Prepares attributes .
29,004
protected function renderChildren ( array $ children = [ ] , $ force ) { $ html = '' ; foreach ( $ children as $ child ) { $ html .= $ child -> render ( $ force ) -> get ( ) ; } return $ html ; }
Renders the HTML of the children attached .
29,005
public function setActions ( $ actions ) { if ( ! is_array ( $ actions ) ) { $ actions = array ( $ actions ) ; } $ this -> actions = array_filter ( $ actions , array ( $ this , 'isValidAction' ) ) ; return $ this ; }
Sets the actions this event should listen for .
29,006
public function show ( $ uid ) { $ options = $ this -> getParams ( 'includes' ) ; $ user = Subbly :: api ( 'subbly.user' ) -> find ( $ uid , $ options ) ; return $ this -> jsonResponse ( array ( 'user' => $ this -> presenter -> single ( $ user ) , ) ) ; }
Get User datas .
29,007
protected function _prepareArrayModule ( array & $ module , & $ moduleObject = false ) { $ moduleName = key ( $ module ) ; $ module = $ module [ $ moduleName ] ; if ( is_object ( $ module ) ) $ moduleObject = $ module ; $ module = $ moduleName ; }
Resolve to instance modules options
29,008
public function createDoctrineConnection ( array $ params ) { $ options = ! empty ( $ params [ 'options' ] ) ? ( array ) $ params [ 'options' ] : [ ] ; if ( array_key_exists ( 'encoding' , $ params ) ) { $ params [ 'charset' ] = $ params [ 'encoding' ] ; unset ( $ params [ 'encoding' ] ) ; } unset ( $ params [ 'managed' ] ) ; unset ( $ params [ 'options' ] ) ; $ params = array_merge ( [ 'charset' => 'utf8' ] , $ params ) ; if ( array_key_exists ( 'username' , $ params ) ) { if ( ! array_key_exists ( 'user' , $ params ) ) { $ params [ 'user' ] = $ params [ 'username' ] ; unset ( $ params [ 'username' ] ) ; } } if ( isset ( $ params [ 'dsn' ] ) ) { list ( $ type , $ tmp ) = explode ( ':' , $ params [ 'dsn' ] , 2 ) ; unset ( $ params [ 'dsn' ] ) ; $ cfg = [ 'driver' => 'pdo_' . $ type ] ; if ( $ cfg [ 'driver' ] == 'pdo_sqlite' ) { if ( $ tmp == ':memory:' ) { $ cfg [ 'memory' ] = true ; } else { $ cfg [ 'path' ] = $ tmp [ 1 ] ; } } else { foreach ( explode ( ';' , $ tmp ) as $ conf ) { $ parts = array_map ( 'trim' , explode ( '=' , $ conf , 2 ) ) ; $ cfg [ $ parts [ 0 ] ] = $ parts [ 1 ] ; } } $ params = array_merge ( $ cfg , $ params ) ; } $ conn = new Doctrine \ Connection ( DriverManager :: getConnection ( $ params ) , $ options ) ; $ conn -> setEventDispatcher ( $ this -> eventDispatcher ) ; return $ conn ; }
Create a connection backed by a Doctrine DBAL connection .
29,009
private static function findInArray ( array $ array , string $ key , $ default = null ) { if ( ( $ pos = strrpos ( $ key , '.' ) ) !== false ) { $ array = self :: findInArray ( $ array , substr ( $ key , 0 , $ pos ) , $ default ) ; $ key = substr ( $ key , $ pos + 1 ) ; } return is_array ( $ array ) && array_key_exists ( $ key , $ array ) ? $ array [ $ key ] : $ default ; }
Retrieves the value of an array element or object property with the given key or property name .
29,010
public function offsetGet ( $ offset ) { if ( false === array_key_exists ( $ offset , $ this -> container ) ) { throw OutOfBoundsException :: arrayKey ( $ offset ) ; } if ( is_callable ( $ this -> container [ $ offset ] ) ) { return $ this -> container [ $ offset ] ( $ this ) ; } return $ this -> container [ $ offset ] ; }
Returns the service or parameter value .
29,011
public function once ( $ callable ) { return function ( Container $ container ) use ( $ callable ) { static $ called = false ; static $ result ; if ( false === $ called ) { $ result = $ callable ( $ container ) ; $ called = true ; } return $ result ; } ; }
Returns a closure that will only invoke the given callable once . Each subsequent call will return the same result from the first invocation . The invoked callable will receive this service container as its only parameter .
29,012
public function register ( ProviderInterface $ provider , array $ parameters = null ) { $ provider -> register ( $ this ) ; if ( null !== $ parameters ) { $ this -> container = array_replace_recursive ( $ this -> container , $ parameters ) ; } }
Registers the service provider with the service container . If any parameters are provided they will recursively replace or add values to the service container .
29,013
public function setPaths ( $ paths , $ namespace = self :: DEFAULT_NAMESPACE ) { if ( ! is_array ( $ paths ) ) { $ paths = [ $ paths ] ; } $ this -> paths [ $ namespace ] = [ ] ; foreach ( $ paths as $ path ) { $ this -> addPath ( $ path , $ namespace ) ; } }
Sets the paths where templates are stored .
29,014
public function RemoveValidMimeType ( MimeType $ mimeType ) { $ result = array ( ) ; for ( $ idx = 0 ; $ idx < count ( $ this -> mimeTypes ) ; ++ $ idx ) { if ( $ this -> mimeTypes [ $ idx ] != ( string ) $ mimeType ) $ result [ ] = $ this -> mimeTypes [ $ idx ] ; } $ this -> mimeTypes = $ result ; }
Remove a valid mime type
29,015
public static function firstSundayOfYear ( $ year = null ) { $ year = $ year ? ( int ) $ year : Date ( 'Y' ) ; $ sunday = Carbon :: parse ( $ year . '-01-01' ) -> startOfWeek ( Carbon :: SUNDAY ) ; return ( ( int ) $ sunday -> format ( 'Y' ) === $ year ) ? $ sunday : $ sunday -> addDays ( 7 ) ; }
Determine the first sunday of the given year .
29,016
public static function firstWeekOfYear ( $ year = null ) { $ year = $ year ? ( int ) $ year : Date ( 'Y' ) ; return Carbon :: parse ( $ year . '-01-01' ) -> startOfWeek ( Carbon :: SUNDAY ) ; }
Determine the first week of the given year .
29,017
public static function human ( $ date , $ format = 'l, M j' ) : string { $ diff = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInDays ( self :: parse ( $ date ) , false ) ; if ( $ diff == 0 ) { return 'Today' ; } elseif ( $ diff == 1 ) { return 'Tomorrow' ; } elseif ( $ diff == - 1 ) { return 'Yesterday' ; } elseif ( $ diff > 0 && $ diff < 7 ) { return self :: parse ( $ date ) -> format ( 'l' ) ; } elseif ( $ diff < 0 && $ diff > - 7 ) { return 'last ' . self :: parse ( $ date ) -> format ( 'l' ) ; } else { return self :: parse ( $ date ) -> format ( $ format ) ; } }
Convert the provided date into a custom human readable form .
29,018
public static function lastUpdated ( $ date , $ withTime = true ) : string { $ objDate = self :: parse ( $ date ) ; $ date = self :: parse ( $ objDate ) -> format ( 'Y-m-d' ) ; $ days = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInDays ( self :: parse ( $ date ) ) ; if ( $ days == 0 ) { $ msg = 'today' ; } elseif ( $ days == 1 ) { $ msg = 'yesterday' ; } elseif ( $ days > 1 && $ days < 7 ) { $ msg = $ objDate -> format ( 'l' ) ; } elseif ( $ days >= 7 && $ days < 32 ) { $ msg = $ days . ' days ago' ; $ withTime = false ; } elseif ( $ days >= 32 && $ days < 365 ) { $ months = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInMonths ( $ objDate ) ; $ msg = $ months . ( ( $ months > 1 ) ? ' months ' : ' month ' ) . 'ago' ; $ withTime = false ; } else { $ years = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInYears ( $ objDate ) ; $ msg = $ years . ( ( $ years > 1 ) ? ' years ' : ' year ' ) . 'ago' ; $ withTime = false ; } return ( $ withTime ) ? $ msg . ' at ' . $ objDate -> format ( 'g:ia' ) : $ msg ; }
Create a human readable representation of a typical last_updated DATETIME value .
29,019
public static function sunday ( $ date = null ) { if ( $ date ) { return Carbon :: parse ( $ date ) -> startOfWeek ( Carbon :: SUNDAY ) ; } return Carbon :: now ( ) -> startOfWeek ( Carbon :: SUNDAY ) ; }
Helper method that determines the Sunday of the given week .
29,020
public static function sundays ( $ year = null ) : array { $ year = ( $ year ) ? ( int ) $ year : Date ( 'Y' ) ; $ this_sunday = static :: firstSundayOfYear ( $ year ) ; if ( $ this_sunday -> format ( 'm-d' ) != '01-01' ) { $ this_sunday -> subDays ( 7 ) ; } $ sundays = [ ] ; while ( ( int ) $ this_sunday -> format ( 'Y' ) <= ( $ year ) ) { $ sundays [ ] = clone $ this_sunday ; $ this_sunday = $ this_sunday -> addDays ( 7 ) ; } return $ sundays ; }
Return an array of Sundays for the provided year .
29,021
public static function weekDetails ( $ date ) : array { $ sunday = self :: sunday ( $ date ) ; $ current = ( $ sunday -> eq ( self :: sunday ( ) ) ) ? 1 : 0 ; $ future = ( $ sunday -> gt ( self :: now ( ) ) ) ? 1 : 0 ; $ past = ( ! $ current && ! $ future ) ? 1 : 0 ; return [ 'sunday' => $ sunday -> format ( 'Y-m-d' ) , 'past' => $ past , 'current' => $ current , 'future' => $ future , 'prev_week' => $ sunday -> copy ( ) -> subDays ( 7 ) -> format ( 'Y-m-d' ) , 'next_week' => $ sunday -> copy ( ) -> addDays ( 7 ) -> format ( 'Y-m-d' ) , ] ; }
Convert the provided date into an array that describes the week containing the given date .
29,022
public static function weekdays ( $ num = 1 ) : array { $ days = [ ] ; $ day = self :: parse ( Date ( 'Y-m-d' ) ) ; while ( count ( $ days ) < $ num ) { if ( ! $ day -> isWeekend ( ) ) { $ days [ ] = clone $ day ; } $ day -> addWeekday ( ) ; } return $ days ; }
Return the provided number of weekdays .
29,023
protected function buildValueArray ( array $ componentNames ) { $ result = [ ] ; foreach ( $ componentNames as $ componentName ) { $ result [ $ componentName ] = $ this -> getValue ( $ componentName ) ; } ; return $ result ; }
Returns built value array indexed by component name .
29,024
protected function initializeDataPool ( ) { try { $ dataPool = $ this -> getStore ( ) -> read ( $ this -> addPrefix ( $ this -> getScope ( ) ) ) ; } catch ( Doozr_Form_Service_Exception $ exception ) { $ dataPool = $ this -> getDataPoolSkeleton ( ) ; } return $ this -> dataPool ( $ dataPool ) ; }
Initializes the data pool by creating an initial pool based on a default skeleton .
29,025
protected function transferValidDataAndFilesToPool ( $ step ) { $ pool = $ this -> getDataPool ( ) ; if ( null === $ pool ) { throw new Doozr_Form_Service_Exception ( 'Pool is invalid. Need either to be loaded first or a handler to prevent invalid call' ) ; } $ components = $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_COMPONENTS ] [ $ step ] ; $ data = [ ] ; $ files = [ ] ; foreach ( $ components as $ componentName => $ configuration ) { if ( false === $ this -> hasError ( $ componentName ) ) { $ data [ $ componentName ] = $ this -> getValue ( $ componentName ) ; if ( Doozr_Form_Service_Constant :: COMPONENT_TYPE_FILE === $ configuration [ 'type' ] ) { $ files [ $ componentName ] = $ data [ $ componentName ] ; } } } $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_DATA ] [ $ step ] = $ data ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_FILES ] [ $ step ] = $ files ; $ this -> setDataPool ( $ pool ) ; return $ this ; }
Transfers data from request for a passed step to store . This happens mostly after validation .
29,026
protected function setForm ( Doozr_Form_Service_Component_Interface_Form $ form = null ) { if ( null !== $ form && null === $ form -> getName ( ) ) { $ form -> setName ( $ this -> getScope ( ) ) ; } $ this -> form = $ form ; }
Setter for form .
29,027
protected function setI18n ( Doozr_I18n_Service_Interface $ i18n = null ) { if ( null !== $ i18n ) { try { $ i18n -> addDomain ( $ this -> getScope ( ) ) ; $ i18n -> addDomain ( 'default' ) ; } catch ( Doozr_I18n_Service_Exception $ exception ) { } $ this -> i18n = $ i18n ; } }
Setter for I18n Translator service .
29,028
public function render ( ) { $ file = '' ; $ line = '' ; if ( true === headers_sent ( $ file , $ line ) ) { throw new Doozr_Form_Service_Exception ( sprintf ( 'If any output is sent before render() was successfully called ' . 'then transportation of token can not be guaranteed! File %s Line %s' , $ file , $ line ) ) ; } $ requestMethod = $ this -> getForm ( ) -> getMethod ( ) ; if ( null !== $ requestMethod ) { $ this -> setMethod ( $ requestMethod ) ; } else { $ this -> getForm ( ) -> setMethod ( $ this -> getMethod ( ) ) ; } $ this -> token ( $ this -> getTokenHandler ( ) -> generateToken ( ) ) -> addMetaComponents ( ) -> handleBackgroundDataTransfer ( ) ; return $ this -> getForm ( ) -> render ( ) -> get ( ) ; }
Renders the forms after the preparation is done . This method does generate a token for the current form add all meta fields required for validation and so on handles the data transfer from request to the next and finally it renders the HTML and returns a valid form .
29,029
public function translate ( $ string , array $ arguments = null , $ htmlEscape = true ) { if ( null === $ this -> getI18n ( ) ) { throw new Doozr_Form_Service_Exception ( 'Please set an instance of Doozr_I18n_Service (or compatible) first before calling encrypt()' ) ; } return $ this -> getI18n ( ) -> translate ( $ string , $ htmlEscape , $ arguments ) ; }
Translates the passed value to the current locale via I18n service .
29,030
public function getValue ( $ componentName , $ default = null ) { $ value = $ this -> getSubmittedValue ( $ componentName ) ; if ( null === $ value || ( true === is_array ( $ value ) && true === array_key_exists ( 'error' , $ value ) && $ value [ 'error' ] !== UPLOAD_ERR_OK ) ) { $ value = $ this -> getPoolValue ( $ componentName , $ this -> getStep ( ) ) ; } if ( null === $ value ) { $ value = $ default ; } return $ value ; }
Returns the submitted value for a passed fieldname or the default value if the field wasn t submitted not submitted .
29,031
protected function receiveTokenFieldValueFromRequest ( $ value = null ) { $ requestQueryParameter = $ this -> getRequest ( ) -> getQueryParams ( ) ; $ requestBody = $ this -> getRequest ( ) -> getParsedBody ( ) ; $ fieldname = $ this -> getFieldnameToken ( ) ; if ( true === isset ( $ requestQueryParameter [ $ fieldname ] ) ) { $ value = $ requestQueryParameter [ $ fieldname ] ; } elseif ( true === isset ( $ requestBody [ $ fieldname ] ) ) { $ value = $ requestBody [ $ fieldname ] ; } return $ value ; }
Checks and returns the token of current request .
29,032
protected function isASubmittedFormInRequest ( $ value = Doozr_Form_Service_Constant :: DEFAULT_SUBMITTED ) { $ requestQueryParameter = $ this -> getRequest ( ) -> getQueryParams ( ) ; $ requestBody = $ this -> getRequest ( ) -> getParsedBody ( ) ; $ fieldname = $ this -> getFieldnameSubmitted ( ) ; if ( true === isset ( $ requestQueryParameter [ $ fieldname ] ) && $ this -> getScope ( ) === $ requestQueryParameter [ $ fieldname ] ) { $ value = true ; } elseif ( true === isset ( $ requestBody [ $ fieldname ] ) && $ this -> getScope ( ) === $ requestBody [ $ fieldname ] ) { $ value = true ; } return $ value ; }
Checks and returns the submission status of this form .
29,033
protected function receiveJumpFieldValueFromRequest ( $ value = Doozr_Form_Service_Constant :: DEFAULT_JUMPED ) { $ requestQueryParameter = $ this -> getRequest ( ) -> getQueryParams ( ) ; $ requestBody = $ this -> getRequest ( ) -> getParsedBody ( ) ; $ fieldname = $ this -> getFieldnameJump ( ) ; if ( true === isset ( $ requestQueryParameter [ $ fieldname ] ) ) { $ value = ( int ) $ requestQueryParameter [ $ fieldname ] ; } elseif ( true === isset ( $ requestBody [ $ fieldname ] ) ) { $ value = ( int ) $ requestBody [ $ fieldname ] ; } return $ value ; }
Returns whether we jumped to a step . It looks 1 ) in request ...
29,034
protected function invalidateDataPool ( ) { $ this -> getStore ( ) -> delete ( $ this -> addPrefix ( $ this -> getScope ( ) ) ) ; $ this -> setDataPool ( null ) ; }
Invalidates the whole data pool .
29,035
protected function addToDataPool ( $ key , $ value , $ step = Doozr_Form_Service_Constant :: DEFAULT_STEP_FIRST ) { $ pool = $ this -> getDataPool ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_DATA ] [ $ step ] [ $ key ] = $ value ; $ this -> setDataPool ( $ pool ) ; return true ; }
Adds an component to internal registry with passed value .
29,036
protected function handleBackgroundDataTransfer ( ) { $ pool = $ this -> getDataPool ( ) ; $ lastValidStep = ( true === $ this -> wasSubmitted ( ) && true === $ this -> isValid ( ) ) ? $ this -> getStep ( ) : $ this -> getDataPoolValue ( Doozr_Form_Service_Constant :: IDENTIFIER_LASTVALIDSTEP ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_COMPONENTS ] [ $ this -> getActiveStep ( ) ] = $ this -> getComponents ( $ this -> getForm ( ) ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_METHOD ] = $ this -> getMethod ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_STEP ] = $ this -> getActiveStep ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_FILES ] [ $ this -> getActiveStep ( ) ] = $ this -> getFiles ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_STEPS ] = $ this -> getSteps ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_TOKEN ] = $ this -> getToken ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_UPLOAD ] = $ this -> getUpload ( ) ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_LASTVALIDSTEP ] = $ lastValidStep ; $ pool [ Doozr_Form_Service_Constant :: IDENTIFIER_TOKENBEHAVIOR ] = $ this -> getInvalidTokenBehavior ( ) ; $ this -> getStore ( ) -> create ( $ this -> addPrefix ( $ this -> getScope ( ) ) , $ pool ) ; $ this -> setDataPool ( $ pool ) ; $ this -> sendHeader ( ) ; dump ( $ this -> getActiveStep ( ) ) ; }
Handles the data transfer from one request to next one . Important to keep the meta - data being transferred between two separate requests .
29,037
protected function getDataPoolSkeleton ( ) { return [ Doozr_Form_Service_Constant :: IDENTIFIER_DATA => [ ] , Doozr_Form_Service_Constant :: IDENTIFIER_FILES => [ ] , Doozr_Form_Service_Constant :: IDENTIFIER_COMPONENTS => [ ] , Doozr_Form_Service_Constant :: IDENTIFIER_METHOD => Doozr_Form_Service_Constant :: METHOD_GET , Doozr_Form_Service_Constant :: IDENTIFIER_STEP => Doozr_Form_Service_Constant :: DEFAULT_STEP_FIRST , Doozr_Form_Service_Constant :: IDENTIFIER_STEPS => Doozr_Form_Service_Constant :: DEFAULT_STEP_LAST , Doozr_Form_Service_Constant :: IDENTIFIER_TOKEN => null , Doozr_Form_Service_Constant :: IDENTIFIER_TOKENBEHAVIOR => Doozr_Form_Service_Constant :: DEFAULT_TOKEN_BEHAVIOR , Doozr_Form_Service_Constant :: IDENTIFIER_LASTVALIDSTEP => null , Doozr_Form_Service_Constant :: IDENTIFIER_UPLOAD => Doozr_Form_Service_Constant :: DEFAULT_HAS_FILE_UPLOAD , ] ; }
Returns a registry skeleton for initializing store .
29,038
protected function addMetaComponents ( ) { $ metaComponentHandler = $ this -> getRegistry ( ) -> getContainer ( ) -> build ( 'doozr.form.service.handler.metacomponenthandler' , [ $ this -> getScope ( ) , $ this -> getRegistry ( ) , $ this -> getToken ( ) , $ this -> getStep ( ) , $ this -> getSteps ( ) , $ this -> getUpload ( ) , $ this -> getAngularDirectives ( ) , $ this -> getFieldnameToken ( ) , $ this -> getFieldnameSubmitted ( ) , $ this -> getFieldnameStep ( ) , $ this -> getFieldnameSteps ( ) , $ this -> getFieldnameJump ( ) , $ this -> getFieldnameUpload ( ) , ] ) ; $ metaDataComponents = $ metaComponentHandler -> getMetaComponents ( ) ; foreach ( $ metaDataComponents as $ metaDataComponent ) { $ this -> getForm ( ) -> addChild ( $ metaDataComponent ) ; } return $ this ; }
Adds meta control layer components to form .
29,039
protected function extractParts ( $ value ) { $ split = [ substr ( $ value , 0 , 1 ) , substr ( $ value , 1 , 7 ) ] ; if ( $ this -> withDC ) { $ split [ ] = substr ( 7 , 1 ) ; } return $ split ; }
Gets the value splited in text and number parts .
29,040
public function setMessages ( array $ messages ) { return tap ( $ this , function ( $ instance ) use ( $ messages ) { $ instance -> messages = [ $ instance -> messagesWrapper => $ messages ] ; } ) ; }
Set the Payload messages .
29,041
public function setOutput ( $ output , ? string $ wrapper = null ) { if ( $ wrapper ) { $ this -> setOutputWrapper ( $ wrapper ) ; } return tap ( $ this , function ( $ instance ) use ( $ output ) { $ instance -> output = $ output ; } ) ; }
Set the Payload output .
29,042
private function setOutputWrapper ( string $ wrapper ) { tap ( $ this , function ( $ instance ) use ( $ wrapper ) { $ this -> outputWrapper = $ wrapper ; } ) ; }
Set a wrapper for payload output .
29,043
public function toArray ( ) { $ output = $ this -> outputWrapper || $ this -> messages ? $ this -> getwrappedOutput ( ) : $ this -> output ; return $ this -> messages ? array_merge ( $ output , $ this -> messages ) : $ output ; }
Convert the Payload instance to an array .
29,044
public function determineOrderPrices ( OrderInterface $ order , PricingContextInterface $ pricingContext = null ) { if ( $ pricingContext === null ) { $ pricingContext = new PricingContext ( ) ; } foreach ( $ order -> getItems ( ) as $ item ) { $ this -> determineOrderItemPrices ( $ item , $ pricingContext ) ; } $ itemsTotalNet = 0 ; foreach ( $ order -> getItems ( ) as $ item ) { $ itemsTotalNet += $ item -> getPrice ( 'netValue' ) ; } $ order -> setPrice ( 'totalNet' , $ itemsTotalNet ) ; $ order -> setPrice ( 'totalValue' , $ itemsTotalNet ) ; if ( isset ( $ pricingContext [ 'partner' ] ) ) { if ( $ partner = $ pricingContext [ 'partner' ] ) { if ( count ( $ partner -> getPreferredPaymentProfile ( ) ) ) { $ paymentProfile = $ partner -> getPreferredPaymentProfile ( ) ; $ rate = $ this -> taxProvider -> getTaxByState ( $ paymentProfile -> getBillingState ( ) ) ; $ totalTax = $ itemsTotalNet * $ rate ; $ order -> setPrice ( 'taxRate' , $ rate ) ; $ order -> setPrice ( 'taxes' , $ totalTax ) ; $ order -> setPrice ( 'totalValue' , $ itemsTotalNet + $ totalTax ) ; } } } }
method that updates the pricing for the given order
29,045
public static function load ( $ service ) { $ arguments = array_slice ( func_get_args ( ) , 1 ) ; $ fullQualifiedService = self :: getFullQualifiedService ( $ service ) ; $ className = $ fullQualifiedService [ 'namespace' ] . '_' . ucfirst ( $ fullQualifiedService [ 'name' ] ) . '_Service' ; ( self :: $ instance === null ) ? self :: init ( ) : null ; self :: getService ( $ fullQualifiedService [ 'name' ] , $ fullQualifiedService [ 'namespace' ] ) ; self :: $ map -> reset ( ) -> generate ( $ className ) ; self :: $ registry -> getContainer ( ) -> addToMap ( self :: $ map ) ; $ instance = self :: $ registry -> getContainer ( ) -> build ( $ className , $ arguments ) ; $ identifier = strtolower ( ( $ fullQualifiedService [ 'alias' ] !== null ) ? $ fullQualifiedService [ 'alias' ] : $ fullQualifiedService [ 'name' ] ) ; $ instance -> setUuid ( self :: registerService ( $ identifier , $ instance ) ) ; return $ instance ; }
Loads a service from any namespace .
29,046
protected static function registerService ( $ name , Doozr_Base_Service_Interface $ service ) { $ uuid = ( true === $ service -> isSingleton ( ) ) ? self :: getRegistry ( ) -> set ( $ service , $ name ) : self :: getRegistry ( ) -> add ( $ service , $ name ) ; return $ uuid ; }
Registers a service in Doozr s registry .
29,047
protected static function initDependencyInjection ( ) { include_once DOOZR_DOCUMENT_ROOT . 'Doozr/Di/Map/Annotation.php' ; include_once DOOZR_DOCUMENT_ROOT . 'Doozr/Di/Parser/Annotation.php' ; include_once DOOZR_DOCUMENT_ROOT . 'Doozr/Di/Dependency.php' ; $ collection = new Doozr_Di_Collection ( ) ; $ parser = new Doozr_Di_Parser_Annotation ( ) ; $ dependency = new Doozr_Di_Dependency ( ) ; self :: $ map = new Doozr_Di_Map_Annotation ( $ collection , $ parser , $ dependency ) ; }
Initializes the dependency injection path parser map ...
29,048
protected static function getService ( $ service , $ namespace = self :: DEFAULT_NAMESPACE ) { $ key = $ service . $ namespace ; if ( ! isset ( self :: $ loaded [ $ key ] ) || self :: $ loaded [ $ key ] !== true ) { include_once self :: getServiceFile ( $ service , $ namespace ) ; self :: $ loaded [ $ key ] = true ; } return true ; }
This method is intend to conditional includes the service main classfile .
29,049
public function setFilename ( $ filename , $ content_disposition_type = 'attachement' ) { $ this -> params [ 'content-disposition-filename' ] = $ filename ; $ this -> setContentDispositionType ( $ content_disposition_type ) ; return $ this ; }
Set the content disposition filename and type .
29,050
public function setCharset ( $ charset ) { if ( $ this -> getContentType ( ) == '' ) { throw new Exception \ RuntimeException ( __METHOD__ . ' Content-type must be specified prior to setting charset' ) ; } $ this -> params [ 'content-type-charset' ] = $ charset ; return $ this ; }
Set the content type charset .
29,051
public function setContentDispositionType ( $ content_disposition_type ) { if ( ! in_array ( $ content_disposition_type , $ this -> disposition_types , true ) ) { $ supported = implode ( ',' , $ this -> disposition_types ) ; throw new Exception \ InvalidArgumentException ( __METHOD__ . " Content disposition type '$content_disposition_type' not in supported types: $supported" ) ; } $ this -> params [ 'content-disposition-type' ] = $ content_disposition_type ; return $ this ; }
Set the preferred content disposition type attachement or inline .
29,052
public function getSynchMappings ( $ direction = LDAP_USER_PROV_DIRECTION_ALL , $ prov_events = NULL ) { if ( ! $ prov_events ) { $ prov_events = ldap_user_all_events ( ) ; } $ mappings = array ( ) ; if ( $ direction == LDAP_USER_PROV_DIRECTION_ALL ) { $ directions = array ( LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER , LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY ) ; } else { $ directions = array ( $ direction ) ; } foreach ( $ directions as $ direction ) { if ( ! empty ( $ this -> ldapUserSynchMappings [ $ direction ] ) ) { foreach ( $ this -> ldapUserSynchMappings [ $ direction ] as $ attribute => $ mapping ) { if ( ! empty ( $ mapping [ 'prov_events' ] ) ) { $ result = count ( array_intersect ( $ prov_events , $ mapping [ 'prov_events' ] ) ) ; if ( $ result ) { $ mappings [ $ attribute ] = $ mapping ; } } } } } return $ mappings ; }
Util to fetch mappings for a given direction
29,053
public function getLdapUserRequiredAttributes ( $ direction = LDAP_USER_PROV_DIRECTION_ALL , $ ldap_context = NULL ) { $ attributes_map = array ( ) ; $ required_attributes = array ( ) ; if ( $ this -> drupalAcctProvisionServer ) { $ prov_events = $ this -> ldapContextToProvEvents ( $ ldap_context ) ; $ attributes_map = $ this -> getSynchMappings ( $ direction , $ prov_events ) ; $ required_attributes = array ( ) ; foreach ( $ attributes_map as $ detail ) { if ( count ( array_intersect ( $ prov_events , $ detail [ 'prov_events' ] ) ) ) { if ( $ detail [ 'ldap_attr' ] ) { ldap_servers_token_extract_attributes ( $ required_attributes , $ detail [ 'ldap_attr' ] ) ; } } } } return $ required_attributes ; }
Util to fetch attributes required for this user conf not other modules .
29,054
public function ldapContextToProvEvents ( $ ldap_context = NULL ) { switch ( $ ldap_context ) { case 'ldap_user_prov_to_drupal' : $ result = array ( LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER , LDAP_USER_EVENT_CREATE_DRUPAL_USER , LDAP_USER_EVENT_LDAP_ASSOCIATE_DRUPAL_ACCT ) ; break ; case 'ldap_user_prov_to_ldap' : $ result = array ( LDAP_USER_EVENT_SYNCH_TO_LDAP_ENTRY , LDAP_USER_EVENT_CREATE_LDAP_ENTRY ) ; break ; default : $ result = ldap_user_all_events ( ) ; } return $ result ; }
converts the more general ldap_context string to its associated ldap user event
29,055
public function ldapContextToProvDirection ( $ ldap_context = NULL ) { switch ( $ ldap_context ) { case 'ldap_user_prov_to_drupal' : $ result = LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ; break ; case 'ldap_user_prov_to_ldap' : case 'ldap_user_delete_drupal_user' : $ result = LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY ; break ; case 'ldap_user_insert_drupal_user' : case 'ldap_user_update_drupal_user' : case 'ldap_authentication_authenticate' : case 'ldap_user_insert_drupal_user' : case 'ldap_user_disable_drupal_user' : $ result = LDAP_USER_PROV_DIRECTION_ALL ; break ; default : $ result = LDAP_USER_PROV_DIRECTION_ALL ; } return $ result ; }
converts the more general ldap_context string to its associated ldap user prov direction
29,056
function setSynchMapping ( $ reset = TRUE ) { $ synch_mapping_cache = cache_get ( 'ldap_user_synch_mapping' ) ; if ( ! $ reset && $ synch_mapping_cache ) { $ this -> synchMapping = $ synch_mapping_cache -> data ; } else { $ available_user_attrs = array ( ) ; foreach ( array ( LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER , LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY ) as $ direction ) { $ sid = $ this -> provisionSidFromDirection [ $ direction ] ; $ available_user_attrs [ $ direction ] = array ( ) ; $ ldap_server = ( $ sid ) ? ldap_servers_get_servers ( $ sid , NULL , TRUE ) : FALSE ; $ params = array ( 'ldap_server' => $ ldap_server , 'ldap_user_conf' => $ this , 'direction' => $ direction , ) ; drupal_alter ( 'ldap_user_attrs_list' , $ available_user_attrs [ $ direction ] , $ params ) ; } } $ this -> synchMapping = $ available_user_attrs ; cache_set ( 'ldap_user_synch_mapping' , $ this -> synchMapping ) ; }
derive mapping array from ldap user configuration and other configurations . if this becomes a resource hungry function should be moved to ldap_user functions and stored with static variable . should be cached also .
29,057
public function synchToDrupalAccount ( $ drupal_user , & $ user_edit , $ prov_event = LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER , $ ldap_user = NULL , $ save = FALSE ) { $ debug = array ( 'account' => $ drupal_user , 'user_edit' => $ user_edit , 'ldap_user' => $ ldap_user , ) ; if ( ( ! $ ldap_user && ! isset ( $ drupal_user -> name ) ) || ( ! $ drupal_user && $ save ) || ( $ ldap_user && ! isset ( $ ldap_user [ 'sid' ] ) ) ) { return FALSE ; } if ( ! $ ldap_user && $ this -> drupalAcctProvisionServer ) { $ ldap_user = ldap_servers_get_user_ldap_data ( $ drupal_user -> name , $ this -> drupalAcctProvisionServer , 'ldap_user_prov_to_drupal' ) ; } if ( ! $ ldap_user ) { return FALSE ; } if ( $ this -> drupalAcctProvisionServer ) { $ ldap_server = ldap_servers_get_servers ( $ this -> drupalAcctProvisionServer , NULL , TRUE ) ; $ this -> entryToUserEdit ( $ ldap_user , $ user_edit , $ ldap_server , LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER , array ( $ prov_event ) ) ; } if ( $ save ) { $ account = user_load ( $ drupal_user -> uid ) ; $ result = user_save ( $ account , $ user_edit , 'ldap_user' ) ; return $ result ; } else { return TRUE ; } }
given a drupal account query ldap and get all user fields and create user account
29,058
public function deleteDrupalAccount ( $ username ) { $ user = user_load_by_name ( $ username ) ; if ( is_object ( $ user ) ) { user_delete ( $ user -> uid ) ; return TRUE ; } else { return FALSE ; } }
given a drupal account delete user account
29,059
public function getProvisionRelatedLdapEntry ( $ account , $ prov_events = NULL ) { if ( ! $ prov_events ) { $ prov_events = ldap_user_all_events ( ) ; } $ sid = $ this -> ldapEntryProvisionServer ; if ( ! $ sid ) { return FALSE ; } $ ldap_server = ldap_servers_get_servers ( $ sid , NULL , TRUE ) ; $ params = array ( 'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY , 'prov_events' => $ prov_events , 'module' => 'ldap_user' , 'function' => 'getProvisionRelatedLdapEntry' , 'include_count' => FALSE , ) ; list ( $ proposed_ldap_entry , $ error ) = $ this -> drupalUserToLdapEntry ( $ account , $ ldap_server , $ params ) ; if ( ! ( is_array ( $ proposed_ldap_entry ) && isset ( $ proposed_ldap_entry [ 'dn' ] ) && $ proposed_ldap_entry [ 'dn' ] ) ) { return FALSE ; } $ ldap_entry = $ ldap_server -> dnExists ( $ proposed_ldap_entry [ 'dn' ] , 'ldap_entry' , array ( ) ) ; return $ ldap_entry ; }
given a drupal account find the related ldap entry .
29,060
public function deleteProvisionedLdapEntries ( $ account ) { $ boolean_result = FALSE ; $ language = ( $ account -> language ) ? $ account -> language : 'und' ; if ( isset ( $ account -> ldap_user_prov_entries [ $ language ] [ 0 ] ) ) { foreach ( $ account -> ldap_user_prov_entries [ $ language ] as $ i => $ field_instance ) { $ parts = explode ( '|' , $ field_instance [ 'value' ] ) ; if ( count ( $ parts ) == 2 ) { list ( $ sid , $ dn ) = $ parts ; $ ldap_server = ldap_servers_get_servers ( $ sid , NULL , TRUE ) ; if ( is_object ( $ ldap_server ) && $ dn ) { $ boolean_result = $ ldap_server -> delete ( $ dn ) ; $ tokens = array ( '%sid' => $ sid , '%dn' => $ dn , '%username' => $ account -> name , '%uid' => $ account -> uid ) ; if ( $ boolean_result ) { watchdog ( 'ldap_user' , 'LDAP entry on server %sid deleted dn=%dn. username=%username, uid=%uid' , $ tokens , WATCHDOG_INFO ) ; } else { watchdog ( 'ldap_user' , 'LDAP entry on server %sid not deleted because error. username=%username, uid=%uid' , $ tokens , WATCHDOG_ERROR ) ; } } else { $ boolean_result = FALSE ; } } } } return $ boolean_result ; }
given a drupal account delete ldap entry that was provisioned based on it normally this will be 0 or 1 entry but the ldap_user_provisioned_ldap_entries field attached to the user entity track each ldap entry provisioned
29,061
function drupalUserToLdapEntry ( $ account , $ ldap_server , $ params , $ ldap_user_entry = NULL ) { $ provision = ( isset ( $ params [ 'function' ] ) && $ params [ 'function' ] == 'provisionLdapEntry' ) ; $ result = LDAP_USER_PROV_RESULT_NO_ERROR ; if ( ! $ ldap_user_entry ) { $ ldap_user_entry = array ( ) ; } if ( ! is_object ( $ account ) || ! is_object ( $ ldap_server ) ) { return array ( NULL , LDAP_USER_PROV_RESULT_BAD_PARAMS ) ; } $ watchdog_tokens = array ( '%drupal_username' => $ account -> name , ) ; $ include_count = ( isset ( $ params [ 'include_count' ] ) && $ params [ 'include_count' ] ) ; $ direction = isset ( $ params [ 'direction' ] ) ? $ params [ 'direction' ] : LDAP_USER_PROV_DIRECTION_ALL ; $ prov_events = empty ( $ params [ 'prov_events' ] ) ? ldap_user_all_events ( ) : $ params [ 'prov_events' ] ; $ mappings = $ this -> getSynchMappings ( $ direction , $ prov_events ) ; foreach ( $ mappings as $ field_key => $ field_detail ) { list ( $ ldap_attr_name , $ ordinal , $ conversion ) = ldap_servers_token_extract_parts ( $ field_key , TRUE ) ; $ ordinal = ( ! $ ordinal ) ? 0 : $ ordinal ; if ( $ ldap_user_entry && isset ( $ ldap_user_entry [ $ ldap_attr_name ] ) && is_array ( $ ldap_user_entry [ $ ldap_attr_name ] ) && isset ( $ ldap_user_entry [ $ ldap_attr_name ] [ $ ordinal ] ) ) { continue ; } $ synched = $ this -> isSynched ( $ field_key , $ params [ 'prov_events' ] , LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY ) ; if ( $ synched ) { $ token = ( $ field_detail [ 'user_attr' ] == 'user_tokens' ) ? $ field_detail [ 'user_tokens' ] : $ field_detail [ 'user_attr' ] ; $ value = ldap_servers_token_replace ( $ account , $ token , 'user_account' ) ; if ( substr ( $ token , 0 , 10 ) == '[password.' && ( ! $ value || $ value == $ token ) ) { if ( ! $ provision ) { continue ; } } if ( $ ldap_attr_name == 'dn' && $ value ) { $ ldap_user_entry [ 'dn' ] = $ value ; } elseif ( $ value ) { if ( ! isset ( $ ldap_user_entry [ $ ldap_attr_name ] ) || ! is_array ( $ ldap_user_entry [ $ ldap_attr_name ] ) ) { $ ldap_user_entry [ $ ldap_attr_name ] = array ( ) ; } $ ldap_user_entry [ $ ldap_attr_name ] [ $ ordinal ] = $ value ; if ( $ include_count ) { $ ldap_user_entry [ $ ldap_attr_name ] [ 'count' ] = count ( $ ldap_user_entry [ $ ldap_attr_name ] ) ; } } } } drupal_alter ( 'ldap_entry' , $ ldap_user_entry , $ params ) ; return array ( $ ldap_user_entry , $ result ) ; }
populate ldap entry array for provisioning
29,062
function ldapAssociateDrupalAccount ( $ drupal_username ) { if ( $ this -> drupalAcctProvisionServer ) { $ prov_events = array ( LDAP_USER_EVENT_LDAP_ASSOCIATE_DRUPAL_ACCT ) ; $ ldap_server = ldap_servers_get_servers ( $ this -> drupalAcctProvisionServer , 'enabled' , TRUE ) ; $ account = user_load_by_name ( $ drupal_username ) ; $ ldap_user = ldap_servers_get_user_ldap_data ( $ drupal_username , $ this -> drupalAcctProvisionServer , 'ldap_user_prov_to_drupal' ) ; if ( ! $ account ) { watchdog ( 'ldap_user' , 'Failed to LDAP associate drupal account %drupal_username because account not found' , array ( '%drupal_username' => $ drupal_username ) , WATCHDOG_ERROR ) ; return FALSE ; } elseif ( ! $ ldap_user ) { watchdog ( 'ldap_user' , 'Failed to LDAP associate drupal account %drupal_username because corresponding LDAP entry not found' , array ( '%drupal_username' => $ drupal_username ) , WATCHDOG_ERROR ) ; return FALSE ; } else { $ user_edit = array ( ) ; $ user_edit [ 'data' ] [ 'ldap_user' ] [ 'init' ] = array ( 'sid' => $ ldap_user [ 'sid' ] , 'dn' => $ ldap_user [ 'dn' ] , 'mail' => $ account -> mail , ) ; $ ldap_user_puid = $ ldap_server -> userPuidFromLdapEntry ( $ ldap_user [ 'attr' ] ) ; if ( $ ldap_user_puid ) { $ user_edit [ 'ldap_user_puid' ] [ LANGUAGE_NONE ] [ 0 ] [ 'value' ] = $ ldap_user_puid ; } $ user_edit [ 'ldap_user_puid_property' ] [ LANGUAGE_NONE ] [ 0 ] [ 'value' ] = $ ldap_server -> unique_persistent_attr ; $ user_edit [ 'ldap_user_puid_sid' ] [ LANGUAGE_NONE ] [ 0 ] [ 'value' ] = $ ldap_server -> sid ; $ user_edit [ 'ldap_user_current_dn' ] [ LANGUAGE_NONE ] [ 0 ] [ 'value' ] = $ ldap_user [ 'dn' ] ; $ account = user_save ( $ account , $ user_edit , 'ldap_user' ) ; return ( boolean ) $ account ; } } else { return FALSE ; } }
set ldap associations of a drupal account by altering user fields
29,063
public function isSynched ( $ attr_token , $ prov_events , $ direction ) { $ result = ( boolean ) ( isset ( $ this -> synchMapping [ $ direction ] [ $ attr_token ] [ 'prov_events' ] ) && count ( array_intersect ( $ prov_events , $ this -> synchMapping [ $ direction ] [ $ attr_token ] [ 'prov_events' ] ) ) ) ; if ( ! $ result ) { if ( isset ( $ this -> synchMapping [ $ direction ] [ $ attr_token ] ) ) { } else { } } return $ result ; }
given configuration of synching determine is a given synch should occur
29,064
private function browseSteps ( ) : \ Generator { $ steps = $ this -> steps ; ksort ( $ steps ) ; foreach ( $ steps as & $ stepsSublist ) { foreach ( $ stepsSublist as & $ step ) { yield \ key ( $ step ) => \ current ( $ step ) ; } } }
To browse steps stored into an ordered matrix as a single array
29,065
private function compileStep ( ) : array { if ( empty ( $ this -> compiled ) ) { $ this -> compiled = [ ] ; foreach ( $ this -> browseSteps ( ) as $ name => $ step ) { $ this -> compiled [ ] = $ step ; } $ this -> updateStates ( ) ; } return $ this -> compiled ; }
To compile all steps into a single array to allow chefs to follow them easier
29,066
public static function configBit ( int $ flags , int $ mask , bool $ condition ) : int { return $ condition ? static :: setBit ( $ flags , $ mask ) : static :: clearBit ( $ flags , $ mask ) ; }
Set the bit .
29,067
public function src ( $ email , $ size = 100 , $ rating = null ) { $ this -> gravatar -> setAvatarSize ( $ size ) ; if ( ! is_null ( $ rating ) ) { $ this -> gravatar -> setMaxRating ( $ rating ) ; } return htmlentities ( $ this -> gravatar -> buildGravatarURL ( $ email ) ) ; }
Construct the src for the image from the gravatar servers .
29,068
public function exists ( $ email ) { $ url = $ this -> gravatar -> buildGravatarURL ( $ email ) ; $ headers = get_headers ( $ url , 1 ) ; return ( boolean ) strpos ( $ headers [ 0 ] , '200' ) ; }
Checks to see whether an avatar for a given user exists or not .
29,069
private static function getStringValue ( $ value ) : string { if ( is_bool ( $ value ) ) { return $ value === true ? 'true' : 'false' ; } return ! is_string ( $ value ) ? strval ( $ value ) : $ value ; }
Get string representation of value
29,070
public function toXml ( string $ outer = null ) : string { $ result = '' ; foreach ( $ this -> array as $ key => $ value ) { $ key = self :: getStringValue ( $ key ) ; if ( strncmp ( $ key , '@' , 1 ) === 0 ) { } else { $ encodedTag = htmlspecialchars ( $ outer ? $ outer : $ key , ENT_QUOTES ) ; if ( is_array ( $ value ) && ( count ( $ value ) > 0 ) && isset ( $ value [ 0 ] ) ) { $ x = new XArray ( $ value ) ; $ result .= $ x -> toXml ( $ key ) ; unset ( $ x ) ; } else { if ( is_array ( $ value ) ) { $ attrs = '' ; foreach ( $ value as $ attrKey => $ attrValue ) { $ attrKey = self :: getStringValue ( $ attrKey ) ; if ( strncmp ( $ attrKey , '@' , 1 ) === 0 ) { $ attrValue = self :: getStringValue ( $ attrValue ) ; $ attrs .= ' ' . htmlspecialchars ( substr ( $ attrKey , 1 ) , ENT_QUOTES ) . '="' . htmlspecialchars ( $ attrValue , ENT_QUOTES ) . '"' ; } } $ x = new XArray ( $ value ) ; $ result .= '<' . $ encodedTag . $ attrs . '>' . $ x -> toXml ( ) . '</' . $ encodedTag . '>' ; unset ( $ x ) ; } else { $ value = self :: getStringValue ( $ value ) ; if ( $ encodedTag !== '#text' ) { $ result .= '<' . $ encodedTag . '>' . htmlspecialchars ( $ value , ENT_QUOTES ) . '</' . $ encodedTag . '>' ; } else { $ result .= htmlspecialchars ( $ value , ENT_QUOTES ) ; } } } } } return $ result ; }
Return the array as an XML string
29,071
public function show ( $ id ) { $ team = Team :: with ( 'user' ) -> findOrFail ( $ id ) ; $ this -> authorize ( 'view' , $ team ) ; return fractal ( $ team , new TeamTransformer ( ) ) -> withResourceName ( 'team' ) -> respond ( ) ; }
Fetch details for a Team
29,072
public static function getParent ( BlockView $ view , $ type ) { $ parent = null ; if ( null !== $ view -> parent ) { if ( static :: isType ( $ view -> parent , $ type ) ) { $ parent = $ view -> parent ; } else { $ parent = static :: getParent ( $ view -> parent , $ type ) ; } } return $ parent ; }
Get the parent with a specific type .
29,073
public function setAutocapitalize ( $ state ) { if ( is_bool ( $ state ) ) { if ( $ state === true ) { $ state = 'on' ; } else { $ state = 'off' ; } } $ this -> setAttribute ( 'autocapitalize' , $ state ) ; }
Sets the HTML input element property autocapitalize .
29,074
public function receive ( ) { $ this -> setRequestSources ( $ this -> emitValidRequestSources ( DOOZR_RUNTIME_ENVIRONMENT ) ) ; $ protocolVersion = explode ( '/' , ( isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ) ? $ _SERVER [ 'SERVER_PROTOCOL' ] : '/' ) ; $ this -> withProtocolVersion ( ( true === isset ( $ protocolVersion [ 1 ] ) ) ? $ protocolVersion [ 1 ] : '1.0' ) ; $ headers = $ this -> normalizeHeaders ( getallheaders ( ) ) ; foreach ( $ headers as $ header => $ value ) { $ this -> withHeader ( $ header , $ value ) ; } $ this -> withMethod ( $ this -> receiveMethod ( ) ) ; $ this -> equalizeRequestArguments ( $ this -> getMethod ( ) , $ headers ) ; $ this -> withCookieParams ( $ _COOKIE ) ; $ uploadedFileFactory = new Doozr_Request_File_UploadedFileFactory ( $ _FILES ) ; $ uploadedFiles = $ uploadedFileFactory -> build ( ) ; $ this -> withUploadedFiles ( $ uploadedFiles ) ; $ queryArguments = [ ] ; parse_str ( $ _SERVER [ 'QUERY_STRING' ] , $ queryArguments ) ; $ this -> withQueryParams ( $ queryArguments ) ; $ this -> withAttribute ( 'isAjax' , $ this -> isAjax ( ) ) ; $ this -> withParsedBody ( $ this -> receiveArguments ( $ this -> getMethod ( ) ) ) ; $ this -> withRequestTarget ( $ this -> getUri ( ) -> getPath ( ) ) ; return true ; }
Receive method .
29,075
protected function emitValidRequestSources ( $ mode ) { $ requestSources = [ 'ENVIRONMENT' => self :: NATIVE , 'SERVER' => self :: NATIVE , ] ; switch ( $ mode ) { case Doozr_Kernel :: RUNTIME_ENVIRONMENT_CLI : $ requestSources = array_merge ( $ requestSources , [ 'CLI' => self :: NATIVE , ] ) ; break ; case Doozr_Kernel :: RUNTIME_ENVIRONMENT_WEB : case Doozr_Kernel :: RUNTIME_ENVIRONMENT_HTTPD : default : $ requestSources = array_merge ( $ requestSources , [ 'GET' => self :: NATIVE , 'POST' => self :: NATIVE , 'HEAD' => self :: EMULATED , 'OPTIONS' => self :: EMULATED , 'PUT' => self :: EMULATED , 'DELETE' => self :: EMULATED , 'TRACE' => self :: EMULATED , 'CONNECT' => self :: EMULATED , 'COOKIE' => self :: NATIVE , 'REQUEST' => self :: NATIVE , 'SESSION' => self :: NATIVE , 'FILES' => self :: NATIVE , ] ) ; break ; } return $ requestSources ; }
Combines the request sources to a single array by passed runtimeEnvironment .
29,076
protected function receiveArguments ( $ method = Doozr_Http :: REQUEST_METHOD_GET ) { global $ _GET , $ _POST , $ _DELETE , $ _PUT ; switch ( $ method ) { case Doozr_Http :: REQUEST_METHOD_GET : $ arguments = $ _GET ; break ; case Doozr_Http :: REQUEST_METHOD_POST : $ arguments = $ _POST ; break ; case Doozr_Http :: REQUEST_METHOD_PUT : $ arguments = $ _PUT ; break ; case Doozr_Http :: REQUEST_METHOD_DELETE : $ arguments = $ _DELETE ; break ; default : $ arguments = [ ] ; } return $ arguments ; }
Returns the query parameter for a HTTP method as array .
29,077
public function getOptions ( ContainerInterface $ container ) { $ options = $ container -> get ( 'config' ) ; $ options = $ options [ 'zend_authentication' ] [ 'options' ] ; $ options [ 'objectManager' ] = $ container -> get ( EntityManager :: class ) ; return new Authentication ( $ options ) ; }
Gets options from configuration .
29,078
public function parse ( $ filter , $ aliases ) { $ result = '' ; $ clause = $ filter -> getClause ( ) ; if ( is_array ( $ clause ) ) $ clause = new \ Praxigento \ Core \ Api \ App \ Web \ Request \ Conditions \ Filter \ Clause ( $ clause ) ; $ group = $ filter -> getGroup ( ) ; if ( is_array ( $ group ) ) $ group = new \ Praxigento \ Core \ Api \ App \ Web \ Request \ Conditions \ Filter \ Group ( $ group ) ; if ( $ clause ) { $ attr = $ clause -> getAttr ( ) ; $ func = $ clause -> getFunc ( ) ; $ args = $ clause -> getArgs ( ) ; $ value = $ clause -> getValue ( ) ; $ valAttr = $ this -> mapAlias ( $ attr , $ aliases ) ; $ valLvalue = $ this -> dba -> quote ( $ value ) ; $ template = $ this -> parseFunc ( $ func ) ; $ template = str_replace ( self :: PH_ATTR , $ valAttr , $ template ) ; $ template = str_replace ( self :: PH_VAL , $ valLvalue , $ template ) ; $ result = $ template ; } elseif ( $ group ) { $ with = $ group -> getWith ( ) ; $ entries = $ group -> getEntries ( ) ; $ parts = [ ] ; foreach ( $ entries as $ entry ) { if ( is_array ( $ entry ) ) $ entry = new \ Praxigento \ Core \ Api \ App \ Web \ Request \ Conditions \ Filter ( $ entry ) ; $ sql = $ this -> parse ( $ entry , $ aliases ) ; $ parts [ ] = $ sql ; } foreach ( $ parts as $ part ) { if ( $ part ) $ result .= "($part) $with " ; } $ tail = substr ( $ result , - 1 * ( strlen ( $ with ) + 2 ) ) ; if ( $ tail == " $with " ) { $ result = substr ( $ result , 0 , strlen ( $ result ) - strlen ( $ tail ) ) ; } } return $ result ; }
Parse tree - like filter structure and return string for SQL WHERE clause .
29,079
public function getUserField ( $ field = null , $ userInfo = null ) { if ( empty ( $ field ) ) { return null ; } if ( ! empty ( $ userInfo ) && is_array ( $ userInfo ) ) { $ targetUserInfo = $ userInfo ; } else { $ targetUserInfo = $ this -> _userInfo ; } if ( empty ( $ targetUserInfo ) || ! is_array ( $ targetUserInfo ) ) { return null ; } $ result = Hash :: get ( $ targetUserInfo , $ field ) ; return $ result ; }
Return value of field from user auth information
29,080
private static function conectar ( ) { try { if ( self :: $ connect == null ) : $ dsn = 'mysql:host=' . self :: $ host . ';dbname=' . self :: $ database ; $ options = [ \ PDO :: MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8' ] ; self :: $ connect = new \ PDO ( $ dsn , self :: $ user , self :: $ pass , $ options ) ; endif ; } catch ( \ PDOException $ e ) { self :: error ( "<b>Erro ao se conectar ao Banco</b><br><br> #Linha: {$e->getLine()}<br> {$e->getMessage()}" , $ e -> getCode ( ) ) ; die ; } self :: $ connect -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; return self :: $ connect ; }
Conecta com o banco de dados com o pattern singleton . Retorna um objeto PDO!
29,081
public static function files ( String $ path , $ extension = NULL , Bool $ pathType = false ) : Array { $ path = Info :: rpath ( $ path ) ; if ( ! is_dir ( $ path ) ) { throw new FolderNotFoundException ( $ path ) ; } return Filesystem :: getFiles ( $ path , $ extension , $ pathType ) ; }
Used to retrieve a list of files and directories within a directory . If it is desired to list files with a certain extension between the files to be listed the file extension for the second parameter can be used .
29,082
public static function allFiles ( String $ pattern = '*' , Bool $ allFiles = false ) : Array { return Filesystem :: getRecursiveFiles ( $ pattern , $ allFiles ) ; }
Used to retrieve a list of all subdirectories and files belonging to a directory . You can set the second parameter to true if you want to list the files that are also in the nested indexes .
29,083
public function setUid ( $ uid = false ) { $ uid = ( ! $ uid ) ? $ uid = md5 ( $ this -> name . $ this -> namespace . $ this -> priority ) : $ uid ; $ this -> uid = $ uid ; return $ uid ; }
Sets the unique - identifier of this autoloader
29,084
public static function expectedToken ( $ expected , array $ token = null , DocLexer $ lexer = null ) { if ( ( null === $ token ) && $ lexer ) { $ token = $ lexer -> lookahead ; } $ message = "Expected $expected, received " ; if ( $ token ) { $ message .= "'{$token['value']}' at position {$token['position']}." ; } else { $ message .= 'end of string.' ; } return new self ( $ message ) ; }
Creates a new exception for the expected token .
29,085
public function getValue ( $ field ) { if ( is_array ( $ this -> values ) ) { return isset ( $ this -> values [ $ field ] ) ? $ this -> values [ $ field ] : null ; } if ( is_object ( $ this -> values ) ) { return $ this -> values -> $ field ; } return null ; }
Get value of selected field or null if it doesn t exists
29,086
public function setValue ( $ field , $ value ) { if ( is_array ( $ this -> values ) ) { $ this -> values [ $ field ] = $ value ; } elseif ( is_object ( $ this -> values ) ) { $ this -> values -> $ field = $ value ; } }
Change value for a field .
29,087
protected function filterAlfanumeric ( $ field , $ details , $ label , $ message ) { if ( ! $ this -> filterString ( $ field , $ details , $ label , $ message ) ) { return false ; } if ( ctype_alnum ( $ this -> getValue ( $ field ) ) ) { return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( "$label must be alfanumeric!" ) ) ; }
Checks if it s string and then if it s alfanumeric . Same options as for string check .
29,088
protected function filterDigit ( $ field , $ details , $ label , $ message ) { if ( ctype_digit ( $ this -> getValue ( $ field ) ) ) { return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( "$label must be digit!" ) ) ; }
Checks if it s digit .
29,089
protected function filterRegexp ( $ field , $ details , $ label , $ message ) { if ( preg_match ( $ details [ 'expression' ] , $ this -> getValue ( $ field ) ) ) { return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( "Doesn't match expression!" ) ) ; }
Checks to see if matches the given expression
29,090
protected function filterDate ( $ field , $ details , $ label , $ message ) { if ( false != ( $ date = @ strtotime ( $ this -> getValue ( $ field ) ) ) ) { if ( isset ( $ details [ 'min' ] ) && $ date < $ details [ 'min' ] ) { throw new \ Exception ( $ message ? $ message : $ this -> translate ( "Date must be bigger than $details[min]!" ) ) ; } if ( isset ( $ details [ 'max' ] ) && $ date > $ details [ 'max' ] ) { throw new \ Exception ( $ message ? $ message : $ this -> translate ( "Date must be smaller than $details[min]!" ) ) ; } if ( isset ( $ details [ 'format' ] ) ) { $ this -> setValue ( $ field , date ( $ details [ 'format' ] , $ date ) ) ; } return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( "{$this->getValue($field)} is not a date!" ) ) ; }
Checks if value is date or time and if it fits in interval
29,091
protected function filterEmail ( $ field , $ details , $ label , $ message ) { if ( ! $ this -> filterString ( $ field , $ details , $ label , $ message ) ) { return false ; } $ email = $ this -> getValue ( $ field ) ; $ isValid = true ; $ atIndex = strrpos ( $ email , "@" ) ; if ( is_bool ( $ atIndex ) && ! $ atIndex ) { $ isValid = false ; } else { $ domain = substr ( $ email , $ atIndex + 1 ) ; $ local = substr ( $ email , 0 , $ atIndex ) ; $ localLen = strlen ( $ local ) ; $ domainLen = strlen ( $ domain ) ; if ( $ localLen < 1 || $ localLen > 64 ) { $ isValid = false ; } else if ( $ domainLen < 1 || $ domainLen > 255 ) { $ isValid = false ; } else if ( $ local [ 0 ] == '.' || $ local [ $ localLen - 1 ] == '.' ) { $ isValid = false ; } else if ( preg_match ( '/\\.\\./' , $ local ) ) { $ isValid = false ; } else if ( ! preg_match ( '/^[A-Za-z0-9\\-\\.]+$/' , $ domain ) ) { $ isValid = false ; } elseif ( preg_match ( '/\\.\\./' , $ domain ) ) { $ isValid = false ; } elseif ( ! preg_match ( '/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/' , str_replace ( "\\\\" , "" , $ local ) ) ) { if ( ! preg_match ( '/^"(\\\\"|[^"])+"$/' , str_replace ( "\\\\" , "" , $ local ) ) ) { $ isValid = false ; } } if ( $ isValid && ! ( checkdnsrr ( $ domain , "MX" ) || checkdnsrr ( $ domain , "A" ) ) ) { $ isValid = false ; } } if ( $ isValid ) { return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( "This is not an email!" ) ) ; }
Check if field value is an email address
29,092
protected function filterCompare ( $ field , $ details , $ label , $ message ) { if ( isset ( $ details [ 'value' ] ) ) { $ value = $ details [ 'value' ] ; $ secondLabel = '' ; } else { $ value = $ this -> getValue ( $ details [ 'column' ] ) ; $ secondLabel = isset ( $ this -> labels [ $ details [ 'column' ] ] ) ? $ this -> labels [ $ details [ 'column' ] ] : ucwords ( str_replace ( '_' , ' ' , $ details [ 'column' ] ) ) ; } if ( ! isset ( $ details [ 'sign' ] ) || '==' == $ details [ 'sign' ] ) { if ( $ this -> getValue ( $ field ) == $ value ) { return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( isset ( $ details [ 'value' ] ) ? "Invalid value!" : "$label can't be different than $secondLabel!" ) ) ; } else { $ result = eval ( "return \$this->getValue(\$field) $details[sign] \$value" ) ; if ( $ result ) { return true ; } throw new \ Exception ( $ message ? $ message : $ this -> translate ( "Invalid value!" ) ) ; } }
Compare two fields or a field with a static value .
29,093
public static function toPHPString ( $ config , $ prefix = "" ) { $ r = [ ] ; foreach ( $ config as $ key => $ value ) { if ( is_int ( $ key ) ) { $ line = $ prefix . self :: $ tabContent ; } else { $ key = addslashes ( $ key ) ; $ line = $ prefix . self :: $ tabContent . "\"$key\" => " ; } if ( is_string ( $ value ) ) { $ value = addslashes ( $ value ) ; $ line .= "\"$value\"" ; $ r [ ] = $ line ; continue ; } elseif ( is_bool ( $ value ) ) { $ line .= ( $ value ? "true" : "false" ) ; $ r [ ] = $ line ; continue ; } elseif ( is_int ( $ value ) ) { $ line .= "$value" ; $ r [ ] = $ line ; continue ; } $ line .= "[\n" . implode ( ",\n" , self :: toPHPString ( $ value , $ prefix . self :: $ tabContent ) ) . "\n$prefix" . self :: $ tabContent . "]" ; $ r [ ] = $ line ; } return $ r ; }
Returns php code for array
29,094
public function addFile ( $ filename ) { if ( ! is_file ( $ filename ) ) { throw new FileNotFoundException ( sprintf ( "File '%s' not found." , $ filename ) ) ; } if ( pathinfo ( $ filename , PATHINFO_EXTENSION ) != 'yml' ) { throw new \ InvalidArgumentException ( sprintf ( "Invalid extension for file '%s'." , $ filename ) ) ; } if ( ! in_array ( $ filename , $ this -> files ) ) { $ this -> files [ ] = $ filename ; } return $ this ; }
Add yml fixtures file to load
29,095
public function addDirectory ( $ path , $ recursive = true ) { if ( realpath ( $ path ) === false || ! is_dir ( realpath ( $ path ) ) ) { throw new FileNotFoundException ( sprintf ( "Directory '%s' not found." , $ path ) ) ; } $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( '*.yml' ) -> depth ( $ recursive ? '>= 0' : '== 0' ) -> in ( $ path ) -> sortByName ( ) ; foreach ( $ finder as $ file ) { $ this -> addFile ( $ file -> getRealpath ( ) ) ; } return $ this ; }
Add directory with yml files to load
29,096
protected function getEntity ( $ class , $ name ) { if ( isset ( $ this -> entities [ $ class ] [ $ name ] ) ) { return $ this -> entities [ $ class ] [ $ name ] ; } elseif ( $ this -> hasReferencer ( ) && $ this -> getReferencer ( ) -> hasReference ( $ name ) ) { return $ this -> getManager ( ) -> merge ( $ this -> getReferencer ( ) -> getReference ( $ name ) ) ; } throw new \ Exception ( sprintf ( "No entity found for name '%s'." , $ name ) ) ; }
Get existing entity by reference or same file loading
29,097
public function serializeRepositoryFilter ( VisitorInterface $ visitor , RepositoryFilterInterface $ repositoryFilter , array $ type , Context $ context ) { return $ visitor -> visitArray ( iterator_to_array ( $ repositoryFilter ) , $ type , $ context ) ; }
Serialize a RepositoryFilter into an array
29,098
public function index ( $ locationId ) { $ location = Location :: findOrFail ( $ locationId ) ; $ this -> authorize ( 'view' , $ location ) ; return $ this -> respondRelatedAddresses ( $ locationId , 'location' ) ; }
Produce a list of Addresss related to a selected Location
29,099
protected function _format ( $ value , $ rule ) { $ format = ( array ) $ this -> get ( $ rule ) ; $ value = ( float ) $ value ; $ roundedValue = $ this -> round ( $ value , $ rule ) ; $ isPositive = ( $ value >= 0 ) ; $ valueStr = number_format ( abs ( $ roundedValue ) , $ format [ 'num_decimals' ] , $ format [ 'decimal_sep' ] , $ format [ 'thousands_sep' ] ) ; $ template = $ isPositive ? $ format [ 'format_positive' ] : $ format [ 'format_negative' ] ; return array ( 'value' => $ valueStr , 'template' => $ template , 'isPositive' => $ isPositive , ) ; }
Convert value to money format from config