idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
8,600
|
private function calculateYIQValue ( RGB $ color ) { $ yiq = ( ( $ color -> getRed ( ) * 299 ) + ( $ color -> getGreen ( ) * 587 ) + ( $ color -> getBlue ( ) * 114 ) ) / 1000 ; return $ yiq ; }
|
calculates the YIQ value for a given color .
|
8,601
|
protected static function extractKeyword ( string $ haystack , string $ needle , & $ matches = null ) { $ pattern = '/' . ( strpos ( $ needle , '^' ) === 0 ? '' : ' ?' ) . $ needle . ( strrpos ( $ needle , '$' ) === strlen ( $ needle ) - 1 ? '' : ' ?' ) . '/i' ; if ( preg_match ( $ pattern , $ haystack , $ matches , PREG_OFFSET_CAPTURE ) ) { $ m = $ matches [ 0 ] ; $ haystack = substr_replace ( $ haystack , ' ' , $ m [ 1 ] , strlen ( $ m [ 0 ] ) ) ; return trim ( $ haystack ) ; } return false ; }
|
Extracts a keyword from a string
|
8,602
|
public function getDriver ( $ key ) { if ( isset ( $ this -> _drivers [ $ key ] ) ) { return $ this -> _drivers [ $ key ] ; } throw new MissingDriverException ( sprintf ( 'Driver %s does not exist' , $ key ) ) ; }
|
Return a driver by key .
|
8,603
|
public function createSubjectAction ( Category $ category ) { $ forum = $ category -> getForum ( ) ; $ collection = new ResourceCollection ( array ( $ forum -> getResourceNode ( ) ) ) ; if ( ! $ this -> authorization -> isGranted ( 'post' , $ collection ) ) { throw new AccessDeniedException ( $ collection -> getErrorsForDisplay ( ) ) ; } $ form = $ this -> get ( 'form.factory' ) -> create ( new SubjectType ( ) , new Subject ) ; $ form -> handleRequest ( $ this -> get ( 'request' ) ) ; if ( $ form -> isValid ( ) ) { $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ subject = $ form -> getData ( ) ; $ subject -> setCreator ( $ user ) ; $ subject -> setAuthor ( $ user -> getFirstName ( ) . ' ' . $ user -> getLastName ( ) ) ; $ subject -> setCategory ( $ category ) ; $ this -> manager -> createSubject ( $ subject ) ; $ dataMessage = $ form -> get ( 'message' ) -> getData ( ) ; if ( $ dataMessage [ 'content' ] !== null ) { $ message = new Message ( ) ; $ message -> setContent ( $ dataMessage [ 'content' ] ) ; $ message -> setCreator ( $ user ) ; $ message -> setAuthor ( $ user -> getFirstName ( ) . ' ' . $ user -> getLastName ( ) ) ; $ message -> setSubject ( $ subject ) ; $ this -> manager -> createMessage ( $ message , $ subject ) ; return new RedirectResponse ( $ this -> generateUrl ( 'claro_forum_subjects' , array ( 'category' => $ category -> getId ( ) ) ) ) ; } } $ form -> get ( 'message' ) -> addError ( new FormError ( $ this -> get ( 'translator' ) -> trans ( 'field_content_required' , array ( ) , 'forum' ) ) ) ; return array ( 'form' => $ form -> createView ( ) , '_resource' => $ forum , 'workspace' => $ forum -> getResourceNode ( ) -> getWorkspace ( ) ) ; }
|
The form submission is working but I had to do some weird things to make it works .
|
8,604
|
protected function addWithDecryptKey ( Builder $ builder ) { $ builder -> macro ( 'withDecryptKey' , function ( Builder $ builder , $ decryptKey ) { $ model = $ builder -> getModel ( ) ; $ encryptedFields = $ model :: getEncryptedFields ( ) ; if ( ! empty ( $ encryptedFields ) ) { $ builder -> setEncryptionModel ( $ model ) ; $ encryptionService = $ model :: getEncryptionService ( ) ; foreach ( $ encryptedFields as $ encryptedField ) { $ decryptStmt = $ encryptionService -> getDecryptExpression ( $ encryptedField , $ decryptKey ) ; $ builder -> addEncryptionSelect ( [ 'column' => $ encryptedField , 'select' => DB :: raw ( "$decryptStmt as $encryptedField" ) ] ) ; } } return $ builder ; } ) ; }
|
Add the with - decrypt - key extension to the builder .
|
8,605
|
public static function factory ( $ aOptions ) { if ( $ aOptions instanceof \ Traversable ) $ aOptions = \ Zend \ Stdlib \ ArrayUtils :: iteratorToArray ( $ aOptions ) ; elseif ( ! is_array ( $ aOptions ) ) throw new \ InvalidArgumentException ( __METHOD__ . ' expects an array or Traversable object; received "' . ( is_object ( $ aOptions ) ? get_class ( $ aOptions ) : gettype ( $ aOptions ) ) . '"' ) ; $ oBrowscapService = new static ( ) ; if ( isset ( $ aOptions [ 'browscap_ini_path' ] ) ) $ oBrowscapService -> setBrowscapIniPath ( $ aOptions [ 'browscap_ini_path' ] ) ; if ( isset ( $ aOptions [ 'cache' ] ) ) $ oBrowscapService -> setCache ( $ aOptions [ 'cache' ] ) ; if ( isset ( $ aOptions [ 'allows_native_get_browser' ] ) ) $ oBrowscapService -> setAllowsNativeGetBrowser ( ! ! $ aOptions [ 'allows_native_get_browser' ] ) ; return $ oBrowscapService ; }
|
Instantiate AccessControl Authentication Service
|
8,606
|
public function loadBrowscapIni ( ) { $ sBrowscapIniPath = $ this -> getBrowscapIniPath ( ) ; if ( is_readable ( $ sBrowscapIniPath ) ) { $ aBrowscap = parse_ini_file ( $ this -> getBrowscapIniPath ( ) , true , INI_SCANNER_RAW ) ; if ( $ aBrowscap === false ) throw new \ RuntimeException ( 'Error appends while parsing browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; } else { if ( ( $ oFileHandle = @ fopen ( $ sBrowscapIniPath , 'r' ) ) === false ) throw new \ InvalidArgumentException ( 'Unable to load browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; $ sBrowscapIniContents = '' ; while ( ( $ sContent = fgets ( $ oFileHandle ) ) !== false ) { $ sBrowscapIniContents .= $ sContent . PHP_EOL ; } if ( ! feof ( $ oFileHandle ) ) throw new \ RuntimeException ( 'Unable to retrieve contents from browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; fclose ( $ oFileHandle ) ; $ aBrowscap = parse_ini_string ( $ sBrowscapIniContents , true , INI_SCANNER_RAW ) ; if ( $ aBrowscap === false ) throw new \ RuntimeException ( 'Error appends while parsing browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; } $ aBrowscapKeys = array_keys ( $ aBrowscap ) ; $ aBrowscap = array_combine ( $ aBrowscapKeys , array_map ( function ( $ aUserAgentInfos , $ sUserAgent ) { $ aUserAgentInfos = array_map ( function ( $ sValue ) { if ( $ sValue === 'true' ) return 1 ; elseif ( $ sValue === 'false' ) return '' ; else return $ sValue ; } , $ aUserAgentInfos ) ; $ aUserAgentInfos [ 'browser_name_regex' ] = '^' . str_replace ( array ( '\\' , '.' , '?' , '*' , '^' , '$' , '[' , ']' , '|' , '(' , ')' , '+' , '{' , '}' , '%' ) , array ( '\\\\' , '\\.' , '.' , '.*' , '\\^' , '\\$' , '\\[' , '\\]' , '\\|' , '\\(' , '\\)' , '\\+' , '\\{' , '\\}' , '\\%' ) , $ sUserAgent ) . '$' ; return array_change_key_case ( $ aUserAgentInfos , CASE_LOWER ) ; } , $ aBrowscap , $ aBrowscapKeys ) ) ; uksort ( $ aBrowscap , function ( $ sUserAgentA , $ sUserAgentB ) { if ( ( $ sUserAgentALength = strlen ( $ sUserAgentA ) ) > ( $ sUserAgentBLength = strlen ( $ sUserAgentB ) ) ) return - 1 ; elseif ( $ sUserAgentALength < $ sUserAgentBLength ) return 1 ; else return strcasecmp ( $ sUserAgentA , $ sUserAgentB ) ; } ) ; return $ this -> setBrowscap ( $ aBrowscap ) ; }
|
Load and parse browscap . ini file
|
8,607
|
public function image ( ) { if ( Request :: hasFile ( 'image' ) && Request :: has ( 'table_name' ) && Request :: has ( 'field_name' ) ) { return json_encode ( self :: saveImage ( Request :: input ( 'table_name' ) , Request :: input ( 'field_name' ) , Request :: file ( 'image' ) , null , Request :: file ( 'image' ) -> getClientOriginalExtension ( ) ) ) ; } elseif ( ! Request :: hasFile ( 'image' ) ) { return 'no image' ; } elseif ( ! Request :: hasFile ( 'table_name' ) ) { return 'no table_name' ; } elseif ( ! Request :: hasFile ( 'field_name' ) ) { return 'no field_name' ; } }
|
handle image upload route
|
8,608
|
public function addRoute ( $ route , $ class , $ action , $ parameters = [ ] , $ hostparameters = [ ] ) { $ this -> log -> debug ( 'adding route : ' . $ route . ' to class ' . $ class . ' and action ' . $ action ) ; $ this -> routes [ $ route ] = [ "class" => $ class , "action" => $ action , "parameters" => $ parameters , "hostparameters" => $ hostparameters ] ; return $ this ; }
|
add route to list of known routes
|
8,609
|
public function setBaseHost ( $ baseHost = null ) { $ this -> log -> debug ( 'Setting Router baseHost to ' . $ baseHost ) ; $ this -> baseHost = $ baseHost ; return $ this ; }
|
method to set the basicHost for hostparameters in routing
|
8,610
|
private function handleRoute ( $ info , ServerRequestInterface $ request , $ route ) : ResponseInterface { $ attributes = [ 'params' => [ 'url' => [ ] , 'host' => [ ] ] ] ; if ( $ paramstr = substr ( $ request -> getUri ( ) -> getPath ( ) , strlen ( $ route ) ) ) { $ attributes [ 'params' ] [ 'url' ] = $ this -> filterParameters ( $ info [ 'parameters' ] , explode ( "/" , $ paramstr ) ) ; } if ( count ( $ info [ "hostparameters" ] ) > 0 ) { $ attributes [ 'params' ] [ 'host' ] = $ this -> extractHostParameters ( $ request , $ info ) ; } $ request = $ request -> withAttribute ( 'king23.router' , $ attributes ) ; $ controller = $ this -> container -> get ( $ info [ "class" ] ) ; return $ controller -> dispatch ( $ info [ "action" ] , $ request ) ; }
|
Handle a regular route
|
8,611
|
private function extractHostParameters ( $ request , $ info ) { $ hostname = $ this -> cleanHostName ( $ request ) ; if ( empty ( $ hostname ) ) { $ params = [ ] ; } else { $ params = array_reverse ( explode ( "." , $ hostname ) ) ; } $ parameters = $ this -> filterParameters ( $ info [ 'hostparameters' ] , $ params ) ; return $ parameters ; }
|
extract parameters from hostname
|
8,612
|
private function cleanHostName ( ServerRequestInterface $ request ) { if ( is_null ( $ this -> baseHost ) ) { $ hostname = $ request -> getUri ( ) -> getHost ( ) ; } else { $ hostname = str_replace ( $ this -> baseHost , "" , $ request -> getUri ( ) -> getHost ( ) ) ; } if ( substr ( $ hostname , - 1 ) == "." ) { $ hostname = substr ( $ hostname , 0 , - 1 ) ; } return $ hostname ; }
|
will get hostname and clean basehost off it
|
8,613
|
public static function put ( $ arTags , $ sKeys , & $ arValue , $ iMinute ) { $ obDate = Carbon :: now ( ) -> addMinute ( $ iMinute ) ; $ sCacheDriver = config ( 'cache.default' ) ; if ( ! empty ( $ arTags ) ) { if ( $ sCacheDriver == 'redis' ) { Cache :: tags ( $ arTags ) -> put ( $ sKeys , $ arValue , $ obDate ) ; return ; } else { $ sKeys = implode ( '_' , $ arTags ) . '_' . $ sKeys ; } } Cache :: put ( $ sKeys , $ arValue , $ obDate ) ; }
|
Put cache data
|
8,614
|
public static function forever ( $ arTags , $ sKeys , & $ arValue ) { $ sCacheDriver = config ( 'cache.default' ) ; if ( ! empty ( $ arTags ) ) { if ( $ sCacheDriver == 'redis' ) { Cache :: tags ( $ arTags ) -> forever ( $ sKeys , $ arValue ) ; return ; } else { $ sKeys = implode ( '_' , $ arTags ) . '_' . $ sKeys ; } } Cache :: forever ( $ sKeys , $ arValue ) ; }
|
Forever cache data
|
8,615
|
public static function clear ( $ arTags , $ sKeys = null ) { $ sCacheDriver = config ( 'cache.default' ) ; if ( ! empty ( $ arTags ) ) { if ( $ sCacheDriver == 'redis' ) { if ( ! empty ( $ sKeys ) ) { Cache :: tags ( $ arTags ) -> forget ( $ sKeys ) ; } else { Cache :: tags ( $ arTags ) -> flush ( ) ; } } else { $ sKeys = implode ( '_' , $ arTags ) . '_' . $ sKeys ; Cache :: forget ( $ sKeys ) ; } } }
|
Clear cache data
|
8,616
|
public function onTrial ( ) { if ( ! is_null ( $ this -> getTrialEndDate ( ) ) ) { return Carbon :: today ( ) -> lt ( $ this -> getTrialEndDate ( ) ) ; } else { return false ; } }
|
Determine if the entity is within their trial period .
|
8,617
|
public function onGracePeriod ( ) { if ( ! is_null ( $ endsAt = $ this -> getSubscriptionEndDate ( ) ) ) { return Carbon :: now ( ) -> lt ( Carbon :: instance ( $ endsAt ) ) ; } else { return false ; } }
|
Determine if the entity is on grace period after cancellation .
|
8,618
|
public function subscribed ( ) { if ( $ this -> requiresCardUpFront ( ) ) { return $ this -> braintreeIsActive ( ) || $ this -> onGracePeriod ( ) ; } else { return $ this -> braintreeIsActive ( ) || $ this -> onTrial ( ) || $ this -> onGracePeriod ( ) ; } }
|
Determine if the entity has an active subscription .
|
8,619
|
public function push ( MiddlewareInterface $ middleware ) : self { $ stack = clone $ this ; array_unshift ( $ stack -> middlewares , $ middleware ) ; return $ stack ; }
|
Creates a new stack with the given middleware pushed .
|
8,620
|
protected function getDataDirectoryPath ( ) { $ data_dir = $ this -> getEnvironment ( ) -> getDataDirectory ( ) ; $ config = $ this -> getConfiguration ( ) ; return str_replace ( '{branch}' , $ config -> getBranch ( ) , $ data_dir ) ; }
|
The absolute path of the client site data directory .
|
8,621
|
protected function mysqlAesKey ( $ key ) { $ newKey = str_repeat ( chr ( 0 ) , 16 ) ; for ( $ i = 0 , $ len = strlen ( $ key ) ; $ i < $ len ; $ i ++ ) { $ newKey [ $ i % 16 ] = $ newKey [ $ i % 16 ] ^ $ key [ $ i ] ; } return $ newKey ; }
|
Converts the key into the MySQL equivalent version
|
8,622
|
private function prependYui ( ContainerBuilder $ container ) { $ container -> setParameter ( 'smile_ez_uicron.public_dir' , 'bundles/smileezuicron' ) ; $ yuiConfigFile = __DIR__ . '/../Resources/config/yui.yml' ; $ config = Yaml :: parse ( file_get_contents ( $ yuiConfigFile ) ) ; $ container -> prependExtensionConfig ( 'ez_platformui' , $ config ) ; $ container -> addResource ( new FileResource ( $ yuiConfigFile ) ) ; }
|
Prepend ezplatform yui interface plugin
|
8,623
|
private function prependCss ( ContainerBuilder $ container ) { $ container -> setParameter ( 'smile_ez_uicron.css_dir' , 'bundles/smileezuicron/css' ) ; $ cssConfigFile = __DIR__ . '/../Resources/config/css.yml' ; $ config = Yaml :: parse ( file_get_contents ( $ cssConfigFile ) ) ; $ container -> prependExtensionConfig ( 'ez_platformui' , $ config ) ; $ container -> addResource ( new FileResource ( $ cssConfigFile ) ) ; }
|
Prepend ezplatform css interface plugin
|
8,624
|
public function generateHeaders ( ) { $ this -> setHeader ( "Content-Type" , "text/" . $ this -> subType . "; charset=" . $ this -> charset ) ; $ this -> setHeader ( "Content-Transfer-Encoding" , $ this -> encoding ) ; return parent :: generateHeaders ( ) ; }
|
Returns the headers set for this part as a RFC822 compliant string .
|
8,625
|
protected function buildCollection ( array $ sources , array $ extensions ) { $ collection = new Collection ( ) ; $ collection -> setAllowedExtensions ( $ extensions ) ; foreach ( $ sources as $ path ) { if ( is_dir ( $ path ) ) { $ collection -> addDirectory ( $ path ) ; continue ; } $ collection -> addFile ( $ path ) ; } return $ collection ; }
|
Constructs a Fileset collection and returns that .
|
8,626
|
public function swrite ( $ severity , $ value = '' ) { if ( sizeof ( $ this -> cache ) == $ this -> messageLimit ) { array_shift ( $ this -> cache ) ; } $ this -> cache [ ] = $ value ; }
|
Stores messages in the public cache by priority
|
8,627
|
public function actionRemoveItems ( ) { if ( false === Yii :: $ app -> request -> isAjax ) { throw new NotFoundHttpException ( Yii :: t ( 'users' , 'Page not found' ) ) ; } $ type = Yii :: $ app -> request -> post ( 'item-type' , 0 ) ; self :: checkPermissions ( $ type ) ; $ items = Yii :: $ app -> request -> post ( 'items' , [ ] ) ; $ authManager = Yii :: $ app -> getAuthManager ( ) ; $ removed = 0 ; foreach ( $ items as $ item ) { try { $ authManager -> remove ( new Item ( [ 'name' => $ item ] ) ) ; $ removed ++ ; } catch ( \ Exception $ e ) { Yii :: $ app -> session -> setFlash ( 'warning' , Yii :: t ( 'users' , "Unknown RBAC item name '{name}'" , [ 'name' => $ item ] ) ) ; } } if ( 0 !== $ removed ) { Yii :: $ app -> session -> setFlash ( 'info' , Yii :: t ( 'users' , "Items removed: {count}" , [ 'count' => $ removed ] ) ) ; } }
|
Respond only on Ajax
|
8,628
|
public function actionDelete ( $ id , $ type , $ returnUrl = '' ) { self :: checkPermissions ( $ type ) ; if ( true === Yii :: $ app -> getAuthManager ( ) -> remove ( new Item ( [ 'name' => $ id ] ) ) ) { Yii :: $ app -> session -> setFlash ( 'info' , Yii :: t ( 'users' , "Item successfully removed" ) ) ; } else { Yii :: $ app -> session -> setFlash ( 'warning' , Yii :: t ( 'users' , "Unknown RBAC item name '{name}'" , [ 'name' => $ id ] ) ) ; } $ returnUrl = empty ( $ returnUrl ) ? [ '/users/rbac-manage/index' , 'type' => $ type ] : $ returnUrl ; return $ this -> redirect ( $ returnUrl ) ; }
|
Deletes an existing RBAC Item model .
|
8,629
|
public function transform ( $ data = null , $ rules = null ) { if ( ! $ data ) $ data = $ this -> data ; if ( ! $ rules ) $ rules = $ this -> rules ; $ rules = array_merge ( $ this -> defaultRules , $ rules ) ; foreach ( $ rules as $ key => $ rule ) { if ( isset ( $ data [ $ key ] ) ) { if ( $ rule == 'datetime' ) $ data [ $ key ] = Carbon :: parse ( $ data [ $ key ] ) ; elseif ( $ rule == 'time' ) $ data [ $ key ] = Carbon :: parse ( $ data [ $ key ] ) ; elseif ( $ rule == 'date' ) $ data [ $ key ] = Carbon :: parse ( $ data [ $ key ] ) ; elseif ( $ rule == 'image' ) $ data [ $ key ] = $ this -> transformImage ( $ data [ $ key ] ) ; elseif ( $ rule == 'strip_tags' ) $ data [ $ key ] = strip_tags ( $ data [ $ key ] ) ; elseif ( is_string ( $ rule ) and class_exists ( $ rule ) ) $ data [ $ key ] = new $ rule ( $ data [ $ key ] ) ; elseif ( is_array ( $ rule ) ) $ data [ $ key ] = $ data [ $ key ] ; } } return $ data ; }
|
Transform data types for item
|
8,630
|
public function match ( $ permissions , array $ authzGroups ) { $ privileges = [ ] ; foreach ( $ permissions as $ permissionAuthzGroup => $ permissionPrivileges ) { $ matchingAuthzGroup = $ this -> getMatchingAuthzGroup ( $ permissionAuthzGroup , $ authzGroups ) ; if ( ! $ matchingAuthzGroup ) { continue ; } $ privileges [ ] = $ permissionPrivileges ; } return $ this -> flatten ( $ privileges ) ; }
|
Get a flat list of privileges for matching authz groups
|
8,631
|
public function matchFull ( $ permissions , array $ authzGroups ) { $ privileges = [ ] ; foreach ( $ permissions as $ permissionAuthzGroup => $ permissionPrivileges ) { $ matchingAuthzGroup = $ this -> getMatchingAuthzGroup ( $ permissionAuthzGroup , $ authzGroups ) ; if ( ! $ matchingAuthzGroup ) { continue ; } $ privileges = $ this -> addAuthzGroupsToPrivileges ( $ privileges , $ permissionPrivileges , [ $ permissionAuthzGroup , $ matchingAuthzGroup ] ) ; } return $ privileges ; }
|
Get a list of privileges for matching authz groups containing more information Returns an array of objects where the privilege is the key and authzgroups the value
|
8,632
|
protected function getMatchingAuthzGroup ( $ permissionAuthzGroup , array $ authzGroups ) { $ invert = $ this -> stringStartsWith ( $ permissionAuthzGroup , '!' ) ; if ( $ invert ) { $ permissionAuthzGroup = substr ( $ permissionAuthzGroup , 1 ) ; } $ matches = [ ] ; foreach ( $ authzGroups as $ authzGroup ) { $ match = $ this -> authzGroupsAreEqual ( $ permissionAuthzGroup , $ authzGroup ) ; if ( $ match && $ invert ) { return null ; } if ( $ match && ! $ invert || ! $ match && $ invert ) { $ matches [ ] = $ authzGroup ; } } return ! empty ( $ matches ) ? $ matches [ 0 ] : null ; }
|
Check if one of the authz groups match
|
8,633
|
protected function authzGroupsAreEqual ( $ permissionAuthzGroup , $ authzGroup ) { return $ this -> pathsAreEqual ( $ permissionAuthzGroup , $ authzGroup ) && $ this -> queryParamsAreEqual ( $ permissionAuthzGroup , $ authzGroup ) ; }
|
Check if authz groups match
|
8,634
|
protected function pathsAreEqual ( $ permissionAuthzGroup , $ authzGroup ) { $ permissionAuthzGroupPath = rtrim ( strtok ( $ permissionAuthzGroup , '?' ) , '/' ) ; $ authzGroupPath = rtrim ( strtok ( $ authzGroup , '?' ) , '/' ) ; return $ this -> matchAuthzGroupPaths ( $ permissionAuthzGroupPath , $ authzGroupPath ) || $ this -> matchAuthzGroupPaths ( $ authzGroupPath , $ permissionAuthzGroupPath ) ; }
|
Compare the paths of two authz groups
|
8,635
|
protected function matchAuthzGroupPaths ( $ pattern , $ subject ) { $ regex = '^' . str_replace ( '[^/]+' , '\\*' , preg_quote ( $ pattern , '~' ) ) . '$' ; $ regex = str_replace ( '\\*' , '(.*)' , $ regex ) ; $ match = preg_match ( '~' . $ regex . '~i' , $ subject ) ; return $ match ; }
|
Check if one paths mathes the other
|
8,636
|
protected function queryParamsAreEqual ( $ permissionAuthzGroup , $ authzGroup ) { $ authzGroupQueryParams = array_change_key_case ( $ this -> getStringQueryParameters ( $ authzGroup ) , CASE_LOWER ) ; $ permissionAuthzGroupQueryParams = array_change_key_case ( $ this -> getStringQueryParameters ( $ permissionAuthzGroup ) , CASE_LOWER ) ; ksort ( $ authzGroupQueryParams ) ; ksort ( $ permissionAuthzGroupQueryParams ) ; return $ permissionAuthzGroupQueryParams === $ authzGroupQueryParams ; }
|
Compare the query parameters of two authz groups
|
8,637
|
protected function getStringQueryParameters ( $ string ) { $ query = parse_url ( $ string , PHP_URL_QUERY ) ; $ params = [ ] ; if ( $ query ) parse_str ( $ query , $ params ) ; return $ params ; }
|
Get the query parameters used in a string
|
8,638
|
protected function flatten ( $ input ) { $ list = [ ] ; foreach ( $ input as $ item ) { $ list = array_merge ( $ list , ( array ) $ item ) ; } return array_unique ( $ list ) ; }
|
Turn a 2 dimensional privilege array into a list of privileges
|
8,639
|
protected function addAuthzGroupsToPrivileges ( array $ privileges , $ authzGroupsPrivileges , array $ authzGroups ) { $ authzGroupsPrivileges = ! is_string ( $ authzGroupsPrivileges ) ? $ authzGroupsPrivileges : [ $ authzGroupsPrivileges ] ; foreach ( $ authzGroupsPrivileges as $ privilege ) { $ current = ! empty ( $ privileges [ $ privilege ] ) ? $ privileges [ $ privilege ] : [ ] ; $ privileges [ $ privilege ] = array_unique ( array_merge ( $ current , $ authzGroups ) ) ; } return $ privileges ; }
|
Populate an array of privileges with their corresponding authz groups
|
8,640
|
public static function fromHex ( $ hex ) { $ string = "" ; if ( strlen ( $ hex ) % 2 == 1 ) { throw new Exception ( "given parameter '" . $ hex . "' is not a valid hexadecimal number" ) ; } foreach ( str_split ( $ hex , 2 ) as $ chunk ) { $ string .= chr ( hexdec ( $ chunk ) ) ; } return new self ( $ string ) ; }
|
Returns the Str based on a given hex value .
|
8,641
|
protected function createRequest ( $ type , $ url , $ token ) { return $ this -> client -> createRequest ( $ type , $ url , $ this -> getDefaultHeaders ( $ token ) ) ; }
|
Creates an authorized request
|
8,642
|
public function buildTable ( $ name , $ id ) { $ this -> modelBuilder -> build ( $ name ) ; $ this -> formBuilder -> build ( $ name ) ; $ migration = $ this -> migrationBuilder -> buildSourceTableMigration ( $ name ) ; $ this -> migrateUp ( $ migration ) ; }
|
Builds a source table and associated entities
|
8,643
|
public function buildField ( $ name , $ type , $ indexed , $ tableName , NodeTypeContract $ nodeType ) { $ this -> modelBuilder -> build ( $ tableName , $ nodeType -> getFields ( ) ) ; $ this -> buildForm ( $ nodeType ) ; $ migration = $ this -> migrationBuilder -> buildFieldMigrationForTable ( $ name , $ type , $ indexed , $ tableName ) ; $ this -> migrateUp ( $ migration ) ; }
|
Builds a field on a source table and associated entities
|
8,644
|
public function destroyTable ( $ name , array $ fields , $ id ) { $ this -> modelBuilder -> destroy ( $ name ) ; $ this -> formBuilder -> destroy ( $ name ) ; $ migration = $ this -> migrationBuilder -> getMigrationClassPathByKey ( $ name ) ; $ this -> migrateDown ( $ migration ) ; $ this -> migrationBuilder -> destroySourceTableMigration ( $ name , $ fields ) ; }
|
Destroys a source table and all associated entities
|
8,645
|
public function destroyField ( $ name , $ tableName , NodeTypeContract $ nodeType ) { $ this -> modelBuilder -> build ( $ tableName , $ nodeType -> getFields ( ) ) ; $ this -> formBuilder -> build ( $ tableName , $ nodeType -> getFields ( ) ) ; $ migration = $ this -> migrationBuilder -> getMigrationClassPathByKey ( $ tableName , $ name ) ; $ this -> migrateDown ( $ migration ) ; $ this -> migrationBuilder -> destroyFieldMigrationForTable ( $ name , $ tableName ) ; }
|
Destroys a field on a source table and all associated entities
|
8,646
|
protected function getFunctionArgs ( \ stdClass $ route , \ ReflectionFunctionAbstract $ refl ) { $ args = [ ] ; $ params = $ refl -> getParameters ( ) ; foreach ( $ params as $ param ) { $ key = $ param -> name ; if ( property_exists ( $ route , $ key ) ) { $ value = $ route -> $ key ; } else { if ( ! $ param -> isOptional ( ) ) { $ fn = $ refl instanceof \ ReflectionMethod ? $ refl -> class . '::' . $ refl -> name : $ refl -> name ; throw new \ RuntimeException ( "Missing argument '$key' for {$fn}()" ) ; } $ value = $ param -> isDefaultValueAvailable ( ) ? $ param -> getDefaultValue ( ) : null ; } $ args [ $ key ] = $ value ; } return $ args ; }
|
Get the arguments for a function from a route using reflection
|
8,647
|
public function validateLogin ( $ email , $ password ) { $ password = md5 ( $ password ) ; $ result = $ this -> fetchOne ( "SELECT * FROM {$this->table} WHERE email = ? AND password = ?" , array ( $ email , $ password ) ) ; if ( ! empty ( $ result ) ) { return true ; } return false ; }
|
Validates username and password against the DB . If success sets the user info in the object and return true . If fails returns false .
|
8,648
|
public function regeneratePassword ( ) { $ clean_password = generatePassword ( 6 , 4 ) ; $ password = md5 ( $ clean_password ) ; $ this -> db ( ) -> executeUpdate ( "UPDATE {$this->table} SET password = ? WHERE ID = ?" , array ( $ password , $ this -> getId ( ) ) ) ; return $ clean_password ; }
|
Regenerates and sets the new password for a User .
|
8,649
|
public function isLogged ( ) { $ this -> byPassIsLogged = true ; try { if ( ! session_id ( ) ) { if ( $ this -> sessionManager ) { $ this -> sessionManager -> start ( ) ; } else { throw new MoufException ( "The session must be initialized before checking if the user is logged. Please use session_start()." ) ; } } if ( isset ( $ _SESSION [ $ this -> sessionPrefix . 'MoufUserId' ] ) ) { return true ; } else { foreach ( $ this -> authProviders as $ provider ) { if ( $ provider -> isLogged ( $ this ) ) { return true ; } } } } catch ( \ Exception $ e ) { $ this -> byPassIsLogged = false ; throw $ e ; } $ this -> byPassIsLogged = false ; return false ; }
|
Returns true if the user is logged false otherwise .
|
8,650
|
public function logoff ( ) { if ( ! session_id ( ) ) { if ( $ this -> sessionManager ) { $ this -> sessionManager -> start ( ) ; } else { throw new MoufException ( "The session must be initialized before trying to login. Please use session_start()." ) ; } } if ( isset ( $ _SESSION [ $ this -> sessionPrefix . 'MoufUserLogin' ] ) ) { $ login = $ _SESSION [ $ this -> sessionPrefix . 'MoufUserLogin' ] ; if ( is_array ( $ this -> authenticationListeners ) ) { foreach ( $ this -> authenticationListeners as $ listener ) { $ listener -> beforeLogOut ( $ this ) ; } } if ( $ this -> log instanceof LoggerInterface ) { $ this -> log -> debug ( "User '{login}' logs out." , array ( 'login' => $ login ) ) ; } else { $ this -> log -> trace ( "User '" . $ login . "' logs out." ) ; } unset ( $ _SESSION [ $ this -> sessionPrefix . 'MoufUserId' ] ) ; unset ( $ _SESSION [ $ this -> sessionPrefix . 'MoufUserLogin' ] ) ; } }
|
Logs the user off .
|
8,651
|
public function getUserLogin ( ) { if ( ! session_id ( ) ) { if ( $ this -> sessionManager ) { $ this -> sessionManager -> start ( ) ; } else { throw new MoufException ( "The session must be initialized before checking if the user is logged. Please use session_start()." ) ; } } if ( isset ( $ _SESSION [ $ this -> sessionPrefix . 'MoufUserLogin' ] ) ) { return $ _SESSION [ $ this -> sessionPrefix . 'MoufUserLogin' ] ; } else { foreach ( $ this -> authProviders as $ provider ) { $ login = $ provider -> getUserLogin ( $ this ) ; if ( $ login ) { return $ login ; } } } return null ; }
|
Returns the current user login .
|
8,652
|
public function apply ( $ builder ) { if ( ! empty ( $ values = $ this -> getValues ( ) ) ) { $ range = json_decode ( $ values , true ) ; if ( ! isset ( $ range [ 'start' ] ) or ! isset ( $ range [ 'end' ] ) ) { return $ builder ; } $ start = $ range [ 'start' ] . ' 00:00:00' ; $ end = $ range [ 'end' ] . ' 23:59:59' ; $ builder -> whereBetween ( 'tbl_notifications_stack.created_at' , [ $ start , $ end ] ) ; } }
|
Filters data by parameters from memory
|
8,653
|
public function broadcast ( array $ params ) { if ( ! isset ( $ params [ 'identifier' ] ) && ! isset ( $ params [ 'device_token' ] ) ) { throw new MissingArgumentException ( 'identifier or device_token' ) ; } if ( ! isset ( $ params [ 'message' ] ) ) { throw new MissingArgumentException ( 'message' ) ; } return $ this -> post ( 'sharing/broadcast' , $ params ) ; }
|
Shares activity information directly with a provider . The information provided in the parameters is passed to a provider to publish on their network .
|
8,654
|
public function direct ( array $ params ) { if ( ! isset ( $ params [ 'identifier' ] ) && ! isset ( $ params [ 'device_token' ] ) ) { throw new MissingArgumentException ( 'identifier or device_token' ) ; } if ( ! isset ( $ params [ 'recipients' ] ) ) { throw new MissingArgumentException ( 'recipients' ) ; } else if ( ! is_array ( $ params [ 'recipients' ] ) ) { throw new InvalidArgumentException ( 'Invalid Argument: recipients must be passed as array' ) ; } else { $ params [ 'recipients' ] = json_encode ( array_values ( $ params [ 'recipients' ] ) ) ; } if ( ! isset ( $ params [ 'message' ] ) ) { throw new MissingArgumentException ( 'message' ) ; } return $ this -> post ( 'sharing/direct' , $ params ) ; }
|
Shares activity information directly with the specified recipents on a provider s network instead of publishing it to everyone on the network .
|
8,655
|
public function getShareProviders ( $ format = 'json' , $ callback = '' ) { $ params = compact ( 'format' ) ; if ( ! empty ( $ callback ) ) { $ params [ 'callback' ] = $ callback ; } return $ this -> post ( 'get_share_providers' , $ params ) ; }
|
Returns a list of email and sharing providers configured for the widget . This call has no required parameters ; it identifies the proper application by the realm prefacing the URL path .
|
8,656
|
public function isDateWillComeIn ( $ interval ) { if ( ! ( $ interval instanceof \ DateInterval ) ) { $ interval = new \ DateInterval ( ( string ) $ interval ) ; } $ now = new \ DateTime ( 'now' ) ; return 0 === $ this -> diff ( $ now -> add ( $ interval ) ) -> invert ; }
|
Return TRUE if this date will come in a given interval
|
8,657
|
public function replyTo ( Message $ message , $ messageOrContent , $ cost = 0 , $ messageId = null , $ adjustCost = true ) { return $ this -> reply ( $ message -> id , $ message -> mobile , $ messageOrContent , $ cost , $ messageId , $ adjustCost ) ; }
|
Reply to a message
|
8,658
|
public function run ( $ view , $ data = array ( ) ) { return parent :: run ( $ view , \ array_merge ( View :: get_additional_data ( $ view , $ data ) , $ data ) ) ; }
|
Run the blade engine . Is only called when rendering a view .
|
8,659
|
public function setPhone ( \ Gpupo \ CommonSchema \ ORM \ Entity \ People \ Phone $ phone = null ) { $ this -> phone = $ phone ; return $ this ; }
|
Set phone .
|
8,660
|
public function setAlternativePhone ( \ Gpupo \ CommonSchema \ ORM \ Entity \ People \ AlternativePhone $ alternativePhone = null ) { $ this -> alternative_phone = $ alternativePhone ; return $ this ; }
|
Set alternativePhone .
|
8,661
|
public function setAddressBilling ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Trading \ Order \ Customer \ AddressBilling $ addressBilling = null ) { $ this -> address_billing = $ addressBilling ; return $ this ; }
|
Set addressBilling .
|
8,662
|
public function setAddressDelivery ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Trading \ Order \ Customer \ AddressDelivery $ addressDelivery = null ) { $ this -> address_delivery = $ addressDelivery ; return $ this ; }
|
Set addressDelivery .
|
8,663
|
public static function copy ( BaseColumn $ column ) { $ definition = self :: filterArray ( get_object_vars ( $ column ) ) ; return new self ( $ definition [ 'name' ] , $ definition ) ; }
|
Copy to new column
|
8,664
|
public function quoteIdentifier ( $ identifier ) { if ( sizeof ( $ this -> identifierQuoteChars ) === 2 ) { $ identifier = $ this -> identifierQuoteChars [ "start" ] . str_replace ( $ this -> identifierQuoteChars [ "end" ] , $ this -> identifierQuoteChars [ "end" ] . $ this -> identifierQuoteChars [ "end" ] , $ identifier ) . $ this -> identifierQuoteChars [ "end" ] ; } return $ identifier ; }
|
Returns the quoted version of an identifier to be used in an SQL query . This method takes a given identifier and quotes it so it can safely be used in SQL queries .
|
8,665
|
static public function validate ( ezcDbSchema $ schema ) { $ indexes = array ( ) ; $ errors = array ( ) ; foreach ( $ schema -> getSchema ( ) as $ tableName => $ table ) { foreach ( $ table -> indexes as $ indexName => $ dummy ) { $ indexes [ $ indexName ] [ ] = $ tableName ; } } foreach ( $ indexes as $ indexName => $ tableList ) { if ( count ( $ tableList ) > 1 ) { $ errors [ ] = "The index name '$indexName' is not unique. It exists for the tables: '" . join ( "', '" , $ tableList ) . "'." ; } } return $ errors ; }
|
Validates if all the index names used are unique accross the schema .
|
8,666
|
public function rest_api_init ( ) { $ register = [ ] ; foreach ( [ 'GET' , 'POST' , 'PUT' , 'PATCH' , 'DELETE' , 'HEAD' , 'OPTION' ] as $ method ) { $ method_name = strtolower ( "handle_{$method}" ) ; if ( ! method_exists ( $ this , $ method_name ) ) { continue ; } $ register [ ] = [ 'methods' => $ method , 'callback' => [ $ this , 'invoke' ] , 'args' => $ this -> get_arguments ( $ method ) , 'permission_callback' => [ $ this , 'permission_callback' ] , ] ; } if ( ! $ register ) { throw new \ Exception ( sprintf ( 'Class %s has no handler.' , get_called_class ( ) ) , 500 ) ; } else { register_rest_route ( $ this -> namespace , $ this -> get_route ( ) , $ register ) ; } }
|
Register rest endpoints
|
8,667
|
public static function getTableEnumList ( string $ field , string $ labelKey = null , string $ translationCode = null ) { $ type = DB :: select ( DB :: raw ( 'SHOW COLUMNS FROM ' . self :: getTableName ( ) . ' WHERE Field = "' . $ field . '"' ) ) [ 0 ] -> Type ; preg_match ( '/^enum\((.*)\)$/' , $ type , $ matches ) ; $ values = [ ] ; foreach ( explode ( ',' , $ matches [ 1 ] ) as $ value ) { $ value = trim ( $ value , "'" ) ; if ( is_null ( $ labelKey ) ) { $ values [ ] = $ value ; } else { $ values [ ] = [ 'id' => $ value , $ labelKey => trans ( $ translationCode . $ value ) , ] ; } } return $ values ; }
|
Get table enum field list with translations or not
|
8,668
|
public static function get ( $ module ) { if ( self :: $ modules === array ( ) ) self :: initialize ( ) ; if ( ! isset ( self :: $ modules [ $ module ] ) ) return false ; return self :: $ modules [ $ module ] ; }
|
Retrieve module information .
|
8,669
|
public static function installRequiredFiles ( ) { $ htaccess = __DIR__ . '/../../../../../../.htaccess' ; $ robots = __DIR__ . '/../../../../../../robots.txt' ; $ wpConfig = __DIR__ . '/../../../../../../wp-config-custom' ; $ fileSystem = new Filesystem ( ) ; try { if ( false === $ fileSystem -> exists ( $ htaccess ) ) { $ fileSystem -> copy ( $ htaccess . '.dist' , $ htaccess ) ; } if ( false === $ fileSystem -> exists ( $ robots ) ) { $ fileSystem -> copy ( $ robots . '.dist' , $ robots ) ; } if ( false === $ fileSystem -> exists ( $ wpConfig . '.php' ) ) { $ fileSystem -> copy ( $ wpConfig . '-sample.php' , $ wpConfig . '.php' ) ; } } catch ( \ Exception $ exception ) { echo sprintf ( "Something wrong happens during process: \n%s\n" , $ exception -> getMessage ( ) ) ; } }
|
Static method that creates . htaccess robots . txt and wp - config - custom . php files if they do not exist .
|
8,670
|
protected function decorateWhere ( $ method , & $ args ) { $ column = $ args [ 0 ] ; $ expression = isset ( $ args [ 1 ] ) ? $ args [ 1 ] : null ; $ value = isset ( $ args [ 2 ] ) ? $ args [ 2 ] : null ; if ( ! $ expression instanceof Entity && ! $ value instanceof Entity ) { return ; } $ entity_class = $ this -> entity_class ; $ relation = $ entity_class :: getRelationDefinition ( $ column ) ; $ column = $ relation [ 3 ] ; $ relation_column = $ relation [ 2 ] ; if ( $ expression instanceof Entity ) { $ expression = $ expression -> getRaw ( $ relation_column ) ; } else { $ value = $ value -> getRaw ( $ relation_column ) ; } $ args = [ $ column , $ expression , $ value ] ; }
|
Modify the arguments of a where method to account for selecting by entity objects .
|
8,671
|
public function execute ( ) { if ( $ this -> counting ) { return $ this -> executeCount ( ) ; } if ( $ this -> single ) { return $ this -> executeSingle ( $ this -> entity_class ) ; } return $ this -> executeCollection ( $ this -> entity_class ) ; }
|
Execute the query and return the result .
|
8,672
|
public function setBody ( $ body ) { $ node = $ this -> getBody ( false ) ; if ( ! $ node ) { $ node = $ this -> createElement ( 'body' ) ; $ this -> doc -> appendChild ( $ node ) ; } $ node -> nodeValue = htmlspecialchars ( $ body ) ; }
|
Sets the body of the message to be send
|
8,673
|
public function setSubject ( $ subject ) { $ node = $ this -> getSubject ( false ) ; if ( ! $ node ) { $ node = $ this -> createElement ( 'subject' ) ; $ this -> doc -> appendChild ( $ node ) ; } $ node -> nodeValue = htmlspecialchars ( $ subject ) ; }
|
Set the subject of the message
|
8,674
|
public function setHTML ( $ html ) { $ node = $ this -> createDocumentFragment ( ) ; $ node -> appendXML ( '<html xmlns="http://www.w3.org/1999/xhtml">' . $ html . '</html>' ) ; $ this -> doc -> appendChild ( $ node ) ; }
|
Sets the html node of the message expiremental
|
8,675
|
public function reply ( $ str ) { $ message = new \ sb \ XMPP \ Message ( ) ; $ message -> setTo ( $ this -> getFrom ( ) ) ; $ message -> setFrom ( $ this -> getTo ( ) ) ; $ message -> setBody ( $ str ) ; $ this -> client -> sendMessage ( $ message ) ; }
|
Creates a reply message and sends it to the user that sent the original message . This can be used only on \ sb \ XMPP \ Message instances that came over the socket and were passed to the onMessage method .
|
8,676
|
public static function is ( $ feature ) { return function ( $ features ) use ( $ feature ) { return fphp \ Model \ Feature :: has ( $ features , $ feature ) ; } ; }
|
Returns a formula that tests for the presence of a feature .
|
8,677
|
public static function _and ( ) { $ args = func_get_args ( ) ; return function ( $ features ) use ( $ args ) { $ acc = true ; foreach ( $ args as $ arg ) $ acc = $ acc && $ arg ( $ features ) ; return $ acc ; } ; }
|
Returns a formula that is the conjunction of other formulas . Formulas can be supplied variadically .
|
8,678
|
public static function _or ( ) { $ args = func_get_args ( ) ; return function ( $ features ) use ( $ args ) { $ acc = false ; foreach ( $ args as $ arg ) $ acc = $ acc || $ arg ( $ features ) ; return $ acc ; } ; }
|
Returns a formula that is the disjunction of other formulas . Formulas can be supplied variadically .
|
8,679
|
public static function equiv ( $ constraintA , $ constraintB ) { return function ( $ features ) use ( $ constraintA , $ constraintB ) { return $ constraintA ( $ features ) === $ constraintB ( $ features ) ; } ; }
|
Returns a formula that is the biconditional of two formulas .
|
8,680
|
public static function implies ( $ constraintA , $ constraintB ) { return function ( $ features ) use ( $ constraintA , $ constraintB ) { return ! $ constraintA ( $ features ) || $ constraintB ( $ features ) ; } ; }
|
Returns a formula that is the material conditional of two formulas .
|
8,681
|
private function generateHead ( ) { $ out = '<?xml version="1.0" encoding="utf-8"?>' . "\n" ; if ( $ this -> version == self :: RSS2 ) { $ out .= '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" >' . PHP_EOL ; } elseif ( $ this -> version == self :: RSS1 ) { $ out .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" >' . PHP_EOL ; } elseif ( $ this -> version == self :: ATOM ) { $ out .= '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL ; } return $ out ; }
|
Prints the xml and rss namespace
|
8,682
|
private function makeNode ( $ tagName , $ tagContent , $ attributes = null ) { $ nodeText = '' ; $ attrText = '' ; if ( is_array ( $ attributes ) ) { foreach ( $ attributes as $ key => $ value ) { $ attrText .= " $key=\"$value\" " ; } } if ( is_array ( $ tagContent ) && $ this -> version == self :: RSS1 ) { $ attrText = ' rdf:parseType="Resource"' ; } $ attrText .= ( in_array ( $ tagName , $ this -> CDATAEncoding ) && $ this -> version == self :: ATOM ) ? ' type="html" ' : '' ; $ nodeText .= ( in_array ( $ tagName , $ this -> CDATAEncoding ) ) ? "<{$tagName}{$attrText}><![CDATA[" : "<{$tagName}{$attrText}>" ; if ( is_array ( $ tagContent ) ) { foreach ( $ tagContent as $ key => $ value ) { $ nodeText .= $ this -> makeNode ( $ key , $ value ) ; } } else { $ nodeText .= ( in_array ( $ tagName , $ this -> CDATAEncoding ) ) ? $ this -> sanitizeCDATA ( $ tagContent ) : htmlspecialchars ( $ tagContent ) ; } $ nodeText .= ( in_array ( $ tagName , $ this -> CDATAEncoding ) ) ? "]]></$tagName>" : "</$tagName>" ; return $ nodeText . PHP_EOL ; }
|
Creates a single node as xml format
|
8,683
|
public function handle ( GetResponseEvent $ event ) { $ request = BridgeRequest :: createFromRequest ( $ event -> getRequest ( ) ) ; $ response = new BridgeResponse ; if ( ! $ this -> oauth2Server -> verifyResourceRequest ( $ request , $ response ) ) { return ; } try { $ token = $ this -> oauth2Server -> getAccessTokenData ( $ request ) ; $ token = $ this -> authenticationManager -> authenticate ( new OAuth2Token ( $ token [ 'client_id' ] , $ token [ 'user_id' ] , $ token [ 'access_token' ] , $ this -> providerKey , [ ] , explode ( " " , $ token [ 'scope' ] ) ) ) ; $ this -> tokenStorage -> setToken ( $ token ) ; } catch ( AuthenticationException $ failed ) { $ this -> handleAuthenticationError ( $ event , $ request , $ failed ) ; } }
|
Handles basic authentication .
|
8,684
|
public static function preProcessing ( Dwoo_Compiler $ compiler , array $ params , $ prepend , $ append , $ type ) { return Dwoo_Compiler :: PHP_OPEN . $ prepend . '$this->addStack("' . $ type . '", array(' . Dwoo_Compiler :: implode_r ( $ compiler -> getCompiledParams ( $ params ) ) . '));' . $ append . Dwoo_Compiler :: PHP_CLOSE ; }
|
called at compile time to define what the block should output in the compiled template code happens when the block is declared
|
8,685
|
private function download ( $ productLineName ) { $ productLineName = str_replace ( "\"" , "" , $ productLineName ) ; if ( headers_sent ( ) ) throw new DownloadZipExporterException ( "could download zip archive" ) ; header ( "Content-Type: application/zip" ) ; header ( "Content-Disposition: attachment; filename=\"$productLineName.zip\"" ) ; set_time_limit ( 0 ) ; $ file = @ fopen ( $ this -> target , "rb" ) ; while ( ! feof ( $ file ) ) { print ( @ fread ( $ file , 1024 * 8 ) ) ; ob_flush ( ) ; flush ( ) ; } }
|
Downloads the temporary ZIP archive . This only works when no headers and no output have been sent yet otherwise users receive corrupted ZIP files .
|
8,686
|
public function export ( $ product ) { try { parent :: export ( $ product ) ; $ this -> download ( $ product -> getProductLine ( ) -> getName ( ) ) ; } catch ( \ Exception $ e ) { } try { $ this -> remove ( ) ; } catch ( \ Exception $ e ) { } }
|
Exports a product as a ZIP archive and offers it for downloading . This only works when no headers and no output have been sent yet . Note that any occurring errors are ignored so that the downloaded archive will not be corrupted . There is currently no way to obtain error information in this case because feature - php does not have an external log file .
|
8,687
|
protected function finalizeConfiguration ( string $ code , array $ dataGridConfiguration ) : array { if ( isset ( $ dataGridConfiguration [ 'parent' ] ) ) { $ parent = $ dataGridConfiguration [ 'parent' ] ; if ( empty ( $ this -> globalConfiguration [ 'configurations' ] [ $ parent ] ) ) { throw new UnexpectedValueException ( "Unknown configuration {$parent}" ) ; } $ parentConfig = $ this -> globalConfiguration [ 'configurations' ] [ $ parent ] ; $ dataGridConfiguration = array_merge ( $ parentConfig , $ dataGridConfiguration ) ; } unset ( $ dataGridConfiguration [ 'parent' ] ) ; if ( empty ( $ dataGridConfiguration [ 'form_theme' ] ) ) { $ dataGridConfiguration [ 'form_theme' ] = $ this -> globalConfiguration [ 'default_form_theme' ] ; } if ( empty ( $ dataGridConfiguration [ 'template' ] ) ) { $ dataGridConfiguration [ 'template' ] = $ this -> globalConfiguration [ 'default_datagrid_template' ] ; } if ( empty ( $ dataGridConfiguration [ 'column_value_renderer' ] ) ) { $ dataGridConfiguration [ 'column_value_renderer' ] = $ this -> globalConfiguration [ 'default_column_value_renderer' ] ; } if ( empty ( $ dataGridConfiguration [ 'column_label_renderer' ] ) ) { $ dataGridConfiguration [ 'column_label_renderer' ] = $ this -> globalConfiguration [ 'default_column_label_renderer' ] ; } if ( isset ( $ dataGridConfiguration [ 'query_handler' ] ) ) { if ( \ is_array ( $ dataGridConfiguration [ 'query_handler' ] ) ) { $ dataGridConfiguration [ 'query_handler' ] = $ this -> finalizeFilterConfiguration ( $ code , $ dataGridConfiguration [ 'query_handler' ] ) ; } elseif ( 0 === strpos ( $ dataGridConfiguration [ 'query_handler' ] , '@' ) ) { $ dataGridConfiguration [ 'query_handler' ] = new Reference ( ltrim ( $ dataGridConfiguration [ 'query_handler' ] , '@' ) ) ; } else { throw new UnexpectedValueException ( 'query_handler option must be either a service or a valid filter configuration' ) ; } } return $ dataGridConfiguration ; }
|
Handle configuration parsing logic not handled by the semantic configuration definition
|
8,688
|
public function afterInitialize ( Event $ event , ModelsManager $ manager , $ model ) { $ reflector = $ this -> annotations -> get ( $ model ) ; $ annotations = $ reflector -> getClassAnnotations ( ) ; if ( $ annotations ) { foreach ( $ annotations as $ annotation ) { switch ( $ annotation -> getName ( ) ) { case 'Source' : $ arguments = $ annotation -> getArguments ( ) ; $ model -> setConnectionService ( $ arguments [ 0 ] ) ; $ manager -> setModelSource ( $ model , $ arguments [ 1 ] ) ; break ; case 'HasMany' : $ arguments = $ annotation -> getArguments ( ) ; if ( ! isset ( $ arguments [ 3 ] ) ) { $ arguments [ 3 ] = null ; } $ manager -> addHasMany ( $ model , $ arguments [ 0 ] , $ arguments [ 1 ] , $ arguments [ 2 ] , $ arguments [ 3 ] ) ; break ; case 'HasManyToMany' : $ arguments = $ annotation -> getArguments ( ) ; if ( ! isset ( $ arguments [ 6 ] ) ) { $ arguments [ 6 ] = null ; } $ manager -> addHasManyToMany ( $ model , $ arguments [ 0 ] , $ arguments [ 1 ] , $ arguments [ 2 ] , $ arguments [ 3 ] , $ arguments [ 4 ] , $ arguments [ 5 ] , $ arguments [ 6 ] ) ; break ; case 'HasOne' : $ arguments = $ annotation -> getArguments ( ) ; if ( ! isset ( $ arguments [ 3 ] ) ) { $ arguments [ 3 ] = null ; } $ manager -> addHasOne ( $ model , $ arguments [ 0 ] , $ arguments [ 1 ] , $ arguments [ 2 ] , $ arguments [ 3 ] ) ; break ; case 'BelongsTo' : $ arguments = $ annotation -> getArguments ( ) ; if ( ! isset ( $ arguments [ 3 ] ) ) { $ arguments [ 3 ] = null ; } $ manager -> addBelongsTo ( $ model , $ arguments [ 0 ] , $ arguments [ 1 ] , $ arguments [ 2 ] , $ arguments [ 3 ] ) ; break ; } } } }
|
This is called after initialize the model
|
8,689
|
public function dequeue ( ) { if ( ! count ( $ this -> cached_jobs ) ) { $ this -> cached_jobs = $ this -> repo -> getAvailableJobs ( $ this -> name ) ; } if ( ! count ( $ this -> cached_jobs ) ) { return ; } $ job_row = array_shift ( $ this -> cached_jobs ) ; $ job = Job \ WrappedJob :: fromString ( $ job_row [ 'job' ] ) -> withAddedPayload ( [ '_doctrine' => [ 'id' => $ job_row [ 'id' ] ] ] ) -> withQueueProvider ( 'doctrine' ) ; $ this -> repo -> processJob ( $ job ) ; return $ job ; }
|
take a job off of the queue
|
8,690
|
public function getChildren ( $ objects , $ path ) { $ array = array ( ) ; if ( ! is_array ( $ path ) ) { $ path = explode ( '/' , $ path ) ; } if ( ! is_array ( $ objects ) ) { $ objects = array ( $ objects ) ; } $ ret = $ objects ; foreach ( $ path as $ child ) { $ array = [ ] ; $ meta = null ; $ properties = null ; if ( $ ret && is_object ( current ( $ ret ) ) ) { $ meta = $ this -> mapper -> getMeta ( get_class ( current ( $ ret ) ) , ! 'strict' ) ; if ( $ meta ) { $ properties = $ meta -> getProperties ( ) ; } } foreach ( $ ret as $ o ) { $ field = isset ( $ properties [ $ child ] ) ? $ properties [ $ child ] : null ; if ( ! $ field || ! isset ( $ field [ 'getter' ] ) ) { $ value = $ o -> { $ child } ; } else { $ g = [ $ o , $ field [ 'getter' ] ] ; $ value = $ g ( ) ; } if ( is_array ( $ value ) || $ value instanceof \ Traversable ) { $ array = array_merge ( $ array , $ value ) ; } elseif ( $ value !== null ) { $ array [ ] = $ value ; } } $ ret = $ array ; } return $ ret ; }
|
Retrieve all object child values through a property path .
|
8,691
|
public function indexBy ( $ list , $ property , $ meta = null , $ allowDupes = null , $ ignoreNulls = null ) { $ allowDupes = $ allowDupes !== null ? $ allowDupes : false ; $ ignoreNulls = $ ignoreNulls !== null ? $ ignoreNulls : true ; if ( ! $ list ) { return [ ] ; } if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { if ( ! ( $ first = current ( $ list ) ) ) { throw new \ UnexpectedValueException ( ) ; } $ meta = $ this -> mapper -> getMeta ( get_class ( $ first ) ) ; } $ index = array ( ) ; $ props = $ meta ? $ meta -> getProperties ( ) : [ ] ; foreach ( $ list as $ object ) { $ propDef = ! isset ( $ props [ $ property ] ) ? null : $ props [ $ property ] ; $ value = ! $ propDef || ! isset ( $ propDef [ 'getter' ] ) ? $ object -> { $ property } : call_user_func ( array ( $ object , $ propDef [ 'getter' ] ) ) ; if ( $ value === null && $ ignoreNulls ) { continue ; } if ( ! $ allowDupes && isset ( $ index [ $ value ] ) ) { throw new \ UnexpectedValueException ( "Duplicate value for property $property" ) ; } $ index [ $ value ] = $ object ; } return $ index ; }
|
Iterate over an array of objects and returns an array of objects indexed by a property
|
8,692
|
public function groupBy ( $ list , $ property , $ meta = null ) { if ( ! $ list ) { return [ ] ; } if ( ! $ meta ) { if ( ! ( $ first = current ( $ list ) ) ) { throw new \ UnexpectedValueException ( ) ; } $ meta = $ this -> mapper -> getMeta ( get_class ( $ first ) ) ; } $ groups = [ ] ; $ props = $ meta -> getProperties ( ) ; foreach ( $ list as $ object ) { $ propDef = ! isset ( $ props [ $ property ] ) ? null : $ props [ $ property ] ; $ value = ! $ propDef || ! isset ( $ propDef [ 'getter' ] ) ? $ object -> { $ property } : call_user_func ( array ( $ object , $ propDef [ 'getter' ] ) ) ; $ groups [ $ value ] [ ] = $ object ; } return $ groups ; }
|
Iterate over an array of objects and group them by the value of a property
|
8,693
|
protected function _open ( $ mode ) { $ this -> _fileHandler = @ bzopen ( $ this -> _filePath , $ mode ) ; if ( false === $ this -> _fileHandler ) { throw new Mage_Exception ( 'Failed to open file ' . $ this -> _filePath ) ; } }
|
Open bz archive file
|
8,694
|
protected function _read ( $ length ) { $ data = bzread ( $ this -> _fileHandler , $ length ) ; if ( false === $ data ) { throw new Mage_Exception ( 'Failed to read data from ' . $ this -> _filePath ) ; } return $ data ; }
|
Read data from bz archive
|
8,695
|
public function buildValue ( ) { $ actions = [ 'add' => [ ] , 'replace' => [ ] , 'remove' => [ ] , ] ; foreach ( $ this -> actions as $ action ) { switch ( $ action -> getName ( ) ) { case 'add' : $ actions [ 'add' ] [ ] = [ $ action -> getArgument ( 0 ) ] ; break ; case 'replace' : $ actions [ 'replace' ] [ ] = [ $ action -> getArgument ( 0 ) , $ action -> getArgument ( 1 ) ] ; break ; case 'remove' : $ actions [ 'remove' ] [ ] = [ $ action -> getArgument ( 0 ) ] ; break ; } } $ builder = $ this -> getBuilder ( ) ; foreach ( $ actions as $ action => $ calls ) { foreach ( $ calls as $ arguments ) { call_user_func_array ( [ $ builder , $ action ] , $ arguments ) ; } } return $ builder -> get ( ) ; }
|
Builds a block option value using the given builder
|
8,696
|
protected function getBuilder ( ) { $ isArray = false ; if ( $ this -> actions ) { $ action = reset ( $ this -> actions ) ; $ arguments = $ action -> getArguments ( ) ; if ( $ arguments ) { $ argument = reset ( $ arguments ) ; if ( is_array ( $ argument ) ) { $ isArray = true ; } } } if ( $ isArray ) { return new ArrayOptionValueBuilder ( ) ; } return new StringOptionValueBuilder ( ) ; }
|
Returns options builder based on values in value bag
|
8,697
|
public function getNodeValue ( $ nodeName , $ itemNum = 0 , $ extraTextBefore = '' , $ extraTextAfter = '' ) { $ node = $ this -> getElementsByTagName ( $ nodeName ) -> item ( $ itemNum ) ; if ( isset ( $ node ) ) { $ texto = html_entity_decode ( trim ( $ node -> nodeValue ) , ENT_QUOTES , 'UTF-8' ) ; return $ extraTextBefore . $ texto . $ extraTextAfter ; } return '' ; }
|
getNodeValue . Extrai o valor do node DOM .
|
8,698
|
public function getNode ( $ nodeName , $ itemNum = 0 ) { $ node = $ this -> getElementsByTagName ( $ nodeName ) -> item ( $ itemNum ) ; if ( isset ( $ node ) ) { return $ node ; } return '' ; }
|
getNode Retorna o node solicitado .
|
8,699
|
public function appChild ( & $ parent , $ child , $ msg = '' ) { if ( empty ( $ parent ) ) { throw new Exception ( $ msg ) ; } if ( ! empty ( $ child ) ) { $ parent -> appendChild ( $ child ) ; } }
|
appChild Acrescenta DOMElement a pai DOMElement Caso o pai esteja vazio retorna uma exception com a mensagem O parametro child pode ser vazio .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.