idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
59,900
private function configureProcessProperties ( OptionsResolver $ resolver ) { $ resolver -> setRequired ( 'command' ) -> setAllowedTypes ( 'command' , 'string' ) ; $ resolver -> setDefined ( 'process_name' ) -> setAllowedTypes ( 'process_name' , 'string' ) ; $ resolver -> setDefined ( 'numprocs' ) -> setAllowedTypes ( 'numprocs' , 'int' ) ; $ resolver -> setDefined ( 'numprocs_start' ) -> setAllowedTypes ( 'numprocs_start' , 'int' ) ; $ resolver -> setDefined ( 'priority' ) -> setAllowedTypes ( 'priority' , 'int' ) ; }
Configures process related properties .
59,901
private function configureStartControlProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'autostart' ) -> setAllowedTypes ( 'autostart' , 'bool' ) ; $ resolver -> setDefined ( 'autorestart' ) -> setAllowedTypes ( 'autorestart' , [ 'bool' , 'string' ] ) -> setAllowedValues ( 'autorestart' , [ true , false , 'true' , 'false' , 'unexpected' ] ) -> setNormalizer ( 'autorestart' , function ( Options $ options , $ value ) { return ( is_bool ( $ value ) or $ value === 'unexpected' ) ? $ value : ( $ value === 'true' ? true : false ) ; } ) ; $ resolver -> setDefined ( 'startsecs' ) -> setAllowedTypes ( 'startsecs' , 'int' ) ; $ resolver -> setDefined ( 'startretries' ) -> setAllowedTypes ( 'startretries' , 'int' ) ; }
Configures start control related properties .
59,902
private function configureStopControlProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'exitcodes' ) ; $ this -> configureArrayProperty ( 'exitcodes' , $ resolver ) ; $ resolver -> setDefined ( 'stopsignal' ) -> setAllowedTypes ( 'stopsignal' , 'string' ) -> setAllowedValues ( 'stopsignal' , [ 'TERM' , 'HUP' , 'INT' , 'QUIT' , 'KILL' , 'USR1' , 'USR2' ] ) ; $ resolver -> setDefined ( 'stopwaitsecs' ) -> setAllowedTypes ( 'stopwaitsecs' , 'int' ) ; $ resolver -> setDefined ( 'stopasgroup' ) -> setAllowedTypes ( 'stopasgroup' , 'bool' ) ; $ resolver -> setDefined ( 'killasgroup' ) -> setAllowedTypes ( 'killasgroup' , 'bool' ) ; }
Configures stop control related properties .
59,903
private function configureLogProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'redirect_stderr' ) -> setAllowedTypes ( 'redirect_stderr' , 'bool' ) ; $ this -> configureStdoutLogProperties ( $ resolver ) ; $ this -> configureStderrLogProperties ( $ resolver ) ; }
Configures log related properties .
59,904
private function configureStdoutLogProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'stdout_logfile' ) -> setAllowedTypes ( 'stdout_logfile' , 'string' ) ; $ resolver -> setDefined ( 'stdout_logfile_maxbytes' ) ; $ this -> configureByteProperty ( 'stdout_logfile_maxbytes' , $ resolver ) ; $ resolver -> setDefined ( 'stdout_logfile_backups' ) -> setAllowedTypes ( 'stdout_logfile_backups' , 'int' ) ; $ resolver -> setDefined ( 'stdout_capture_maxbytes' ) ; $ this -> configureByteProperty ( 'stdout_capture_maxbytes' , $ resolver ) ; $ resolver -> setDefined ( 'stdout_events_enabled' ) -> setAllowedTypes ( 'stdout_events_enabled' , 'bool' ) ; $ resolver -> setDefined ( 'stdout_syslog' ) -> setAllowedTypes ( 'stdout_syslog' , 'bool' ) ; }
Configures stdout log related properties .
59,905
private function configureStderrLogProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'stderr_logfile' ) -> setAllowedTypes ( 'stderr_logfile' , 'string' ) ; $ resolver -> setDefined ( 'stderr_logfile_maxbytes' ) ; $ this -> configureByteProperty ( 'stderr_logfile_maxbytes' , $ resolver ) ; $ resolver -> setDefined ( 'stderr_logfile_backups' ) -> setAllowedTypes ( 'stderr_logfile_backups' , 'int' ) ; $ resolver -> setDefined ( 'stderr_capture_maxbytes' ) ; $ this -> configureByteProperty ( 'stderr_capture_maxbytes' , $ resolver ) ; $ resolver -> setDefined ( 'stderr_events_enabled' ) -> setAllowedTypes ( 'stderr_events_enabled' , 'bool' ) ; $ resolver -> setDefined ( 'stderr_syslog' ) -> setAllowedTypes ( 'stderr_syslog' , 'bool' ) ; }
Configures stderr log related properties .
59,906
public static function fromHeader ( string $ string ) : array { $ cookies = \ explode ( ";" , $ string ) ; $ result = [ ] ; try { foreach ( $ cookies as $ cookie ) { $ parts = \ explode ( '=' , $ cookie , 2 ) ; if ( 2 !== \ count ( $ parts ) ) { return [ ] ; } list ( $ name , $ value ) = $ parts ; $ result [ ] = new self ( \ trim ( $ name ) , \ trim ( $ value , " \t\"" ) ) ; } } catch ( InvalidCookieException $ e ) { return [ ] ; } return $ result ; }
Parses the cookies from a cookie header .
59,907
public function withExpiry ( \ DateTimeInterface $ date ) : self { $ new = clone $ this ; if ( $ date instanceof \ DateTimeImmutable ) { $ new -> expiry = $ date ; } elseif ( $ date instanceof \ DateTime ) { $ new -> expiry = \ DateTimeImmutable :: createFromMutable ( $ date ) ; } else { $ new -> expiry = new \ DateTimeImmutable ( "@" . $ date -> getTimestamp ( ) ) ; } return $ new ; }
Applies the given expiry to the cookie .
59,908
public function changeField ( $ name , array $ attributes ) { Argument :: i ( ) -> test ( 1 , 'string' ) ; $ this -> changeFields [ $ name ] = $ attributes ; return $ this ; }
Changes attributes of the table given the field name
59,909
public function getSEOScoreTips ( ) { $ score_criteria_tips = array ( 'pagesubject_defined' => _t ( 'SEO.SEOScoreTipPageSubjectDefined' , 'Page subject is not defined for page' ) , 'pagesubject_in_title' => _t ( 'SEO.SEOScoreTipPageSubjectInTitle' , 'Page subject is not in the title of this page' ) , 'pagesubject_in_firstparagraph' => _t ( 'SEO.SEOScoreTipPageSubjectInFirstParagraph' , 'Page subject is not present in the first paragraph of the content of this page' ) , 'pagesubject_in_url' => _t ( 'SEO.SEOScoreTipPageSubjectInURL' , 'Page subject is not present in the URL of this page' ) , 'pagesubject_in_metadescription' => _t ( 'SEO.SEOScoreTipPageSubjectInMetaDescription' , 'Page subject is not present in the meta description of the page' ) , 'numwords_content_ok' => _t ( 'SEO.SEOScoreTipNumwordsContentOk' , 'The content of this page is too short and does not have enough words. Please create content of at least 300 words based on the Page subject.' ) , 'pagetitle_length_ok' => _t ( 'SEO.SEOScoreTipPageTitleLengthOk' , 'The title of the page is not long enough and should have a length of at least 40 characters.' ) , 'content_has_links' => _t ( 'SEO.SEOScoreTipContentHasLinks' , 'The content of this page does not have any (outgoing) links.' ) , 'page_has_images' => _t ( 'SEO.SEOScoreTipPageHasImages' , 'The content of this page does not have any images.' ) , 'content_has_subtitles' => _t ( 'SEO.SEOScoreTipContentHasSubtitles' , 'The content of this page does not have any subtitles' ) , 'images_have_alt_tags' => _t ( 'SEO.SEOScoreTipImagesHaveAltTags' , 'All images on this page do not have alt tags' ) , 'images_have_title_tags' => _t ( 'SEO.SEOScoreTipImagesHaveTitleTags' , 'All images on this page do not have title tags' ) ) ; return $ score_criteria_tips ; }
getSEOScoreTips . Get array of tips translated in current locale
59,910
public function getHTMLStars ( ) { $ treshold_score = $ this -> seo_score - 2 < 0 ? 0 : $ this -> seo_score - 2 ; $ num_stars = intval ( ceil ( $ treshold_score ) / 2 ) ; $ num_nostars = 5 - $ num_stars ; $ html = '<div id="fivestar-widget">' ; for ( $ i = 1 ; $ i <= $ num_stars ; $ i ++ ) { $ html .= '<div class="star on"></div>' ; } if ( $ treshold_score % 2 ) { $ html .= '<div class="star on-half"></div>' ; $ num_nostars -- ; } for ( $ i = 1 ; $ i <= $ num_nostars ; $ i ++ ) { $ html .= '<div class="star"></div>' ; } $ html .= '</div>' ; return $ html ; }
getHTMLStars . Get html of stars rating in CMS maximum score is 12 threshold 2
59,911
public function getSEOScoreCalculation ( ) { $ this -> score_criteria [ 'pagesubject_defined' ] = $ this -> checkPageSubjectDefined ( ) ; $ this -> score_criteria [ 'pagesubject_in_title' ] = $ this -> checkPageSubjectInTitle ( ) ; $ this -> score_criteria [ 'pagesubject_in_firstparagraph' ] = $ this -> checkPageSubjectInFirstParagraph ( ) ; $ this -> score_criteria [ 'pagesubject_in_url' ] = $ this -> checkPageSubjectInUrl ( ) ; $ this -> score_criteria [ 'pagesubject_in_metadescription' ] = $ this -> checkPageSubjectInMetaDescription ( ) ; $ this -> score_criteria [ 'numwords_content_ok' ] = $ this -> checkNumWordsContent ( ) ; $ this -> score_criteria [ 'pagetitle_length_ok' ] = $ this -> checkPageTitleLength ( ) ; $ this -> score_criteria [ 'content_has_links' ] = $ this -> checkContentHasLinks ( ) ; $ this -> score_criteria [ 'page_has_images' ] = $ this -> checkPageHasImages ( ) ; $ this -> score_criteria [ 'content_has_subtitles' ] = $ this -> checkContentHasSubtitles ( ) ; $ this -> score_criteria [ 'images_have_alt_tags' ] = $ this -> checkImageAltTags ( ) ; $ this -> score_criteria [ 'images_have_title_tags' ] = $ this -> checkImageTitleTags ( ) ; $ this -> seo_score = intval ( array_sum ( $ this -> score_criteria ) ) ; }
getSEOScoreCalculation . Do SEO score calculation and set class Array score_criteria 12 corresponding assoc values Also set class Integer seo_score with score 0 - 12 based on values which are true in score_criteria array Do SEO score calculation and set class Array score_criteria 11 corresponding assoc values Also set class Integer seo_score with score 0 - 12 based on values which are true in score_criteria array
59,912
public function setSEOScoreTipsUL ( ) { $ tips = $ this -> getSEOScoreTips ( ) ; $ this -> seo_score_tips = '<ul id="seo_score_tips">' ; foreach ( $ this -> score_criteria as $ index => $ crit ) { if ( ! $ crit ) { $ this -> seo_score_tips .= '<li>' . $ tips [ $ index ] . '</li>' ; } } $ this -> seo_score_tips .= '</ul>' ; }
setSEOScoreTipsUL . Set SEO Score tips ul > li for SEO tips literal field based on score_criteria
59,913
private function createDOMDocumentFromHTML ( $ html = null ) { if ( $ html != null ) { libxml_use_internal_errors ( true ) ; $ dom = new DOMDocument ; $ dom -> loadHTML ( $ html ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( false ) ; return $ dom ; } }
checkContentHasSubtitles . check if page Content has a h2 s in it
59,914
public function checkPageSubjectInImageAltTags ( ) { $ html = $ this -> getPageContent ( ) ; if ( $ html == '' ) { return false ; } $ dom = $ this -> createDOMDocumentFromHTML ( $ html ) ; $ images = $ dom -> getElementsByTagName ( 'img' ) ; foreach ( $ images as $ image ) { if ( $ image -> hasAttribute ( 'alt' ) && $ image -> getAttribute ( 'alt' ) != '' ) { if ( preg_match ( '/' . preg_quote ( $ this -> owner -> SEOPageSubject , '/' ) . '/i' , $ image -> getAttribute ( 'alt' ) ) ) { return true ; } } } return false ; }
checkPageSubjectInImageAlt . Checks if image alt tags contain page subject
59,915
private function checkImageAltTags ( ) { $ html = $ this -> getPageContent ( ) ; if ( $ html == '' ) { return false ; } $ dom = $ this -> createDOMDocumentFromHTML ( $ html ) ; $ images = $ dom -> getElementsByTagName ( 'img' ) ; $ imagesWithAltTags = 0 ; foreach ( $ images as $ image ) { if ( $ image -> hasAttribute ( 'alt' ) && $ image -> getAttribute ( 'alt' ) != '' ) { $ imagesWithAltTags ++ ; } } if ( $ imagesWithAltTags == $ images -> length ) { return true ; } return false ; }
checkImageAltTags . Checks if images in content have alt tags
59,916
private function checkImageTitleTags ( ) { $ html = $ this -> getPageContent ( ) ; if ( $ html == '' ) { return false ; } $ dom = $ this -> createDOMDocumentFromHTML ( $ html ) ; $ images = $ dom -> getElementsByTagName ( 'img' ) ; $ imagesWithTitleTags = 0 ; foreach ( $ images as $ image ) { if ( $ image -> hasAttribute ( 'title' ) && $ image -> getAttribute ( 'title' ) != '' ) { $ imagesWithTitleTags ++ ; } } if ( $ imagesWithTitleTags == $ images -> length ) { return true ; } return false ; }
checkImageTitleTags . Checks if images in content have title tags
59,917
public function checkPageSubjectInTitle ( ) { if ( $ this -> checkPageSubjectDefined ( ) ) { if ( preg_match ( '/' . preg_quote ( $ this -> owner -> SEOPageSubject , '/' ) . '/i' , $ this -> owner -> MetaTitle ) ) { return true ; } elseif ( preg_match ( '/' . preg_quote ( $ this -> owner -> SEOPageSubject , '/' ) . '/i' , $ this -> owner -> Title ) ) { return true ; } else { return false ; } } return false ; }
checkPageSubjectInTitle . Checks if defined PageSubject is present in the Page Title
59,918
public function checkPageSubjectInContent ( ) { if ( $ this -> checkPageSubjectDefined ( ) ) { if ( preg_match ( '/' . preg_quote ( $ this -> owner -> SEOPageSubject , '/' ) . '/i' , $ this -> getPageContent ( ) ) ) { return true ; } else { return false ; } } return false ; }
checkPageSubjectInContent . Checks if defined PageSubject is present in the Page Content
59,919
public function checkPageSubjectInFirstParagraph ( ) { if ( $ this -> checkPageSubjectDefined ( ) ) { $ first_paragraph = $ this -> owner -> dbObject ( 'Content' ) -> FirstParagraph ( ) ; if ( trim ( $ first_paragraph != '' ) ) { if ( preg_match ( '/' . preg_quote ( $ this -> owner -> SEOPageSubject , '/' ) . '/i' , $ first_paragraph ) ) { return true ; } else { return false ; } } } return false ; }
checkPageSubjectInFirstParagraph . Checks if defined PageSubject is present in the Page Content s First Paragraph
59,920
public function checkPageSubjectInUrl ( ) { if ( $ this -> checkPageSubjectDefined ( ) ) { $ url_segment = $ this -> owner -> URLSegment ; $ pagesubject_url_segment = $ this -> owner -> generateURLSegment ( $ this -> owner -> SEOPageSubject ) ; if ( preg_match ( '/' . preg_quote ( $ pagesubject_url_segment , '/' ) . '/i' , $ url_segment ) ) { return true ; } else { return false ; } } return false ; }
checkPageSubjectInUrl . Checks if defined PageSubject is present in the Page URLSegment
59,921
public function checkPageSubjectInMetaDescription ( ) { if ( $ this -> checkPageSubjectDefined ( ) ) { if ( preg_match ( '/' . preg_quote ( $ this -> owner -> SEOPageSubject , '/' ) . '/i' , $ this -> owner -> MetaDescription ) ) { return true ; } else { return false ; } } return false ; }
checkPageSubjectInMetaDescription . Checks if defined PageSubject is present in the Page MetaDescription
59,922
private function checkPageTitleLength ( ) { $ site_title_length = strlen ( $ this -> owner -> getSiteConfig ( ) -> Title ) ; return ( ( $ this -> getNumCharsTitle ( ) + 3 + $ site_title_length ) >= 40 ) ? true : false ; }
checkPageTitleLength . check if length of Title and SiteConfig . Title has a minimal of 40 chars
59,923
private function checkPageHasImages ( ) { $ html = $ this -> getPageContent ( ) ; if ( $ html == '' ) { return false ; } $ dom = $ this -> createDOMDocumentFromHTML ( $ html ) ; $ elements = $ dom -> getElementsByTagName ( 'img' ) ; return ( $ elements -> length ) ? true : false ; }
checkPageHasImages . check if page Content has a img s in it
59,924
public static function fromSruRecord ( SruRecord $ record , Client $ client = null ) { $ record -> data -> registerXPathNamespace ( 'marc' , 'http://www.loc.gov/MARC21/slim' ) ; $ mmsId = $ record -> data -> text ( './/marc:controlfield[@tag="001"]' ) ; return ( new self ( $ client , $ mmsId ) ) -> setMarcRecord ( $ record -> data -> asXML ( ) ) ; }
Initialize from SRU record without having to fetch the Bib record .
59,925
public function save ( ) { $ this -> init ( ) ; $ marcXml = new QuiteSimpleXMLElement ( $ this -> _marc -> toXML ( 'UTF-8' , false , false ) ) ; $ this -> data -> first ( 'record' ) -> replace ( $ marcXml ) ; $ newData = $ this -> data -> asXML ( ) ; $ newData = str_replace ( ' xmlns="http://www.loc.gov/MARC21/slim"' , '' , $ newData ) ; return $ this -> client -> putXML ( $ this -> url ( ) , $ newData ) ; }
Save the MARC record .
59,926
public function getNzMmsId ( ) { $ this -> init ( ) ; $ nz_mms_id = $ this -> data -> text ( "linked_record_id[@type='NZ']" ) ; if ( ! $ nz_mms_id ) { throw new NoLinkedNetworkZoneRecordException ( "Record $this->mms_id is not linked to a network zone record." ) ; } return $ nz_mms_id ; }
Get the MMS ID of the linked record in network zone .
59,927
protected function configureArrayProperty ( $ property , OptionsResolver $ resolver ) { $ resolver -> setAllowedTypes ( $ property , [ 'array' , 'string' ] ) -> setNormalizer ( $ property , function ( Options $ options , $ value ) { return is_array ( $ value ) ? $ value : explode ( ',' , str_replace ( ' ' , '' , $ value ) ) ; } ) ; }
Configures an array property for OptionsResolver .
59,928
protected function configureEnvironmentProperty ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'environment' ) -> setAllowedTypes ( 'environment' , [ 'array' , 'string' ] ) -> setNormalizer ( 'environment' , function ( Options $ options , $ value ) { if ( is_array ( $ value ) ) { $ normalized = [ ] ; foreach ( $ value as $ key => $ val ) { is_string ( $ key ) and $ normalized [ ] = sprintf ( '%s="%s"' , strtoupper ( $ key ) , $ val ) ; } $ value = implode ( ',' , $ normalized ) ; } return $ value ; } ) ; }
Configures an environment property for OptionsResolver .
59,929
protected function configureByteProperty ( $ property , OptionsResolver $ resolver ) { $ resolver -> setAllowedTypes ( $ property , 'byte' ) -> setNormalizer ( $ property , function ( Options $ options , $ value ) { return is_numeric ( $ value ) ? intval ( $ value ) : $ value ; } ) ; }
Configures a byte property for OptionsResolver .
59,930
protected function buildUrl ( $ url , $ query = [ ] ) { $ url = explode ( '?' , $ url , 2 ) ; if ( count ( $ url ) == 2 ) { parse_str ( $ url [ 1 ] , $ query0 ) ; $ query = array_merge ( $ query0 , $ query ) ; } $ query [ 'apikey' ] = $ this -> key ; $ url = $ url [ 0 ] ; if ( strpos ( $ url , $ this -> baseUrl ) === false ) { $ url = $ this -> baseUrl . $ url ; } return $ this -> uriFactory -> createUri ( $ url ) -> withQuery ( http_build_query ( $ query ) ) ; }
Extend an URL with query string parameters and return an UriInterface object .
59,931
public function getJSON ( $ url , $ query = [ ] ) { $ responseBody = $ this -> get ( $ url , $ query , 'application/json' ) ; return json_decode ( $ responseBody ) ; }
Make a GET request accepting JSON .
59,932
public function getXML ( $ url , $ query = [ ] ) { $ responseBody = $ this -> get ( $ url , $ query , 'application/xml' ) ; return new QuiteSimpleXMLElement ( $ responseBody ) ; }
Make a GET request accepting XML .
59,933
public function putJSON ( $ url , $ data ) { $ responseBody = $ this -> put ( $ url , json_encode ( $ data ) , 'application/json' ) ; return json_decode ( $ responseBody ) ; }
Make a PUT request sending JSON data .
59,934
public function putXML ( $ url , $ data ) { $ responseBody = $ this -> put ( $ url , $ data , 'application/xml' ) ; return new QuiteSimpleXMLElement ( $ responseBody ) ; }
Make a PUT request sending XML data .
59,935
public function post ( $ url , $ data , $ contentType = 'application/json' ) { $ uri = $ this -> buildUrl ( $ url ) ; $ request = $ this -> requestFactory -> createRequest ( 'POST' , $ uri ) ; if ( ! is_null ( $ contentType ) ) { $ request = $ request -> withHeader ( 'Content-Type' , $ contentType ) ; $ request = $ request -> withHeader ( 'Accept' , $ contentType ) ; } $ request = $ request -> withBody ( stream_for ( $ data ) ) ; $ response = $ this -> request ( $ request ) ; return strval ( $ response -> getBody ( ) ) ; }
Make a POST request .
59,936
public function postJSON ( $ url , $ data = null ) { $ responseBody = $ this -> post ( $ url , json_encode ( $ data ) , 'application/json' ) ; return json_decode ( $ responseBody ) ; }
Make a POST request sending JSON data .
59,937
public function postXML ( $ url , $ data = null ) { $ responseBody = $ this -> post ( $ url , $ data , 'application/xml' ) ; return new QuiteSimpleXMLElement ( $ responseBody ) ; }
Make a POST request sending XML data .
59,938
public function getRedirectLocation ( $ url , $ query = [ ] ) { $ url = $ this -> buildUrl ( $ url , $ query ) ; $ request = $ this -> requestFactory -> createRequest ( 'GET' , $ url ) ; try { $ response = $ this -> request ( $ request ) ; } catch ( ResourceNotFound $ e ) { return ; } $ locations = $ response -> getHeader ( 'Location' ) ; return count ( $ locations ) ? $ locations [ 0 ] : null ; }
Get the redirect target location of an URL or null if not a redirect .
59,939
protected function parseClientError ( HttpException $ exception ) { $ contentType = explode ( ';' , $ exception -> getResponse ( ) -> getHeaderLine ( 'Content-Type' ) ) [ 0 ] ; $ responseBody = ( string ) $ exception -> getResponse ( ) -> getBody ( ) ; switch ( $ contentType ) { case 'application/json' : $ res = json_decode ( $ responseBody , true ) ; if ( isset ( $ res [ 'web_service_result' ] ) ) { $ res = $ res [ 'web_service_result' ] ; } $ err = $ res [ 'errorList' ] [ 'error' ] [ 0 ] ; $ message = $ err [ 'errorMessage' ] ; $ code = $ err [ 'errorCode' ] ; break ; case 'application/xml' : $ xml = new QuiteSimpleXMLElement ( $ responseBody ) ; $ xml -> registerXPathNamespace ( 'xb' , 'http://com/exlibris/urm/general/xmlbeans' ) ; $ message = $ xml -> text ( '//xb:errorMessage' ) ; $ code = $ xml -> text ( '//xb:errorCode' ) ; break ; default : $ message = $ responseBody ; $ code = '' ; } $ code = empty ( $ code ) ? null : ( string ) $ code ; if ( strtolower ( $ message ) == 'invalid api key' ) { return new InvalidApiKey ( $ message , null , $ exception ) ; } if ( preg_match ( '/(no items?|not) found/i' , $ message ) ) { return new ResourceNotFound ( $ message , $ code , $ exception ) ; } return new RequestFailed ( $ message , $ code , $ exception ) ; }
Generate a client exception .
59,940
protected function setHeaders ( array $ headers ) { $ before = $ this -> headers ; try { foreach ( $ headers as $ name => $ value ) { $ this -> setHeader ( $ name , $ value ) ; } } catch ( \ Throwable $ e ) { $ this -> headers = $ before ; throw $ e ; } }
Sets the headers from the given array .
59,941
private function isValueValid ( array $ values ) : bool { foreach ( $ values as $ value ) { if ( \ preg_match ( "/[^\t\r\n\x20-\x7e\x80-\xfe]|\r\n/" , $ value ) ) { return false ; } } return true ; }
Determines if the given value is a valid header value .
59,942
public static function parseHeaders ( string $ rawHeaders ) : array { \ assert ( \ substr ( $ rawHeaders , - 2 ) === "\r\n" , "Argument 1 must end with CRLF" ) ; $ count = \ preg_match_all ( self :: HEADER_REGEX , $ rawHeaders , $ matches , \ PREG_SET_ORDER ) ; if ( $ count !== \ substr_count ( $ rawHeaders , "\n" ) ) { if ( \ preg_match ( self :: HEADER_FOLD_REGEX , $ rawHeaders ) ) { throw new InvalidHeaderException ( "Invalid header syntax: Obsolete line folding" ) ; } throw new InvalidHeaderException ( "Invalid header syntax" ) ; } $ headers = [ ] ; foreach ( $ matches as $ match ) { $ headers [ \ strtolower ( $ match [ 1 ] ) ] [ ] = $ match [ 2 ] ; } return $ headers ; }
Parses headers according to RFC 7230 and 2616 .
59,943
public static function formatHeaders ( array $ headers ) : string { $ buffer = "" ; $ lines = 0 ; foreach ( $ headers as $ name => $ values ) { $ name = ( string ) $ name ; if ( $ name [ 0 ] === ":" ) { continue ; } foreach ( $ values as $ value ) { $ buffer .= "{$name}: {$value}\r\n" ; $ lines ++ ; } } $ count = \ preg_match_all ( self :: HEADER_REGEX , $ buffer ) ; if ( $ lines !== $ count || $ lines !== \ substr_count ( $ buffer , "\n" ) ) { throw new InvalidHeaderException ( "Invalid headers" ) ; } return $ buffer ; }
Format headers in to their on - the - wire format .
59,944
protected function loadRoutes ( ) : RouteCollection { $ builder = $ this -> getRouteCollectionBuilder ( ) ; if ( \ is_callable ( $ this -> routeCallback ) ) { call_user_func ( $ this -> routeCallback , $ builder ) ; } return $ builder -> build ( ) ; }
Returns routes for request handling .
59,945
public function handle ( Request $ request ) : Response { try { $ matcher = $ this -> getUrlMatcher ( $ request ) ; $ parameters = $ matcher -> match ( $ request -> getPathInfo ( ) ) ; if ( empty ( $ parameters [ '_controller' ] ) ) { throw new InvalidRouteException ( 'Route requires a _controller callable' ) ; } if ( ! \ is_callable ( $ parameters [ '_controller' ] ) ) { throw new InvalidRouteException ( '_controller must be a callable' ) ; } $ callback = $ parameters [ '_controller' ] ; $ result = call_user_func_array ( $ callback , $ this -> getControllerParameters ( $ request , $ parameters ) ) ; if ( ! $ result instanceof Response ) { throw new InvalidResponseException ( 'Response must be an instance of \Symfony\Component\HttpFoundation\Response' ) ; } } catch ( \ Exception $ e ) { $ result = $ this -> handleException ( $ request , $ e ) ; } return $ result ; }
Handles HTTP request and returns response .
59,946
protected function getControllerParameters ( Request $ request , array $ parameters ) : array { $ result = [ $ request ] ; foreach ( $ parameters as $ key => $ value ) { if ( strpos ( $ key , '_' ) !== 0 ) { $ result [ $ key ] = $ value ; } } return $ result ; }
Returns arguments for controller callback .
59,947
public function options ( string $ pattern , $ callback , array $ requirements = [ ] ) { return $ this -> match ( $ pattern , $ callback , $ requirements , [ Request :: METHOD_OPTIONS ] ) ; }
Maps an OPTIONS request to a callable .
59,948
public function compare ( \ DateInterval $ first , \ DateInterval $ second ) { if ( $ this -> safe ) { $ this -> safecheck ( $ first ) ; $ this -> safecheck ( $ second ) ; } if ( $ first -> y > $ second -> y ) { return 1 ; } if ( $ first -> y < $ second -> y ) { return - 1 ; } if ( $ first -> m > $ second -> m ) { return 1 ; } if ( $ first -> m < $ second -> m ) { return - 1 ; } if ( $ first -> d > $ second -> d ) { return 1 ; } if ( $ first -> d < $ second -> d ) { return - 1 ; } if ( $ first -> h > $ second -> h ) { return 1 ; } if ( $ first -> h < $ second -> h ) { return - 1 ; } if ( $ first -> i > $ second -> i ) { return 1 ; } if ( $ first -> i < $ second -> i ) { return - 1 ; } if ( $ first -> s > $ second -> s ) { return 1 ; } if ( $ first -> s < $ second -> s ) { return - 1 ; } return 0 ; }
COmpare the two date intervals .
59,949
protected function replaceEndpoint ( string & $ stub , string $ endpoint ) { if ( strlen ( $ endpoint ) > 0 ) $ stub = str_replace ( '/dummy/endpoint/' , $ endpoint , $ stub ) ; return $ this ; }
Replace the endpoint for the given stub .
59,950
protected function replaceVersion ( string & $ stub , string $ version ) { if ( strlen ( $ version ) > 0 ) $ stub = str_replace ( 'v1' , $ version , $ stub ) ; return $ this ; }
Replace the endpoint version for the given stub .
59,951
protected function replaceScope ( string & $ stub , string $ scope ) { if ( strlen ( $ scope ) > 0 ) $ stub = str_replace ( "'public'" , "'$scope'" , $ stub ) ; return $ this ; }
Replace the scope for the given stub .
59,952
protected function generatePrivateKey ( $ path , $ passphrase ) { if ( $ passphrase ) { $ processArgs = sprintf ( 'genrsa -out %s/private.pem -aes256 -passout pass:%s 4096' , $ path , $ passphrase ) ; } else { $ processArgs = sprintf ( 'genrsa -out %s/private.pem 4096' , $ path ) ; } $ this -> generateKey ( $ processArgs ) ; }
Generate a RSA private key .
59,953
protected function generatePublicKey ( $ path , $ passphrase ) { $ processArgs = sprintf ( 'rsa -pubout -in %s/private.pem -out %s/public.pem -passin pass:%s' , $ path , $ path , $ passphrase ) ; $ this -> generateKey ( $ processArgs ) ; }
Generate a RSA public key .
59,954
protected function generateKey ( $ processArgs ) { $ process = new Process ( sprintf ( 'openssl %s' , $ processArgs ) ) ; $ process -> setTimeout ( 3600 ) ; $ process -> run ( function ( $ type , $ buffer ) { $ this -> io -> write ( $ buffer ) ; } ) ; if ( ! $ process -> isSuccessful ( ) ) { throw new ProcessFailedException ( $ process ) ; } $ process -> getExitCode ( ) ; }
Generate a RSA key .
59,955
public function addUniqueKey ( $ name , array $ fields ) { Argument :: i ( ) -> test ( 1 , 'string' ) ; $ this -> uniqueKeys [ $ name ] = $ fields ; return $ this ; }
Adds a unique key
59,956
public function registerAction ( ) { $ userIdentityField = $ this -> container -> getParameter ( 'rch_jwt_user.user_identity_field' ) ; $ userManager = $ this -> container -> get ( 'fos_user.user_manager' ) ; $ userClass = $ userManager -> getClass ( ) ; $ rules = [ $ userIdentityField => [ 'requirements' => [ 'email' == $ userIdentityField ? new Email ( ) : '[^/]+' ] , ] , 'password' => [ 'requirements' => '[^/]+' ] , ] ; $ params = $ this -> get ( 'rch_jwt_user.credential_fetcher' ) -> create ( $ rules ) -> all ( ) ; $ user = $ this -> createUser ( $ params , $ userManager ) ; return $ this -> renderToken ( $ user , 201 ) ; }
Register a new User and authenticate it .
59,957
public function loginFromOAuthResponseAction ( ) { $ userManager = $ this -> container -> get ( 'fos_user.user_manager' ) ; $ userIdentityField = $ this -> container -> get ( 'rch_jwt_user.user_identity_field' ) ; $ data = $ this -> get ( 'rch_jwt_user.credential_fetcher' ) -> create ( [ $ userIdentityField => [ 'requirements' => $ userIdentityField == 'email' ? new Email ( ) : '[^/+]' ] , 'facebook_id' => [ 'requirements' => '\d+' ] , 'facebook_access_token' => [ 'requirements' => '[^/]+' ] , ] ) -> all ( ) ; if ( true !== $ this -> isValidFacebookAccount ( $ data [ 'facebook_id' ] , $ data [ 'facebook_access_token' ] ) ) { throw new InvalidPropertyUserException ( 'The given facebook_id does not correspond to a valid acount' ) ; } $ user = $ userManager -> findUserBy ( [ 'facebookId' => $ data [ 'facebook_id' ] ] ) ; if ( $ user ) { return $ this -> renderToken ( $ user ) ; } $ user = $ userManager -> findUserBy ( [ $ userIdentityField => $ data [ $ userIdentityField ] ] ) ; if ( $ user ) { $ user -> setFacebookId ( $ data [ 'facebook_id' ] ) ; $ userManager -> updateUser ( $ user ) ; return $ this -> renderToken ( $ user ) ; } $ data [ 'password' ] = $ this -> generateRandomPassword ( ) ; return $ this -> renderToken ( $ this -> createUser ( $ data ) ) ; }
Registers and authenticates User from a facebook OAuth Response .
59,958
protected function createUser ( array $ data , UserProviderInterface $ userManager ) { $ userIdentityfield = $ this -> container -> getParameter ( 'rch_jwt_user.user_identity_field' ) ; $ user = $ userManager -> createUser ( ) -> setUsername ( $ data [ $ userIdentityfield ] ) -> setEmail ( $ data [ $ userIdentityfield ] ) -> setEnabled ( true ) -> setPlainPassword ( $ data [ 'password' ] ) ; if ( isset ( $ data [ 'facebook_id' ] ) ) { $ user -> setFacebookId ( $ data [ 'facebook_id' ] ) ; } try { $ userManager -> updateUser ( $ user ) ; } catch ( \ Exception $ e ) { $ message = $ e -> getMessage ( ) ? : 'An error occured while creating the user.' ; throw new UserException ( 422 , $ message , $ e ) ; } return $ user ; }
Creates a new User .
59,959
protected function renderToken ( UserInterface $ user , $ statusCode = 200 ) { $ body = [ 'token' => $ this -> container -> get ( 'lexik_jwt_authentication.jwt_manager' ) -> create ( $ user ) , 'refresh_token' => $ this -> attachRefreshToken ( $ user ) , 'user' => $ user -> getUsername ( ) , ] ; return new JsonResponse ( $ body , $ statusCode ) ; }
Generates a JWT from given User .
59,960
protected function attachRefreshToken ( UserInterface $ user ) { $ refreshTokenManager = $ this -> container -> get ( 'gesdinet.jwtrefreshtoken.refresh_token_manager' ) ; $ refreshToken = $ refreshTokenManager -> getLastFromUsername ( $ user -> getUsername ( ) ) ; $ refreshTokenTtl = $ this -> container -> getParameter ( 'gesdinet_jwt_refresh_token.ttl' ) ; if ( ! $ refreshToken instanceof RefreshToken ) { $ refreshToken = $ refreshTokenManager -> create ( ) ; $ expirationDate = new \ DateTime ( ) ; $ expirationDate -> modify ( sprintf ( '+%s seconds' , $ refreshTokenTtl ) ) ; $ refreshToken -> setUsername ( $ user -> getUsername ( ) ) ; $ refreshToken -> setRefreshToken ( ) ; $ refreshToken -> setValid ( $ expirationDate ) ; $ refreshTokenManager -> save ( $ refreshToken ) ; } return $ refreshToken -> getRefreshToken ( ) ; }
Provides a refresh token .
59,961
protected function createJsonResponseForException ( UserException $ exception ) { $ message = $ exception -> getMessage ( ) ; $ statusCode = $ exception -> getStatusCode ( ) ; $ content = [ 'error' => str_replace ( '"' , '\'' , $ message ) ] ; return new JsonResponse ( $ content , $ statusCode ) ; }
Create JsonResponse for Exception .
59,962
public function renameTable ( $ table , $ name ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> argument ( 2 , 'string' ) ; $ this -> query = 'RENAME TABLE `' . $ table . '` TO `' . $ name . '`' ; return $ this ; }
Query for renaming a table
59,963
public function setRequirements ( ) { if ( ! isset ( $ this -> options [ 'requirements' ] ) || $ this -> options [ 'requirements' ] === null ) { return $ this ; } $ requirements = $ this -> options [ 'requirements' ] ; if ( ! is_array ( $ requirements ) ) { $ requirements = [ $ requirements ] ; } foreach ( $ requirements as $ constraint ) { $ this -> requirements [ ] = $ constraint ; } unset ( $ this -> options [ 'requirements' ] ) ; return $ this ; }
Set requirements .
59,964
public function removeSection ( $ section ) { if ( $ has = $ this -> hasSection ( $ section ) ) { unset ( $ this -> sections [ $ section ] ) ; } return $ has ; }
Removes a section by name .
59,965
public function toArray ( ) { $ ini = [ ] ; foreach ( $ this -> sections as $ sectionName => $ section ) { $ ini [ $ sectionName ] = $ section -> getProperties ( ) ; } return $ ini ; }
Converts the configuration to array .
59,966
public function mapSection ( $ section , $ className ) { if ( false === class_exists ( $ className ) ) { throw new \ InvalidArgumentException ( 'This section class does not exist' ) ; } elseif ( false === is_a ( $ className , 'Supervisor\Configuration\Section' , true ) ) { throw new \ InvalidArgumentException ( 'This section class must implement Supervisor\Configuration\Section' ) ; } $ this -> sectionMap [ $ section ] = $ className ; }
Adds or overrides a default section mapping .
59,967
public function findSection ( $ section ) { if ( isset ( $ this -> sectionMap [ $ section ] ) ) { return $ this -> sectionMap [ $ section ] ; } return false ; }
Finds a section class by name .
59,968
public function fromBarcode ( $ barcode ) { $ destinationUrl = $ this -> client -> getRedirectLocation ( '/items' , [ 'item_barcode' => $ barcode ] ) ; if ( ! is_null ( $ destinationUrl ) && preg_match ( '$bibs/([0-9]+)/holdings/([0-9]+)/items/([0-9]+)$' , $ destinationUrl , $ matches ) ) { $ mms_id = $ matches [ 1 ] ; $ holding_id = $ matches [ 2 ] ; $ item_id = $ matches [ 3 ] ; $ bib = Bib :: make ( $ this -> client , $ mms_id ) ; $ holding = Holding :: make ( $ this -> client , $ bib , $ holding_id ) ; return Item :: make ( $ this -> client , $ bib , $ holding , $ item_id ) ; } }
Get an Item object from a barcode .
59,969
public function subselect ( $ parentQuery , $ select = '*' ) { Argument :: i ( ) -> test ( 2 , 'string' ) ; return Subselect :: i ( $ parentQuery , $ select ) ; }
Returns the Subselect query builder
59,970
public function getSchema ( ) { $ backup = array ( ) ; $ tables = $ this -> getTables ( ) ; foreach ( $ tables as $ table ) { $ backup [ ] = $ this -> getBackup ( ) ; } return implode ( "\n\n" , $ backup ) ; }
Returns the whole enitre schema and rows of the current databse
59,971
public function attach ( Task $ task , $ task_name = null ) { if ( is_null ( $ task_name ) ) { $ task_name = count ( $ this -> tasks ) ; } $ this -> tasks [ $ task_name ] = $ task ; curl_multi_add_handle ( $ this -> curl , $ task -> createCurl ( ) ) ; $ deferred = new Deferred ( ) ; $ this -> deferred [ $ task_name ] = $ deferred ; return $ deferred -> promise ( ) ; }
add new task and return a promise
59,972
public function get ( $ user_id , $ params = [ ] ) { return User :: make ( $ this -> client , $ user_id ) -> setParams ( $ params ) ; }
Get a User object by id .
59,973
public function search ( $ query , array $ options = [ ] ) { $ limit = array_key_exists ( 'limit' , $ options ) ? $ options [ 'limit' ] : 0 ; $ phrase = array_key_exists ( 'phrase' , $ options ) ? $ options [ 'phrase' ] : false ; $ expand = array_key_exists ( 'expand' , $ options ) ? $ options [ 'expand' ] : false ; $ batchSize = array_key_exists ( 'batchSize' , $ options ) ? $ options [ 'batchSize' ] : 10 ; if ( $ limit != 0 && $ limit < $ batchSize ) { $ batchSize = $ limit ; } $ query = explode ( ' AND ' , $ query ) ; $ query = $ phrase ? str_replace ( ' ' , '_' , $ query ) : str_replace ( ' ' , ',' , $ query ) ; $ query = implode ( ' AND ' , $ query ) ; $ offset = 0 ; while ( true ) { $ response = $ this -> client -> getJSON ( '/users' , [ 'q' => $ query , 'limit' => $ batchSize , 'offset' => $ offset ] ) ; if ( $ response -> total_record_count == - 1 ) { throw new InvalidQuery ( $ query ) ; } if ( $ response -> total_record_count == 0 ) { break ; } if ( ! isset ( $ response -> user ) || empty ( $ response -> user ) ) { break ; } foreach ( $ response -> user as $ data ) { $ offset ++ ; if ( strpos ( $ data -> primary_id , 'no primary id' ) === 0 ) { continue ; } $ user = User :: make ( $ this -> client , $ data -> primary_id ) -> init ( $ data ) ; if ( $ expand ) { $ user -> init ( ) ; } yield $ user ; } if ( $ offset >= $ response -> total_record_count ) { break ; } if ( $ limit != 0 && $ offset >= $ limit ) { break ; } } }
Iterates over all users matching the given query . Handles continuation .
59,974
public function get ( $ mms_id , $ expand = null ) { $ params = [ 'expand' => $ expand ] ; return Bib :: make ( $ this -> client , $ mms_id ) -> setParams ( $ params ) ; }
Get a Bib object .
59,975
public function fromBarcode ( $ barcode ) { $ destinationUrl = $ this -> client -> getRedirectLocation ( '/items' , [ 'item_barcode' => $ barcode ] ) ; if ( ! is_null ( $ destinationUrl ) && preg_match ( '$bibs/([0-9]+)/holdings/([0-9]+)/items/([0-9]+)$' , $ destinationUrl , $ matches ) ) { $ mmsId = $ matches [ 1 ] ; return $ this -> get ( $ mmsId ) ; } }
Get a Bib object from a item barcode .
59,976
public function fromHoldingsId ( $ holdings_id ) { $ data = $ this -> client -> getXML ( '/bibs' , [ 'holdings_id' => $ holdings_id ] ) ; return $ this -> get ( $ data -> text ( 'bib/mms_id' ) ) -> init ( $ data -> first ( 'bib' ) ) ; }
Get a Bib object from a holdings ID .
59,977
public function getGuzzle ( ) { if ( $ this -> guzzle ) return $ this -> guzzle ; $ this -> guzzle = new Client ( ) ; return $ this -> guzzle ; }
Get an instance of Guzzle .
59,978
public function isStorageOk ( ) { $ storage = storage_path ( ) . '/sde/' . $ this -> json -> version . '/' ; $ this -> info ( 'Storage path is: ' . $ storage ) ; if ( File :: isWritable ( storage_path ( ) ) ) { if ( ! File :: exists ( $ storage ) ) File :: makeDirectory ( $ storage , 0755 , true ) ; $ this -> storage_path = $ storage ; return true ; } return false ; }
Check that the storage path is ok . I needed it will be automatically created .
59,979
public function getProgressBar ( $ iterations ) { $ bar = $ this -> output -> createProgressBar ( $ iterations ) ; $ bar -> setFormat ( ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% %memory:6s%' ) ; return $ bar ; }
Get a new progress bar to display based on the amount of iterations we expect to use .
59,980
public function importSde ( ) { $ this -> line ( 'Importing...' ) ; $ bar = $ this -> getProgressBar ( count ( $ this -> json -> tables ) ) ; foreach ( $ this -> json -> tables as $ table ) { $ archive_path = $ this -> storage_path . $ table . $ this -> json -> format ; $ extracted_path = $ this -> storage_path . $ table . '.sql' ; if ( ! File :: exists ( $ archive_path ) ) { $ this -> warn ( $ archive_path . ' seems to be invalid. Skipping.' ) ; continue ; } $ input_file = bzopen ( $ archive_path , 'r' ) ; $ output_file = fopen ( $ extracted_path , 'w' ) ; while ( $ chunk = bzread ( $ input_file , 4096 ) ) fwrite ( $ output_file , $ chunk , 4096 ) ; bzclose ( $ input_file ) ; fclose ( $ output_file ) ; $ import_command = 'mysql -u ' . config ( 'database.connections.mysql.username' ) . ( strlen ( config ( 'database.connections.mysql.password' ) ) ? ' -p' : '' ) . escapeshellcmd ( config ( 'database.connections.mysql.password' ) ) . ' -h ' . config ( 'database.connections.mysql.host' ) . ' -P ' . config ( 'database.connections.mysql.port' ) . ' ' . config ( 'database.connections.mysql.database' ) . ' < ' . $ extracted_path ; exec ( $ import_command , $ output , $ exit_code ) ; if ( $ exit_code !== 0 ) $ this -> error ( 'Warning: Import failed with exit code ' . $ exit_code . ' and command outut: ' . implode ( '\n' , $ output ) ) ; $ bar -> advance ( ) ; } $ bar -> finish ( ) ; $ this -> line ( '' ) ; }
Extract the SDE files downloaded and run the MySQL command to import them into the database .
59,981
public function select ( $ select = 'ROWID,*' ) { Argument :: i ( ) -> test ( 1 , 'string' , 'array' ) ; return \ Eden \ Sql \ Select :: i ( $ select ) ; }
Returns the select query builder
59,982
public function all ( $ status = 'ACTIVE' ) { $ ids = [ $ this -> data -> primary_id ] ; foreach ( $ this -> data -> user_identifier as $ identifier ) { if ( is_null ( $ status ) || $ identifier -> status == $ status ) { $ ids [ ] = $ identifier -> value ; } } return $ ids ; }
Get a flat array of all the user IDs .
59,983
public function allOfType ( $ value , $ status = 'ACTIVE' ) { $ ids = [ ] ; foreach ( $ this -> data -> user_identifier as $ identifier ) { if ( $ identifier -> id_type -> value == $ value && ( is_null ( $ status ) || $ identifier -> status == $ status ) ) { $ ids [ ] = $ identifier -> value ; } } return $ ids ; }
Get all active user identifiers of a given type like BARCODE or UNIV_ID .
59,984
public function firstOfType ( $ value , $ status = 'ACTIVE' ) { foreach ( $ this -> data -> user_identifier as $ identifier ) { if ( $ identifier -> id_type -> value == $ value && ( is_null ( $ status ) || $ identifier -> status == $ status ) ) { return $ identifier -> value ; } } }
Get the first active user identifier of a given type like BARCODE or UNIV_ID .
59,985
protected function onData ( $ data ) { if ( is_null ( $ this -> totalRecordCount ) ) { $ this -> totalRecordCount = $ data -> total_record_count ; } if ( ! isset ( $ data -> { $ this -> responseKey } ) ) { return ; } foreach ( $ data -> { $ this -> responseKey } as $ result ) { $ this -> resources [ ] = $ this -> convertToResource ( $ result ) ; } }
Called when data is available on the object . The resource classes can use this method to process the data .
59,986
public function digestAuth ( $ realm , array $ users ) { if ( $ this -> isCLIRequest ( ) ) { return ; } if ( empty ( $ _SERVER [ 'PHP_AUTH_DIGEST' ] ) ) { $ this -> sendAuthenticateHeader ( $ realm ) ; exit ( ) ; } if ( ! ( $ data = $ this -> httpDigestParse ( $ _SERVER [ 'PHP_AUTH_DIGEST' ] ) ) || ! isset ( $ users [ $ data [ 'username' ] ] ) ) { $ this -> sendAuthenticateHeader ( $ realm ) ; exit ( ) ; } $ A1 = md5 ( $ data [ 'username' ] . ':' . $ realm . ':' . $ users [ $ data [ 'username' ] ] ) ; $ A2 = md5 ( $ _SERVER [ 'REQUEST_METHOD' ] . ':' . $ data [ 'uri' ] ) ; $ valid_response = md5 ( $ A1 . ':' . $ data [ 'nonce' ] . ':' . $ data [ 'nc' ] . ':' . $ data [ 'cnonce' ] . ':' . $ data [ 'qop' ] . ':' . $ A2 ) ; if ( $ data [ 'response' ] != $ valid_response ) { $ this -> sendAuthenticateHeader ( $ realm ) ; exit ( ) ; } }
Perform digest HTTP authentication
59,987
protected function isSSLRequest ( ) { if ( isset ( $ _SERVER [ 'HTTPS' ] ) ) { if ( 'on' == strtolower ( $ _SERVER [ 'HTTPS' ] ) ) { return true ; } if ( '1' == $ _SERVER [ 'HTTPS' ] ) { return true ; } } elseif ( isset ( $ _SERVER [ 'SERVER_PORT' ] ) && ( '443' == $ _SERVER [ 'SERVER_PORT' ] ) ) { return true ; } return false ; }
Checks if application is requested via secure SSL
59,988
public function clear_redis_cache ( ) { $ redis_host = config ( 'database.redis.default.host' ) ; $ redis_port = config ( 'database.redis.default.port' ) ; $ this -> info ( 'Clearing the Redis Cache at: ' . $ redis_host . ':' . $ redis_port ) ; try { $ redis = new Client ( [ 'host' => $ redis_host , 'port' => $ redis_port , ] ) ; $ redis -> flushall ( ) ; $ redis -> disconnect ( ) ; } catch ( Exception $ e ) { $ this -> error ( 'Failed to clear the Redis Cache. Error: ' . $ e -> getMessage ( ) ) ; } }
Flush all keys in Redis .
59,989
public function clear_eseye_cache ( ) { $ eseye_cache = config ( 'eveapi.config.eseye_cache' ) ; if ( File :: isWritable ( $ eseye_cache ) ) { $ this -> info ( 'Clearing the Eseye Cache at: ' . $ eseye_cache ) ; if ( ! File :: deleteDirectory ( $ eseye_cache , true ) ) $ this -> error ( 'Failed to clear the Eseye Cache directory. Check permissions.' ) ; } else { $ this -> warn ( 'Eseye Cache directory at ' . $ eseye_cache . ' is not writable' ) ; } }
Clear the Eseye Storage Cache .
59,990
protected function onData ( $ data ) { if ( isset ( $ this -> bib_data ) ) { $ this -> bib -> init ( $ this -> bib_data ) ; } if ( isset ( $ this -> holding_data ) ) { $ this -> holding -> init ( $ this -> holding_data ) ; } }
Called when data is available to be processed .
59,991
public function checkOut ( User $ user , Library $ library , $ circ_desk = 'DEFAULT_CIRC_DESK' ) { $ postData = [ 'library' => [ 'value' => $ library -> code ] , 'circ_desk' => [ 'value' => $ circ_desk ] , ] ; $ data = $ this -> client -> postJSON ( $ this -> url ( '/loans' , [ 'user_id' => $ user -> id ] ) , $ postData ) ; return Loan :: make ( $ this -> client , $ user , $ data -> loan_id ) -> init ( $ data ) ; }
Create a new loan .
59,992
public function scanIn ( Library $ library , $ circ_desk = 'DEFAULT_CIRC_DESK' , $ params = [ ] ) { $ params [ 'op' ] = 'scan' ; $ params [ 'library' ] = $ library -> code ; $ params [ 'circ_desk' ] = $ circ_desk ; $ data = $ this -> client -> postJSON ( $ this -> url ( '' , $ params ) ) ; return ScanInResponse :: make ( $ this -> client , $ data ) ; }
Perform scan - in on item .
59,993
public function getLoan ( ) { $ data = $ this -> client -> getJSON ( $ this -> url ( '/loans' ) ) ; if ( $ data -> total_record_count == 1 ) { return Loan :: make ( $ this -> client , User :: make ( $ this -> client , $ data -> item_loan [ 0 ] -> user_id ) , $ data -> item_loan [ 0 ] -> loan_id ) -> init ( $ data -> item_loan [ 0 ] ) ; } }
Get the current loan as a Loan object or null if the item is not loaned out .
59,994
public function onAuthenticationSuccessResponse ( AuthenticationSuccessEvent $ event ) { $ data = $ event -> getData ( ) ; $ data [ 'user' ] = $ event -> getUser ( ) -> getUsername ( ) ; $ event -> setData ( $ data ) ; }
Add public data to the authentication response .
59,995
protected function readColumnHeaders ( QuiteSimpleXMLElement $ results ) { $ headers = array_map ( function ( QuiteSimpleXMLElement $ node ) { return $ node -> attr ( 'saw-sql:columnHeading' ) ; } , $ results -> all ( '//xsd:complexType[@name="Row"]/xsd:sequence/xsd:element[position()>1]' ) ) ; if ( ! count ( $ headers ) ) { return ; } if ( ! count ( $ this -> headers ) ) { $ this -> headers = $ headers ; return ; } if ( count ( $ headers ) != count ( $ this -> headers ) ) { throw new \ RuntimeException ( sprintf ( 'The number of returned columns (%d) does not match the number of assigned headers (%d).' , count ( $ headers ) , count ( $ this -> headers ) ) ) ; } }
Read column headers from response and check that we got the right number of columns back .
59,996
public function getItem ( ) { $ bib = Bib :: make ( $ this -> client , $ this -> data -> bib_data -> mms_id ) ; $ holding = Holding :: make ( $ this -> client , $ bib , $ this -> data -> holding_data -> holding_id ) ; return Item :: make ( $ this -> client , $ bib , $ holding , $ this -> data -> item_data -> pid ) -> init ( $ this -> data -> item_data ) ; }
Get the scanned - in item .
59,997
public function getHolding ( ) { $ bib = Bib :: make ( $ this -> client , $ this -> data -> bib_data -> mms_id ) ; return Holding :: make ( $ this -> client , $ bib , $ this -> data -> holding_data -> holding_id ) -> init ( $ this -> data -> holding_data ) ; }
Get the Holding object for the scanned - in item .
59,998
public function getBib ( ) { return Bib :: make ( $ this -> client , $ this -> data -> bib_data -> mms_id ) -> init ( $ this -> data -> bib_data ) ; }
Get the Bib object for the scanned - in item .
59,999
public function environment_info ( ) { $ this -> line ( ' * Getting environment information' ) ; $ user = posix_getpwuid ( posix_geteuid ( ) ) [ 'name' ] ; if ( $ user === 'root' ) { $ this -> error ( 'WARNING: This command is running as root!' ) ; $ this -> error ( 'WARNING: Running as root means that we will probably be able to access ' . 'any file on your system. This command will not be able to help diagnose permission ' . 'problems this way.' ) ; } $ this -> info ( 'Current User: ' . $ user ) ; $ this -> info ( 'PHP Version: ' . phpversion ( ) ) ; $ this -> info ( 'Host OS: ' . php_uname ( ) ) ; $ this -> info ( 'SeAT Basepath: ' . base_path ( ) ) ; }
Print some information about the current environment .