idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
52,500
|
public function start ( ) { if ( 0 !== $ this -> oid ) { throw new StatusError ( 'The context has already been started.' ) ; } list ( $ parent , $ child ) = Stream \ pair ( ) ; switch ( $ pid = pcntl_fork ( ) ) { case - 1 : throw new ForkException ( 'Could not fork process!' ) ; case 0 : Loop \ loop ( $ loop = Loop \ create ( false ) ) ; $ channel = new ChannelledStream ( $ pipe = new DuplexPipe ( $ parent ) ) ; fclose ( $ child ) ; $ coroutine = new Coroutine ( $ this -> execute ( $ channel ) ) ; $ coroutine -> done ( ) ; try { $ loop -> run ( ) ; $ code = 0 ; } catch ( \ Throwable $ exception ) { $ code = 1 ; } $ pipe -> close ( ) ; exit ( $ code ) ; default : $ this -> pid = $ pid ; $ this -> oid = posix_getpid ( ) ; $ this -> channel = new ChannelledStream ( $ this -> pipe = new DuplexPipe ( $ child ) ) ; fclose ( $ parent ) ; } }
|
Starts the context execution .
|
52,501
|
public function free ( ) { if ( is_resource ( $ this -> queue ) && msg_queue_exists ( $ this -> key ) ) { if ( ! msg_remove_queue ( $ this -> queue ) ) { throw new SemaphoreException ( 'Failed to free the semaphore.' ) ; } $ this -> queue = null ; } }
|
Removes the semaphore if it still exists .
|
52,502
|
public function unserialize ( $ serialized ) { list ( $ this -> key , $ this -> maxLocks ) = unserialize ( $ serialized ) ; if ( msg_queue_exists ( $ this -> key ) ) { $ this -> queue = msg_get_queue ( $ this -> key ) ; } }
|
Unserializes a serialized semaphore .
|
52,503
|
public function isFreed ( ) : bool { if ( $ this -> handle !== null ) { $ this -> handleMovedMemory ( ) ; $ header = $ this -> getHeader ( ) ; return $ header [ 'state' ] === static :: STATE_FREED ; } return true ; }
|
Checks if the object has been freed .
|
52,504
|
protected function wrap ( $ value ) { if ( $ this -> isFreed ( ) ) { throw new SharedMemoryException ( 'The object has already been freed.' ) ; } $ serialized = serialize ( $ value ) ; $ size = strlen ( $ serialized ) ; $ header = $ this -> getHeader ( ) ; if ( shmop_size ( $ this -> handle ) < $ size + self :: MEM_DATA_OFFSET ) { $ this -> key = $ this -> key < 0xffffffff ? $ this -> key + 1 : mt_rand ( 0x10 , 0xfffffffe ) ; $ this -> setHeader ( self :: STATE_MOVED , $ this -> key , 0 ) ; $ this -> memDelete ( ) ; shmop_close ( $ this -> handle ) ; $ this -> memOpen ( $ this -> key , 'n' , $ header [ 'permissions' ] , $ size * 2 ) ; } $ this -> setHeader ( self :: STATE_ALLOCATED , $ size , $ header [ 'permissions' ] ) ; $ this -> memSet ( self :: MEM_DATA_OFFSET , $ serialized ) ; }
|
If the value requires more memory to store than currently allocated a new shared memory segment will be allocated with a larger size to store the value in . The previous memory segment will be cleaned up and marked for deletion . Other processes and threads will be notified of the new memory segment on the next read attempt . Once all running processes and threads disconnect from the old segment it will be freed by the OS .
|
52,505
|
public function free ( ) { if ( ! $ this -> isFreed ( ) ) { $ this -> setHeader ( static :: STATE_FREED , 0 , 0 ) ; $ this -> memDelete ( ) ; shmop_close ( $ this -> handle ) ; $ this -> handle = null ; $ this -> semaphore -> free ( ) ; } }
|
Frees the shared object from memory .
|
52,506
|
public function unserialize ( $ serialized ) { list ( $ this -> key , $ this -> semaphore ) = unserialize ( $ serialized ) ; $ this -> memOpen ( $ this -> key , 'w' , 0 , 0 ) ; }
|
Unserializes the local object handle .
|
52,507
|
private function handleMovedMemory ( ) { while ( true ) { $ header = $ this -> getHeader ( ) ; if ( $ header [ 'state' ] !== self :: STATE_MOVED ) { break ; } shmop_close ( $ this -> handle ) ; $ this -> key = $ header [ 'size' ] ; $ this -> memOpen ( $ this -> key , 'w' , 0 , 0 ) ; } }
|
Updates the current memory segment handle handling any moves made on the data .
|
52,508
|
private function setHeader ( int $ state , int $ size , int $ permissions ) { $ header = pack ( 'CLS' , $ state , $ size , $ permissions ) ; $ this -> memSet ( 0 , $ header ) ; }
|
Sets the header data for the current memory segment .
|
52,509
|
private function memOpen ( int $ key , string $ mode , int $ permissions , int $ size ) { $ this -> handle = @ shmop_open ( $ key , $ mode , $ permissions , $ size ) ; if ( $ this -> handle === false ) { throw new SharedMemoryException ( 'Failed to create shared memory block.' ) ; } }
|
Opens a shared memory handle .
|
52,510
|
private function close ( $ resource ) { if ( is_resource ( $ resource ) ) { fclose ( $ resource ) ; } if ( is_resource ( $ this -> process ) ) { proc_close ( $ this -> process ) ; $ this -> process = null ; } $ this -> stdin -> close ( ) ; }
|
Closes the stream resource provided the open process handle and stdin .
|
52,511
|
public function signal ( int $ signo ) { if ( ! $ this -> isRunning ( ) ) { throw new StatusError ( 'The process is not running.' ) ; } proc_terminate ( $ this -> process , ( int ) $ signo ) ; }
|
Sends the given signal to the process .
|
52,512
|
private function init ( int $ locks ) { $ locks = ( int ) $ locks ; if ( $ locks < 1 ) { $ locks = 1 ; } $ this -> semaphore = new Internal \ Semaphore ( $ locks ) ; $ this -> maxLocks = $ locks ; }
|
Initializes the semaphore with a given number of locks .
|
52,513
|
public function start ( ) { if ( $ this -> isRunning ( ) ) { throw new StatusError ( 'The worker pool has already been started.' ) ; } $ count = $ this -> minSize ; while ( -- $ count >= 0 ) { $ worker = $ this -> createWorker ( ) ; $ this -> idleWorkers -> enqueue ( $ worker ) ; } $ this -> running = true ; }
|
Starts the worker pool execution .
|
52,514
|
private function createWorker ( ) { $ worker = $ this -> factory -> create ( ) ; $ worker -> start ( ) ; $ this -> workers -> attach ( $ worker , 0 ) ; return $ worker ; }
|
Creates a worker and adds them to the pool .
|
52,515
|
private function push ( Worker $ worker ) { if ( ! $ this -> workers -> contains ( $ worker ) ) { throw new InvalidArgumentError ( 'The provided worker was not part of this queue.' ) ; } if ( 0 === ( $ this -> workers [ $ worker ] -= 1 ) ) { foreach ( $ this -> busyQueue as $ key => $ busy ) { if ( $ busy === $ worker ) { unset ( $ this -> busyQueue [ $ key ] ) ; break ; } } $ this -> idleWorkers -> push ( $ worker ) ; } }
|
Pushes the worker back into the queue .
|
52,516
|
public function acquire ( ) : \ Generator { $ tsl = function ( ) { if ( $ this -> locks > 0 ) { -- $ this -> locks ; return false ; } return true ; } ; while ( $ this -> locks < 1 || $ this -> synchronized ( $ tsl ) ) { yield from Coroutine \ sleep ( self :: LATENCY_TIMEOUT ) ; } return new Lock ( function ( ) { $ this -> release ( ) ; } ) ; }
|
Uses a double locking mechanism to acquire a lock without blocking . A synchronous mutex is used to make sure that the semaphore is queried one at a time to preserve the integrity of the semaphore itself . Then a lock count is used to check if a lock is available without blocking .
|
52,517
|
public function filterActions ( \ Illuminate \ Database \ Eloquent \ Model $ instance ) : array { $ listButtons = [ ] ; if ( $ this -> count ( ) ) { $ buttons = $ this -> getActions ( ) ; foreach ( $ buttons as & $ button ) { if ( $ button -> getValues ( $ instance ) ) { $ listButtons [ ] = $ button -> render ( ) ; unset ( $ button ) ; } } } return $ listButtons ; }
|
The method gets the buttons for the grid table
|
52,518
|
public static function & make_entry ( $ original , $ translation ) { $ entry = new EntryTranslations ( ) ; $ parts = explode ( chr ( 4 ) , $ original ) ; if ( isset ( $ parts [ 1 ] ) ) { $ original = $ parts [ 1 ] ; $ entry -> context = $ parts [ 0 ] ; } $ parts = explode ( chr ( 0 ) , $ original ) ; $ entry -> singular = $ parts [ 0 ] ; if ( isset ( $ parts [ 1 ] ) ) { $ entry -> is_plural = true ; $ entry -> plural = $ parts [ 1 ] ; } $ entry -> translations = explode ( chr ( 0 ) , $ translation ) ; return $ entry ; }
|
Build a from original string and translation strings found in a MO file .
|
52,519
|
public function loginUser ( $ customer ) { $ this -> front -> Request ( ) -> setPost ( 'email' , $ customer -> getEmail ( ) ) ; $ this -> front -> Request ( ) -> setPost ( 'passwordMD5' , $ customer -> getPassword ( ) ) ; return $ this -> admin -> sLogin ( true ) ; }
|
Logs in the user for the given customer object
|
52,520
|
public static function hasColumn ( \ Illuminate \ Database \ Eloquent \ Model $ model , string $ column ) : bool { $ table = $ model -> getTable ( ) ; $ columns = app ( 'cache' ) -> remember ( 'amigrid.columns.' . $ table , 60 , function ( ) use ( $ table ) { return \ Schema :: getColumnListing ( $ table ) ; } ) ; return array_search ( $ column , $ columns ) !== false ; }
|
Check if model s table has column
|
52,521
|
public function getTableForCreate ( ) { $ schema = new Schema ( ) ; $ table = $ schema -> createTable ( $ this -> getTableName ( ) ) ; $ table -> addColumn ( 'id' , 'integer' , array ( 'autoincrement' => true ) ) ; $ table -> addColumn ( 'meta_key' , 'string' , array ( 'length' => 255 ) ) ; $ table -> addColumn ( 'meta_value' , 'object' ) ; $ table -> setPrimaryKey ( array ( 'id' ) ) ; $ table -> addUniqueIndex ( array ( 'meta_key' ) ) ; return $ table ; }
|
Object Representation of the table used in this class .
|
52,522
|
public function setRoute ( string $ route = null , array $ params = [ ] ) : ButtonInterface { if ( $ this -> isVisibility ( ) ) { if ( $ route === null ) { $ url = '#' ; } else { $ url = '#' ; if ( app ( 'router' ) -> has ( $ route ) ) { $ url = route ( $ route , $ params ) ; } else { $ this -> setVisible ( false ) ; } } $ this -> setUrl ( $ url ) ; } return $ this ; }
|
If not found route the button is not visible automatically
|
52,523
|
public function get ( $ num ) { if ( isset ( $ this -> cache [ $ num ] ) ) { return $ this -> cache [ $ num ] ; } return $ this -> cache [ $ num ] = $ this -> execute ( $ num ) ; }
|
Get the plural form for a number . Caches the value for repeated calls .
|
52,524
|
public function writeRevision ( ) { if ( $ this -> syncCommit ) { $ localRevision = $ this -> syncCommit ; } else { $ localRevision = $ this -> git -> localRevision ( ) [ 0 ] ; } try { $ this -> bridge -> put ( $ localRevision , $ this -> revisionFile ) ; } catch ( Exception $ e ) { throw new Exception ( "Could not update the revision file on server: {$e->getMessage()}" ) ; } }
|
Writes latest revision to the remote revision file
|
52,525
|
public static function forKey ( $ key , Exception $ cause = null ) { return new static ( sprintf ( 'Expected a key of type integer or string. Got: %s' , is_object ( $ key ) ? get_class ( $ key ) : gettype ( $ key ) ) , 0 , $ cause ) ; }
|
Creates an exception for an invalid key .
|
52,526
|
public function get ( ) : \ Assurrussa \ GridView \ Helpers \ GridViewResult { $ gridViewResult = $ this -> _getGridView ( ) ; $ gridViewResult -> data = $ this -> pagination -> get ( $ this -> page , $ this -> limit ) ; $ gridViewResult -> pagination = $ this -> _getPaginationRender ( ) ; $ gridViewResult -> simple = false ; return $ gridViewResult ; }
|
Return get result
|
52,527
|
private function _filterSearch ( string $ search = null , string $ value = null , string $ operator = '=' , string $ beforeValue = '' , string $ afterValue = '' ) : void { if ( $ search ) { if ( $ value ) { $ value = trim ( $ value ) ; } $ search = trim ( $ search ) ; $ this -> _query -> where ( function ( $ query ) use ( $ search , $ value , $ operator , $ beforeValue , $ afterValue ) { $ tableName = $ this -> _model -> getTable ( ) ; if ( $ value ) { if ( Model :: hasColumn ( $ this -> _model , $ search ) ) { $ query -> orWhere ( $ tableName . '.' . $ search , $ operator , $ beforeValue . $ value . $ afterValue ) ; } } elseif ( $ this -> isStrictMode ( ) ) { if ( method_exists ( $ this -> _model , 'toFieldsAmiGrid' ) ) { $ list = $ this -> _model -> toFieldsAmiGrid ( ) ; foreach ( $ list as $ column ) { if ( Model :: hasColumn ( $ this -> _model , $ column ) ) { $ query -> orWhere ( $ tableName . '.' . $ column , $ operator , $ beforeValue . $ search . $ afterValue ) ; } } } } else { $ list = \ Schema :: getColumnListing ( $ tableName ) ; foreach ( $ list as $ column ) { if ( $ this -> _hasFilterExecuteForCyrillicColumn ( $ search , $ column ) ) { continue ; } if ( Model :: hasColumn ( $ this -> _model , $ column ) ) { $ query -> orWhere ( $ tableName . '.' . $ column , $ operator , $ beforeValue . $ search . $ afterValue ) ; } } } } ) ; } }
|
The method filters the data according
|
52,528
|
public static function serialize ( $ value ) { if ( is_resource ( $ value ) ) { throw SerializationFailedException :: forValue ( $ value ) ; } try { $ serialized = serialize ( $ value ) ; } catch ( Exception $ e ) { throw SerializationFailedException :: forValue ( $ value , $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return $ serialized ; }
|
Serializes a value .
|
52,529
|
public static function unserialize ( $ serialized ) { if ( ! is_string ( $ serialized ) ) { throw UnserializationFailedException :: forValue ( $ serialized ) ; } $ errorMessage = null ; $ errorCode = 0 ; set_error_handler ( function ( $ errno , $ errstr ) use ( & $ errorMessage , & $ errorCode ) { $ errorMessage = $ errstr ; $ errorCode = $ errno ; } ) ; $ value = unserialize ( $ serialized ) ; restore_error_handler ( ) ; if ( null !== $ errorMessage ) { if ( false !== $ pos = strpos ( $ errorMessage , '): ' ) ) { $ errorMessage = substr ( $ errorMessage , $ pos + 3 ) ; } throw UnserializationFailedException :: forValue ( $ serialized , $ errorMessage , $ errorCode ) ; } return $ value ; }
|
Unserializes a value .
|
52,530
|
public function key ( ) { if ( null === $ this -> singular || '' === $ this -> singular ) { return false ; } $ key = ! $ this -> context ? $ this -> singular : $ this -> context . chr ( 4 ) . $ this -> singular ; $ key = str_replace ( array ( "\r\n" , "\r" ) , "\n" , $ key ) ; return $ key ; }
|
Generates a unique key for this entry .
|
52,531
|
public function export_headers ( ) { $ header_string = '' ; foreach ( $ this -> headers as $ header => $ value ) { $ header_string .= "$header: $value\n" ; } $ poified = self :: poify ( $ header_string ) ; if ( $ this -> comments_before_headers ) { $ before_headers = self :: prepend_each_line ( rtrim ( $ this -> comments_before_headers ) . "\n" , '# ' ) ; } else { $ before_headers = '' ; } return rtrim ( "{$before_headers}msgid \"\"\nmsgstr $poified" ) ; }
|
Exports headers to a PO entry .
|
52,532
|
public function export ( $ include_headers = true ) { $ res = '' ; if ( $ include_headers ) { $ res .= $ this -> export_headers ( ) ; $ res .= "\n\n" ; } $ res .= $ this -> export_entries ( ) ; return $ res ; }
|
Exports the whole PO file as a string .
|
52,533
|
public static function poify ( $ string ) { $ quote = '"' ; $ slash = '\\' ; $ newline = "\n" ; $ replaces = array ( "$slash" => "$slash$slash" , "$quote" => "$slash$quote" , "\t" => '\t' , ) ; $ string = str_replace ( array_keys ( $ replaces ) , array_values ( $ replaces ) , $ string ) ; $ po = $ quote . implode ( "${slash}n$quote$newline$quote" , explode ( $ newline , $ string ) ) . $ quote ; if ( false !== strpos ( $ string , $ newline ) && ( substr_count ( $ string , $ newline ) > 1 || ! ( $ newline === substr ( $ string , - strlen ( $ newline ) ) ) ) ) { $ po = "$quote$quote$newline$po" ; } $ po = str_replace ( "$newline$quote$quote" , '' , $ po ) ; return $ po ; }
|
Formats a string in PO - style .
|
52,534
|
public static function unpoify ( $ string ) { $ escapes = array ( 't' => "\t" , 'n' => "\n" , 'r' => "\r" , '\\' => '\\' ) ; $ lines = array_map ( 'trim' , explode ( "\n" , $ string ) ) ; $ lines = array_map ( array ( __NAMESPACE__ . '\PO' , 'trim_quotes' ) , $ lines ) ; $ unpoified = '' ; $ previous_is_backslash = false ; foreach ( $ lines as $ line ) { preg_match_all ( '/./u' , $ line , $ chars ) ; $ chars = $ chars [ 0 ] ; foreach ( $ chars as $ char ) { if ( ! $ previous_is_backslash ) { if ( '\\' == $ char ) { $ previous_is_backslash = true ; } else { $ unpoified .= $ char ; } } else { $ previous_is_backslash = false ; $ unpoified .= isset ( $ escapes [ $ char ] ) ? $ escapes [ $ char ] : $ char ; } } } $ unpoified = str_replace ( array ( "\r\n" , "\r" ) , "\n" , $ unpoified ) ; return $ unpoified ; }
|
Gives back the original string from a PO - formatted string .
|
52,535
|
public static function export_entry ( EntryTranslations & $ entry ) { if ( null === $ entry -> singular || '' === $ entry -> singular ) { return false ; } $ po = array ( ) ; if ( ! empty ( $ entry -> translator_comments ) ) { $ po [ ] = self :: comment_block ( $ entry -> translator_comments ) ; } if ( ! empty ( $ entry -> extracted_comments ) ) { $ po [ ] = self :: comment_block ( $ entry -> extracted_comments , '.' ) ; } if ( ! empty ( $ entry -> references ) ) { $ po [ ] = self :: comment_block ( implode ( ' ' , $ entry -> references ) , ':' ) ; } if ( ! empty ( $ entry -> flags ) ) { $ po [ ] = self :: comment_block ( implode ( ', ' , $ entry -> flags ) , ',' ) ; } if ( ! is_null ( $ entry -> context ) ) { $ po [ ] = 'msgctxt ' . self :: poify ( $ entry -> context ) ; } $ po [ ] = 'msgid ' . self :: poify ( $ entry -> singular ) ; if ( ! $ entry -> is_plural ) { $ translation = empty ( $ entry -> translations ) ? '' : $ entry -> translations [ 0 ] ; $ translation = self :: match_begin_and_end_newlines ( $ translation , $ entry -> singular ) ; $ po [ ] = 'msgstr ' . self :: poify ( $ translation ) ; } else { $ po [ ] = 'msgid_plural ' . self :: poify ( $ entry -> plural ) ; $ translations = empty ( $ entry -> translations ) ? array ( '' , '' ) : $ entry -> translations ; foreach ( $ translations as $ i => $ translation ) { $ translation = self :: match_begin_and_end_newlines ( $ translation , $ entry -> plural ) ; $ po [ ] = "msgstr[$i] " . self :: poify ( $ translation ) ; } } return implode ( "\n" , $ po ) ; }
|
Builds a string from the entry for inclusion in PO file .
|
52,536
|
public function loginAndRegisterVia ( $ provider ) { $ this -> authenticationService = $ this -> authenticationServiceFactory -> getInstance ( $ provider ) ; $ isUserLoggedIn = $ this -> accountService -> checkUser ( ) ; if ( $ isUserLoggedIn ) { return $ isUserLoggedIn ; } if ( $ this -> authenticationService !== null ) { $ isAuthenticated = $ this -> authenticationService -> login ( ) ; $ customer = null ; if ( $ isAuthenticated ) { $ user = $ this -> authenticationService -> getUser ( ) ; if ( $ user !== null && $ user -> getEmail ( ) !== '' ) { $ customer = $ this -> customerService -> getCustomerByIdentity ( $ provider , $ user -> getId ( ) ) ; if ( $ customer !== null ) { $ isUserLoggedIn = $ this -> tryLoginCustomer ( $ customer ) ; } else { $ customer = $ this -> customerService -> getCustomerByEmail ( $ user -> getEmail ( ) ) ; if ( $ customer !== null ) { $ customer = $ this -> registerService -> connectUserWithExistingCustomer ( $ user , $ customer ) ; } else { $ customer = $ this -> registerService -> registerCustomerByUser ( $ user ) ; } $ isUserLoggedIn = $ this -> tryLoginCustomer ( $ customer ) ; } } } else { $ isUserLoggedIn = false ; } $ this -> container -> get ( 'events' ) -> notify ( 'Port1HybridAuth_Service_SingleSignOn_CustomerLoggedIn' , [ 'customer' => $ customer , 'isUserLoggedIn' => $ isUserLoggedIn ] ) ; } return $ isUserLoggedIn ; }
|
the overall method for the SSO workflow login + register
|
52,537
|
public function setCheckbox ( ) : ColumnInterface { return $ this -> setKey ( 'checkbox' ) -> setValue ( '<input type="checkbox" class="js_adminSelectAll">' ) -> setSort ( false ) -> setScreening ( true ) -> setHandler ( function ( $ data ) { if ( $ data && $ data -> id ) { return '<input type="checkbox" class="js_adminCheckboxRow" value="' . $ data -> id . '">' ; } return '' ; } ) ; }
|
template for checkbox
|
52,538
|
public function setKeyAction ( ) : ColumnInterface { $ this -> key = self :: ACTION_NAME ; $ this -> setValue ( '' ) ; $ this -> setSort ( false ) ; $ this -> setScreening ( true ) ; return $ this ; }
|
Method for a single column with actions
|
52,539
|
public function gettext_select_plural_form ( $ count ) { if ( ! isset ( $ this -> _gettext_select_plural_form ) || is_null ( $ this -> _gettext_select_plural_form ) ) { list ( $ nplurals , $ expression ) = $ this -> nplurals_and_expression_from_header ( $ this -> get_header ( 'Plural-Forms' ) ) ; $ this -> _nplurals = $ nplurals ; $ this -> _gettext_select_plural_form = $ this -> make_plural_form_function ( $ nplurals , $ expression ) ; } return call_user_func ( $ this -> _gettext_select_plural_form , $ count ) ; }
|
The gettext implementation of select_plural_form .
|
52,540
|
public function make_plural_form_function ( $ nplurals , $ expression ) { try { $ handler = new PluralForms ( rtrim ( $ expression , ';' ) ) ; return array ( $ handler , 'get' ) ; } catch ( \ Exception $ e ) { return $ this -> make_plural_form_function ( 2 , 'n != 1' ) ; } }
|
Makes a function which will return the right translation index according to the plural forms header .
|
52,541
|
public function parenthesize_plural_exression ( $ expression ) { $ expression .= ';' ; $ res = '' ; $ depth = 0 ; for ( $ i = 0 ; $ i < strlen ( $ expression ) ; ++ $ i ) { $ char = $ expression [ $ i ] ; switch ( $ char ) { case '?' : $ res .= ' ? (' ; $ depth ++ ; break ; case ':' : $ res .= ') : (' ; break ; case ';' : $ res .= str_repeat ( ')' , $ depth ) . ';' ; $ depth = 0 ; break ; default : $ res .= $ char ; } } return rtrim ( $ res , ';' ) ; }
|
Adds parentheses to the inner parts of ternary operators in plural expressions because PHP evaluates ternary operators from left to right .
|
52,542
|
public function aroundExecute ( CategoryView $ subject , \ Closure $ proceed ) { if ( ! $ subject -> getRequest ( ) -> isAjax ( ) ) { return $ proceed ( ) ; } try { $ this -> cleanRequestUri ( ) ; $ this -> removeAjaxQueryParams ( ) ; $ page = $ proceed ( ) ; if ( ! $ page ) { throw new \ Exception ( 'No page result.' ) ; } if ( $ this -> response -> isRedirect ( ) ) { throw new \ Exception ( 'Unable to process page result, redirect detected.' ) ; } $ className = '\Magento\Framework\View\Result\Page' ; if ( ! ( $ page instanceof $ className ) ) { throw new \ Exception ( sprintf ( 'Unable to process page result. Instance of %s expected, instance of %s got.' , $ className , get_class ( $ page ) ) ) ; } $ layout = $ page -> getLayout ( ) ; $ block = $ layout -> getBlock ( 'category.products.list' ) ; if ( ! $ block ) { throw new \ Exception ( 'Unable to load block content.' ) ; } $ pager = $ layout -> getBlock ( 'product_list_toolbar_pager' ) ; if ( ! $ pager ) { throw new \ Exception ( 'Unable to load pager block.' ) ; } $ htmlContent = $ layout -> renderElement ( 'content' ) ; $ response = [ 'success' => true , 'current_page_url' => $ this -> getCurrentPageUrl ( $ pager ) , 'previous_page_url' => $ this -> getPreviousPageUrl ( $ pager ) , 'next_page_url' => $ this -> getNextPageUrl ( $ pager ) , 'html' => [ 'content' => $ htmlContent , 'sidebar_main' => $ layout -> renderElement ( 'sidebar.main' ) ] ] ; } catch ( \ Exception $ e ) { $ this -> logger -> critical ( $ e ) ; $ response = [ 'success' => false , 'error_message' => 'Sorry, something went wrong. Please try again later.' ] ; } return $ this -> jsonResponse ( $ response ) ; }
|
Category view action
|
52,543
|
protected function getRepository ( ) { if ( $ this -> repository === null ) { $ this -> repository = $ this -> container -> get ( 'models' ) -> getRepository ( Customer :: class ) ; } return $ this -> repository ; }
|
Helper function to get access on the static declared repository
|
52,544
|
private function addIdentityFieldsToUser ( ) { $ service = $ this -> container -> get ( 'shopware_attribute.crud_service' ) ; foreach ( self :: PROVIDERS as $ provider ) { $ service -> update ( 's_user_attributes' , strtolower ( $ provider ) . '_identity' , 'string' , [ 'label' => 'Identity ' . $ provider , 'translatable' => false , 'displayInBackend' => true , 'entity' => Customer :: class , 'position' => 100 , 'custom' => false , ] ) ; } $ models = $ this -> container -> get ( 'models' ) ; $ metaDataCache = $ models -> getConfiguration ( ) -> getMetadataCacheImpl ( ) ; $ metaDataCache -> deleteAll ( ) ; $ models -> generateAttributeModels ( [ 's_user_attributes' ] ) ; }
|
Adds the identity attribute to the customer model .
|
52,545
|
protected function cleanRequestUri ( ) { $ requestUri = $ this -> request -> getRequestUri ( ) ; $ requestUriQuery = parse_url ( $ requestUri , PHP_URL_QUERY ) ; parse_str ( $ requestUriQuery , $ requestParams ) ; if ( is_array ( $ requestParams ) && count ( $ requestParams ) > 0 ) { foreach ( $ this -> ajaxQueryParams as $ queryParam ) { if ( array_key_exists ( $ queryParam , $ requestParams ) ) { unset ( $ requestParams [ $ queryParam ] ) ; } } } $ this -> request -> setRequestUri ( str_replace ( $ requestUriQuery , http_build_query ( $ requestParams ) , $ requestUri ) ) ; }
|
Remove query parameters added to the request URI for AJAX requests
|
52,546
|
protected function removeAjaxQueryParams ( ) { $ query = $ this -> request -> getQuery ( ) ; if ( count ( $ query ) > 0 ) { foreach ( $ this -> ajaxQueryParams as $ queryParam ) { $ query -> set ( $ queryParam , null ) ; } } }
|
Remove query parameters added for AJAX requests
|
52,547
|
protected function jsonResponse ( $ data ) { $ resultJson = $ this -> resultJsonFactory -> create ( ) ; $ resultJson -> setHeader ( 'Content-type' , 'application/json' , true ) ; $ resultJson -> setData ( $ data ) ; return $ resultJson ; }
|
Build a JSON response
|
52,548
|
protected function getCurrentPageUrl ( $ pager ) { if ( $ pager -> isFirstPage ( ) ) { $ pageUrl = $ pager -> getPageUrl ( null ) ; } else { $ pageUrl = $ pager -> getPageUrl ( $ pager -> getCurrentPage ( ) ) ; } return $ this -> removeTags -> filter ( $ pageUrl ) ; }
|
Retrieve current page URL
|
52,549
|
public static function validateMultiple ( $ keys ) { foreach ( $ keys as $ key ) { if ( ! is_string ( $ key ) && ! is_int ( $ key ) ) { throw InvalidKeyException :: forKey ( $ key ) ; } } }
|
Validates that multiple keys are valid .
|
52,550
|
public function connectUserWithExistingCustomer ( $ user , $ customer ) { $ result = false ; if ( $ user -> getEmail ( ) === $ customer -> getEmail ( ) ) { \ call_user_func ( [ $ customer -> getAttribute ( ) , 'set' . ucfirst ( $ user -> getType ( ) ) . 'Identity' ] , $ user -> getId ( ) ) ; $ result = $ this -> udapteCustomerAttributes ( $ customer ) ; } return $ result ; }
|
Connects a user with an existing customer
|
52,551
|
protected function command ( $ command , $ repoPath = null ) { if ( ! $ repoPath ) { $ repoPath = $ this -> repo ; } $ command = 'git --git-dir="' . $ repoPath . '/.git" --work-tree="' . $ repoPath . '" ' . $ command ; exec ( escapeshellcmd ( $ command ) , $ output , $ returnStatus ) ; if ( $ returnStatus != 0 ) { throw new Exception ( "The following command was attempted but failed:\r\n$command" ) ; } return $ output ; }
|
Runs a Git command .
|
52,552
|
protected function checkSubSubmodules ( $ repo , $ name ) { $ output = $ this -> command ( 'submodule foreach git submodule status' ) ; if ( $ output ) { foreach ( $ output as $ line ) { $ line = explode ( ' ' , trim ( $ line ) ) ; if ( trim ( $ line [ 0 ] ) == 'Entering' ) continue ; $ this -> submodules [ ] = array ( 'revision' => $ line [ 0 ] , 'name' => $ name . '/' . $ line [ 1 ] , 'path' => $ repo . '/' . $ name . '/' . $ line [ 1 ] ) ; $ this -> ignoredFiles [ ] = $ name . '/' . $ line [ 1 ] ; } } }
|
Checks submodules of submodules
|
52,553
|
public function register ( ) : void { $ this -> app -> bind ( \ Assurrussa \ GridView \ Interfaces \ GridInterface :: class , function ( $ app ) { return $ app -> make ( GridView :: class ) ; } ) ; $ this -> app -> alias ( \ Assurrussa \ GridView \ GridView :: class , GridView :: NAME ) ; $ this -> app -> alias ( \ Assurrussa \ GridView \ GridView :: class , \ Assurrussa \ GridView \ Interfaces \ GridInterface :: class ) ; }
|
Register the application services . Use a Helpers service provider that loads all . php files from a folder .
|
52,554
|
protected function registerProviders ( ) : void { foreach ( $ this -> providers as $ provider ) { $ this -> app -> register ( $ provider ) ; } }
|
Register the providers .
|
52,555
|
public function prependBeforeFilter ( $ filter , array $ options = [ ] ) { array_unshift ( $ this -> beforeFilters , $ this -> parseFilter ( $ filter , $ options ) ) ; }
|
Register a new before filter before any before filters on the controller .
|
52,556
|
public function prependAfterFilter ( $ filter , array $ options = [ ] ) { array_unshift ( $ this -> afterFilters , $ this -> parseFilter ( $ filter , $ options ) ) ; }
|
Register a new after filter before any after filters on the controller .
|
52,557
|
public function authorize ( $ args = null ) { $ args = is_array ( $ args ) ? $ args : func_get_args ( ) ; $ this -> _authorized = true ; return call_user_func_array ( [ $ this -> getCurrentAuthority ( ) , 'authorize' ] , $ args ) ; }
|
Throws a Efficiently \ AuthorityController \ Exceptions \ AccessDenied exception if the currentAuthority cannot perform the given action . This is usually called in a controller action or before filter to perform the authorization .
|
52,558
|
public function can ( $ args = null ) { $ args = is_array ( $ args ) ? $ args : func_get_args ( ) ; return call_user_func_array ( [ $ this -> getCurrentAuthority ( ) , 'can' ] , $ args ) ; }
|
Use in the controller or view to check the user s permission for a given action and object .
|
52,559
|
public function getRange ( ) : string { if ( empty ( $ this -> _rangeEnd ) ) { return $ this -> _rangeStart ; } else { return $ this -> _rangeStart . ',' . $ this -> _rangeEnd ; } }
|
Get the date range comma separated
|
52,560
|
public function setRange ( string $ rangeStart = null , string $ rangeEnd = null ) : Matomo { $ this -> _date = '' ; $ this -> _rangeStart = $ rangeStart ; $ this -> _rangeEnd = $ rangeEnd ; if ( is_null ( $ rangeEnd ) ) { if ( strpos ( $ rangeStart , 'last' ) !== false || strpos ( $ rangeStart , 'previous' ) !== false ) { $ this -> setDate ( $ rangeStart ) ; } else { $ this -> _rangeEnd = self :: DATE_TODAY ; } } return $ this ; }
|
Set date range
|
52,561
|
public function reset ( ) : Matomo { $ this -> _period = self :: PERIOD_DAY ; $ this -> _date = '' ; $ this -> _rangeStart = 'yesterday' ; $ this -> _rangeEnd = null ; return $ this ; }
|
Reset all default variables .
|
52,562
|
private function _request ( string $ method , array $ params = [ ] , array $ optional = [ ] ) { $ url = $ this -> _parseUrl ( $ method , $ params + $ optional ) ; if ( $ url === false ) { throw new InvalidRequestException ( 'Could not parse URL!' ) ; } $ req = Request :: get ( $ url ) ; $ req -> strict_ssl = $ this -> _verifySsl ; $ req -> max_redirects = $ this -> _maxRedirects ; $ req -> setConnectionTimeout ( 5 ) ; try { $ buffer = $ req -> send ( ) ; } catch ( ConnectionErrorException $ e ) { throw new InvalidRequestException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } if ( ! empty ( $ buffer ) ) { try { return $ this -> _finishResponse ( $ this -> _parseResponse ( $ buffer ) , $ method , $ params + $ optional ) ; } catch ( InvalidResponseException $ e ) { throw new InvalidRequestException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } throw new InvalidRequestException ( 'Empty response!' ) ; }
|
Make API request
|
52,563
|
private function _finishResponse ( $ response , string $ method , array $ params ) { $ valid = $ this -> _isValidResponse ( $ response ) ; if ( $ valid === true ) { if ( isset ( $ response -> value ) ) { return $ response -> value ; } else { return $ response ; } } else { throw new InvalidResponseException ( $ valid . ' (' . $ this -> _parseUrl ( $ method , $ params ) . ')' ) ; } }
|
Validate request and return the values .
|
52,564
|
private function _parseUrl ( string $ method , array $ params = [ ] ) { $ params = [ 'module' => 'API' , 'method' => $ method , 'token_auth' => $ this -> _token , 'idSite' => $ this -> _siteId , 'period' => $ this -> _period , 'format' => $ this -> _format , 'language' => $ this -> _language , 'filter_limit' => $ this -> _filter_limit ] + $ params ; foreach ( $ params as $ key => $ value ) { $ params [ $ key ] = urlencode ( $ value ) ; } if ( ! empty ( $ this -> _rangeStart ) && ! empty ( $ this -> _rangeEnd ) ) { $ params = $ params + [ 'date' => $ this -> _rangeStart . ',' . $ this -> _rangeEnd , ] ; } elseif ( ! empty ( $ this -> _date ) ) { $ params = $ params + [ 'date' => $ this -> _date , ] ; } else { throw new InvalidArgumentException ( 'Specify a date or a date range!' ) ; } $ url = $ this -> _site ; $ i = 0 ; foreach ( $ params as $ param => $ val ) { if ( ! empty ( $ val ) ) { $ i ++ ; if ( $ i > 1 ) { $ url .= '&' ; } else { $ url .= '?' ; } if ( is_array ( $ val ) ) { $ val = implode ( ',' , $ val ) ; } $ url .= $ param . '=' . $ val ; } } return $ url ; }
|
Create request url with parameters
|
52,565
|
private function _isValidResponse ( $ response ) { if ( is_null ( $ response ) ) { return self :: ERROR_EMPTY ; } if ( ! isset ( $ response -> result ) or ( $ response -> result != 'error' ) ) { return true ; } return $ response -> message ; }
|
Check if the request was successfull .
|
52,566
|
private function _parseResponse ( Response $ response ) { switch ( $ this -> _format ) { case self :: FORMAT_JSON : return json_decode ( $ response , $ this -> _isJsonDecodeAssoc ) ; break ; default : return $ response ; } }
|
Parse request result
|
52,567
|
public function getMetadata ( $ apiModule , $ apiAction , $ apiParameters = [ ] , array $ optional = [ ] ) { return $ this -> _request ( 'API.getMetadata' , [ 'apiModule' => $ apiModule , 'apiAction' => $ apiAction , 'apiParameters' => $ apiParameters , ] , $ optional ) ; }
|
Get metadata from the API
|
52,568
|
public function getReportMetadata ( array $ idSites , $ hideMetricsDoc = '' , $ showSubtableReports = '' , array $ optional = [ ] ) { return $ this -> _request ( 'API.getReportMetadata' , [ 'idSites' => $ idSites , 'hideMetricsDoc' => $ hideMetricsDoc , 'showSubtableReports' => $ showSubtableReports , ] , $ optional ) ; }
|
Get metadata from a report
|
52,569
|
public function getProcessedReport ( $ apiModule , $ apiAction , $ segment = '' , $ apiParameters = '' , $ idGoal = '' , $ showTimer = '1' , $ hideMetricsDoc = '' , array $ optional = [ ] ) { return $ this -> _request ( 'API.getProcessedReport' , [ 'apiModule' => $ apiModule , 'apiAction' => $ apiAction , 'segment' => $ segment , 'apiParameters' => $ apiParameters , 'idGoal' => $ idGoal , 'showTimer' => $ showTimer , 'hideMetricsDoc' => $ hideMetricsDoc , ] , $ optional ) ; }
|
Get processed report
|
52,570
|
public function getRowEvolution ( $ apiModule , $ apiAction , $ segment = '' , $ column = '' , $ idGoal = '' , $ legendAppendMetric = '1' , $ labelUseAbsoluteUrl = '1' , array $ optional = [ ] ) { return $ this -> _request ( 'API.getRowEvolution' , [ 'apiModule' => $ apiModule , 'apiAction' => $ apiAction , 'segment' => $ segment , 'column' => $ column , 'idGoal' => $ idGoal , 'legendAppendMetric' => $ legendAppendMetric , 'labelUseAbsoluteUrl' => $ labelUseAbsoluteUrl , ] , $ optional ) ; }
|
Get row evolution
|
52,571
|
public function configureExistingCustomDimension ( $ idDimension , $ name , $ active , array $ optional = [ ] ) { return $ this -> _request ( 'CustomDimensions.configureExistingCustomDimension' , [ 'idDimension' => $ idDimension , 'name' => $ name , 'active' => $ active , ] , $ optional ) ; }
|
Updates an existing Custom Dimension . This method updates all values you need to pass existing values of the dimension if you do not want to reset any value . Requires at least Admin access for the specified website .
|
52,572
|
public function sendFeedbackForFeature ( $ featureName , $ like , $ message = '' , array $ optional = [ ] ) { return $ this -> _request ( 'Feedback.sendFeedbackForFeature' , [ 'featureName' => $ featureName , 'like' => $ like , 'message' => $ message , ] , $ optional ) ; }
|
Get a multidimensional array
|
52,573
|
public function addGoal ( $ name , $ matchAttribute , $ pattern , $ patternType , $ caseSensitive = '' , $ revenue = '' , $ allowMultipleConversionsPerVisit = '' , array $ optional = [ ] ) { return $ this -> _request ( 'Goals.addGoal' , [ 'name' => $ name , 'matchAttribute' => $ matchAttribute , 'pattern' => $ pattern , 'patternType' => $ patternType , 'caseSensitive' => $ caseSensitive , 'revenue' => $ revenue , 'allowMultipleConversionsPerVisit' => $ allowMultipleConversionsPerVisit , ] , $ optional ) ; }
|
Add a goal
|
52,574
|
public function updateGoal ( $ idGoal , $ name , $ matchAttribute , $ pattern , $ patternType , $ caseSensitive = '' , $ revenue = '' , $ allowMultipleConversionsPerVisit = '' , array $ optional = [ ] ) { return $ this -> _request ( 'Goals.updateGoal' , [ 'idGoal' => $ idGoal , 'name' => $ name , 'matchAttribute' => $ matchAttribute , 'pattern' => $ pattern , 'patternType' => $ patternType , 'caseSensitive' => $ caseSensitive , 'revenue' => $ revenue , 'allowMultipleConversionsPerVisit' => $ allowMultipleConversionsPerVisit , ] , $ optional ) ; }
|
Update a goal
|
52,575
|
public function getGoal ( $ segment = '' , $ idGoal = '' , $ columns = [ ] , array $ optional = [ ] ) { return $ this -> _request ( 'Goals.get' , [ 'segment' => $ segment , 'idGoal' => $ idGoal , 'columns' => $ columns , ] , $ optional ) ; }
|
Get conversion rates from a goal
|
52,576
|
public function getImageGraph ( $ apiModule , $ apiAction , $ graphType = '' , $ outputType = '0' , $ columns = '' , $ labels = '' , $ showLegend = '1' , $ width = '' , $ height = '' , $ fontSize = '9' , $ legendFontSize = '' , $ aliasedGraph = '1' , $ idGoal = '' , $ colors = [ ] , array $ optional = [ ] ) { return $ this -> _request ( 'ImageGraph.get' , [ 'apiModule' => $ apiModule , 'apiAction' => $ apiAction , 'graphType' => $ graphType , 'outputType' => $ outputType , 'columns' => $ columns , 'labels' => $ labels , 'showLegend' => $ showLegend , 'width' => $ width , 'height' => $ height , 'fontSize' => $ fontSize , 'legendFontSize' => $ legendFontSize , 'aliasedGraph' => $ aliasedGraph , 'idGoal ' => $ idGoal , 'colors' => $ colors , ] , $ optional ) ; }
|
Generate a png report
|
52,577
|
public function getMoversAndShakers ( $ reportUniqueId , $ segment , $ comparedToXPeriods = 1 , $ limitIncreaser = 4 , $ limitDecreaser = 4 , array $ optional = [ ] ) { return $ this -> _request ( 'Insights.getMoversAndShakers' , [ 'reportUniqueId' => $ reportUniqueId , 'segment' => $ segment , 'comparedToXPeriods' => $ comparedToXPeriods , 'limitIncreaser' => $ limitIncreaser , 'limitDecreaser' => $ limitDecreaser , ] , $ optional ) ; }
|
Get movers and shakers
|
52,578
|
public function getLastVisitsDetails ( $ segment = '' , $ minTimestamp = '' , $ doNotFetchActions = '' , array $ optional = [ ] ) { return $ this -> _request ( 'Live.getLastVisitsDetails' , [ 'segment' => $ segment , 'minTimestamp' => $ minTimestamp , 'doNotFetchActions' => $ doNotFetchActions , ] , $ optional ) ; }
|
Get information about the last visits
|
52,579
|
public function addReport ( $ description , $ period , $ hour , $ reportType , $ reportFormat , $ reports , $ parameters , $ idSegment = '' , array $ optional = [ ] ) { return $ this -> _request ( 'ScheduledReports.addReport' , [ 'description' => $ description , 'period' => $ period , 'hour' => $ hour , 'reportType' => $ reportType , 'reportFormat' => $ reportFormat , 'reports' => $ reports , 'parameters' => $ parameters , 'idSegment' => $ idSegment , ] , $ optional ) ; }
|
Add scheduled report
|
52,580
|
public function updateReport ( $ idReport , $ description , $ period , $ hour , $ reportType , $ reportFormat , $ reports , $ parameters , $ idSegment = '' , array $ optional = [ ] ) { return $ this -> _request ( 'ScheduledReports.updateReport' , [ 'idReport' => $ idReport , 'description' => $ description , 'period' => $ period , 'hour' => $ hour , 'reportType' => $ reportType , 'reportFormat' => $ reportFormat , 'reports' => $ reports , 'parameters' => $ parameters , 'idSegment' => $ idSegment , ] , $ optional ) ; }
|
Updated scheduled report
|
52,581
|
public function getJavascriptTag ( $ matomoUrl , $ mergeSubdomains = '' , $ groupPageTitlesByDomain = '' , $ mergeAliasUrls = '' , $ visitorCustomVariables = '' , $ pageCustomVariables = '' , $ customCampaignNameQueryParam = '' , $ customCampaignKeywordParam = '' , $ doNotTrack = '' , $ disableCookies = '' , array $ optional = [ ] ) { return $ this -> _request ( 'SitesManager.getJavascriptTag' , [ 'piwikUrl' => $ matomoUrl , 'mergeSubdomains' => $ mergeSubdomains , 'groupPageTitlesByDomain' => $ groupPageTitlesByDomain , 'mergeAliasUrls' => $ mergeAliasUrls , 'visitorCustomVariables' => $ visitorCustomVariables , 'pageCustomVariables' => $ pageCustomVariables , 'customCampaignNameQueryParam' => $ customCampaignNameQueryParam , 'customCampaignKeywordParam' => $ customCampaignKeywordParam , 'doNotTrack' => $ doNotTrack , 'disableCookies' => $ disableCookies , ] , $ optional ) ; }
|
Get the JS tag of the current site
|
52,582
|
public function getImageTrackingCode ( $ matomoUrl , $ actionName = '' , $ idGoal = '' , $ revenue = '' , array $ optional = [ ] ) { return $ this -> _request ( 'SitesManager.getImageTrackingCode' , [ 'piwikUrl' => $ matomoUrl , 'actionName' => $ actionName , 'idGoal' => $ idGoal , 'revenue' => $ revenue , ] , $ optional ) ; }
|
Get image tracking code of the current site
|
52,583
|
public function updateSite ( $ siteName , $ urls , $ ecommerce = '' , $ siteSearch = '' , $ searchKeywordParameters = '' , $ searchCategoryParameters = '' , $ excludeIps = '' , $ excludedQueryParameters = '' , $ timezone = '' , $ currency = '' , $ group = '' , $ startDate = '' , $ excludedUserAgents = '' , $ keepURLFragments = '' , $ type = '' , $ settings = '' , array $ optional = [ ] ) { return $ this -> _request ( 'SitesManager.updateSite' , [ 'siteName' => $ siteName , 'urls' => $ urls , 'ecommerce' => $ ecommerce , 'siteSearch' => $ siteSearch , 'searchKeywordParameters' => $ searchKeywordParameters , 'searchCategoryParameters' => $ searchCategoryParameters , 'excludeIps' => $ excludeIps , 'excludedQueryParameters' => $ excludedQueryParameters , 'timezone' => $ timezone , 'currency' => $ currency , 'group' => $ group , 'startDate' => $ startDate , 'excludedUserAgents' => $ excludedUserAgents , 'keepURLFragments' => $ keepURLFragments , 'type' => $ type , 'settings' => $ settings , ] , $ optional ) ; }
|
Update current site
|
52,584
|
public function getTransitionsForPageTitle ( $ pageTitle , $ segment = '' , $ limitBeforeGrouping = '' , array $ optional = [ ] ) { return $ this -> _request ( 'Transitions.getTransitionsForPageTitle' , [ 'pageTitle' => $ pageTitle , 'segment' => $ segment , 'limitBeforeGrouping' => $ limitBeforeGrouping , ] , $ optional ) ; }
|
Get transitions for a page title
|
52,585
|
public function setUserPreference ( $ userLogin , $ preferenceName , $ preferenceValue , array $ optional = [ ] ) { return $ this -> _request ( 'UsersManager.setUserPreference' , [ 'userLogin' => $ userLogin , 'preferenceName' => $ preferenceName , 'preferenceValue' => $ preferenceValue , ] , $ optional ) ; }
|
Set user preference
|
52,586
|
public function setUserAccess ( $ userLogin , $ access , $ idSites , array $ optional = [ ] ) { return $ this -> _request ( 'UsersManager.setUserAccess' , [ 'userLogin' => $ userLogin , 'access' => $ access , 'idSites' => $ idSites , ] , $ optional ) ; }
|
Grant access to multiple sites
|
52,587
|
public function getTokenAuth ( $ userLogin , $ md5Password , array $ optional = [ ] ) { return $ this -> _request ( 'UsersManager.getTokenAuth' , [ 'userLogin' => $ userLogin , 'md5Password' => md5 ( $ md5Password ) , ] , $ optional ) ; }
|
Get the token for a user
|
52,588
|
protected function getResourceClass ( ) { if ( array_key_exists ( 'class' , $ this -> options ) ) { if ( $ this -> options [ 'class' ] === false ) { return $ this -> getName ( ) ; } elseif ( is_string ( $ this -> options [ 'class' ] ) ) { return studly_case ( $ this -> options [ 'class' ] ) ; } } return studly_case ( $ this -> getNamespacedName ( ) ) ; }
|
only be used for authorization not loading since there s no class to load through .
|
52,589
|
protected function getCreateActions ( ) { $ optionNew = array_key_exists ( 'new' , $ this -> options ) ? $ this -> options [ 'new' ] : [ ] ; $ optionCreate = array_key_exists ( 'create' , $ this -> options ) ? $ this -> options [ 'create' ] : [ ] ; $ options = array_merge ( ( array ) $ optionNew , ( array ) $ optionCreate ) ; return array_unique ( array_flatten ( array_merge ( [ 'new' , 'create' , 'store' ] , $ options ) ) ) ; }
|
And the Rails create action is named store in Laravel .
|
52,590
|
public function can ( $ action , $ resource , $ resourceValue = null ) { if ( is_object ( $ resource ) ) { $ resourceValue = $ resource ; $ resource = get_classname ( $ resourceValue ) ; } elseif ( is_array ( $ resource ) ) { $ resourceValue = head ( array_values ( $ resource ) ) ; $ resource = head ( array_keys ( $ resource ) ) ; } $ skipConditions = false ; if ( is_string ( $ resource ) && ! is_object ( $ resourceValue ) && $ this -> hasCondition ( $ action , $ resource ) ) { $ skipConditions = true ; } $ self = $ this ; $ rules = $ this -> getRulesFor ( $ action , $ resource ) ; if ( ! $ rules -> isEmpty ( ) ) { $ allowed = array_reduce ( $ rules -> all ( ) , function ( $ result , $ rule ) use ( $ self , $ resourceValue , $ skipConditions ) { if ( $ skipConditions ) { return $ rule -> getBehavior ( ) ; } else { if ( $ rule -> isRestriction ( ) ) { $ result = $ result && $ rule -> isAllowed ( $ self , $ resourceValue ) ; } else { $ result = $ result || $ rule -> isAllowed ( $ self , $ resourceValue ) ; } } return $ result ; } , false ) ; } else { $ allowed = false ; } return $ allowed ; }
|
Determine if current user can access the given action and resource
|
52,591
|
public function addAlias ( $ name , $ actions ) { $ actions = ( array ) $ actions ; $ this -> addAliasAction ( $ name , $ actions ) ; parent :: addAlias ( $ name , $ this -> getExpandActions ( $ actions ) ) ; }
|
Define new alias for an action
|
52,592
|
public function getRulesFor ( $ action , $ resource ) { $ aliases = array_merge ( ( array ) $ action , $ this -> getAliasesForAction ( $ action ) ) ; return $ this -> rules -> getRelevantRules ( $ aliases , $ resource ) ; }
|
Returns all rules relevant to the given action and resource
|
52,593
|
public function getExpandActions ( $ actions ) { $ actions = ( array ) $ actions ; return array_flatten ( array_map ( function ( $ action ) use ( $ actions ) { return array_key_exists ( $ action , $ this -> getAliasedActions ( ) ) ? [ $ action , $ this -> getExpandActions ( $ this -> getAliasedActions ( ) [ $ action ] ) ] : $ action ; } , $ actions ) ) ; }
|
rely on the actions to be expanded .
|
52,594
|
public function isRelevant ( $ action , $ resource ) { $ resource = is_array ( $ resource ) ? head ( array_keys ( $ resource ) ) : $ resource ; return parent :: isRelevant ( $ action , $ resource ) ; }
|
Determine if current rule is relevant based on an action and resource
|
52,595
|
public function matchesAction ( $ action ) { $ action = ( array ) $ action ; return $ this -> action === 'manage' || in_array ( $ this -> action , $ action ) ; }
|
Determine if the instance s action matches the one passed in
|
52,596
|
public function only ( $ keys = null ) { $ keys = is_array ( $ keys ) ? $ keys : func_get_args ( ) ; return array_only ( $ this -> params , $ keys ) ; }
|
Get a subset of the items from the parameters .
|
52,597
|
public function request ( $ verb , array $ params = array ( ) ) { if ( ! $ this -> url ) { throw new RuntimeException ( "Cannot perform request when URL not set. Use setUrl() method" ) ; } $ params = array_merge ( array ( 'verb' => $ verb ) , $ params ) ; $ url = $ this -> url . ( parse_url ( $ this -> url , PHP_URL_QUERY ) ? '&' : '?' ) . http_build_query ( $ params ) ; try { $ resp = $ this -> httpAdapter -> request ( $ url ) ; return $ this -> decodeResponse ( $ resp ) ; } catch ( HttpException $ e ) { $ this -> checkForOaipmhException ( $ e ) ; } }
|
Perform a request and return a OAI SimpleXML Document
|
52,598
|
private function checkForOaipmhException ( HttpException $ httpException ) { try { if ( $ resp = $ httpException -> getBody ( ) ) { $ this -> decodeResponse ( $ resp ) ; } } catch ( MalformedResponseException $ e ) { } throw $ httpException ; }
|
Check for OAI - PMH Exception from HTTP Exception
|
52,599
|
protected function decodeResponse ( $ resp ) { try { $ xml = @ new \ SimpleXMLElement ( $ resp ) ; } catch ( \ Exception $ e ) { throw new MalformedResponseException ( sprintf ( "Could not decode XML Response: %s" , $ e -> getMessage ( ) ) ) ; } if ( isset ( $ xml -> error ) ) { $ code = ( string ) $ xml -> error [ 'code' ] ; $ msg = ( string ) $ xml -> error ; throw new OaipmhException ( $ code , $ msg ) ; } return $ xml ; }
|
Decode the response into XML
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.