idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
23,300
public function getThemeConfig ( $ theme ) { $ themesConfig = $ this -> getThemesConfig ( ) ; if ( ! empty ( $ themesConfig [ $ theme ] ) ) { return $ themesConfig [ $ theme ] ; } elseif ( ! empty ( $ themesConfig [ 'generic' ] ) ) { return $ themesConfig [ 'generic' ] ; } throw new RuntimeException ( 'No theme config found for ' . $ theme . ' and no default theme found' ) ; }
Get a themes config
23,301
public function getSiteLayout ( Site $ site , $ layout = null ) { $ themeLayoutConfig = $ this -> getSiteThemeLayoutsConfig ( $ site -> getTheme ( ) ) ; if ( empty ( $ layout ) ) { $ layout = $ site -> getSiteLayout ( ) ; } if ( ! empty ( $ themeLayoutConfig [ $ layout ] ) && ! empty ( $ themeLayoutConfig [ $ layout ] [ 'file' ] ) ) { return $ themeLayoutConfig [ $ layout ] [ 'file' ] ; } elseif ( ! empty ( $ themeLayoutConfig [ 'default' ] ) && ! empty ( $ themeLayoutConfig [ 'default' ] [ 'file' ] ) ) { return $ themeLayoutConfig [ 'default' ] [ 'file' ] ; } throw new RuntimeException ( 'No Layouts Found in config' ) ; }
Get Layout method will attempt to locate and fetch the correct layout for the site and page . If found it will pass back the path to correct view template so that the indexAction can pass that value on to the renderer .
23,302
public function getSitePageTemplateConfig ( Site $ site , $ template = null ) { $ themePageConfig = $ this -> getSiteThemePagesTemplateConfig ( $ site ) ; if ( ! empty ( $ themePageConfig [ $ template ] ) ) { return $ themePageConfig [ $ template ] ; } elseif ( ! empty ( $ themePageConfig [ 'default' ] ) ) { return $ themePageConfig [ 'default' ] ; } throw new RuntimeException ( 'No Page Template Found in config' ) ; }
Get Page Template method will attempt to locate and fetch the correct template config for the page . Default page template is set by the themes configuration and can also be set per page .
23,303
public function getSitePageTemplate ( Site $ site , $ template = null ) { $ themePageConfig = $ this -> getSitePageTemplateConfig ( $ site , $ template ) ; if ( empty ( $ themePageConfig [ 'file' ] ) ) { throw new RuntimeException ( 'No Page Template Found in config' ) ; } return $ themePageConfig [ 'file' ] ; }
Get Page Template method will attempt to locate and fetch the correct template for the page . If found it will pass back the path to correct view template so that the indexAction can pass that value on to the renderer . Default page template is set by the themes configuration and can also be set per page .
23,304
public function isLayoutValid ( Site $ site , $ layoutKey ) { $ themesConfig = $ this -> getSiteThemeLayoutsConfig ( $ site -> getTheme ( ) ) ; if ( ! empty ( $ themesConfig [ $ layoutKey ] ) ) { return true ; } return false ; }
Check to see if a layout is valid and available for a theme
23,305
public function canAdd ( ResourceEntityInterface $ entity ) { return empty ( $ this -> className ) || get_class ( $ entity ) == $ this -> className ; }
Verifica que la entidad sea del tipo correcto .
23,306
public function coreScriptFilter ( $ content ) { $ attributes = [ ] ; $ attributes [ "type" ] = "text/javascript" ; $ innerHTML = null !== $ content ? implode ( "" , [ "\n" , $ content , "\n" ] ) : "" ; return static :: coreHTMLElement ( "script" , $ innerHTML , $ attributes ) ; }
Displays a script .
23,307
final public function setDestinationDirectory ( string $ destinationDirectory ) { if ( $ destinationDirectory [ strlen ( $ destinationDirectory ) - 1 ] != DIRECTORY_SEPARATOR ) { $ destinationDirectory .= DIRECTORY_SEPARATOR ; } $ this -> destinationDirectory = $ destinationDirectory ; }
Apply the uploaded file directory to be used as a destination . Specified path starts from the project root directory . Will trim unnecessary leading slashes .
23,308
final public function setDestinationFilename ( string $ filename ) { $ extension = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; if ( empty ( $ extension ) && ! empty ( $ this -> uploadFile -> getExtension ( ) ) ) { $ filename .= '.' . $ this -> uploadFile -> getExtension ( ) ; } $ this -> destinationFilename = $ filename ; }
Apply the uploaded filename to be used in the destination directory . To keep the same extension simply omit to specify it in the filename .
23,309
protected function receiveHeader ( ) { if ( strlen ( $ this -> bufferData ) > 8 ) { $ header = substr ( $ this -> bufferData , 0 , 8 ) ; $ this -> waitingFor = intval ( $ header ) ; $ this -> bufferData = substr ( $ this -> bufferData , 8 ) ; $ this -> headerReceived = true ; return strlen ( $ this -> bufferData ) > 0 ; } return false ; }
Try to receive header from buffer on success the next operation is receiveBody
23,310
protected function receiveBody ( ) { if ( strlen ( $ this -> bufferData ) >= $ this -> waitingFor ) { $ this -> messages [ ] = substr ( $ this -> bufferData , 0 , $ this -> waitingFor ) ; $ this -> bufferData = substr ( $ this -> bufferData , $ this -> waitingFor ) ; $ this -> headerReceived = false ; return strlen ( $ this -> bufferData ) > 0 ; } return false ; }
Try to read the number of bytes given from header into message On success the next operation is receiveHeader
23,311
public static function encodeMessage ( $ message ) { $ waitingData = strlen ( $ message ) ; $ header = str_pad ( ( string ) $ waitingData , 8 , '0' , STR_PAD_LEFT ) ; return $ header . $ message ; }
Encode the message with header and body to directly write to any socket
23,312
public static function getFontAwesomeBreadcrumbNodes ( ) { $ breadcrumbNodes = [ ] ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.edit_profile" , "fa:user" , "fos_user_profile_edit" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.show_profile" , "fa:user" , "fos_user_profile_show" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.change_password" , "fa:lock" , "fos_user_change_password" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; return $ breadcrumbNodes ; }
Get a FOSUser breadcrumb node with Font Awesome icons .
23,313
public static function getMaterialDesignIconicFontBreadcrumbNodes ( ) { $ breadcrumbNodes = [ ] ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.edit_profile" , "zmdi:account" , "fos_user_profile_edit" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.show_profile" , "zmdi:account" , "fos_user_profile_show" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.change_password" , "zmdi:lock" , "fos_user_change_password" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; return $ breadcrumbNodes ; }
Get a FOSUser breadcrumb node with Material Design Iconic Font icons .
23,314
public function scriptVariables ( ) { $ data = json_encode ( [ 'locale' => $ this -> get ( 'locale' ) , 'app_name' => $ this -> get ( 'app_name' ) , 'app_skin' => $ this -> get ( 'app_skin' ) , 'app_theme' => $ this -> get ( 'app_theme' ) , 'app_url' => $ this -> get ( 'app_url' ) , ] ) ; if ( JSON_ERROR_NONE !== json_last_error ( ) ) { throw new \ RuntimeException ( json_last_error_msg ( ) ) ; } return $ data ; }
Get the variables for vue . js or another javascript .
23,315
public static function coreHTMLElement ( $ element , $ content , array $ attrs = [ ] ) { $ template = "<%element%%attributes%>%innerHTML%</%element%>" ; $ attributes = trim ( StringHelper :: parseArray ( $ attrs ) ) ; if ( 0 < strlen ( $ attributes ) ) { $ attributes = " " . $ attributes ; } $ innerHTML = null !== $ content ? trim ( $ content , " " ) : "" ; return StringHelper :: replace ( $ template , [ "%element%" , "%attributes%" , "%innerHTML%" ] , [ trim ( $ element ) , $ attributes , $ innerHTML ] ) ; }
Displays an HTML element .
23,316
public static function start ( $ alias ) { if ( isset ( self :: $ timers [ $ alias ] ) ) { throw new \ RuntimeException ( 'Timer has already been started.' ) ; } self :: $ timers [ $ alias ] = microtime ( ) ; }
Starts timer .
23,317
public static function getDifference ( $ alias ) { if ( ! isset ( self :: $ timers [ $ alias ] ) ) { throw new \ RuntimeException ( 'Timer has not been started' ) ; } return microtime ( ) - self :: $ timers [ $ alias ] ; }
Gets current time passed since start .
23,318
protected function originalPath ( File $ file , string $ thumbSize = null ) { return $ file -> getOriginal ( 'type' ) . DS . $ file -> getOriginal ( 'category' ) . ( $ thumbSize ? DS . $ thumbSize : '' ) . DS . $ file -> getOriginal ( 'name' ) . '.' . $ file -> getOriginal ( 'extension' ) ; }
Get original path to file .
23,319
public static function renderAge ( DateTime $ birthDate , DateTime $ refDate = null ) { if ( null === $ refDate ) { $ refDate = new DateTime ( ) ; } $ diff = $ refDate -> getTimestamp ( ) - $ birthDate -> getTimestamp ( ) ; $ years = new DateTime ( "@" . $ diff ) ; return intval ( $ years -> format ( "Y" ) ) - 1970 ; }
Render an age .
23,320
protected function cacheForgetByKeys ( $ entity = null ) { $ keys = $ this -> keysToForgetCache ; if ( is_array ( $ keys ) and array_diff_key ( $ keys , array_keys ( array_keys ( $ keys ) ) ) ) { foreach ( $ keys as $ key => $ method ) { cache ( ) -> forget ( $ key ) ; if ( is_subclass_of ( $ entity , ParentModel :: class ) ) { if ( method_exists ( $ model = $ entity -> getModel ( ) , $ method ) ) { $ model -> $ method ( ) ; } } } } }
Clearing cache by keys .
23,321
public function setDomain ( Domain $ domain ) { $ this -> domain = $ domain ; $ this -> domainId = $ domain -> getDomainId ( ) ; }
Add a domain to the site
23,322
public function setLanguage ( Language $ language ) { $ this -> language = $ language ; $ this -> languageId = $ language -> getLanguageId ( ) ; }
Sets the Language property
23,323
public function getContainer ( $ name ) { $ container = $ this -> containers -> get ( $ name ) ; if ( empty ( $ container ) ) { return null ; } return $ container ; }
Get all the page entities for the site .
23,324
private function getMatches ( $ line , $ matchCommentOnly = false ) { if ( preg_match ( $ this -> regex , $ line , $ matches ) ) { if ( ! empty ( $ matches [ 'tag2' ] ) ) { $ matches [ 'tag' ] = $ matches [ 'tag2' ] ; $ matches [ 'hint' ] = $ matches [ 'hint2' ] ; } return $ matches ; } if ( $ matchCommentOnly && preg_match ( $ this -> regexCommentLine , $ line , $ matches ) ) { $ matches [ 'tag' ] = null ; $ matches [ 'var' ] = '' ; $ matches [ 'hint' ] = '' ; return $ matches ; } }
Get all matches .
23,325
public function getPageByName ( SiteEntity $ site , $ pageName , $ pageType = PageTypes :: NORMAL ) { $ results = $ this -> getPagesByName ( $ site , $ pageName , $ pageType ) ; if ( empty ( $ results ) ) { return null ; } return $ results [ 0 ] ; }
Get a page entity by name
23,326
public function getPublishedRevisionId ( $ siteId , $ name , $ type = PageTypes :: NORMAL ) { $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'publishedRevision.revisionId' ) -> from ( \ Rcm \ Entity \ Page :: class , 'page' ) -> join ( 'page.publishedRevision' , 'publishedRevision' ) -> join ( 'page.site' , 'site' ) -> where ( 'site.siteId = :siteId' ) -> andWhere ( 'page.name = :pageName' ) -> andWhere ( 'page.pageType = :pageType' ) -> setParameter ( 'siteId' , $ siteId ) -> setParameter ( 'pageName' , $ name ) -> setParameter ( 'pageType' , $ type ) ; try { return $ queryBuilder -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( NoResultException $ e ) { return null ; } }
Gets the DB result of the Published Revision
23,327
public function getAllPageIdsAndNamesBySiteThenType ( $ siteId , $ type ) { $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'page.name, page.pageId' ) -> from ( \ Rcm \ Entity \ Page :: class , 'page' ) -> join ( 'page.site' , 'site' ) -> where ( 'page.pageType = :pageType' ) -> andWhere ( 'site.siteId = :siteId' ) -> setParameter ( 'pageType' , $ type ) -> setParameter ( 'siteId' , $ siteId ) ; $ result = $ queryBuilder -> getQuery ( ) -> getArrayResult ( ) ; if ( empty ( $ result ) ) { return null ; } $ return = [ ] ; foreach ( $ result as & $ page ) { $ return [ $ page [ 'pageId' ] ] = $ page [ 'name' ] ; } return $ return ; }
Get a list of page id s and page names by a given type
23,328
public function setPageDeleted ( PageEntity $ page , string $ modifiedByUserId , string $ modifiedReason = Tracking :: UNKNOWN_REASON ) { $ pageType = $ page -> getPageType ( ) ; if ( strpos ( $ pageType , self :: PAGE_TYPE_DELETED ) !== false ) { return ; } $ page -> setPageType ( self :: PAGE_TYPE_DELETED . $ pageType ) ; $ page -> setModifiedByUserId ( $ modifiedByUserId , $ modifiedReason ) ; $ this -> _em -> persist ( $ page ) ; $ this -> _em -> flush ( $ page ) ; }
setPageDeleted - A way of making pages appear deleted without deleting the DB entries
23,329
public function copyPage ( SiteEntity $ destinationSite , PageEntity $ pageToCopy , $ pageData , $ pageRevisionId = null , $ publishNewPage = false , $ doFlush = true ) { if ( empty ( $ pageData [ 'name' ] ) ) { throw new InvalidArgumentException ( 'Missing needed information (name) to create page copy.' ) ; } if ( empty ( $ pageData [ 'createdByUserId' ] ) ) { throw new InvalidArgumentException ( 'Missing needed information (createdByUserId) to create page copy.' ) ; } if ( empty ( $ pageData [ 'createdReason' ] ) ) { $ pageData [ 'createdReason' ] = 'Copy page in ' . get_class ( $ this ) ; } if ( empty ( $ pageData [ 'author' ] ) ) { throw new InvalidArgumentException ( 'Missing needed information (author) to create page copy.' ) ; } unset ( $ pageData [ 'pageId' ] ) ; unset ( $ pageData [ 'createdDate' ] ) ; unset ( $ pageData [ 'lastPublished' ] ) ; $ pageData [ 'site' ] = $ destinationSite ; $ clonedPage = $ pageToCopy -> newInstance ( $ pageData [ 'createdByUserId' ] , $ pageData [ 'createdReason' ] ) ; $ clonedPage -> populate ( $ pageData ) ; $ this -> assertCanCreateSitePage ( $ clonedPage -> getSite ( ) , $ clonedPage -> getName ( ) , $ clonedPage -> getPageType ( ) ) ; $ revisionToUse = $ clonedPage -> getStagedRevision ( ) ; if ( ! empty ( $ pageRevisionId ) ) { $ sourceRevision = $ pageToCopy -> getRevisionById ( $ pageRevisionId ) ; if ( empty ( $ sourceRevision ) ) { throw new PageNotFoundException ( 'Page revision not found.' ) ; } $ revisionToUse = $ sourceRevision -> newInstance ( $ pageData [ 'createdByUserId' ] , $ pageData [ 'createdReason' ] ) ; $ clonedPage -> setRevisions ( [ ] ) ; $ clonedPage -> addRevision ( $ revisionToUse ) ; } if ( empty ( $ revisionToUse ) ) { throw new RuntimeException ( 'Page revision not found.' ) ; } if ( $ publishNewPage ) { $ clonedPage -> setPublishedRevision ( $ revisionToUse ) ; } else { $ clonedPage -> setStagedRevision ( $ revisionToUse ) ; } $ destinationSite -> addPage ( $ clonedPage ) ; $ this -> _em -> persist ( $ clonedPage ) ; if ( $ doFlush ) { $ this -> _em -> flush ( $ clonedPage ) ; } return $ clonedPage ; }
Copy a page
23,330
public function publishPageRevision ( $ siteId , $ pageName , $ pageType , $ revisionId , string $ modifiedByUserId , string $ modifiedReason = Tracking :: UNKNOWN_REASON ) { $ pageQueryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ pageQueryBuilder -> select ( 'page, revision' ) -> from ( \ Rcm \ Entity \ Page :: class , 'page' ) -> join ( 'page.revisions' , 'revision' ) -> where ( 'page.name = :pageName' ) -> andWhere ( 'page.pageType = :pageType' ) -> andWhere ( 'page.site = :siteId' ) -> andWhere ( 'revision.revisionId = :revisionId' ) -> setParameter ( 'pageName' , $ pageName ) -> setParameter ( 'pageType' , $ pageType ) -> setParameter ( 'siteId' , $ siteId ) -> setParameter ( 'revisionId' , $ revisionId ) ; try { $ page = $ pageQueryBuilder -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ e ) { throw new PageNotFoundException ( 'Unable to locate page by revision. ' . json_encode ( [ 'revisionId' => $ revisionId , 'siteId' => $ siteId , 'pageName' => $ pageName , 'pageType' => $ pageType , ] ) ) ; } $ revision = $ page -> getRevisionById ( $ revisionId ) ; if ( empty ( $ revision ) ) { throw new RuntimeException ( 'Revision not found. ' . json_encode ( [ 'revisionId' => $ revisionId , 'pageId' => $ page -> getPageId ( ) ] ) ) ; } $ page -> setPublishedRevision ( $ revision ) ; $ page -> setModifiedByUserId ( $ modifiedByUserId , $ modifiedReason ) ; $ revision -> setModifiedByUserId ( $ modifiedByUserId , $ modifiedReason ) ; $ this -> _em -> flush ( [ $ revision , $ page ] ) ; return $ page ; }
Get a page entity containing a Revision Id .
23,331
public function getSitePage ( SiteEntity $ site , $ pageId ) { try { $ page = $ this -> findOneBy ( [ 'site' => $ site , 'pageId' => $ pageId ] ) ; } catch ( \ Exception $ e ) { $ page = null ; } return $ page ; }
get Site Page
23,332
public function sitePageExists ( SiteEntity $ site , $ pageName , $ pageType ) { try { $ page = $ this -> getPageByName ( $ site , $ pageName , $ pageType ) ; } catch ( \ Exception $ e ) { $ page = null ; } return ! empty ( $ page ) ; }
Site has page
23,333
public function isValid ( $ value ) { $ this -> setValue ( $ value ) ; if ( ! $ this -> layoutManager -> isLayoutValid ( $ this -> currentSite , $ value ) ) { $ this -> error ( self :: MAIN_LAYOUT ) ; return false ; } return true ; }
Is the layout valid?
23,334
public function getPluginViewData ( $ pluginName , $ pluginInstanceId , $ forcedAlternativeInstanceConfig = null ) { $ request = ServerRequestFactory :: fromGlobals ( ) ; $ blockConfig = $ this -> blockConfigRepository -> findById ( $ pluginName ) ; if ( $ pluginInstanceId < 0 ) { $ instanceWithData = new InstanceWithDataBasic ( $ pluginInstanceId , $ pluginName , $ blockConfig -> getDefaultConfig ( ) , null ) ; } else { $ instanceWithData = $ this -> instanceWithDataService -> __invoke ( $ pluginInstanceId , $ request ) ; } if ( $ forcedAlternativeInstanceConfig !== null ) { $ instanceWithData = new InstanceWithDataBasic ( $ instanceWithData -> getId ( ) , $ instanceWithData -> getName ( ) , $ forcedAlternativeInstanceConfig , $ instanceWithData -> getData ( ) ) ; } $ html = $ this -> blockRendererService -> __invoke ( $ instanceWithData ) ; $ return = [ 'html' => $ html , 'css' => [ ] , 'js' => [ ] , 'editJs' => '' , 'editCss' => '' , 'displayName' => $ blockConfig -> getLabel ( ) , 'tooltip' => $ blockConfig -> getDescription ( ) , 'icon' => $ blockConfig -> getIcon ( ) , 'siteWide' => false , 'md5' => '' , 'fromCache' => false , 'canCache' => $ blockConfig -> getCache ( ) , 'pluginName' => $ blockConfig -> getName ( ) , 'pluginInstanceId' => $ pluginInstanceId , ] ; return $ return ; }
Get a plugin instance rendered view .
23,335
public function getDefaultInstanceConfig ( $ pluginName ) { $ blockConfig = $ this -> blockConfigRepository -> findById ( $ pluginName ) ; if ( empty ( $ blockConfig ) ) { throw new \ Exception ( 'Block config not found for ' . $ pluginName ) ; } return $ blockConfig -> getDefaultConfig ( ) ; }
Default instance configs are NOT required anymore
23,336
public function listAvailablePluginsByType ( ) { $ list = [ ] ; foreach ( $ this -> config [ 'rcmPlugin' ] as $ name => $ data ) { $ displayName = $ name ; $ type = 'Misc' ; $ icon = $ this -> config [ 'Rcm' ] [ 'defaultPluginIcon' ] ; if ( isset ( $ data [ 'type' ] ) ) { $ type = $ data [ 'type' ] ; } if ( isset ( $ data [ 'display' ] ) ) { $ displayName = $ data [ 'display' ] ; } if ( isset ( $ data [ 'icon' ] ) && ! empty ( $ data [ 'icon' ] ) ) { $ icon = $ data [ 'icon' ] ; } $ list [ $ type ] [ $ name ] = [ 'name' => $ name , 'displayName' => $ displayName , 'icon' => $ icon , 'siteWide' => false ] ; } return $ list ; }
Returns an array the represents the available plugins
23,337
public function loadUserByUsername ( $ username ) { try { $ payload = $ this -> googleClient -> verifyIdToken ( $ username ) ; $ email = $ payload [ 'email' ] ; $ googleUserId = $ payload [ 'sub' ] ; $ user = $ this -> userService -> findByGoogleUserId ( $ googleUserId ) ; if ( ! empty ( $ user ) ) { return $ user ; } $ user = $ this -> userService -> findUserByEmail ( $ email ) ; if ( ! empty ( $ user ) ) { $ this -> updateUserWithGoogleUserId ( $ user , $ googleUserId ) ; return $ user ; } return $ this -> registerUser ( $ email , $ googleUserId ) ; } catch ( \ LogicException $ ex ) { throw new UsernameNotFoundException ( "Google AuthToken Did Not validate, ERROR MESSAGE " . $ ex -> getMessage ( ) , ProgrammerException :: GOOGLE_USER_PROVIDER_LOGIC_EXCEPTION ) ; } catch ( \ Exception $ ex ) { throw new UsernameNotFoundException ( "Google AuthToken Did Not validate, ERROR MESSAGE " . $ ex -> getMessage ( ) , ProgrammerException :: GOOGLE_USER_PROVIDER_EXCEPTION ) ; } }
1 ) We validate the access token by fetching the user information 2 ) We search for google user id and if one is found we return that user 3 ) Then we search by email and if one is found we update the user to have that google user id 4 ) If nothing is found we register the user with google user id
23,338
protected function updateUserWithGoogleUserId ( BaseUser $ user , $ googleUserId ) { $ user -> setGoogleUserId ( $ googleUserId ) ; $ this -> userService -> save ( $ user ) ; }
Updates the user with their google id creating a link between their google account and user information .
23,339
public function setUrl ( $ url ) : self { if ( \ is_string ( $ url ) ) { $ this -> options [ 'url' ] = $ url ; return $ this ; } if ( $ url instanceof Leg ) { $ this -> setUrlFromLeg ( $ url ) ; return $ this ; } if ( $ url instanceof BoardData ) { $ this -> setUrlFromBoardData ( $ url ) ; return $ this ; } throw new \ InvalidArgumentException ( sprintf ( 'setUrl must be a string, Leg or BoardData object' ) ) ; }
Set journey details from a URL .
23,340
public function massUpdate ( CommentsRequest $ request ) { $ this -> authorize ( 'otherUpdate' , $ this -> model ) ; $ comments = $ this -> model -> whereIn ( 'id' , $ request -> comments ) ; $ messages = [ ] ; switch ( $ request -> mass_action ) { case 'published' : if ( ! $ comments -> update ( [ 'is_approved' => true ] ) ) { $ messages [ ] = 'unable to published' ; } break ; case 'unpublished' : if ( ! $ comments -> update ( [ 'is_approved' => false ] ) ) { $ messages [ ] = 'unable to unpublished' ; } break ; case 'delete' : if ( ! $ comments -> get ( ) -> each -> delete ( ) ) { $ messages [ ] = 'unable to delete' ; } break ; } $ message = empty ( $ messages ) ? 'msg.complete' : 'msg.complete_but_null' ; return $ this -> makeRedirect ( true , 'admin.comments.index' , $ message ) ; }
Mass updates to Comment .
23,341
public function find ( string $ id , array $ headers = [ ] ) { $ url = $ this -> url ( 'time_machines/%s' , $ id ) ; return $ this -> get ( $ url , [ ] , $ headers ) ; }
Retrieves a specified time machine .
23,342
public function startAfresh ( string $ id , array $ data , array $ headers = [ ] ) { $ url = $ this -> url ( 'time_machines/%s/start_afresh' , $ id ) ; return $ this -> post ( $ url , $ data , $ headers ) ; }
Restart the time machine .
23,343
public function travelForward ( string $ id , array $ data , array $ headers = [ ] ) { $ url = $ this -> url ( 'time_machines/%s/travel_forward' , $ id ) ; return $ this -> post ( $ url , $ data , $ headers ) ; }
Travel forward in time .
23,344
public function send ( ) { $ header = $ this -> buildCompleteHeader ( ) ; $ reportOnly = ( $ this -> reportOnly ) ? "-Report-Only" : "" ; header ( "Content-Security-Policy$reportOnly: " . $ header ) ; if ( $ this -> compatible ) { header ( "X-Content-Security-Policy$reportOnly: " . $ header ) ; } }
Build and send the complete CSP security header according to the object specified data .
23,345
private function buildCompleteHeader ( ) : string { $ header = "" ; foreach ( $ this -> headers as $ sourceType => $ value ) { $ header .= $ this -> buildHeaderLine ( $ sourceType , $ value ) ; } if ( ! empty ( $ this -> reportUri ) ) { $ header .= 'report-uri ' . $ this -> reportUri . ';' ; } return $ header ; }
Generates the complete CSP header base on object data .
23,346
private function buildHeaderLine ( string $ name , array $ sources ) : string { $ header = '' ; if ( ! empty ( $ sources ) ) { $ value = "" ; foreach ( $ sources as $ source ) { if ( ! empty ( $ value ) ) { $ value .= ' ' ; } $ value .= $ source ; } $ header = ( $ name == "script-src" && ! empty ( self :: $ nonce ) ) ? "$name $value 'nonce-" . self :: $ nonce . "';" : "$name $value;" ; } return $ header ; }
Retrieve a specific CSP line based on the provided sources .
23,347
public function create ( $ data ) { if ( ! $ this -> isAllowed ( ResourceName :: RESOURCE_SITES , 'admin' ) ) { $ this -> getResponse ( ) -> setStatusCode ( Response :: STATUS_CODE_401 ) ; return $ this -> getResponse ( ) ; } $ inputFilter = new SiteDuplicateInputFilter ( ) ; $ inputFilter -> setData ( $ data ) ; if ( ! $ inputFilter -> isValid ( ) ) { return new ApiJsonModel ( [ ] , 1 , 'Some values are missing or invalid.' , $ inputFilter -> getMessages ( ) ) ; } $ data = $ inputFilter -> getValues ( ) ; $ siteManager = $ this -> getSiteManager ( ) ; try { $ data = $ siteManager -> prepareSiteData ( $ data ) ; $ domainRepo = $ this -> getEntityManager ( ) -> getRepository ( \ Rcm \ Entity \ Domain :: class ) ; $ domain = $ domainRepo -> createDomain ( $ data [ 'domainName' ] , $ this -> getCurrentUserId ( ) , 'Create new domain in ' . get_class ( $ this ) , null , true ) ; } catch ( \ Exception $ e ) { return new ApiJsonModel ( null , 1 , $ e -> getMessage ( ) ) ; } $ entityManager = $ this -> getEntityManager ( ) ; $ siteRepo = $ entityManager -> getRepository ( \ Rcm \ Entity \ Site :: class ) ; $ existingSite = $ siteRepo -> find ( $ data [ 'siteId' ] ) ; if ( empty ( $ existingSite ) ) { return new ApiJsonModel ( null , 1 , "Site {$data['siteId']} not found." ) ; } try { $ copySite = $ siteManager -> copySiteAndPopulate ( $ existingSite , $ domain , $ data ) ; } catch ( \ Exception $ exception ) { if ( $ entityManager -> contains ( $ domain ) ) { $ entityManager -> remove ( $ domain ) ; } throw $ exception ; } return new ApiJsonModel ( $ copySite , 0 , 'Success' ) ; }
create - Clone a site
23,348
protected function compileRegex ( $ rule ) { $ regex = '^' . preg_replace_callback ( '@\{[\w]+\??\}@' , function ( $ matches ) { $ optional = false ; $ key = str_replace ( [ '{' , '}' ] , '' , $ matches [ 0 ] ) ; if ( substr ( $ key , - 1 ) == '?' ) { $ optional = true ; } if ( isset ( $ this -> customFilters [ $ key ] ) ) { if ( isset ( $ this -> defaultFilters [ $ this -> customFilters [ $ key ] ] ) ) { return '(' . $ this -> defaultFilters [ $ this -> customFilters [ $ key ] ] . ')' . ( ( $ optional ) ? '?' : '' ) ; } else { if ( substr ( $ this -> customFilters [ $ key ] , 0 , 1 ) == '{' && substr ( $ this -> customFilters [ $ key ] , - 1 ) == '}' ) { throw new \ RuntimeException ( "The custom filter named \"{$key}\" references a non-existent builtin filter named \"{$this->customFilters[$key]}\"." ) ; } else { return '(' . $ this -> customFilters [ $ key ] . ')' . ( ( $ optional ) ? '?' : '' ) ; } } } elseif ( isset ( $ this -> defaultTokens [ $ key ] ) ) { return '(' . $ this -> defaultTokens [ $ key ] . ')' . ( ( $ optional ) ? '?' : '' ) ; } else { return '(' . $ this -> defaultFilters [ '{default}' ] . ')' . ( ( $ optional ) ? '?' : '' ) ; } } , $ rule ) . '$' ; $ regex = str_replace ( [ '?/' , '??' ] , [ '?/?' , '?' ] , $ regex ) ; return $ regex ; }
Build a regular expression from the given rule .
23,349
public function process ( Request $ request ) { $ results = [ ] ; if ( isset ( $ this -> options [ 'hostname' ] ) ) { $ regex = $ this -> compileRegex ( $ this -> options [ 'hostname' ] ) ; $ tokens = $ this -> compileTokens ( $ this -> options [ 'hostname' ] ) ; $ hostnameResults = $ this -> compileResults ( $ regex , $ tokens , $ request -> getHttpHost ( ) ) ; if ( $ hostnameResults === false ) { return false ; } else { $ results = array_merge ( $ results , $ hostnameResults ) ; } } $ regex = $ this -> compileRegex ( $ this -> rule ) ; $ tokens = $ this -> compileTokens ( $ this -> rule ) ; $ urlResults = $ this -> compileResults ( $ regex , $ tokens , $ request -> getRequestUri ( ) ) ; if ( $ urlResults === false ) { return false ; } else { $ results = array_merge ( $ results , $ urlResults ) ; } if ( isset ( $ this -> options [ 'targets' ] ) ) { $ results = array_merge ( $ results , $ this -> options [ 'targets' ] ) ; } $ this -> payload = $ results ; return true ; }
Process this route .
23,350
public function start ( ) : bool { if ( ! is_null ( $ this -> expiration ) ) { $ this -> expiration -> start ( ) ; } if ( ! is_null ( $ this -> fingerprint ) ) { $ this -> fingerprint -> start ( ) ; } if ( ! isset ( $ _SESSION [ '__HANDLER_INITIATED' ] ) ) { return $ this -> initialSessionStart ( ) ; } else { return $ this -> laterSessionStart ( ) ; } }
Throws an exception if the fingerprint mismatch .
23,351
private function laterSessionStart ( ) { if ( ! is_null ( $ this -> fingerprint ) && ! $ this -> fingerprint -> hasValidFingerprint ( ) ) { throw new \ Exception ( "Session fingerprint doesn't match" ) ; } if ( ! is_null ( $ this -> expiration ) && $ this -> expiration -> isObsolete ( ) ) { return true ; } return false ; }
Should be used for every session starts if the handlers has been previously initiated . Validates if the session identifier should be regenerated and validates current fingerprint .
23,352
public static function hideEmail ( $ email ) { $ character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' ; $ key = str_shuffle ( $ character_set ) ; $ cipher_text = '' ; $ id = 'e' . rand ( 1 , 999999999 ) ; for ( $ i = 0 ; $ i < strlen ( $ email ) ; $ i += 1 ) $ cipher_text .= $ key [ strpos ( $ character_set , $ email [ $ i ] ) ] ; $ script = 'var a="' . $ key . '";var b=a.split("").sort().join("");var c="' . $ cipher_text . '";var d="";' ; $ script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));' ; $ script .= 'document.getElementById("' . $ id . '").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>"' ; $ script = "eval(\"" . str_replace ( [ "\\" , '"' ] , [ "\\\\" , '\"' ] , $ script ) . "\")" ; $ script = '<script type="text/javascript">/*<![CDATA[*/' . $ script . '/*]]>*/</script>' ; return '<span id="' . $ id . '">[javascript protected email address]</span>' . $ script ; }
Protects the email from bots
23,353
public static function summary ( $ str , $ limit = 100 , $ strip = false ) { $ str = ( $ strip == true ) ? strip_tags ( $ str ) : $ str ; return static :: truncate ( $ str , $ limit - 3 , '...' ) ; }
Get the first x chars from a string . If the string is bigger it pads it with ...
23,354
public function find ( $ modelitemId ) { $ this -> model = $ this -> model -> findOrFail ( $ modelitemId ) ; return $ this -> model ; }
Finds an existing Model entry and sets it to the current model .
23,355
private function query ( $ count ) { $ this -> applyQueryFilters ( ) ; if ( $ this -> hasTranslating ( ) ) { $ this -> applyTranslationFilter ( ) ; } if ( $ this -> orderBy ( ) ) { $ this -> query = $ this -> query -> orderBy ( $ this -> orderBy ( ) , $ this -> sortBy ( ) ) ; } if ( $ count ) { return $ this -> query -> count ( ) ; } if ( $ this -> perPage > 0 ) { return $ this -> query -> paginate ( $ this -> perPage ) ; } return $ this -> query -> get ( ) ; }
Performs the Model Query .
23,356
public function totals ( ) { if ( $ this -> hasSoftDeleting ( ) ) { return [ 'all' => $ this -> items ( $ count = true ) , 'with_trashed' => $ this -> allItems ( $ count = true ) , 'only_trashed' => $ this -> onlyTrashedItems ( $ count = true ) , ] ; } return [ 'all' => $ this -> items ( $ count = true ) ] ; }
Return Totals of All With Trashed and Only Trashed .
23,357
public function orderBy ( ) { if ( Request :: input ( 'order' ) ) { return Request :: input ( 'order' ) ; } if ( $ this -> orderBy ) { return $ this -> orderBy ; } return $ this -> model -> getKeyName ( ) ; }
Return Managed Model OrderBy .
23,358
private function applyQueryFilters ( ) { if ( is_array ( $ this -> queryFilter ( ) ) ) { $ this -> createQueryFilter ( ) ; } else { $ this -> queryFilter ( ) ; } $ this -> queryFilterRequest ( ) ; }
Apply the Query Filters .
23,359
private function queryFilterRequest ( ) { if ( ! $ safeFilter = Request :: get ( 'filter' ) ) { return false ; } if ( ! isset ( $ this -> safeFilters ( ) [ $ safeFilter ] ) ) { return false ; } return $ this -> query = $ this -> filters ( ) [ $ this -> safeFilters ( ) [ $ safeFilter ] ] ; }
Apply the Query Filters specific to this Request .
23,360
private function createQueryFilter ( ) { if ( count ( $ this -> queryFilter ( ) ) > 0 ) { foreach ( $ this -> queryFilter ( ) as $ filter => $ parameters ) { if ( ! is_array ( $ parameters ) ) { $ parameters = [ $ parameters ] ; } $ this -> query = call_user_func_array ( [ $ this -> query , $ filter ] , $ parameters ) ; } } }
Create the Query Filter from Array .
23,361
public function safeFilters ( ) { $ filters = [ ] ; foreach ( $ this -> filters ( ) as $ filterName => $ query ) { $ filters [ str_slug ( $ filterName ) ] = $ filterName ; } return $ filters ; }
Associative array of safe filter names to their corresponding normal counterpart .
23,362
protected function getSessionConfig ( ServiceLocatorInterface $ serviceLocator , $ sessionConfig ) { if ( empty ( $ sessionConfig ) || empty ( $ sessionConfig [ 'config' ] ) ) { return new SessionConfig ( ) ; } $ class = '\Zend\Session\Config\SessionConfig' ; $ options = [ ] ; if ( isset ( $ sessionConfig [ 'config' ] [ 'class' ] ) ) { $ class = $ sessionConfig [ 'config' ] [ 'class' ] ; } if ( isset ( $ sessionConfig [ 'config' ] [ 'options' ] ) ) { $ options = $ sessionConfig [ 'config' ] [ 'options' ] ; } if ( $ serviceLocator -> has ( $ class ) ) { $ sessionConfigObject = $ serviceLocator -> get ( $ class ) ; } else { $ sessionConfigObject = new $ class ( ) ; } if ( ! $ sessionConfigObject instanceof ConfigInterface ) { throw new InvalidArgumentException ( 'Session Config class must implement ' . '\Zend\Session\Config\ConfigInterface' ) ; } $ sessionConfigObject -> setOptions ( $ options ) ; return $ sessionConfigObject ; }
Build the session config object
23,363
protected function getSessionSaveHandler ( ServiceLocatorInterface $ serviceLocator , $ sessionConfig ) { if ( ! isset ( $ sessionConfig [ 'save_handler' ] ) ) { return null ; } $ saveHandler = $ serviceLocator -> get ( $ sessionConfig [ 'save_handler' ] ) ; if ( ! $ saveHandler instanceof SaveHandlerInterface ) { throw new InvalidArgumentException ( 'Session Save Handler class must implement ' . 'Zend\Session\Storage\StorageInterface' ) ; } return $ saveHandler ; }
Get the Session Save Handler
23,364
protected function setValidatorChain ( SessionManager $ sessionManager , ServiceLocatorInterface $ serviceLocator , $ sessionConfig ) { if ( ! isset ( $ sessionConfig [ 'validators' ] ) || ! is_array ( $ sessionConfig [ 'validators' ] ) ) { return ; } $ chain = $ sessionManager -> getValidatorChain ( ) ; foreach ( $ sessionConfig [ 'validators' ] as & $ validator ) { if ( $ serviceLocator -> has ( $ validator ) ) { $ validator = $ serviceLocator -> get ( $ validator ) ; } else { $ validator = new $ validator ( ) ; } if ( ! $ validator instanceof ValidatorInterface ) { throw new InvalidArgumentException ( 'Session Save Handler class must implement ' . 'Zend\Session\Validator\ValidatorInterface' ) ; } $ chain -> attach ( 'session.validate' , [ $ validator , 'isValid' ] ) ; } }
Attach the Service Validators to the Session
23,365
protected function callRepositoryMethod ( string $ method , ... $ args ) { $ om = $ this -> getManager ( ) ; $ repo = $ om -> getRepository ( $ this -> getEntity ( ) ) ; if ( ! method_exists ( $ repo , $ method ) || ! is_callable ( [ $ repo , $ method ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Method "%s" doesn\'t exist or isn\'t callable in EntityRepository "%s"' , $ method , get_class ( $ repo ) ) ) ; } return $ repo -> $ method ( ... $ args ) ; }
Call a given method on an EntityRepository .
23,366
public function supports ( Request $ request ) { $ post = json_decode ( $ request -> getContent ( ) , true ) ; return ! empty ( $ post [ self :: TOKEN_FIELD ] ) ; }
1 ) Returns true if the request has json body with token in it
23,367
public function getCredentials ( Request $ request ) { $ post = json_decode ( $ request -> getContent ( ) , true ) ; return new CredentialTokenModel ( $ post [ self :: TOKEN_FIELD ] ) ; }
2 ) Returns CredentialTokenModel with json field token
23,368
final public function run ( Request $ request ) { $ this -> request = $ request ; $ path = $ this -> request -> getUri ( ) -> getPath ( ) ; $ this -> requestedUri = ( $ path != "/" ) ? rtrim ( $ path , "/" ) : "/" ; $ this -> requestedMethod = strtoupper ( $ this -> request -> getMethod ( ) ) ; $ this -> requestedRepresentation = $ this -> request -> getAccept ( ) ; $ this -> verifyRequestMethod ( ) ; $ route = $ this -> findRouteFromRequest ( ) ; $ this -> prepareResponse ( $ route ) ; }
Launch the routing process to determine according to the initiated request the best route to execute . Cannot be overridden .
23,369
final protected function addRoute ( $ method , $ uri , $ callback , $ acceptedFormats ) { $ this -> routes [ $ method ] [ ] = [ 'route' => new Route ( $ uri ) , 'callback' => $ callback , 'acceptedRequestFormats' => $ acceptedFormats ] ; }
Add a new route for the application . Make sure to create the adequate structure with corresponding parameters regex pattern if needed . Cannot be overridden .
23,370
private function createResponse ( $ route ) : ? Response { $ controller = $ this -> getRouteControllerInstance ( $ route ) ; if ( ! is_null ( $ controller ) ) { $ responseBefore = $ controller -> before ( ) ; if ( $ responseBefore instanceof Response ) { return $ responseBefore ; } } $ values = $ route [ 'route' ] -> getArguments ( $ this -> requestedUri ) ; $ this -> loadRequestParameters ( $ values ) ; $ callback = new Callback ( $ route [ 'callback' ] ) ; $ arguments = $ this -> getFunctionArguments ( $ callback -> getReflection ( ) , array_values ( $ values ) ) ; $ response = $ callback -> executeArray ( $ arguments ) ; if ( ! is_null ( $ controller ) ) { $ responseAfter = $ controller -> after ( $ response ) ; if ( $ responseAfter instanceof Response ) { return $ responseAfter ; } } return $ response ; }
Creates the response to return while executing the before and after methods if they are available .
23,371
private function loadRequestParameters ( $ values ) { foreach ( $ values as $ param => $ value ) { $ this -> request -> prependParameter ( $ param , $ value ) ; } }
Load parameters located inside the request object .
23,372
public function checkDomain ( MvcEvent $ event ) { if ( $ this -> isConsoleRequest ( ) ) { return null ; } $ currentDomain = $ this -> siteService -> getCurrentDomain ( ) ; $ site = $ this -> siteService -> getCurrentSite ( $ currentDomain ) ; $ redirectUrl = $ this -> domainRedirectService -> getSiteNotAvailableRedirectUrl ( $ site ) ; if ( ! $ site -> isSiteAvailable ( ) && empty ( $ redirectUrl ) ) { $ response = new Response ( ) ; $ response -> setStatusCode ( 404 ) ; $ event -> stopPropagation ( true ) ; return $ response ; } if ( $ redirectUrl ) { $ response = new Response ( ) ; $ response -> setStatusCode ( 302 ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Location' , '//' . $ redirectUrl ) ; $ event -> stopPropagation ( true ) ; return $ response ; } $ redirectUrl = $ this -> domainRedirectService -> getPrimaryRedirectUrl ( $ site ) ; if ( $ redirectUrl ) { $ response = new Response ( ) ; $ response -> setStatusCode ( 302 ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Location' , '//' . $ redirectUrl ) ; $ event -> stopPropagation ( true ) ; return $ response ; } return null ; }
Check the domain is a known domain for the CMS . If not the primary it will redirect the user to the primary domain . Useful for multiple domain sites .
23,373
public function checkRedirect ( MvcEvent $ event ) { if ( $ this -> isConsoleRequest ( ) ) { return null ; } $ redirectUrl = $ this -> redirectService -> getRedirectUrl ( ) ; if ( empty ( $ redirectUrl ) ) { return null ; } $ queryParams = $ event -> getRequest ( ) -> getQuery ( ) -> toArray ( ) ; header ( 'Location: ' . $ redirectUrl . ( count ( $ queryParams ) ? '?' . http_build_query ( $ queryParams ) : null ) , true , 302 ) ; exit ; }
Check the defined redirects . If requested URL is found redirect to the new location .
23,374
public function addLocale ( MvcEvent $ event ) { $ locale = $ this -> siteService -> getCurrentSite ( ) -> getLocale ( ) ; $ this -> localeService -> setLocale ( $ locale ) ; return null ; }
Set the system locale to Site Requirements
23,375
public function getConfigList ( $ key = null ) { if ( is_null ( $ key ) ) { return $ this -> configList ; } elseif ( empty ( $ this -> configList [ $ key ] ) ) { return null ; } else { return $ this -> configList [ $ key ] ; } }
Returns the SavantPHP configuration parameter bag .
23,376
public function setPath ( $ path ) { $ this -> configList [ self :: TPL_PATH_LIST ] = [ ] ; $ this -> addPath ( '.' ) ; $ this -> addPath ( $ path ) ; }
Sets an entire array of possible search paths for templates
23,377
public function fetch ( $ tpl = null ) { if ( is_null ( $ tpl ) ) { $ tpl = $ this -> configList [ self :: TPL_FILE ] ; } $ result = $ this -> getPathToTemplate ( $ tpl ) ; if ( ! $ result || $ this -> isError ( $ result ) ) { return $ result ; } else { $ this -> configList [ self :: FETCHED_TPL_FILE ] = $ result ; unset ( $ result ) ; unset ( $ tpl ) ; ob_start ( ) ; include $ this -> configList [ self :: FETCHED_TPL_FILE ] ; $ this -> configList [ self :: FETCHED_TPL_FILE ] = null ; return ob_get_clean ( ) ; } }
Gets & executes a template source .
23,378
public function error ( $ code , $ info = [ ] , $ level = E_USER_ERROR , $ trace = true ) { if ( $ this -> configList [ self :: EXCEPTIONS ] ) { throw new SavantPHPexception ( $ code ) ; } $ config = [ 'code' => $ code , 'info' => ( array ) $ info , 'level' => $ level , 'trace' => $ trace ] ; return new SavantPHPerror ( $ config ) ; }
Returns an error object or throws an exception .
23,379
public function isError ( $ obj ) { if ( ! is_object ( $ obj ) ) { return false ; } else { $ is = $ obj instanceof SavantPHPerror ; $ sub = is_subclass_of ( $ obj , 'SavantPHPerror' ) ; return ( $ is || $ sub ) ; } }
Tests if an object is of the SavantPHPerror class .
23,380
public static function buildFromArray ( array $ resources ) { $ resource = @ $ resources [ 0 ] ; if ( ! $ resource instanceof EntityResource ) { throw new LogicException ( self :: ERROR_EMPTY_ARRAY ) ; } return new static ( $ resources , $ resource -> getMetadata ( ) ) ; }
Factory method para construir a partir de un array de EntityResource .
23,381
public function getComments ( bool $ nested = false ) { $ comments = $ this -> comments ( ) -> get ( ) ; if ( $ comments -> firstWhere ( 'user_id' , '>' , 'null' ) ) { $ comments -> load ( [ 'user:users.id,users.name,users.email,users.avatar' ] ) ; } return $ comments -> treated ( $ nested , $ this -> getAttributes ( ) ) ; }
Get a list comments with user relation if need
23,382
public function processResponse ( ResponseInterface $ response ) { if ( ! $ response instanceof Response || ! $ this -> getRequest ( ) ) { return ; } $ response = $ this -> handleResponse ( $ response ) ; $ this -> renderResponse ( $ response ) ; $ this -> terminateApp ( ) ; }
Process Rcm Response objects or simply return if response is a normal Zend Response .
23,383
protected function handleResponse ( Response $ response ) { $ statusCode = $ response -> getStatusCode ( ) ; switch ( $ statusCode ) { case 401 : $ response = $ this -> processNotAuthorized ( ) ; break ; } return $ response ; }
Handle the RCM Response object
23,384
protected function processNotAuthorized ( ) { $ loginPage = $ this -> currentSite -> getLoginPage ( ) ; $ notAuthorized = $ this -> currentSite -> getNotAuthorizedPage ( ) ; $ returnToUrl = urlencode ( $ this -> request -> getServer ( 'REQUEST_URI' ) ) ; $ newResponse = new Response ( ) ; $ newResponse -> setStatusCode ( '302' ) ; if ( ! $ this -> userService -> hasIdentity ( ) ) { $ newResponse -> getHeaders ( ) -> addHeaderLine ( 'Location: ' . $ loginPage . '?redirect=' . $ returnToUrl ) ; } else { $ newResponse -> getHeaders ( ) -> addHeaderLine ( 'Location: ' . $ notAuthorized ) ; } return $ newResponse ; }
Process 401 Response Objects . This will redirect the visitor to the sites configured login page .
23,385
protected function renderResponse ( Response $ response ) { $ sendEvent = new SendResponseEvent ( ) ; $ sendEvent -> setResponse ( $ response ) ; $ this -> responseSender -> __invoke ( $ sendEvent ) ; }
Renders the Response object .
23,386
protected function fontAwesomeIcon ( FontAwesomeIconInterface $ icon ) { $ attributes = [ ] ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderFont ( $ icon ) ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderName ( $ icon ) ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderSize ( $ icon ) ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderFixedWidth ( $ icon ) ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderBordered ( $ icon ) ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderPull ( $ icon ) ; $ attributes [ "class" ] [ ] = FontAwesomeIconRenderer :: renderAnimation ( $ icon ) ; $ attributes [ "style" ] = FontAwesomeIconRenderer :: renderStyle ( $ icon ) ; return static :: coreHTMLElement ( "i" , null , $ attributes ) ; }
Displays a Font Awesome icon .
23,387
protected function fontAwesomeList ( $ items ) { $ innerHTML = true === is_array ( $ items ) ? implode ( "\n" , $ items ) : $ items ; return static :: coreHTMLElement ( "ul" , $ innerHTML , [ "class" => "fa-ul" ] ) ; }
Displays a Font Awesome list .
23,388
protected function fontAwesomeListIcon ( $ icon , $ content ) { $ glyphicon = static :: coreHTMLElement ( "span" , $ icon , [ "class" => "fa-li" ] ) ; $ innerHTML = null !== $ content ? $ content : "" ; return static :: coreHTMLElement ( "li" , $ glyphicon . $ innerHTML ) ; }
Displays a Font Awesome list icon .
23,389
protected function displayFooter ( StyleInterface $ io , $ exitCode , $ count ) { if ( 0 < $ exitCode ) { $ io -> error ( "Some errors occurred while unzipping assets" ) ; return ; } if ( 0 === $ count ) { $ io -> success ( "No assets were provided by any bundle" ) ; return ; } $ io -> success ( "All assets were successfully unzipped" ) ; }
Display the footer .
23,390
protected function displayResult ( StyleInterface $ io , array $ results ) { $ exitCode = 0 ; $ rows = [ ] ; $ success = $ this -> getCheckbox ( true ) ; $ warning = $ this -> getCheckbox ( false ) ; foreach ( $ results as $ bundle => $ assets ) { foreach ( $ assets as $ asset => $ result ) { $ rows [ ] = [ true === $ result ? $ success : $ warning , $ bundle , basename ( $ asset ) , ] ; $ exitCode += true === $ result ? 0 : 1 ; } } $ io -> table ( [ "" , "Bundle" , "Asset" ] , $ rows ) ; return $ exitCode ; }
Displays the result .
23,391
public function supports ( Request $ request ) { return ! empty ( $ request -> headers -> get ( self :: AUTHORIZATION_HEADER ) ) || ! empty ( $ request -> cookies -> get ( AuthResponseService :: AUTH_COOKIE ) ) ; }
1 ) Returns true if the guard
23,392
public function getCredentials ( Request $ request ) { $ token = ! empty ( $ request -> headers -> get ( self :: AUTHORIZATION_HEADER ) ) ? $ request -> headers -> get ( self :: AUTHORIZATION_HEADER ) : $ request -> cookies -> get ( AuthResponseService :: AUTH_COOKIE ) ; return new CredentialTokenModel ( str_replace ( self :: BEARER , '' , $ token ) ) ; }
2 ) Gets the token from header and creates a CredentialToken Model
23,393
public function getAdminWrapperAction ( ) { $ allowed = $ this -> cmsPermissionChecks -> siteAdminCheck ( $ this -> currentSite ) ; if ( ! $ allowed ) { return null ; } $ routeMatch = $ this -> getEvent ( ) -> getRouteMatch ( ) ; $ siteId = $ this -> currentSite -> getSiteId ( ) ; $ sourcePageName = $ routeMatch -> getParam ( 'page' , 'index' ) ; if ( $ sourcePageName instanceof Page ) { $ sourcePageName = $ sourcePageName -> getName ( ) ; } $ pageType = $ routeMatch -> getParam ( 'pageType' , 'n' ) ; $ view = new ViewModel ( ) ; $ view -> setVariable ( 'restrictions' , false ) ; if ( $ this -> cmsPermissionChecks -> isPageRestricted ( $ siteId , $ pageType , $ sourcePageName , 'read' ) == true ) { $ view -> setVariable ( 'restrictions' , true ) ; } $ view -> setVariable ( 'adminMenu' , $ this -> adminPanelConfig ) ; $ view -> setTemplate ( 'rcm-admin/admin/admin' ) ; return $ view ; }
Get the Admin Menu Bar
23,394
public function setName ( $ name ) { $ name = strtolower ( $ name ) ; if ( preg_match ( "/[^a-z\-0-9\.]/" , $ name ) ) { throw new InvalidArgumentException ( 'Page names can only contain letters, numbers, dots, and dashes.' . ' No spaces. This page name is invalid: ' . $ name ) ; } $ this -> name = $ name ; }
Sets the Name property
23,395
public function setParent ( Page $ parent ) { $ this -> parent = $ parent ; $ this -> parentId = $ parent -> getPageId ( ) ; }
Set the parent page . Used to generate breadcrumbs or navigation
23,396
public function isValid ( $ value , array $ fields = [ ] ) : bool { $ callback = new Callback ( $ this -> validation ) ; $ arguments = $ this -> getFunctionArguments ( $ callback -> getReflection ( ) , $ value , $ fields ) ; return $ callback -> executeArray ( $ arguments ) ; }
Determines if the specified value matched the defined rule validation .
23,397
public function getRequest ( ) : RequestInterface { if ( ! $ this -> request ) { $ this -> resolveOptions ( ) ; $ this -> request = $ this -> createRequest ( ) ; } return parent :: getRequest ( ) ; }
Get the request object .
23,398
protected function doCall ( ) { $ this -> resolveOptions ( ) ; $ this -> request = $ this -> createRequest ( ) ; $ this -> response = $ this -> client -> send ( $ this -> request ) ; return $ this -> generateResponse ( $ this -> response ) ; }
Return the generated response .
23,399
protected function resolveOptions ( ) : void { $ resolver = new OptionsResolver ( ) ; $ this -> configureOptions ( $ resolver ) ; $ this -> options = $ resolver -> resolve ( $ this -> options ) ; }
Resolve options .