idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
800
|
public function destroy ( UserRemoverListener $ listener , $ id ) { $ user = Foundation :: make ( 'orchestra.user' ) -> findOrFail ( $ id ) ; if ( ( string ) $ user -> id === ( string ) Auth :: user ( ) -> id ) { return $ listener -> selfDeletionFailed ( ) ; } try { $ this -> fireEvent ( 'deleting' , [ $ user ] ) ; $ user -> transaction ( function ( ) use ( $ user ) { $ user -> delete ( ) ; } ) ; $ this -> fireEvent ( 'deleted' , [ $ user ] ) ; } catch ( Exception $ e ) { return $ listener -> userDeletionFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> userDeleted ( ) ; }
|
Destroy a user .
|
801
|
protected function saving ( Eloquent $ user , $ input = [ ] , $ type = 'create' ) { $ beforeEvent = ( $ type === 'create' ? 'creating' : 'updating' ) ; $ afterEvent = ( $ type === 'create' ? 'created' : 'updated' ) ; $ user -> fullname = $ input [ 'fullname' ] ; $ user -> email = $ input [ 'email' ] ; $ this -> fireEvent ( $ beforeEvent , [ $ user ] ) ; $ this -> fireEvent ( 'saving' , [ $ user ] ) ; $ user -> transaction ( function ( ) use ( $ user , $ input ) { $ user -> save ( ) ; $ user -> roles ( ) -> sync ( $ input [ 'roles' ] ) ; } ) ; $ this -> fireEvent ( $ afterEvent , [ $ user ] ) ; $ this -> fireEvent ( 'saved' , [ $ user ] ) ; return true ; }
|
Save the user .
|
802
|
public function saveNodeValue ( NodePath $ nodePath , string $ property , $ value ) { try { $ this -> data = $ this -> storeValue ( $ nodePath , $ this -> data , $ property , $ value ) ; } catch ( InconsistentValueException $ e ) { if ( $ property == 'nodeType' ) { $ node = $ this -> getNode ( $ nodePath ) ; $ this -> handleUpgrade ( $ node , $ nodePath , $ value ) ; } else { throw $ e ; } } }
|
Save a single property value for a given node .
|
803
|
private function storeValue ( NodePath $ nodePath , array $ data , string $ property , $ value ) : array { $ nodePath = $ nodePath -> popFirst ( $ nodeName ) ; $ nodeName = $ this -> encodeNodeName ( $ nodeName ) ; if ( ! isset ( $ data [ $ nodeName ] ) ) { $ data [ $ nodeName ] = [ ] ; } if ( $ nodePath -> isEmpty ( ) ) { if ( ! empty ( $ data [ $ nodeName ] [ $ property ] ) && ( $ data [ $ nodeName ] [ $ property ] != $ value ) ) { throw new InconsistentValueException ( "Attempting to overwrite '$property' value '" . $ data [ $ nodeName ] [ $ property ] . "' with '$value'." ) ; } $ data [ $ nodeName ] [ $ property ] = $ value ; } else { $ data [ $ nodeName ] = $ this -> storeValue ( $ nodePath , $ data [ $ nodeName ] , $ property , $ value ) ; } return $ data ; }
|
Store a particular value of a particular property for a given node .
|
804
|
private function handleUpgrade ( array $ node , NodePath $ nodePath , string $ newType ) { if ( ( ( $ node [ 'nodeType' ] == 'array' ) || ( $ newType == 'array' ) ) && $ this -> autoUpgradeToArray ) { $ this -> checkArrayUpgrade ( $ node , $ nodePath , $ newType ) ; if ( ! empty ( $ node [ self :: ARRAY_NAME ] ) ) { foreach ( $ node [ self :: ARRAY_NAME ] as $ key => $ value ) { $ newNode [ self :: ARRAY_NAME ] [ $ key ] = $ value ; } } foreach ( $ node as $ key => $ value ) { if ( is_array ( $ value ) && ( $ key != self :: ARRAY_NAME ) ) { $ newNode [ self :: ARRAY_NAME ] [ $ key ] = $ value ; } } if ( $ newType != 'array' ) { $ newNode [ self :: ARRAY_NAME ] [ 'nodeType' ] = $ newType ; } else { $ newNode [ self :: ARRAY_NAME ] [ 'nodeType' ] = $ node [ 'nodeType' ] ; } $ newNode [ 'nodeType' ] = 'array' ; if ( ! empty ( $ node [ 'headerNames' ] ) ) { $ newNode [ self :: ARRAY_NAME ] [ 'headerNames' ] = self :: DATA_COLUMN ; $ newNode [ 'headerNames' ] = $ node [ 'headerNames' ] ; } $ this -> data = $ this -> storeNode ( $ nodePath , $ this -> data , $ newNode ) ; } elseif ( ( $ node [ 'nodeType' ] != 'null' ) && ( $ newType == 'null' ) ) { } elseif ( ( $ node [ 'nodeType' ] == 'null' ) && ( $ newType != 'null' ) ) { $ newNode = $ this -> getNode ( $ nodePath ) ; $ newNode [ 'nodeType' ] = $ newType ; $ this -> data = $ this -> storeNode ( $ nodePath , $ this -> data , $ newNode ) ; } else { throw new JsonParserException ( 'Unhandled nodeType change from "' . $ node [ 'nodeType' ] . '" to "' . $ newType . '" in "' . $ nodePath -> __toString ( ) . '"' ) ; } }
|
Upgrade a node to array
|
805
|
public function getData ( ) { foreach ( $ this -> data as $ value ) { $ this -> validateDefinitions ( $ value ) ; } return [ 'data' => $ this -> data , 'parent_aliases' => $ this -> parentAliases ] ; }
|
Return complete structure .
|
806
|
public function getNode ( NodePath $ nodePath , array $ data = null ) { if ( empty ( $ data ) ) { $ data = $ this -> data ; } $ nodePath = $ nodePath -> popFirst ( $ nodeName ) ; $ nodeName = $ this -> encodeNodeName ( $ nodeName ) ; if ( ! isset ( $ data [ $ nodeName ] ) ) { return null ; } if ( $ nodePath -> isEmpty ( ) ) { return $ data [ $ nodeName ] ; } else { return $ this -> getNode ( $ nodePath , $ data [ $ nodeName ] ) ; } }
|
Get structure of a particular node .
|
807
|
public function getNodeProperty ( NodePath $ nodePath , string $ property ) { $ data = $ this -> getNode ( $ nodePath ) ; if ( isset ( $ data [ $ property ] ) ) { return $ data [ $ property ] ; } else { return null ; } }
|
Return a particular property of the node .
|
808
|
private function getNodeChildrenProperties ( NodePath $ nodePath , string $ property ) : array { $ nodeData = $ this -> getNode ( $ nodePath ) ; $ result = [ ] ; if ( ! empty ( $ nodeData ) ) { if ( $ nodeData [ 'nodeType' ] == 'object' ) { foreach ( $ nodeData as $ itemName => $ value ) { if ( is_array ( $ value ) ) { $ itemName = $ this -> decodeNodeName ( $ itemName ) ; if ( isset ( $ value [ $ property ] ) ) { $ result [ $ itemName ] = $ value [ $ property ] ; } else { $ result [ $ itemName ] = null ; } } } } elseif ( $ nodeData [ 'nodeType' ] == 'scalar' ) { foreach ( $ nodeData as $ itemName => $ value ) { if ( $ itemName == $ property ) { $ result [ $ nodePath -> getLast ( ) ] = $ value ; } } } } return $ result ; }
|
Return a particular property of a the children of the node .
|
809
|
public function getColumnTypes ( NodePath $ nodePath ) { $ values = $ this -> getNodeChildrenProperties ( $ nodePath , 'nodeType' ) ; $ result = [ ] ; foreach ( $ values as $ key => $ value ) { if ( $ key === self :: ARRAY_NAME ) { $ result [ self :: DATA_COLUMN ] = $ value ; } else { $ result [ $ key ] = $ value ; } } return $ result ; }
|
Get columns from a node and return their data types .
|
810
|
public function generateHeaderNames ( ) { foreach ( $ this -> data as $ baseType => & $ baseArray ) { foreach ( $ baseArray as $ nodeName => & $ nodeData ) { if ( is_array ( $ nodeData ) ) { $ nodeName = $ this -> decodeNodeName ( $ nodeName ) ; $ this -> generateHeaderName ( $ nodeData , new NodePath ( [ $ baseType , $ nodeName ] ) , self :: ARRAY_NAME , $ baseType ) ; } } } }
|
Generate header names for the whole structure .
|
811
|
public function getParentTargetName ( string $ name ) { if ( empty ( $ this -> parentAliases [ $ name ] ) ) { return $ name ; } return $ this -> parentAliases [ $ name ] ; }
|
Get new name of a parent column
|
812
|
private function getSafeName ( string $ name ) : string { $ name = preg_replace ( '/[^A-Za-z0-9-]/' , '_' , $ name ) ; if ( strlen ( $ name ) > 64 ) { if ( str_word_count ( $ name ) > 1 && preg_match_all ( '/\b(\w)/' , $ name , $ m ) ) { $ short = implode ( '' , $ m [ 1 ] ) ; } else { $ short = md5 ( $ name ) ; } $ short .= "_" ; $ remaining = 64 - strlen ( $ short ) ; $ nextSpace = strpos ( $ name , " " , ( strlen ( $ name ) - $ remaining ) ) ? : strpos ( $ name , "_" , ( strlen ( $ name ) - $ remaining ) ) ; $ newName = $ nextSpace === false ? $ short : $ short . substr ( $ name , $ nextSpace ) ; } else { $ newName = $ name ; } $ newName = preg_replace ( '/[^A-Za-z0-9-]+/' , '_' , $ newName ) ; $ newName = trim ( $ newName , "_" ) ; return $ newName ; }
|
If necessary change the name to a safe to store in database .
|
813
|
private function getUniqueName ( string $ baseType , string $ headerName ) : string { if ( isset ( $ this -> headerIndex [ $ baseType ] [ $ headerName ] ) ) { $ newName = $ headerName ; $ i = 0 ; while ( isset ( $ this -> headerIndex [ $ baseType ] [ $ newName ] ) ) { $ newName = $ headerName . '_u' . $ i ; $ i ++ ; } $ headerName = $ newName ; } $ this -> headerIndex [ $ baseType ] [ $ headerName ] = 1 ; return $ headerName ; }
|
If necessary change the name to a unique one .
|
814
|
private function generateHeaderName ( array & $ data , NodePath $ nodePath , string $ parentName , string $ baseType ) { if ( empty ( $ data [ 'headerNames' ] ) ) { if ( $ parentName != self :: ARRAY_NAME ) { $ headerName = $ this -> getSafeName ( $ parentName ) ; $ headerName = $ this -> getUniqueName ( $ baseType , $ headerName ) ; $ data [ 'headerNames' ] = $ headerName ; } else { $ data [ 'headerNames' ] = self :: DATA_COLUMN ; } } if ( $ data [ 'nodeType' ] == 'array' ) { $ baseType = $ baseType . '.' . $ parentName ; $ parentName = '' ; } foreach ( $ data as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ key = $ this -> decodeNodeName ( $ key ) ; if ( ! $ parentName || ( ! empty ( $ data [ $ key ] [ 'type' ] ) && $ data [ $ key ] [ 'type' ] == 'parent' ) ) { $ childName = $ key ; } else { $ childName = $ parentName . '.' . $ key ; } $ this -> generateHeaderName ( $ value , $ nodePath -> addChild ( $ key ) , $ childName , $ baseType ) ; } } }
|
Generate header name for a node and sub - nodes .
|
815
|
public function load ( array $ definitions ) { $ this -> data = $ definitions [ 'data' ] ?? [ ] ; $ this -> parentAliases = $ definitions [ 'parent_aliases' ] ?? [ ] ; foreach ( $ this -> data as $ value ) { $ this -> validateDefinitions ( $ value ) ; } }
|
Load structure data .
|
816
|
public function configure ( $ model , $ name ) { return $ this -> form -> of ( "orchestra.extension: {$name}" , function ( FormGrid $ form ) use ( $ model , $ name ) { $ form -> setup ( $ this , "orchestra::extensions/{$name}/configure" , $ model ) ; $ handles = data_get ( $ model , 'handles' , $ this -> extension -> option ( $ name , 'handles' ) ) ; $ configurable = data_get ( $ model , 'configurable' , true ) ; if ( ! is_null ( $ handles ) && $ configurable !== false ) { $ form -> fieldset ( function ( Fieldset $ fieldset ) use ( $ handles ) { $ fieldset -> control ( 'input:text' , 'handles' ) -> label ( trans ( 'orchestra/foundation::label.extensions.handles' ) ) -> value ( str_replace ( [ '{{domain}}' , '{domain}' ] , '{domain}' , $ handles ) ) ; } ) ; } } ) ; }
|
Form View Generator for Orchestra \ Extension .
|
817
|
protected function refreshApplication ( Foundation $ foundation , Memory $ memory ) : void { if ( ! $ foundation -> installed ( ) ) { $ this -> error ( 'Abort as application is not installed!' ) ; return ; } $ this -> call ( 'extension:detect' , [ '--quiet' => true ] ) ; try { Collection :: make ( $ memory -> get ( 'extensions.active' , [ ] ) ) -> keys ( ) -> each ( function ( $ extension ) { $ options = [ 'name' => $ extension , '--force' => true ] ; $ this -> call ( 'extension:refresh' , $ options ) ; $ this -> call ( 'extension:update' , $ options ) ; } ) ; $ this -> laravel -> make ( 'orchestra.extension.provider' ) -> writeFreshManifest ( ) ; } catch ( PDOException $ e ) { } }
|
Refresh application for Orchestra Platform .
|
818
|
protected function optimizeApplication ( ) : void { $ this -> info ( 'Optimizing application for Orchestra Platform' ) ; $ this -> call ( 'config:clear' ) ; $ this -> call ( 'route:clear' ) ; if ( $ this -> laravel -> environment ( 'production' ) && ! $ this -> option ( 'no-cache' ) ) { $ this -> call ( 'config:cache' ) ; $ this -> call ( 'route:cache' ) ; } }
|
Optimize application for Orchestra Platform .
|
819
|
protected function updateRequest ( ) { $ headers = [ ] ; foreach ( $ this -> all ( ) as $ key => $ values ) { foreach ( $ values as $ value ) { $ headers [ ] = $ key . ': ' . $ value ; } } $ this -> request -> setOption ( CURLOPT_HTTPHEADER , $ headers ) ; }
|
Updates the headers in the associated request .
|
820
|
protected function changePermission ( string $ path , $ mode = 0755 , bool $ recursively = false ) : void { $ filesystem = $ this -> getContainer ( ) [ 'files' ] ; $ filesystem -> chmod ( $ path , $ mode ) ; if ( $ recursively === false ) { return ; } $ lists = $ filesystem -> allFiles ( $ path ) ; $ ignoredPath = function ( $ dir ) { return ( \ substr ( $ dir , - 3 ) === '/..' || \ substr ( $ dir , - 2 ) === '/.' ) ; } ; if ( $ lists !== [ $ path ] ) { foreach ( $ lists as $ dir ) { if ( ! $ ignoredPath ( $ dir ) ) { $ this -> changePermission ( $ dir , $ mode , true ) ; } } } }
|
Change CHMOD permission .
|
821
|
protected function prepareDirectory ( string $ path , $ mode = 0755 ) : void { $ filesystem = $ this -> getContainer ( ) [ 'files' ] ; if ( ! $ filesystem -> isDirectory ( $ path ) ) { $ filesystem -> makeDirectory ( $ path , $ mode , true ) ; } }
|
Prepare destination directory .
|
822
|
protected function basePath ( string $ path ) : string { if ( \ preg_match ( '/^\/(home)\/([a-zA-Z0-9]+)\/(.*)$/' , $ path , $ matches ) ) { $ path = '/' . \ ltrim ( $ matches [ 3 ] , '/' ) ; } return $ path ; }
|
Get base path for FTP .
|
823
|
protected function destination ( string $ name , bool $ recursively = false ) : Fluent { $ filesystem = $ this -> getContainer ( ) [ 'files' ] ; $ publicPath = $ this -> basePath ( $ this -> getContainer ( ) [ 'path.public' ] ) ; $ publicPath = \ rtrim ( $ publicPath , '/' ) . '/' ; $ workingPath = $ basePath = "{$publicPath}packages/" ; if ( $ filesystem -> isDirectory ( $ folder = "{$basePath}{$name}/" ) ) { $ recursively = true ; $ workingPath = $ folder ; } if ( ! $ recursively && Str :: contains ( $ name , '/' ) ) { [ $ vendor , ] = \ explode ( '/' , $ name ) ; if ( $ filesystem -> isDirectory ( $ folder = "{$basePath}{$vendor}/" ) ) { $ workingPath = $ folder ; } } return new Fluent ( [ 'workingPath' => $ workingPath , 'basePath' => $ basePath , 'resursively' => $ recursively , ] ) ; }
|
Check upload path .
|
824
|
public static function rowcol ( $ row = 1 , $ col = 1 ) { $ row = intval ( $ row ) ; $ col = intval ( $ col ) ; if ( $ row < 0 ) { $ row = Misc :: rows ( ) + $ row + 1 ; } if ( $ col < 0 ) { $ col = Misc :: cols ( ) + $ col + 1 ; } fwrite ( self :: $ stream , "\033[{$row};{$col}f" ) ; }
|
Move the cursor to a specific row and column
|
825
|
protected function registerPublisher ( ) : void { $ this -> app -> singleton ( 'orchestra.publisher' , function ( Application $ app ) { $ memory = $ app -> make ( 'orchestra.platform.memory' ) ; return ( new PublisherManager ( $ app ) ) -> attach ( $ memory ) ; } ) ; }
|
Register the service provider for publisher .
|
826
|
public function update ( Listener $ listener , array $ input ) { $ user = Auth :: user ( ) ; if ( ! $ this -> validateCurrentUser ( $ user , $ input ) ) { return $ listener -> abortWhenUserMismatched ( ) ; } $ validation = $ this -> validator -> on ( 'update' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> updateProfileFailedValidation ( $ validation -> getMessageBag ( ) ) ; } try { $ this -> saving ( $ user , $ input ) ; } catch ( Exception $ e ) { return $ listener -> updateProfileFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> profileUpdated ( ) ; }
|
Update profile information .
|
827
|
protected function saving ( $ user , array $ input ) { $ user -> setAttribute ( 'email' , $ input [ 'email' ] ) ; $ user -> setAttribute ( 'fullname' , $ input [ 'fullname' ] ) ; $ this -> fireEvent ( 'updating' , [ $ user ] ) ; $ this -> fireEvent ( 'saving' , [ $ user ] ) ; $ user -> saveOrFail ( ) ; $ this -> fireEvent ( 'updated' , [ $ user ] ) ; $ this -> fireEvent ( 'saved' , [ $ user ] ) ; }
|
Save user profile .
|
828
|
protected function addRequiredForSecretField ( ValidatorResolver $ resolver , $ field , $ hidden ) { $ resolver -> sometimes ( $ field , 'required' , function ( $ input ) use ( $ hidden ) { return $ input -> $ hidden == 'yes' ; } ) ; }
|
Add required for secret or password field .
|
829
|
public function show ( Listener $ listener ) { $ panes = $ this -> widget -> make ( 'pane.orchestra' ) ; return $ listener -> showDashboard ( [ 'panes' => $ panes ] ) ; }
|
View dashboard .
|
830
|
public function add ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ innerKey => $ innerValue ) { Arr :: set ( $ this -> variables , $ innerKey , $ innerValue ) ; } } elseif ( $ key instanceof Closure ) { $ this -> variables [ ] = $ key ; } else { Arr :: set ( $ this -> variables , $ key , $ value ) ; } return $ this ; }
|
Add a variable .
|
831
|
public function render ( $ namespace = 'config' ) { foreach ( $ this -> variables as $ key => $ variable ) { if ( $ variable instanceof Closure ) { $ variable = $ variable ( ) ; if ( is_array ( $ variable ) ) { $ this -> add ( $ variable ) ; } } } $ variables = array_filter ( $ this -> variables , function ( $ variable ) { return ! $ variable instanceof Closure ; } ) ; return new HtmlString ( '<script>window.' . $ namespace . ' = ' . json_encode ( $ variables ) . ';</script>' ) ; }
|
Render as a HTML string .
|
832
|
public static function string ( $ str , $ row = null , $ col = null ) { if ( $ col !== null || $ row !== null ) { Cursor :: rowcol ( $ row , $ col ) ; } fwrite ( self :: $ stream , $ str ) ; }
|
Output a string
|
833
|
public static function line ( $ str , $ col = null , $ erase = true ) { if ( $ col !== null ) { Cursor :: rowcol ( $ col , 1 ) ; } if ( $ erase ) { Erase :: line ( ) ; } fwrite ( self :: $ stream , $ str ) ; }
|
Output a line erasing the line first
|
834
|
public function exist ( $ id ) { $ entity = $ this -> entityQuery -> get ( 'site_commerce_type' ) -> condition ( 'id' , $ id ) -> execute ( ) ; return ( bool ) $ entity ; }
|
Helper function to check whether an SiteCommerceType configuration entity exists .
|
835
|
public function begin ( ) { $ this -> current = $ this -> current instanceof Transaction ? $ this -> current -> newTransaction ( ) : new Transaction ; }
|
Should be called after transaction started .
|
836
|
public function commit ( ) { $ this -> assert ( ) ; $ current = $ this -> current ; $ this -> current = $ current -> getParentKeepingChildren ( ) ; if ( ! $ this -> current instanceof Transaction ) { foreach ( $ current -> flatten ( ) as $ payload ) { $ payload -> fire ( ) ; } } }
|
Should be called after transaction committed .
|
837
|
protected function dispatch ( DelayedEvent $ event ) { if ( $ this -> current instanceof Transaction ) { $ this -> current -> attach ( $ event ) ; } else { $ event -> fire ( ) ; } }
|
Dispaches payload .
|
838
|
protected function getPatternFilters ( $ route ) { $ patterns = [ ] ; foreach ( $ route -> methods ( ) as $ method ) { $ inner = $ this -> getMethodPatterns ( $ route -> uri ( ) , $ method ) ; $ patterns = array_merge ( $ patterns , array_keys ( $ inner ) ) ; } return $ patterns ; }
|
Get all of the pattern filters matching the route .
|
839
|
protected function getMethodPatterns ( $ uri , $ method ) { return $ this -> router -> findPatternFilters ( Request :: create ( $ uri , $ method ) ) ; }
|
Get the pattern filters for a given URI and method .
|
840
|
public function queue ( $ queue ) : bool { $ queue = \ array_unique ( \ array_merge ( $ this -> queued ( ) , ( array ) $ queue ) ) ; $ this -> memory -> put ( 'orchestra.publisher.queue' , $ queue ) ; return true ; }
|
Add a process to be queue .
|
841
|
public function widget ( string $ type ) { return ! \ is_null ( $ this -> widget ) ? $ this -> widget -> make ( "{$type}.orchestra" ) : null ; }
|
Get widget services by type .
|
842
|
protected function createAdminMenu ( ) : void { $ menu = $ this -> menu ( ) ; $ events = $ this -> app -> make ( 'events' ) ; $ handlers = [ UserMenuHandler :: class , ExtensionMenuHandler :: class , SettingMenuHandler :: class , ] ; $ menu -> add ( 'home' ) -> title ( \ trans ( 'orchestra/foundation::title.home' ) ) -> link ( $ this -> handles ( 'orchestra::/' ) ) -> icon ( 'home' ) ; foreach ( $ handlers as $ handler ) { $ events -> listen ( 'orchestra.started: admin' , $ handler ) ; } }
|
Create Administration Menu for Orchestra Platform .
|
843
|
protected function registerComponents ( MemoryProvider $ memory ) : void { $ this -> app -> make ( 'orchestra.notifier' ) -> setDefaultDriver ( 'orchestra' ) ; $ this -> app -> make ( 'orchestra.mail' ) -> attach ( $ memory ) ; }
|
Register base application components .
|
844
|
public static function forge ( RequestInterface $ request ) { $ headerSize = $ request -> getInfo ( CURLINFO_HEADER_SIZE ) ; $ response = $ request -> getRawResponse ( ) ; $ content = ( strlen ( $ response ) === $ headerSize ) ? '' : substr ( $ response , $ headerSize ) ; $ rawHeaders = rtrim ( substr ( $ response , 0 , $ headerSize ) ) ; $ headers = [ ] ; foreach ( preg_split ( '/(\\r?\\n)/' , $ rawHeaders ) as $ header ) { if ( $ header ) { $ headers [ ] = $ header ; } else { $ headers = [ ] ; } } $ headerBag = [ ] ; $ info = $ request -> getInfo ( ) ; $ status = explode ( ' ' , $ headers [ 0 ] ) ; $ status = explode ( '/' , $ status [ 0 ] ) ; unset ( $ headers [ 0 ] ) ; foreach ( $ headers as $ header ) { $ headerPair = explode ( ': ' , $ header ) ; if ( count ( $ headerPair ) > 1 ) { list ( $ key , $ value ) = $ headerPair ; $ headerBag [ trim ( $ key ) ] = trim ( $ value ) ; } } $ response = new static ( $ content , $ info [ 'http_code' ] , $ headerBag ) ; $ response -> setProtocolVersion ( $ status [ 1 ] ) ; $ response -> setCharset ( substr ( strstr ( $ response -> headers -> get ( 'Content-Type' ) , '=' ) , 1 ) ) ; return $ response ; }
|
Forge a new object based on a request .
|
845
|
public function cartBlock ( $ pid ) { $ site_commerce = $ this -> entityTypeManager -> getStorage ( 'site_commerce' ) -> load ( $ pid ) ; $ position_in_cart = FALSE ; $ databaseSendOrder = \ Drupal :: service ( 'site_orders.database' ) ; if ( $ databaseSendOrder -> hasPositionInCart ( $ site_commerce -> getEntityTypeId ( ) , $ site_commerce -> id ( ) ) ) { $ position_in_cart = TRUE ; } $ type = 'default' ; if ( $ position_in_cart ) { $ type = $ site_commerce -> get ( 'field_cart' ) -> event ; } return [ '#theme' => 'site_commerce_cart_block' , '#site_commerce' => $ site_commerce , '#type' => $ type , ] ; }
|
Callback lazy builder for to cart block .
|
846
|
public function parametrsBlock ( $ id ) { $ databaseSendOrder = \ Drupal :: service ( 'site_orders.database' ) ; $ site_commerce = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'site_commerce' ) -> load ( $ id ) ; $ items = $ site_commerce -> get ( 'field_parametrs' ) -> getValue ( ) ; $ values = [ ] ; foreach ( $ items as $ delta => $ item ) { $ item = ( object ) $ item ; $ hasParametrInCart = $ databaseSendOrder -> hasPositionInCart ( 'site_commerce_parametr' , $ id , $ delta ) ; if ( $ item -> target_id ) { $ position = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'site_commerce' ) -> load ( $ item -> target_id ) ; if ( $ position ) { $ group = 1 ; $ cost = getCostValueForUserPriceGroup ( $ position , $ group , FALSE , FALSE ) ; $ values [ $ delta ] = array ( 'id' => $ id , 'target_id' => $ item -> target_id , 'position' => $ position , 'site_commerce' => $ site_commerce , 'name' => $ item -> name , 'description' => $ item -> description , 'min' => $ position -> field_quantity -> min , 'unit' => $ position -> field_quantity -> unit , 'cost' => $ cost [ 'value' ] , 'currency' => $ cost [ 'currency' ] , 'select' => $ item -> select , 'in_cart' => $ hasParametrInCart , ) ; } } else { $ values [ $ delta ] = array ( 'id' => $ id , 'target_id' => $ item -> target_id , 'position' => NULL , 'site_commerce' => $ site_commerce , 'name' => $ item -> name , 'description' => $ item -> description , 'min' => $ item -> min , 'unit' => $ item -> unit , 'cost' => \ Drupal :: service ( 'kvantstudio.formatter' ) -> price ( $ item -> cost ) , 'currency' => $ item -> currency , 'select' => $ item -> select , 'in_cart' => $ hasParametrInCart , ) ; } } return [ '#theme' => 'site_commerce_parametrs_default_formatter' , '#values' => $ values , '#attached' => array ( 'library' => array ( 'site_commerce/product_parametrs' , 'site_orders/module' , ) , ) , ] ; }
|
Callback lazy builder for parametrs block .
|
847
|
public static function cols ( $ cache = true ) { static $ cols = false ; if ( ! $ cols || ! $ cache ) { $ cols = intval ( `tput cols`); } return $cols ? : 80; } /** * The row size of the current terminal as returned by tput * * @staticvar bool|int $rows the cached value for the number of columns * @param bool $cache Whether to cache the response * @return int */ public static function rows( $cache = true ) { static $rows = false; if( !$rows || !$cache ) { $rows = intval(`tput lines` ) ; } return $ rows ? : 24 ; }
|
The col size of the current terminal as returned by tput
|
848
|
public function createProfileFailed ( array $ errors ) { messages ( 'error' , trans ( 'orchestra/foundation::response.db-failed' , $ errors ) ) ; return $ this -> redirect ( $ this -> getRedirectToRegisterPath ( ) ) -> withInput ( ) ; }
|
Response when create a user failed .
|
849
|
public function showResetForm ( $ token = null ) { if ( is_null ( $ token ) ) { return $ this -> showLinkRequestForm ( ) ; } $ email = Request :: input ( 'email' ) ; set_meta ( 'title' , trans ( 'orchestra/foundation::title.reset-password' ) ) ; return view ( 'orchestra/foundation::forgot.reset' , compact ( 'email' , 'token' ) ) ; }
|
Once user actually visit the reset my password page we now should be able to make the operation to create a new password .
|
850
|
public function reset ( Processor $ processor ) { $ input = Request :: only ( 'email' , 'password' , 'password_confirmation' , 'token' ) ; return $ processor -> update ( $ this , $ input ) ; }
|
Create a new password for the user .
|
851
|
public function passwordResetHasFailed ( $ response ) { $ message = trans ( $ response ) ; $ token = Request :: input ( 'token' ) ; return $ this -> redirectWithMessage ( handles ( "orchestra::forgot/reset/{$token}" ) , $ message , 'error' ) ; }
|
Response when reset password failed .
|
852
|
public function toCleanString ( ) : string { $ path = array_filter ( $ this -> path , function ( $ val ) { return $ val != Structure :: ARRAY_NAME ; } ) ; return implode ( '.' , $ path ) ; }
|
Convert path to user - display string .
|
853
|
public function addChild ( string $ key ) : NodePath { $ path = $ this -> path ; $ path [ ] = $ key ; return new NodePath ( $ path ) ; }
|
Return new path with an added child .
|
854
|
public function popFirst ( & $ first ) : NodePath { $ path = $ this -> path ; $ first = array_shift ( $ path ) ; return new NodePath ( $ path ) ; }
|
Remove the first item from path and return new path
|
855
|
private function getValue ( $ input , $ alternative ) { if ( empty ( $ input ) ) { $ input = Config :: get ( $ alternative ) ; } return $ input ; }
|
Resolve value or grab from configuration .
|
856
|
public function migrationHasSucceed ( Fluent $ extension ) { $ message = trans ( 'orchestra/foundation::response.extensions.migrate' , $ extension -> getAttributes ( ) ) ; return $ this -> redirectWithMessage ( handles ( 'orchestra::extensions' ) , $ message ) ; }
|
Response when extension migration has succeed .
|
857
|
protected function redirectUserTo ( string $ namespace , string $ path , ? string $ redirect = null ) : string { return \ handles ( $ this -> redirectUserPath ( $ namespace , $ path , $ redirect ) ) ; }
|
Get redirection handles .
|
858
|
protected function redirectUserPath ( string $ namespace , string $ path , ? string $ redirect = null ) : string { if ( ! empty ( $ redirect ) ) { $ path = $ redirect ; } $ property = \ sprintf ( 'redirect%sPath' , Str :: ucfirst ( $ namespace ) ) ; return \ property_exists ( $ this , $ property ) ? $ this -> { $ property } : $ path ; }
|
Get redirection path .
|
859
|
public static function toSerialize ( $ resource ) { if ( ! self :: isArray ( $ resource ) ) { $ resource = self :: toArray ( $ resource ) ; } return serialize ( $ resource ) ; }
|
Transforms a resource into a serialized form .
|
860
|
public static function utf8Encode ( $ data ) { if ( is_string ( $ data ) ) { return utf8_encode ( $ data ) ; } else if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ data [ utf8_encode ( $ key ) ] = self :: utf8Encode ( $ value ) ; } } else if ( is_object ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ data -> { $ key } = self :: utf8Encode ( $ value ) ; } } return $ data ; }
|
Encode a resource object for UTF - 8 .
|
861
|
public static function utf8Decode ( $ data ) { if ( is_string ( $ data ) ) { return utf8_decode ( $ data ) ; } else if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ data [ utf8_decode ( $ key ) ] = self :: utf8Decode ( $ value ) ; } } else if ( is_object ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ data -> { $ key } = self :: utf8Decode ( $ value ) ; } } return $ data ; }
|
Decode a resource object for UTF - 8 .
|
862
|
public function form ( $ model ) { return $ this -> form -> of ( 'orchestra.settings' , function ( FormGrid $ form ) use ( $ model ) { $ form -> setup ( $ this , 'orchestra::settings' , $ model ) ; $ this -> application ( $ form ) ; $ this -> mailer ( $ form , $ model ) ; } ) ; }
|
Form View Generator for Setting Page .
|
863
|
protected function indexStep ( $ step ) { $ text = '<h1>' . $ step -> title . '</h1> ' ; $ text .= $ step -> description . ' ' ; $ text = trim ( $ text ) ; $ language = \ Drupal :: languageManager ( ) -> getCurrentLanguage ( ) ; $ transliteration = \ Drupal :: service ( 'transliteration' ) ; $ text_transliterate .= $ transliteration -> transliterate ( $ text , $ language -> getId ( ) ) ; $ text = $ text . $ text_transliterate . ' ' ; $ extra = \ Drupal :: moduleHandler ( ) -> invokeAll ( 'step_update_index' , [ $ step ] ) ; foreach ( $ extra as $ t ) { $ text .= $ t ; } search_index ( $ this -> getPluginId ( ) , $ step -> course_esid , $ language -> getId ( ) , $ text ) ; }
|
Indexes a single step .
|
864
|
public function table ( $ model ) { return $ this -> table -> of ( 'orchestra.users' , function ( TableGrid $ table ) use ( $ model ) { $ table -> with ( $ model ) ; $ table -> sortable ( $ this -> getSortableFields ( ) ) ; $ table -> layout ( 'orchestra/foundation::components.table' ) ; $ this -> prependTableColumns ( $ model , $ table ) ; $ table -> column ( 'fullname' ) -> label ( trans ( 'orchestra/foundation::label.users.fullname' ) ) -> escape ( false ) -> value ( $ this -> getFullnameColumn ( ) ) ; $ table -> column ( 'email' ) -> label ( trans ( 'orchestra/foundation::label.users.email' ) ) ; $ this -> appendTableColumns ( $ model , $ table ) ; } ) ; }
|
Table View Generator for Orchestra \ Model \ User .
|
865
|
public function form ( $ model ) { return $ this -> form -> of ( 'orchestra.users' , function ( FormGrid $ form ) use ( $ model ) { $ form -> resource ( $ this , 'orchestra/foundation::users' , $ model ) ; $ form -> hidden ( 'id' ) ; $ form -> fieldset ( function ( Fieldset $ fieldset ) { $ fieldset -> control ( 'input:text' , 'email' ) -> label ( trans ( 'orchestra/foundation::label.users.email' ) ) ; $ fieldset -> control ( 'input:text' , 'fullname' ) -> label ( trans ( 'orchestra/foundation::label.users.fullname' ) ) ; $ fieldset -> control ( 'input:password' , 'password' ) -> label ( trans ( 'orchestra/foundation::label.users.password' ) ) ; $ fieldset -> control ( 'select' , 'roles[]' ) -> label ( trans ( 'orchestra/foundation::label.users.roles' ) ) -> attributes ( [ 'multiple' => true ] ) -> options ( function ( ) { $ roles = app ( 'orchestra.role' ) ; return $ roles -> pluck ( 'name' , 'id' ) ; } ) -> value ( function ( $ user ) { return $ user -> roles ( ) -> get ( ) -> pluck ( 'id' ) -> all ( ) ; } ) ; } ) ; } ) ; }
|
Form View Generator for Orchestra \ Model \ User .
|
866
|
protected function getFullnameColumn ( ) { return function ( $ row ) { $ roles = $ row -> roles ; $ value = [ ] ; foreach ( $ roles as $ role ) { $ value [ ] = app ( 'html' ) -> create ( 'span' , e ( $ role -> name ) , [ 'class' => 'label label-info' , 'role' => 'role' , ] ) ; } return implode ( '' , [ app ( 'html' ) -> create ( 'strong' , e ( $ row -> fullname ) ) , app ( 'html' ) -> create ( 'br' ) , app ( 'html' ) -> create ( 'span' , app ( 'html' ) -> raw ( implode ( ' ' , $ value ) ) , [ 'class' => 'meta' , ] ) , ] ) ; } ; }
|
Get fullname column for table builder .
|
867
|
protected function getEntityIds ( ) { $ query = $ this -> getStorage ( ) -> getQuery ( ) -> sort ( $ this -> entityType -> getKey ( 'id' ) , 'DESC' ) ; $ this -> limit = 1000 ; if ( $ this -> limit ) { $ query -> pager ( $ this -> limit ) ; } return $ query -> execute ( ) ; }
|
Loads entity IDs using a pager sorted by the entity id .
|
868
|
protected function getDefaultOperations ( EntityInterface $ entity ) { $ operations = [ ] ; if ( $ entity -> access ( 'update' ) && $ entity -> hasLinkTemplate ( 'edit-form' ) ) { $ operations [ 'edit' ] = [ 'title' => $ this -> t ( 'Edit' ) , 'weight' => 10 , 'url' => $ entity -> urlInfo ( 'edit-form' ) , ] ; } if ( $ entity -> access ( 'delete' ) && $ entity -> hasLinkTemplate ( 'delete-form' ) ) { $ operations [ 'delete' ] = [ 'title' => $ this -> t ( 'Delete' ) , 'weight' => 100 , 'url' => $ entity -> urlInfo ( 'delete-form' ) , ] ; } return $ operations ; }
|
Gets this list s default operations .
|
869
|
public function store ( PasswordResetLink $ listener , array $ input ) { $ validation = $ this -> validator -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> resetLinkFailedValidation ( $ validation -> getMessageBag ( ) ) ; } $ response = $ this -> password -> sendResetLink ( [ 'email' => $ input [ 'email' ] ] ) ; if ( $ response != Password :: RESET_LINK_SENT ) { return $ listener -> resetLinkFailed ( $ response ) ; } return $ listener -> resetLinkSent ( $ response ) ; }
|
Request to reset password .
|
870
|
protected function queueToPublisher ( Fluent $ extension ) { Publisher :: queue ( $ extension -> get ( 'name' ) ) ; return $ this -> redirect ( handles ( 'orchestra::publisher' ) ) ; }
|
Queue publishing asset to publisher .
|
871
|
private function checkType ( $ oldType , $ newType , NodePath $ nodePath ) : string { if ( ! is_null ( $ oldType ) && ( $ newType !== $ oldType ) && ( $ newType !== 'null' ) && ( $ oldType !== 'null' ) ) { throw new JsonParserException ( "Data in '$nodePath' contains incompatible data types '$oldType' and '$newType'." ) ; } return $ newType ; }
|
Check that two types same or compatible .
|
872
|
protected function getExtension ( $ vendor , $ package = null ) { $ name = ( is_null ( $ package ) ? $ vendor : implode ( '/' , [ $ vendor , $ package ] ) ) ; return new Fluent ( [ 'name' => $ name , 'uid' => $ name ] ) ; }
|
Get extension information .
|
873
|
public function login ( Listener $ listener , array $ input , ThrottlesCommand $ throttles = null ) { $ validation = $ this -> validator -> on ( 'login' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> userLoginHasFailedValidation ( $ validation -> getMessageBag ( ) ) ; } if ( $ this -> hasTooManyAttempts ( $ throttles ) ) { return $ this -> handleUserHasTooManyAttempts ( $ listener , $ input , $ throttles ) ; } if ( $ this -> authenticate ( $ input ) ) { return $ this -> handleUserWasAuthenticated ( $ listener , $ input , $ throttles ) ; } return $ this -> handleUserFailedAuthentication ( $ listener , $ input , $ throttles ) ; }
|
Login a user .
|
874
|
protected function handleUserHasTooManyAttempts ( Listener $ listener , array $ input , ThrottlesCommand $ throttles = null ) { $ throttles -> incrementLoginAttempts ( ) ; $ throttles -> fireLockoutEvent ( ) ; return $ listener -> sendLockoutResponse ( $ input , $ throttles -> getSecondsBeforeNextAttempts ( ) ) ; }
|
Send the response after the user has too many attempts .
|
875
|
protected function handleUserFailedAuthentication ( Listener $ listener , array $ input , ThrottlesCommand $ throttles = null ) { if ( $ throttles ) { $ throttles -> incrementLoginAttempts ( ) ; } return $ listener -> userLoginHasFailedAuthentication ( $ input ) ; }
|
Send the response after the user failed authentication .
|
876
|
protected function verifyWhenFirstTimeLogin ( Eloquent $ user ) { if ( ( int ) $ user -> getAttribute ( 'status' ) === Eloquent :: UNVERIFIED ) { $ user -> activate ( ) -> save ( ) ; } return $ user ; }
|
Verify user account if has not been verified other this should be ignored in most cases .
|
877
|
public function setOption ( $ option , $ value = null ) { if ( is_array ( $ option ) ) { foreach ( $ option as $ opt => $ val ) { $ this -> setOption ( $ opt , $ val ) ; } return ; } if ( array_key_exists ( $ option , $ this -> defaults ) ) { throw new ProtectedOptionException ( sprintf ( 'Unable to set protected option #%u' , $ option ) ) ; } if ( curl_setopt ( $ this -> handle , $ option , $ value ) === false ) { throw new CurlErrorException ( sprintf ( 'Couldn\'t set option #%u' , $ option ) ) ; } }
|
Set an option for the request .
|
878
|
protected function attachAccessPolicyEvents ( Application $ app ) { Role :: observe ( $ app -> make ( RoleObserver :: class ) ) ; Role :: setDefaultRoles ( \ config ( 'orchestra/foundation::roles' ) ) ; }
|
Attach access policy events .
|
879
|
public static function delete ( $ urls , $ data = null , callable $ callback = null ) { return static :: make ( 'delete' , $ urls , $ data , $ callback ) ; }
|
Make one or multiple DELETE requests .
|
880
|
public static function get ( $ urls , $ data = null , callable $ callback = null ) { return static :: make ( 'get' , $ urls , $ data , $ callback ) ; }
|
Make one or multiple GET requests .
|
881
|
public static function post ( $ urls , $ data = null , callable $ callback = null ) { return static :: make ( 'post' , $ urls , $ data , $ callback ) ; }
|
Make one or multiple POST requests .
|
882
|
public static function put ( $ urls , $ data = null , callable $ callback = null ) { return static :: make ( 'put' , $ urls , $ data , $ callback ) ; }
|
Make one or multiple PUT requests .
|
883
|
protected static function make ( $ verb , $ urls , $ data , callable $ callback = null ) { if ( ! is_array ( $ urls ) ) { $ urls = [ $ urls => $ data ] ; } elseif ( ! ( bool ) count ( array_filter ( array_keys ( $ urls ) , 'is_string' ) ) ) { foreach ( $ urls as $ key => $ url ) { $ urls [ $ url ] = null ; unset ( $ urls [ $ key ] ) ; } } $ dispatcher = new Dispatcher ; $ requests = [ ] ; $ dataStore = [ ] ; foreach ( $ urls as $ url => $ data ) { $ requests [ ] = new Request ( $ url ) ; $ dataStore [ ] = $ data ; } new static ( $ verb , $ dispatcher , $ requests , $ dataStore , $ callback ) ; $ requests = $ dispatcher -> all ( ) ; $ responses = [ ] ; foreach ( $ requests as $ request ) { $ responses [ ] = $ request -> getResponse ( ) ; } return $ responses ; }
|
Make one or multiple requests .
|
884
|
protected function makeRequest ( callable $ callback = null ) { foreach ( $ this -> requests as $ key => $ request ) { $ data = ( isset ( $ this -> data [ $ key ] ) and $ this -> data [ $ key ] !== null ) ? $ this -> data [ $ key ] : null ; $ request -> setOption ( CURLOPT_FOLLOWLOCATION , true ) ; switch ( $ this -> verb ) { case 'DELETE' : $ this -> prepareDeleteRequest ( $ request ) ; break ; case 'GET' : $ this -> prepareGetRequest ( $ request ) ; break ; case 'POST' : $ this -> preparePostRequest ( $ request , $ data ) ; break ; case 'PUT' : $ this -> preparePutRequest ( $ request , $ data ) ; break ; } $ this -> dispatcher -> add ( $ request ) ; } if ( $ callback !== null ) { $ this -> dispatcher -> execute ( $ callback ) ; } else { $ this -> dispatcher -> execute ( ) ; } }
|
Prepares and sends HTTP requests .
|
885
|
protected function preparePostRequest ( RequestInterface $ request , $ data ) { if ( $ data !== null ) { $ request -> setOption ( CURLOPT_POST , true ) ; $ request -> setOption ( CURLOPT_POSTFIELDS , $ data ) ; } else { $ request -> setOption ( CURLOPT_CUSTOMREQUEST , 'POST' ) ; } }
|
Sets a request s HTTP verb to POST .
|
886
|
protected function preparePutRequest ( RequestInterface $ request , $ data ) { $ request -> setOption ( CURLOPT_CUSTOMREQUEST , 'PUT' ) ; if ( $ data !== null ) { $ request -> setOption ( CURLOPT_POSTFIELDS , $ data ) ; } }
|
Sets a request s HTTP verb to PUT .
|
887
|
protected function getUniqueLoginKey ( ) { $ key = $ this -> request -> input ( $ this -> loginKey ) ; $ ip = $ this -> request -> ip ( ) ; return \ mb_strtolower ( $ key ) . $ ip ; }
|
Get the login key .
|
888
|
public function upload ( string $ name ) : bool { $ app = $ this -> getContainer ( ) ; $ config = $ this -> destination ( $ name , $ recursively ) ; try { $ basePath = "{$config->basePath}{$name}/" ; $ this -> changePermission ( $ config -> workingPath , 0777 , $ config -> recursively ) ; $ this -> prepareDirectory ( $ basePath , 0777 ) ; } catch ( RuntimeException $ e ) { } $ app [ 'orchestra.extension' ] -> activate ( $ name ) ; $ this -> changePermission ( $ config -> workingPath , 0755 , $ config -> recursively ) ; return true ; }
|
Upload the file .
|
889
|
public function prepare ( ) { $ id = $ this -> getAttribute ( 'id' ) ; $ menus = $ this -> menu [ 'with' ] ?? [ ] ; $ parent = $ this -> getAttribute ( 'position' ) ; $ position = Str :: startsWith ( $ parent , '^:' ) ? $ parent . '.' : '^:' ; foreach ( ( array ) $ menus as $ class ) { $ menu = $ this -> container -> make ( $ class ) -> setAttribute ( 'position' , "{$position}{$id}" ) -> prepare ( ) ; if ( $ menu -> passes ( ) ) { $ this -> childs [ ] = $ menu ; } } $ this -> name = $ id ; $ this -> showToUser = $ this -> passesAuthorization ( ) ; return $ this ; }
|
Prepare nested menu .
|
890
|
protected function passesAuthorization ( ) : bool { $ passes = false ; if ( \ method_exists ( $ this , 'authorize' ) ) { $ passes = $ this -> container -> call ( [ $ this , 'authorize' ] ) ; } return ( bool ) $ passes ; }
|
Determine if the request passes the authorization check .
|
891
|
protected function buildStacks ( ) { $ stacks = [ ] ; $ stackNo = 0 ; $ currSize = 0 ; foreach ( $ this -> requests as $ request ) { if ( $ currSize === $ this -> stackSize ) { $ currSize = 0 ; $ stackNo ++ ; } $ stacks [ $ stackNo ] [ ] = $ request ; $ currSize ++ ; } return $ stacks ; }
|
Builds stacks of requests .
|
892
|
protected function dispatch ( ) { list ( $ mrc , $ active ) = $ this -> process ( ) ; while ( $ active and $ mrc === CURLM_OK ) { list ( $ mrc , $ active ) = $ this -> process ( ) ; } if ( $ mrc !== CURLM_OK ) { throw new CurlErrorException ( 'cURL read error #' . $ mrc ) ; } }
|
Dispatches all requests in the stack .
|
893
|
protected function process ( ) { if ( curl_multi_select ( $ this -> handle ) === - 1 ) { usleep ( 100 ) ; } do { $ mrc = curl_multi_exec ( $ this -> handle , $ active ) ; } while ( $ mrc === CURLM_CALL_MULTI_PERFORM ) ; return [ $ mrc , $ active ] ; }
|
Processes all requests .
|
894
|
public function addPage ( ) { $ content = array ( ) ; foreach ( \ Drupal :: entityTypeManager ( ) -> getStorage ( 'site_commerce_type' ) -> loadMultiple ( ) as $ type ) { $ content [ $ type -> id ( ) ] = $ type ; } if ( ! count ( $ content ) ) { return $ this -> redirect ( 'entity.site_commerce_type.add_form' ) ; } if ( count ( $ content ) == 1 ) { $ type = array_shift ( $ content ) ; return $ this -> redirect ( 'entity.site_commerce.add_form' , array ( 'site_commerce_type' => $ type -> id ( ) ) ) ; } return array ( '#theme' => 'site_commerce_add_list' , '#content' => $ content , ) ; }
|
Displays add content links for available content types .
|
895
|
public function add ( SiteCommerceTypeInterface $ site_commerce_type ) { $ site_commerce = $ this -> entityManager ( ) -> getStorage ( 'site_commerce' ) -> create ( array ( 'type' => $ site_commerce_type -> id ( ) , ) ) ; $ form = $ this -> entityFormBuilder ( ) -> getForm ( $ site_commerce ) ; return $ form ; }
|
Provides the site_commerce submission form .
|
896
|
public function view ( Listener $ listener ) { $ data [ 'extensions' ] = $ this -> extension -> detect ( ) ; return $ listener -> showExtensions ( $ data ) ; }
|
View all extension page .
|
897
|
protected function addBladeExtensions ( Application $ app ) { $ blade = $ app -> make ( 'blade.compiler' ) ; $ blade -> directive ( 'decorator' , function ( $ expression ) { return "<?php echo \app('orchestra.decorator')->render({$expression}); ?>" ; } ) ; $ blade -> directive ( 'placeholder' , function ( $ expression ) { $ expression = \ preg_replace ( '/\(\s*(.*)\)/' , '$1' , $ expression ) ; return "<?php \$__ps = app('orchestra.widget')->make('placeholder.'.{$expression}); " . "foreach (\$__ps as \$__p) { echo value(\$__p->value ?: ''); } ?>" ; } ) ; $ blade -> directive ( 'get_meta' , function ( $ expression ) { return "<?php echo \get_meta({$expression}); ?>" ; } ) ; $ blade -> directive ( 'set_meta' , function ( $ expression ) { return "<?php \set_meta({$expression}); ?>" ; } ) ; $ blade -> directive ( 'title' , function ( $ expression ) { return "<?php echo \app('html')->title({$expression}); ?>" ; } ) ; $ blade -> extend ( function ( $ view ) { $ view = \ preg_replace ( '/(\s*)(<\?\s)/' , '$1<?php ' , $ view ) ; $ view = \ preg_replace ( '/#\{\{\s*(.+?)\s*\}\}/s' , '<?php $1; ?>' , $ view ) ; return $ view ; } ) ; }
|
Extends blade compiler .
|
898
|
protected function addHtmlExtensions ( Application $ app ) { $ html = $ app -> make ( 'html' ) ; $ html -> macro ( 'title' , function ( $ title = null ) use ( $ html ) { $ builder = new Title ( $ html , \ memorize ( 'site.name' ) , [ 'site' => \ get_meta ( 'html::title.format.site' , '{site.name} (Page {page.number})' ) , 'page' => \ get_meta ( 'html::title.format.page' , '{page.title} — {site.name}' ) , ] ) ; return $ builder -> title ( $ title ? : \ trim ( \ get_meta ( 'title' , '' ) ) ) ; } ) ; }
|
Add title macros for html service location .
|
899
|
private function parse ( array $ data , NodePath $ nodePath , $ parentId = null ) { $ parentId = $ this -> validateParentId ( $ parentId ) ; $ csvFile = $ this -> createCsvFile ( $ this -> structure -> getTypeFromNodePath ( $ nodePath ) , $ nodePath , $ parentId ) ; $ parentCols = array_fill_keys ( array_keys ( $ parentId ) , "string" ) ; foreach ( $ data as $ row ) { if ( is_scalar ( $ row ) || is_null ( $ row ) ) { $ row = ( object ) [ Structure :: DATA_COLUMN => $ row ] ; } elseif ( $ this -> analyzer -> getNestedArrayAsJson ( ) && is_array ( $ row ) ) { $ row = ( object ) [ Structure :: DATA_COLUMN => json_encode ( $ row ) ] ; } if ( ! empty ( $ parentId ) ) { $ row = ( object ) array_replace ( ( array ) $ row , $ parentId ) ; } $ csvRow = $ this -> parseRow ( $ row , $ nodePath , $ parentCols ) ; $ csvFile -> writeRow ( $ csvRow -> getRow ( ) ) ; } }
|
Parse data of known type
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.