idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
700
|
public function canTypeBeContainedByType ( Type \ Union $ input_type , Type \ Union $ container_type ) : bool { return TypeAnalyzer :: canBeContainedBy ( $ this , $ input_type , $ container_type ) ; }
|
Checks if type has any part that is a subtype of other
|
701
|
public function setReturnType ( $ php_type , $ new_type , $ phpdoc_type , $ is_php_compatible , $ description ) { $ new_type = str_replace ( [ '<mixed, mixed>' , '<array-key, mixed>' , '<empty, empty>' ] , '' , $ new_type ) ; $ this -> new_php_return_type = $ php_type ; $ this -> new_phpdoc_return_type = $ phpdoc_type ; $ this -> new_psalm_return_type = $ new_type ; $ this -> return_type_is_php_compatible = $ is_php_compatible ; $ this -> return_type_description = $ description ; }
|
Sets the new return type
|
702
|
public function setParamType ( $ param_name , $ php_type , $ new_type , $ phpdoc_type , $ is_php_compatible ) { $ new_type = str_replace ( [ '<mixed, mixed>' , '<array-key, mixed>' , '<empty, empty>' ] , '' , $ new_type ) ; if ( $ php_type ) { $ this -> new_php_param_types [ $ param_name ] = $ php_type ; } $ this -> new_phpdoc_param_types [ $ param_name ] = $ phpdoc_type ; $ this -> new_psalm_param_types [ $ param_name ] = $ new_type ; $ this -> param_type_is_php_compatible [ $ param_name ] = $ is_php_compatible ; }
|
Sets a new param type
|
703
|
public static function pathToUri ( string $ filepath ) : string { $ filepath = trim ( str_replace ( '\\' , '/' , $ filepath ) , '/' ) ; $ parts = explode ( '/' , $ filepath ) ; $ first = array_shift ( $ parts ) ; if ( substr ( $ first , - 1 ) !== ':' ) { $ first = rawurlencode ( $ first ) ; } $ parts = array_map ( 'rawurlencode' , $ parts ) ; array_unshift ( $ parts , $ first ) ; $ filepath = implode ( '/' , $ parts ) ; return 'file:///' . $ filepath ; }
|
Transforms an absolute file path into a URI as used by the language server protocol .
|
704
|
public static function uriToPath ( string $ uri ) { $ fragments = parse_url ( $ uri ) ; if ( $ fragments === false || ! isset ( $ fragments [ 'scheme' ] ) || $ fragments [ 'scheme' ] !== 'file' ) { throw new \ InvalidArgumentException ( "Not a valid file URI: $uri" ) ; } $ filepath = urldecode ( ( string ) $ fragments [ 'path' ] ) ; if ( strpos ( $ filepath , ':' ) !== false ) { if ( $ filepath [ 0 ] === '/' ) { $ filepath = substr ( $ filepath , 1 ) ; } $ filepath = str_replace ( '/' , '\\' , $ filepath ) ; } return $ filepath ; }
|
Transforms URI into file path
|
705
|
public function addReturnTypes ( Context $ context ) { if ( $ this -> return_vars_in_scope !== null ) { $ this -> return_vars_in_scope = TypeAnalyzer :: combineKeyedTypes ( $ context -> vars_in_scope , $ this -> return_vars_in_scope ) ; } else { $ this -> return_vars_in_scope = $ context -> vars_in_scope ; } if ( $ this -> return_vars_possibly_in_scope !== null ) { $ this -> return_vars_possibly_in_scope = array_merge ( $ context -> vars_possibly_in_scope , $ this -> return_vars_possibly_in_scope ) ; } else { $ this -> return_vars_possibly_in_scope = $ context -> vars_possibly_in_scope ; } }
|
Adds return types for the given function
|
706
|
public function notify ( string $ method , $ params ) : Promise { return $ this -> protocolWriter -> write ( new Message ( new AdvancedJsonRpc \ Notification ( $ method , ( object ) $ params ) ) ) ; }
|
Sends a notification to the client
|
707
|
public function moveByOffset ( $ x_offset , $ y_offset ) { $ this -> action -> addAction ( new WebDriverMoveToOffsetAction ( $ this -> mouse , null , $ x_offset , $ y_offset ) ) ; return $ this ; }
|
Mouse move by offset .
|
708
|
public function setDomain ( $ domain ) { if ( mb_strpos ( $ domain , ':' ) !== false ) { throw new InvalidArgumentException ( sprintf ( 'Cookie domain "%s" should not contain a port' , $ domain ) ) ; } $ this -> cookie [ 'domain' ] = $ domain ; }
|
The domain the cookie is visible to . Defaults to the current browsing context s document s URL domain if omitted .
|
709
|
public function sendKeys ( $ keys ) { $ this -> executor -> execute ( DriverCommand :: SEND_KEYS_TO_ACTIVE_ELEMENT , [ 'value' => WebDriverKeys :: encode ( $ keys ) , ] ) ; return $ this ; }
|
Send keys to active element
|
710
|
public function pressKey ( $ key ) { $ this -> executor -> execute ( DriverCommand :: SEND_KEYS_TO_ACTIVE_ELEMENT , [ 'value' => [ ( string ) $ key ] , ] ) ; return $ this ; }
|
Press a modifier key
|
711
|
public function releaseKey ( $ key ) { $ this -> executor -> execute ( DriverCommand :: SEND_KEYS_TO_ACTIVE_ELEMENT , [ 'value' => [ ( string ) $ key ] , ] ) ; return $ this ; }
|
Release a modifier key
|
712
|
public static function titleContains ( $ title ) { return new static ( function ( WebDriver $ driver ) use ( $ title ) { return mb_strpos ( $ driver -> getTitle ( ) , $ title ) !== false ; } ) ; }
|
An expectation for checking substring of a page Title .
|
713
|
public static function titleMatches ( $ titleRegexp ) { return new static ( function ( WebDriver $ driver ) use ( $ titleRegexp ) { return ( bool ) preg_match ( $ titleRegexp , $ driver -> getTitle ( ) ) ; } ) ; }
|
An expectation for checking current page title matches the given regular expression .
|
714
|
public static function urlContains ( $ url ) { return new static ( function ( WebDriver $ driver ) use ( $ url ) { return mb_strpos ( $ driver -> getCurrentURL ( ) , $ url ) !== false ; } ) ; }
|
An expectation for checking substring of the URL of a page .
|
715
|
public static function urlMatches ( $ urlRegexp ) { return new static ( function ( WebDriver $ driver ) use ( $ urlRegexp ) { return ( bool ) preg_match ( $ urlRegexp , $ driver -> getCurrentURL ( ) ) ; } ) ; }
|
An expectation for checking current page URL matches the given regular expression .
|
716
|
public static function presenceOfAllElementsLocatedBy ( WebDriverBy $ by ) { return new static ( function ( WebDriver $ driver ) use ( $ by ) { $ elements = $ driver -> findElements ( $ by ) ; return count ( $ elements ) > 0 ? $ elements : null ; } ) ; }
|
An expectation for checking that there is at least one element present on a web page .
|
717
|
public static function visibilityOfElementLocated ( WebDriverBy $ by ) { return new static ( function ( WebDriver $ driver ) use ( $ by ) { try { $ element = $ driver -> findElement ( $ by ) ; return $ element -> isDisplayed ( ) ? $ element : null ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; }
|
An expectation for checking that an element is present on the DOM of a page and visible . Visibility means that the element is not only displayed but also has a height and width that is greater than 0 .
|
718
|
public static function visibilityOfAnyElementLocated ( WebDriverBy $ by ) { return new static ( function ( WebDriver $ driver ) use ( $ by ) { $ elements = $ driver -> findElements ( $ by ) ; $ visibleElements = [ ] ; foreach ( $ elements as $ element ) { try { if ( $ element -> isDisplayed ( ) ) { $ visibleElements [ ] = $ element ; } } catch ( StaleElementReferenceException $ e ) { } } return count ( $ visibleElements ) > 0 ? $ visibleElements : null ; } ) ; }
|
An expectation for checking than at least one element in an array of elements is present on the DOM of a page and visible . Visibility means that the element is not only displayed but also has a height and width that is greater than 0 .
|
719
|
public static function elementTextMatches ( WebDriverBy $ by , $ regexp ) { return new static ( function ( WebDriver $ driver ) use ( $ by , $ regexp ) { try { return ( bool ) preg_match ( $ regexp , $ driver -> findElement ( $ by ) -> getText ( ) ) ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; }
|
An expectation for checking if the given regular expression matches the text in specified element .
|
720
|
public static function elementValueContains ( WebDriverBy $ by , $ text ) { return new static ( function ( WebDriver $ driver ) use ( $ by , $ text ) { try { $ element_text = $ driver -> findElement ( $ by ) -> getAttribute ( 'value' ) ; return mb_strpos ( $ element_text , $ text ) !== false ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; }
|
An expectation for checking if the given text is present in the specified elements value attribute .
|
721
|
public static function frameToBeAvailableAndSwitchToIt ( $ frame_locator ) { return new static ( function ( WebDriver $ driver ) use ( $ frame_locator ) { try { return $ driver -> switchTo ( ) -> frame ( $ frame_locator ) ; } catch ( NoSuchFrameException $ e ) { return false ; } } ) ; }
|
Expectation for checking if iFrame exists . If iFrame exists switches driver s focus to the iFrame .
|
722
|
public static function invisibilityOfElementLocated ( WebDriverBy $ by ) { return new static ( function ( WebDriver $ driver ) use ( $ by ) { try { return ! $ driver -> findElement ( $ by ) -> isDisplayed ( ) ; } catch ( NoSuchElementException $ e ) { return true ; } catch ( StaleElementReferenceException $ e ) { return true ; } } ) ; }
|
An expectation for checking that an element is either invisible or not present on the DOM .
|
723
|
public static function invisibilityOfElementWithText ( WebDriverBy $ by , $ text ) { return new static ( function ( WebDriver $ driver ) use ( $ by , $ text ) { try { return ! ( $ driver -> findElement ( $ by ) -> getText ( ) === $ text ) ; } catch ( NoSuchElementException $ e ) { return true ; } catch ( StaleElementReferenceException $ e ) { return true ; } } ) ; }
|
An expectation for checking that an element with text is either invisible or not present on the DOM .
|
724
|
public static function elementToBeClickable ( WebDriverBy $ by ) { $ visibility_of_element_located = self :: visibilityOfElementLocated ( $ by ) ; return new static ( function ( WebDriver $ driver ) use ( $ visibility_of_element_located ) { $ element = call_user_func ( $ visibility_of_element_located -> getApply ( ) , $ driver ) ; try { if ( $ element !== null && $ element -> isEnabled ( ) ) { return $ element ; } return null ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; }
|
An expectation for checking an element is visible and enabled such that you can click it .
|
725
|
public static function stalenessOf ( WebDriverElement $ element ) { return new static ( function ( ) use ( $ element ) { try { $ element -> isEnabled ( ) ; return false ; } catch ( StaleElementReferenceException $ e ) { return true ; } } ) ; }
|
Wait until an element is no longer attached to the DOM .
|
726
|
public static function refreshed ( self $ condition ) { return new static ( function ( WebDriver $ driver ) use ( $ condition ) { try { return call_user_func ( $ condition -> getApply ( ) , $ driver ) ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; }
|
Wrapper for a condition which allows for elements to update by redrawing .
|
727
|
public static function elementSelectionStateToBe ( $ element_or_by , $ selected ) { if ( $ element_or_by instanceof WebDriverElement ) { return new static ( function ( ) use ( $ element_or_by , $ selected ) { return $ element_or_by -> isSelected ( ) === $ selected ; } ) ; } else { if ( $ element_or_by instanceof WebDriverBy ) { return new static ( function ( WebDriver $ driver ) use ( $ element_or_by , $ selected ) { try { $ element = $ driver -> findElement ( $ element_or_by ) ; return $ element -> isSelected ( ) === $ selected ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; } } }
|
An expectation for checking if the given element is selected .
|
728
|
public static function not ( self $ condition ) { return new static ( function ( WebDriver $ driver ) use ( $ condition ) { $ result = call_user_func ( $ condition -> getApply ( ) , $ driver ) ; return ! $ result ; } ) ; }
|
An expectation with the logical opposite condition of the given condition .
|
729
|
protected function byIndex ( $ index , $ select = true ) { $ elements = $ this -> getRelatedElements ( ) ; if ( ! isset ( $ elements [ $ index ] ) ) { throw new NoSuchElementException ( sprintf ( 'Cannot locate %s with index: %d' , $ this -> type , $ index ) ) ; } $ select ? $ this -> selectOption ( $ elements [ $ index ] ) : $ this -> deselectOption ( $ elements [ $ index ] ) ; }
|
Selects or deselects a checkbox or a radio button by its index .
|
730
|
public function defaultContent ( ) { $ params = [ 'id' => null ] ; $ this -> executor -> execute ( DriverCommand :: SWITCH_TO_FRAME , $ params ) ; return $ this -> driver ; }
|
Switch to the main document if the page contains iframes . Otherwise switch to the first frame on the page .
|
731
|
public function frame ( $ frame ) { if ( $ frame instanceof WebDriverElement ) { $ id = [ 'ELEMENT' => $ frame -> getID ( ) ] ; } else { $ id = ( string ) $ frame ; } $ params = [ 'id' => $ id ] ; $ this -> executor -> execute ( DriverCommand :: SWITCH_TO_FRAME , $ params ) ; return $ this -> driver ; }
|
Switch to the iframe by its id or name .
|
732
|
public function window ( $ handle ) { $ params = [ 'name' => ( string ) $ handle ] ; $ this -> executor -> execute ( DriverCommand :: SWITCH_TO_WINDOW , $ params ) ; return $ this -> driver ; }
|
Switch the focus to another window by its handle .
|
733
|
public function activeElement ( ) { $ response = $ this -> driver -> execute ( DriverCommand :: GET_ACTIVE_ELEMENT , [ ] ) ; $ method = new RemoteExecuteMethod ( $ this -> driver ) ; return new RemoteWebElement ( $ method , $ response [ 'ELEMENT' ] ) ; }
|
Switches to the element that currently has focus within the document currently switched to or the body element if this cannot be detected .
|
734
|
public function findElement ( WebDriverBy $ by ) { $ params = [ 'using' => $ by -> getMechanism ( ) , 'value' => $ by -> getValue ( ) , ':id' => $ this -> id , ] ; $ raw_element = $ this -> executor -> execute ( DriverCommand :: FIND_CHILD_ELEMENT , $ params ) ; return $ this -> newElement ( $ raw_element [ 'ELEMENT' ] ) ; }
|
Find the first WebDriverElement within this element using the given mechanism .
|
735
|
public function findElements ( WebDriverBy $ by ) { $ params = [ 'using' => $ by -> getMechanism ( ) , 'value' => $ by -> getValue ( ) , ':id' => $ this -> id , ] ; $ raw_elements = $ this -> executor -> execute ( DriverCommand :: FIND_CHILD_ELEMENTS , $ params ) ; $ elements = [ ] ; foreach ( $ raw_elements as $ raw_element ) { $ elements [ ] = $ this -> newElement ( $ raw_element [ 'ELEMENT' ] ) ; } return $ elements ; }
|
Find all WebDriverElements within this element using the given mechanism .
|
736
|
public function getAttribute ( $ attribute_name ) { $ params = [ ':name' => $ attribute_name , ':id' => $ this -> id , ] ; return $ this -> executor -> execute ( DriverCommand :: GET_ELEMENT_ATTRIBUTE , $ params ) ; }
|
Get the value of a the given attribute of the element .
|
737
|
public function getCSSValue ( $ css_property_name ) { $ params = [ ':propertyName' => $ css_property_name , ':id' => $ this -> id , ] ; return $ this -> executor -> execute ( DriverCommand :: GET_ELEMENT_VALUE_OF_CSS_PROPERTY , $ params ) ; }
|
Get the value of a given CSS property .
|
738
|
public function getLocation ( ) { $ location = $ this -> executor -> execute ( DriverCommand :: GET_ELEMENT_LOCATION , [ ':id' => $ this -> id ] ) ; return new WebDriverPoint ( $ location [ 'x' ] , $ location [ 'y' ] ) ; }
|
Get the location of element relative to the top - left corner of the page .
|
739
|
public function getLocationOnScreenOnceScrolledIntoView ( ) { $ location = $ this -> executor -> execute ( DriverCommand :: GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW , [ ':id' => $ this -> id ] ) ; return new WebDriverPoint ( $ location [ 'x' ] , $ location [ 'y' ] ) ; }
|
Try scrolling the element into the view port and return the location of element relative to the top - left corner of the page afterwards .
|
740
|
public function getSize ( ) { $ size = $ this -> executor -> execute ( DriverCommand :: GET_ELEMENT_SIZE , [ ':id' => $ this -> id ] ) ; return new WebDriverDimension ( $ size [ 'width' ] , $ size [ 'height' ] ) ; }
|
Get the size of element .
|
741
|
public function sendKeys ( $ value ) { $ local_file = $ this -> fileDetector -> getLocalFile ( $ value ) ; if ( $ local_file === null ) { $ params = [ 'value' => WebDriverKeys :: encode ( $ value ) , ':id' => $ this -> id , ] ; $ this -> executor -> execute ( DriverCommand :: SEND_KEYS_TO_ELEMENT , $ params ) ; } else { $ remote_path = $ this -> upload ( $ local_file ) ; $ params = [ 'value' => WebDriverKeys :: encode ( $ remote_path ) , ':id' => $ this -> id , ] ; $ this -> executor -> execute ( DriverCommand :: SEND_KEYS_TO_ELEMENT , $ params ) ; } return $ this ; }
|
Simulate typing into an element which may set its value .
|
742
|
protected function upload ( $ local_file ) { if ( ! is_file ( $ local_file ) ) { throw new WebDriverException ( 'You may only upload files: ' . $ local_file ) ; } $ temp_zip = tempnam ( sys_get_temp_dir ( ) , 'WebDriverZip' ) ; $ zip = new ZipArchive ( ) ; if ( $ zip -> open ( $ temp_zip , ZipArchive :: CREATE ) !== true ) { return false ; } $ info = pathinfo ( $ local_file ) ; $ file_name = $ info [ 'basename' ] ; $ zip -> addFile ( $ local_file , $ file_name ) ; $ zip -> close ( ) ; $ params = [ 'file' => base64_encode ( file_get_contents ( $ temp_zip ) ) , ] ; $ remote_path = $ this -> executor -> execute ( DriverCommand :: UPLOAD_FILE , $ params ) ; unlink ( $ temp_zip ) ; return $ remote_path ; }
|
Upload a local file to the server
|
743
|
public function getPosition ( ) { $ position = $ this -> executor -> execute ( DriverCommand :: GET_WINDOW_POSITION , [ ':windowHandle' => 'current' ] ) ; return new WebDriverPoint ( $ position [ 'x' ] , $ position [ 'y' ] ) ; }
|
Get the position of the current window relative to the upper left corner of the screen .
|
744
|
public function getSize ( ) { $ size = $ this -> executor -> execute ( DriverCommand :: GET_WINDOW_SIZE , [ ':windowHandle' => 'current' ] ) ; return new WebDriverDimension ( $ size [ 'width' ] , $ size [ 'height' ] ) ; }
|
Get the size of the current window . This will return the outer window dimension not just the view port .
|
745
|
public function setSize ( WebDriverDimension $ size ) { $ params = [ 'width' => $ size -> getWidth ( ) , 'height' => $ size -> getHeight ( ) , ':windowHandle' => 'current' , ] ; $ this -> executor -> execute ( DriverCommand :: SET_WINDOW_SIZE , $ params ) ; return $ this ; }
|
Set the size of the current window . This will change the outer window dimension not just the view port .
|
746
|
public function setPosition ( WebDriverPoint $ position ) { $ params = [ 'x' => $ position -> getX ( ) , 'y' => $ position -> getY ( ) , ':windowHandle' => 'current' , ] ; $ this -> executor -> execute ( DriverCommand :: SET_WINDOW_POSITION , $ params ) ; return $ this ; }
|
Set the position of the current window . This is relative to the upper left corner of the screen .
|
747
|
public function setScreenOrientation ( $ orientation ) { $ orientation = mb_strtoupper ( $ orientation ) ; if ( ! in_array ( $ orientation , [ 'PORTRAIT' , 'LANDSCAPE' ] ) ) { throw new IndexOutOfBoundsException ( 'Orientation must be either PORTRAIT, or LANDSCAPE' ) ; } $ this -> executor -> execute ( DriverCommand :: SET_SCREEN_ORIENTATION , [ 'orientation' => $ orientation ] ) ; return $ this ; }
|
Set the browser orientation . The orientation should either LANDSCAPE|PORTRAIT
|
748
|
public function setJavascriptEnabled ( $ enabled ) { $ browser = $ this -> getBrowserName ( ) ; if ( $ browser && $ browser !== WebDriverBrowserType :: HTMLUNIT ) { throw new Exception ( 'isJavascriptEnabled() is a htmlunit-only option. ' . 'See https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#read-write-capabilities.' ) ; } $ this -> set ( WebDriverCapabilityType :: JAVASCRIPT_ENABLED , $ enabled ) ; return $ this ; }
|
This is a htmlUnit - only option .
|
749
|
public static function create ( $ selenium_server_url = 'http://localhost:4444/wd/hub' , $ desired_capabilities = null , $ connection_timeout_in_ms = null , $ request_timeout_in_ms = null , $ http_proxy = null , $ http_proxy_port = null , DesiredCapabilities $ required_capabilities = null ) { $ selenium_server_url = preg_replace ( '#/+$#' , '' , $ selenium_server_url ) ; $ desired_capabilities = self :: castToDesiredCapabilitiesObject ( $ desired_capabilities ) ; $ executor = new HttpCommandExecutor ( $ selenium_server_url , $ http_proxy , $ http_proxy_port ) ; if ( $ connection_timeout_in_ms !== null ) { $ executor -> setConnectionTimeout ( $ connection_timeout_in_ms ) ; } if ( $ request_timeout_in_ms !== null ) { $ executor -> setRequestTimeout ( $ request_timeout_in_ms ) ; } if ( $ required_capabilities !== null ) { $ desired_capabilities -> setCapability ( 'requiredCapabilities' , $ required_capabilities -> toArray ( ) ) ; } $ command = new WebDriverCommand ( null , DriverCommand :: NEW_SESSION , [ 'desiredCapabilities' => $ desired_capabilities -> toArray ( ) ] ) ; $ response = $ executor -> execute ( $ command ) ; $ returnedCapabilities = new DesiredCapabilities ( $ response -> getValue ( ) ) ; $ driver = new static ( $ executor , $ response -> getSessionID ( ) , $ returnedCapabilities ) ; return $ driver ; }
|
Construct the RemoteWebDriver by a desired capabilities .
|
750
|
public function findElement ( WebDriverBy $ by ) { $ params = [ 'using' => $ by -> getMechanism ( ) , 'value' => $ by -> getValue ( ) ] ; $ raw_element = $ this -> execute ( DriverCommand :: FIND_ELEMENT , $ params ) ; return $ this -> newElement ( $ raw_element [ 'ELEMENT' ] ) ; }
|
Find the first WebDriverElement using the given mechanism .
|
751
|
public function findElements ( WebDriverBy $ by ) { $ params = [ 'using' => $ by -> getMechanism ( ) , 'value' => $ by -> getValue ( ) ] ; $ raw_elements = $ this -> execute ( DriverCommand :: FIND_ELEMENTS , $ params ) ; $ elements = [ ] ; foreach ( $ raw_elements as $ raw_element ) { $ elements [ ] = $ this -> newElement ( $ raw_element [ 'ELEMENT' ] ) ; } return $ elements ; }
|
Find all WebDriverElements within the current page using the given mechanism .
|
752
|
public function get ( $ url ) { $ params = [ 'url' => ( string ) $ url ] ; $ this -> execute ( DriverCommand :: GET , $ params ) ; return $ this ; }
|
Load a new web page in the current browser window .
|
753
|
public function executeScript ( $ script , array $ arguments = [ ] ) { $ params = [ 'script' => $ script , 'args' => $ this -> prepareScriptArguments ( $ arguments ) , ] ; return $ this -> execute ( DriverCommand :: EXECUTE_SCRIPT , $ params ) ; }
|
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame . The executed script is assumed to be synchronous and the result of evaluating the script will be returned .
|
754
|
public function executeAsyncScript ( $ script , array $ arguments = [ ] ) { $ params = [ 'script' => $ script , 'args' => $ this -> prepareScriptArguments ( $ arguments ) , ] ; return $ this -> execute ( DriverCommand :: EXECUTE_ASYNC_SCRIPT , $ params ) ; }
|
Inject a snippet of JavaScript into the page for asynchronous execution in the context of the currently selected frame .
|
755
|
public function takeScreenshot ( $ save_as = null ) { $ screenshot = base64_decode ( $ this -> execute ( DriverCommand :: SCREENSHOT ) ) ; if ( $ save_as ) { file_put_contents ( $ save_as , $ screenshot ) ; } return $ screenshot ; }
|
Take a screenshot of the current page .
|
756
|
public static function getAllSessions ( $ selenium_server_url = 'http://localhost:4444/wd/hub' , $ timeout_in_ms = 30000 ) { $ executor = new HttpCommandExecutor ( $ selenium_server_url ) ; $ executor -> setConnectionTimeout ( $ timeout_in_ms ) ; $ command = new WebDriverCommand ( null , DriverCommand :: GET_ALL_SESSIONS , [ ] ) ; return $ executor -> execute ( $ command ) -> getValue ( ) ; }
|
Returns a list of the currently active sessions .
|
757
|
protected function prepareScriptArguments ( array $ arguments ) { $ args = [ ] ; foreach ( $ arguments as $ key => $ value ) { if ( $ value instanceof WebDriverElement ) { $ args [ $ key ] = [ 'ELEMENT' => $ value -> getID ( ) ] ; } else { if ( is_array ( $ value ) ) { $ value = $ this -> prepareScriptArguments ( $ value ) ; } $ args [ $ key ] = $ value ; } } return $ args ; }
|
Prepare arguments for JavaScript injection
|
758
|
public function move ( $ new_x , $ new_y ) { $ this -> x = $ new_x ; $ this -> y = $ new_y ; return $ this ; }
|
Set the point to a new position .
|
759
|
public function moveBy ( $ x_offset , $ y_offset ) { $ this -> x += $ x_offset ; $ this -> y += $ y_offset ; return $ this ; }
|
Move the current by offsets .
|
760
|
public function equals ( self $ point ) { return $ this -> x === $ point -> getX ( ) && $ this -> y === $ point -> getY ( ) ; }
|
Check whether the given point is the same as the instance .
|
761
|
public function equals ( self $ dimension ) { return $ this -> height === $ dimension -> getHeight ( ) && $ this -> width === $ dimension -> getWidth ( ) ; }
|
Check whether the given dimension is the same as the instance .
|
762
|
public function addCookie ( $ cookie ) { if ( is_array ( $ cookie ) ) { $ cookie = Cookie :: createFromArray ( $ cookie ) ; } if ( ! $ cookie instanceof Cookie ) { throw new InvalidArgumentException ( 'Cookie must be set from instance of Cookie class or from array.' ) ; } $ this -> executor -> execute ( DriverCommand :: ADD_COOKIE , [ 'cookie' => $ cookie -> toArray ( ) ] ) ; return $ this ; }
|
Add a specific cookie .
|
763
|
public function getCookieNamed ( $ name ) { $ cookies = $ this -> getCookies ( ) ; foreach ( $ cookies as $ cookie ) { if ( $ cookie [ 'name' ] === $ name ) { return $ cookie ; } } return null ; }
|
Get the cookie with a given name .
|
764
|
public function getCookies ( ) { $ cookieArrays = $ this -> executor -> execute ( DriverCommand :: GET_ALL_COOKIES ) ; $ cookies = [ ] ; foreach ( $ cookieArrays as $ cookieArray ) { $ cookies [ ] = Cookie :: createFromArray ( $ cookieArray ) ; } return $ cookies ; }
|
Get all the cookies for the current domain .
|
765
|
public static function throwException ( $ status_code , $ message , $ results ) { switch ( $ status_code ) { case 1 : throw new IndexOutOfBoundsException ( $ message , $ results ) ; case 2 : throw new NoCollectionException ( $ message , $ results ) ; case 3 : throw new NoStringException ( $ message , $ results ) ; case 4 : throw new NoStringLengthException ( $ message , $ results ) ; case 5 : throw new NoStringWrapperException ( $ message , $ results ) ; case 6 : throw new NoSuchDriverException ( $ message , $ results ) ; case 7 : throw new NoSuchElementException ( $ message , $ results ) ; case 8 : throw new NoSuchFrameException ( $ message , $ results ) ; case 9 : throw new UnknownCommandException ( $ message , $ results ) ; case 10 : throw new StaleElementReferenceException ( $ message , $ results ) ; case 11 : throw new ElementNotVisibleException ( $ message , $ results ) ; case 12 : throw new InvalidElementStateException ( $ message , $ results ) ; case 13 : throw new UnknownServerException ( $ message , $ results ) ; case 14 : throw new ExpectedException ( $ message , $ results ) ; case 15 : throw new ElementNotSelectableException ( $ message , $ results ) ; case 16 : throw new NoSuchDocumentException ( $ message , $ results ) ; case 17 : throw new UnexpectedJavascriptException ( $ message , $ results ) ; case 18 : throw new NoScriptResultException ( $ message , $ results ) ; case 19 : throw new XPathLookupException ( $ message , $ results ) ; case 20 : throw new NoSuchCollectionException ( $ message , $ results ) ; case 21 : throw new TimeOutException ( $ message , $ results ) ; case 22 : throw new NullPointerException ( $ message , $ results ) ; case 23 : throw new NoSuchWindowException ( $ message , $ results ) ; case 24 : throw new InvalidCookieDomainException ( $ message , $ results ) ; case 25 : throw new UnableToSetCookieException ( $ message , $ results ) ; case 26 : throw new UnexpectedAlertOpenException ( $ message , $ results ) ; case 27 : throw new NoAlertOpenException ( $ message , $ results ) ; case 28 : throw new ScriptTimeoutException ( $ message , $ results ) ; case 29 : throw new InvalidCoordinatesException ( $ message , $ results ) ; case 30 : throw new IMENotAvailableException ( $ message , $ results ) ; case 31 : throw new IMEEngineActivationFailedException ( $ message , $ results ) ; case 32 : throw new InvalidSelectorException ( $ message , $ results ) ; case 33 : throw new SessionNotCreatedException ( $ message , $ results ) ; case 34 : throw new MoveTargetOutOfBoundsException ( $ message , $ results ) ; default : throw new UnrecognizedExceptionException ( $ message , $ results ) ; } }
|
Throw WebDriverExceptions based on WebDriver status code .
|
766
|
public function to ( $ url ) { $ params = [ 'url' => ( string ) $ url ] ; $ this -> executor -> execute ( DriverCommand :: GET , $ params ) ; return $ this ; }
|
Navigate to the given URL .
|
767
|
protected function nestedListing ( $ key , $ type , $ value ) { if ( is_int ( $ key ) ) { return $ this -> listing ( $ type , $ value ) ; } else { return '<li>' . $ key . $ this -> listing ( $ type , $ value ) . '</li>' ; } }
|
Create the HTML for a nested listing attribute .
|
768
|
public function tel ( $ name , $ value = null , $ options = [ ] ) { return $ this -> input ( 'tel' , $ name , $ value , $ options ) ; }
|
Create a tel input field .
|
769
|
public function month ( $ name , $ value = null , $ options = [ ] ) { if ( $ value instanceof DateTime ) { $ value = $ value -> format ( 'Y-m' ) ; } return $ this -> input ( 'month' , $ name , $ value , $ options ) ; }
|
Create a month input field .
|
770
|
public function rsyncValidate ( CommandData $ commandData ) { if ( preg_match ( "/^@prod/" , $ commandData -> input ( ) -> getArgument ( 'target' ) ) ) { throw new \ Exception ( dt ( 'Per !file, you may never rsync to the production site.' , [ '!file' => __FILE__ ] ) ) ; } }
|
Limit rsync operations to production site .
|
771
|
protected function configureServer ( array $ ctx ) : array { $ server = $ this -> originalServer ; $ server [ 'REQUEST_TIME' ] = time ( ) ; $ server [ 'REQUEST_TIME_FLOAT' ] = microtime ( true ) ; $ server [ 'REMOTE_ADDR' ] = $ ctx [ 'attributes' ] [ 'ipAddress' ] ?? $ ctx [ 'remoteAddr' ] ?? '127.0.0.1' ; $ server [ 'HTTP_USER_AGENT' ] = '' ; foreach ( $ ctx [ 'headers' ] as $ key => $ value ) { $ key = strtoupper ( str_replace ( '-' , '_' , $ key ) ) ; if ( \ in_array ( $ key , [ 'CONTENT_TYPE' , 'CONTENT_LENGTH' ] ) ) { $ server [ $ key ] = implode ( ', ' , $ value ) ; } else { $ server [ 'HTTP_' . $ key ] = implode ( ', ' , $ value ) ; } } return $ server ; }
|
Returns altered copy of _SERVER variable . Sets ip - address request - time and other values .
|
772
|
private function wrapUploads ( $ files ) : array { if ( empty ( $ files ) ) { return [ ] ; } $ result = [ ] ; foreach ( $ files as $ index => $ f ) { if ( ! isset ( $ f [ 'name' ] ) ) { $ result [ $ index ] = $ this -> wrapUploads ( $ f ) ; continue ; } if ( UPLOAD_ERR_OK === $ f [ 'error' ] ) { $ stream = $ this -> streamFactory -> createStreamFromFile ( $ f [ 'tmpName' ] ) ; } else { $ stream = $ this -> streamFactory -> createStream ( ) ; } $ result [ $ index ] = $ this -> uploadsFactory -> createUploadedFile ( $ stream , $ f [ 'size' ] , $ f [ 'error' ] , $ f [ 'name' ] , $ f [ 'mime' ] ) ; } return $ result ; }
|
Wraps all uploaded files with UploadedFile .
|
773
|
private static function fetchProtocolVersion ( string $ version ) : string { $ v = substr ( $ version , 5 ) ; if ( $ v === '2.0' ) { return '2' ; } if ( ! in_array ( $ v , static :: $ allowedVersions , true ) ) { return '1.1' ; } return $ v ; }
|
Normalize HTTP protocol version to valid values
|
774
|
public function receive ( & $ header ) { $ body = $ this -> relay -> receiveSync ( $ flags ) ; if ( $ flags & Relay :: PAYLOAD_CONTROL ) { if ( $ this -> handleControl ( $ body , $ header , $ flags ) ) { return $ this -> receive ( $ header ) ; } $ header = null ; return null ; } if ( $ flags & Relay :: PAYLOAD_ERROR ) { return new \ Error ( $ body ) ; } return $ body ; }
|
Receive packet of information to process returns null when process must be stopped . Might return Error to wrap error message from server .
|
775
|
public function send ( string $ payload = null , string $ header = null ) { if ( is_null ( $ header ) ) { $ this -> relay -> send ( $ header , Relay :: PAYLOAD_CONTROL | Relay :: PAYLOAD_NONE ) ; } else { $ this -> relay -> send ( $ header , Relay :: PAYLOAD_CONTROL | Relay :: PAYLOAD_RAW ) ; } $ this -> relay -> send ( $ payload , Relay :: PAYLOAD_RAW ) ; }
|
Respond to the server with result of task execution and execution context .
|
776
|
public function error ( string $ message ) { $ this -> relay -> send ( $ message , Relay :: PAYLOAD_CONTROL | Relay :: PAYLOAD_RAW | Relay :: PAYLOAD_ERROR ) ; }
|
Respond to the server with an error . Error must be treated as TaskError and might not cause worker destruction .
|
777
|
private function handleControl ( string $ body = null , & $ header = null , int $ flags = 0 ) : bool { $ header = $ body ; if ( is_null ( $ body ) || $ flags & Relay :: PAYLOAD_RAW ) { return true ; } $ p = json_decode ( $ body , true ) ; if ( $ p === false ) { throw new RoadRunnerException ( "invalid task context, JSON payload is expected" ) ; } if ( ! empty ( $ p [ 'pid' ] ) ) { $ this -> relay -> send ( sprintf ( '{"pid":%s}' , getmypid ( ) ) , Relay :: PAYLOAD_CONTROL ) ; } if ( ! empty ( $ p [ 'stop' ] ) ) { return false ; } $ header = $ p ; return true ; }
|
Handles incoming control command payload and executes it if required .
|
778
|
protected static function validateField ( $ fieldObject ) { $ selectable = true ; if ( isset ( $ fieldObject -> config [ 'selectable' ] ) && $ fieldObject -> config [ 'selectable' ] === false ) { $ selectable = false ; } if ( isset ( $ fieldObject -> config [ 'privacy' ] ) ) { $ privacyClass = $ fieldObject -> config [ 'privacy' ] ; if ( is_callable ( $ privacyClass ) && call_user_func ( $ privacyClass , self :: $ args ) === false ) { $ selectable = null ; } elseif ( is_string ( $ privacyClass ) ) { if ( array_has ( self :: $ privacyValidations , $ privacyClass ) ) { $ validated = self :: $ privacyValidations [ $ privacyClass ] ; } else { $ validated = call_user_func ( [ app ( $ privacyClass ) , 'fire' ] , self :: $ args ) ; self :: $ privacyValidations [ $ privacyClass ] = $ validated ; } if ( ! $ validated ) { $ selectable = null ; } } } return $ selectable ; }
|
Check the privacy status if it s given
|
779
|
protected static function addAlwaysFields ( $ fieldObject , array & $ select , $ parentTable , $ forRelation = false ) { if ( isset ( $ fieldObject -> config [ 'always' ] ) ) { $ always = $ fieldObject -> config [ 'always' ] ; if ( is_string ( $ always ) ) { $ always = explode ( ',' , $ always ) ; } foreach ( $ always as $ field ) { self :: addFieldToSelect ( $ field , $ select , $ parentTable , $ forRelation ) ; } } }
|
Add selects that are given by the always attribute
|
780
|
public function processRequest ( Request $ request ) { $ contentType = $ request -> header ( 'content-type' ) ? : '' ; if ( mb_stripos ( $ contentType , 'multipart/form-data' ) !== false ) { $ this -> validateParsedBody ( $ request ) ; $ request = $ this -> parseUploadedFiles ( $ request ) ; } return $ request ; }
|
Process the request and return either a modified request or the original one
|
781
|
private function parseUploadedFiles ( Request $ request ) { $ bodyParams = $ request -> all ( ) ; if ( ! isset ( $ bodyParams [ 'map' ] ) ) { throw new RequestError ( 'The request must define a `map`' ) ; } $ map = json_decode ( $ bodyParams [ 'map' ] , true ) ; $ result = json_decode ( $ bodyParams [ 'operations' ] , true ) ; if ( isset ( $ result [ 'operationName' ] ) ) { $ result [ 'operation' ] = $ result [ 'operationName' ] ; unset ( $ result [ 'operationName' ] ) ; } foreach ( $ map as $ fileKey => $ locations ) { foreach ( $ locations as $ location ) { $ items = & $ result ; foreach ( explode ( '.' , $ location ) as $ key ) { if ( ! isset ( $ items [ $ key ] ) || ! is_array ( $ items [ $ key ] ) ) { $ items [ $ key ] = [ ] ; } $ items = & $ items [ $ key ] ; } $ items = $ request -> allFiles ( ) [ $ fileKey ] ; } } $ request -> replace ( $ result ) ; return $ request ; }
|
Inject uploaded files defined in the map key into the variables key
|
782
|
private function validateParsedBody ( Request $ request ) { $ bodyParams = $ request -> all ( ) ; if ( null === $ bodyParams ) { throw new InvariantViolation ( 'Request is expected to provide parsed body for "multipart/form-data" requests but got null' ) ; } if ( ! is_array ( $ bodyParams ) ) { throw new RequestError ( 'GraphQL Server expects JSON object or array, but got ' . Utils :: printSafeJson ( $ bodyParams ) ) ; } if ( empty ( $ bodyParams ) ) { throw new InvariantViolation ( 'Request is expected to provide parsed body for "multipart/form-data" requests but got empty array' ) ; } }
|
Validates that the request meet our expectations
|
783
|
protected function bootSchemas ( ) { $ configSchemas = config ( 'graphql.schemas' ) ; foreach ( $ configSchemas as $ name => $ schema ) { $ this -> app [ 'graphql' ] -> addSchema ( $ name , $ schema ) ; } }
|
Add schemas from config
|
784
|
protected function applySecurityRules ( ) { $ maxQueryComplexity = config ( 'graphql.security.query_max_complexity' ) ; if ( $ maxQueryComplexity !== null ) { $ queryComplexity = DocumentValidator :: getRule ( 'QueryComplexity' ) ; $ queryComplexity -> setMaxQueryComplexity ( $ maxQueryComplexity ) ; } $ maxQueryDepth = config ( 'graphql.security.query_max_depth' ) ; if ( $ maxQueryDepth !== null ) { $ queryDepth = DocumentValidator :: getRule ( 'QueryDepth' ) ; $ queryDepth -> setMaxQueryDepth ( $ maxQueryDepth ) ; } $ disableIntrospection = config ( 'graphql.security.disable_introspection' ) ; if ( $ disableIntrospection === true ) { $ disableIntrospection = DocumentValidator :: getRule ( 'DisableIntrospection' ) ; $ disableIntrospection -> setEnabled ( DisableIntrospection :: ENABLED ) ; } }
|
Configure security from config
|
785
|
public function store ( $ id ) { $ data = [ 'title' => request ( 'title' ) , 'excerpt' => request ( 'excerpt' , '' ) , 'slug' => request ( 'slug' ) , 'body' => request ( 'body' , '' ) , 'published' => request ( 'published' ) , 'author_id' => request ( 'author_id' ) , 'featured_image' => request ( 'featured_image' ) , 'featured_image_caption' => request ( 'featured_image_caption' , '' ) , 'publish_date' => request ( 'publish_date' , '' ) , 'meta' => request ( 'meta' , ( object ) [ ] ) , ] ; validator ( $ data , [ 'publish_date' => 'required|date' , 'author_id' => 'required' , 'title' => 'required' , 'slug' => 'required|' . Rule :: unique ( config ( 'wink.database_connection' ) . '.wink_posts' , 'slug' ) -> ignore ( request ( 'id' ) ) , ] ) -> validate ( ) ; $ entry = $ id !== 'new' ? WinkPost :: findOrFail ( $ id ) : new WinkPost ( [ 'id' => request ( 'id' ) ] ) ; $ entry -> fill ( $ data ) ; $ entry -> save ( ) ; $ entry -> tags ( ) -> sync ( $ this -> collectTags ( request ( 'tags' ) ) ) ; return response ( ) -> json ( [ 'entry' => $ entry , ] ) ; }
|
Store a single post .
|
786
|
private function collectTags ( $ incomingTags ) { $ allTags = WinkTag :: all ( ) ; return collect ( $ incomingTags ) -> map ( function ( $ incomingTag ) use ( $ allTags ) { $ tag = $ allTags -> where ( 'slug' , Str :: slug ( $ incomingTag [ 'name' ] ) ) -> first ( ) ; if ( ! $ tag ) { $ tag = WinkTag :: create ( [ 'id' => $ id = Str :: uuid ( ) , 'name' => $ incomingTag [ 'name' ] , 'slug' => Str :: slug ( $ incomingTag [ 'name' ] ) , ] ) ; } return ( string ) $ tag -> id ; } ) -> toArray ( ) ; }
|
Tags incoming from the request .
|
787
|
public function delete ( $ id ) { $ entry = WinkAuthor :: findOrFail ( $ id ) ; if ( $ entry -> posts ( ) -> count ( ) ) { return response ( ) -> json ( [ 'message' => 'Please remove the author\'s posts first.' ] , 402 ) ; } if ( $ entry -> id == auth ( 'wink' ) -> user ( ) -> id ) { return response ( ) -> json ( [ 'message' => 'You cannot delete yourself.' ] , 402 ) ; } $ entry -> delete ( ) ; }
|
Return a single author .
|
788
|
private function registerRoutes ( ) { $ path = config ( 'wink.path' ) ; $ middlewareGroup = config ( 'wink.middleware_group' ) ; Route :: namespace ( 'Wink\Http\Controllers' ) -> middleware ( $ middlewareGroup ) -> as ( 'wink.' ) -> prefix ( $ path ) -> group ( function ( ) { Route :: get ( '/login' , 'LoginController@showLoginForm' ) -> name ( 'auth.login' ) ; Route :: post ( '/login' , 'LoginController@login' ) -> name ( 'auth.attempt' ) ; Route :: get ( '/password/forgot' , 'ForgotPasswordController@showResetRequestForm' ) -> name ( 'password.forgot' ) ; Route :: post ( '/password/forgot' , 'ForgotPasswordController@sendResetLinkEmail' ) -> name ( 'password.email' ) ; Route :: get ( '/password/reset/{token}' , 'ForgotPasswordController@showNewPassword' ) -> name ( 'password.reset' ) ; } ) ; Route :: namespace ( 'Wink\Http\Controllers' ) -> middleware ( [ $ middlewareGroup , Authenticate :: class ] ) -> as ( 'wink.' ) -> prefix ( $ path ) -> group ( function ( ) { $ this -> loadRoutesFrom ( __DIR__ . '/Http/routes.php' ) ; } ) ; }
|
Register the package routes .
|
789
|
public function sendResetLinkEmail ( ) { validator ( request ( ) -> all ( ) , [ 'email' => 'required|email' , ] ) -> validate ( ) ; if ( $ author = WinkAuthor :: whereEmail ( request ( 'email' ) ) -> first ( ) ) { cache ( [ 'password.reset.' . $ author -> id => $ token = Str :: random ( ) ] , now ( ) -> addMinutes ( 30 ) ) ; Mail :: to ( $ author -> email ) -> send ( new ResetPasswordEmail ( encrypt ( $ author -> id . '|' . $ token ) ) ) ; } return redirect ( ) -> route ( 'wink.password.forgot' ) -> with ( 'sent' , true ) ; }
|
Send password reset email .
|
790
|
public function showNewPassword ( $ token ) { try { $ token = decrypt ( $ token ) ; [ $ authorId , $ token ] = explode ( '|' , $ token ) ; $ author = WinkAuthor :: findOrFail ( $ authorId ) ; } catch ( Throwable $ e ) { return redirect ( ) -> route ( 'wink.password.forgot' ) -> with ( 'invalidResetToken' , true ) ; } if ( cache ( 'password.reset.' . $ authorId ) != $ token ) { return redirect ( ) -> route ( 'wink.password.forgot' ) -> with ( 'invalidResetToken' , true ) ; } cache ( ) -> forget ( 'password.reset.' . $ authorId ) ; $ author -> password = \ Hash :: make ( $ password = Str :: random ( ) ) ; $ author -> save ( ) ; return view ( 'wink::reset-password' , [ 'password' => $ password , ] ) ; }
|
Show the new password to the user .
|
791
|
public function index ( ) { $ entries = WinkPage :: when ( request ( ) -> has ( 'search' ) , function ( $ q ) { $ q -> where ( 'title' , 'LIKE' , '%' . request ( 'search' ) . '%' ) ; } ) -> orderBy ( 'created_at' , 'DESC' ) -> paginate ( 30 ) ; return PagesResource :: collection ( $ entries ) ; }
|
Return pages .
|
792
|
public static function makeFromExisting ( IlluminateResponse $ old ) { $ new = static :: create ( $ old -> getOriginalContent ( ) , $ old -> getStatusCode ( ) ) ; $ new -> headers = $ old -> headers ; return $ new ; }
|
Make an API response from an existing Illuminate response .
|
793
|
public function withHeader ( $ key , $ value , $ replace = true ) { return $ this -> header ( $ key , $ value , $ replace ) ; }
|
Add a header to the response .
|
794
|
public function createFromIlluminate ( IlluminateRequest $ old ) { $ new = new static ( $ old -> query -> all ( ) , $ old -> request -> all ( ) , $ old -> attributes -> all ( ) , $ old -> cookies -> all ( ) , $ old -> files -> all ( ) , $ old -> server -> all ( ) , $ old -> content ) ; if ( $ session = $ old -> getSession ( ) ) { $ new -> setLaravelSession ( $ old -> getSession ( ) ) ; } $ new -> setRouteResolver ( $ old -> getRouteResolver ( ) ) ; $ new -> setUserResolver ( $ old -> getUserResolver ( ) ) ; return $ new ; }
|
Create a new Dingo request instance from an Illuminate request instance .
|
795
|
public function getRoutes ( $ version = null ) { if ( ! is_null ( $ version ) ) { return $ this -> routes [ $ version ] ; } return $ this -> routes ; }
|
Get all routes or only for a specific version .
|
796
|
public function gatherRouteMiddlewares ( $ route ) { if ( method_exists ( $ this -> router , 'gatherRouteMiddleware' ) ) { return $ this -> router -> gatherRouteMiddleware ( $ route ) ; } return $ this -> router -> gatherRouteMiddlewares ( $ route ) ; }
|
Gather the route middlewares .
|
797
|
protected function shouldEagerLoad ( $ response ) { if ( $ response instanceof IlluminatePaginator ) { $ response = $ response -> getCollection ( ) ; } return $ response instanceof EloquentCollection && $ this -> eagerLoading ; }
|
Eager loading is only performed when the response is or contains an Eloquent collection and eager loading is enabled .
|
798
|
public function parseFractalIncludes ( Request $ request ) { $ includes = $ request -> input ( $ this -> includeKey ) ; if ( ! is_array ( $ includes ) ) { $ includes = array_map ( 'trim' , array_filter ( explode ( $ this -> includeSeparator , $ includes ) ) ) ; } $ this -> fractal -> parseIncludes ( $ includes ) ; }
|
Parse the includes .
|
799
|
protected function mergeEagerLoads ( $ transformer , $ requestedIncludes ) { $ includes = array_merge ( $ requestedIncludes , $ transformer -> getDefaultIncludes ( ) ) ; $ eagerLoads = [ ] ; foreach ( $ includes as $ key => $ value ) { $ eagerLoads [ ] = is_string ( $ key ) ? $ key : $ value ; } if ( property_exists ( $ transformer , 'lazyLoadedIncludes' ) ) { $ eagerLoads = array_diff ( $ eagerLoads , $ transformer -> lazyLoadedIncludes ) ; } return $ eagerLoads ; }
|
Get includes as their array keys for eager loading .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.