idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
23,200
protected function handleRedirectResponseException ( GetResponseForExceptionEvent $ event , RedirectResponseException $ ex ) { if ( null !== $ ex -> getRedirectUrl ( ) ) { $ event -> setResponse ( new RedirectResponse ( $ ex -> getRedirectUrl ( ) ) ) ; } return $ event ; }
Handle a redirect response exception .
23,201
public function onKernelException ( GetResponseForExceptionEvent $ event ) { $ ex = $ event -> getException ( ) ; if ( true === ( $ ex instanceof BadUserRoleException ) ) { $ this -> handleBadUserRoleException ( $ event , $ ex ) ; } if ( true === ( $ ex instanceof RedirectResponseException ) ) { $ this -> handleRedirectResponseException ( $ event , $ ex ) ; } return $ event ; }
On kernel exception .
23,202
public function onKernelRequest ( GetResponseEvent $ event ) { $ this -> setRequest ( $ event -> getRequest ( ) ) ; $ this -> getThemeManager ( ) -> addGlobal ( ) ; return $ event ; }
On kernel request .
23,203
public function loadUserByUsername ( $ username ) { $ user = $ this -> userService -> findUserByValidRefreshToken ( $ username ) ; if ( empty ( $ user ) ) { throw new UsernameNotFoundException ( 'No user found with refresh token provided.' ) ; } $ this -> userService -> updateUserRefreshToken ( $ user ) ; return $ user ; }
See if the refresh token is valid and if it is it return the user otherwise we throw the UsernameNotFoundException
23,204
protected function shouldShowInNavigation ( & $ page ) { if ( isset ( $ page [ 'rcmOnly' ] ) && $ page [ 'rcmOnly' ] && empty ( $ this -> page ) ) { return false ; } if ( isset ( $ page [ 'acl' ] ) && is_array ( $ page [ 'acl' ] ) && ! empty ( $ page [ 'acl' ] [ 'resource' ] ) ) { $ privilege = null ; if ( ! empty ( $ page [ 'acl' ] [ 'privilege' ] ) ) { $ privilege = $ page [ 'acl' ] [ 'privilege' ] ; } $ resource = $ page [ 'acl' ] [ 'resource' ] ; $ resource = str_replace ( [ ':siteId' , ':pageName' ] , [ $ this -> currentSite -> getSiteId ( ) , $ this -> page -> getName ( ) ] , $ resource ) ; if ( ! empty ( $ this -> page ) ) { $ resource = str_replace ( [ ':siteId' , ':pageName' ] , [ $ this -> currentSite -> getSiteId ( ) , $ this -> page -> getName ( ) ] , $ resource ) ; } else { $ resource = str_replace ( [ ':siteId' ] , [ $ this -> currentSite -> getSiteId ( ) ] , $ resource ) ; } if ( ! $ this -> isAllowed -> __invoke ( GetPsrRequest :: invoke ( ) , $ resource , $ privilege ) ) { return false ; } } return true ; }
Should link be shown in nav bar?
23,205
protected function updatePlaceHolders ( & $ item , $ key , $ revisionNumber ) { if ( empty ( $ this -> page ) ) { return ; } $ find = [ ':rcmPageName' , ':rcmPageType' , ':rcmPageRevision' ] ; $ replace = [ $ this -> page -> getName ( ) , $ this -> page -> getPageType ( ) , $ revisionNumber , ] ; $ item = str_replace ( $ find , $ replace , $ item ) ; }
Update config place holders with correct data
23,206
public function applyFilter ( string $ defaultSort = "" , string $ defaultOrder = "" ) { $ this -> filter = new Filter ( RequestFactory :: read ( ) , $ defaultSort , $ defaultOrder ) ; }
Creates the filter according to the request .
23,207
public function createNewPage ( $ user , int $ siteId , string $ name , string $ pageType , $ data ) { if ( empty ( $ user ) ) { throw new TrackingException ( 'A valid user is required in ' . get_class ( $ this ) ) ; } $ validatedData = $ data ; $ pageData = [ 'name' => $ name , 'siteId' => $ siteId , 'pageTitle' => $ validatedData [ 'pageTitle' ] , 'pageType' => $ pageType , 'siteLayoutOverride' => ( isset ( $ validatedData [ 'siteLayoutOverride' ] ) ? $ validatedData [ 'siteLayoutOverride' ] : null ) , 'createdByUserId' => $ user -> getId ( ) , 'createdReason' => 'New page in ' . get_class ( $ this ) , 'author' => $ user -> getName ( ) , ] ; $ createdPage = $ this -> pageRepo -> createPage ( $ this -> entityManager -> find ( Site :: class , $ siteId ) , $ pageData ) ; $ this -> immuteblePageVersionRepo -> createUnpublished ( new PageLocator ( $ siteId , $ this -> rcmPageNameToPathname -> __invoke ( $ createdPage -> getName ( ) , $ createdPage -> getPageType ( ) ) ) , $ this -> immutablePageContentFactory -> __invoke ( $ createdPage -> getPageTitle ( ) , $ createdPage -> getDescription ( ) , $ createdPage -> getKeywords ( ) , $ this -> revisionRepo -> find ( $ createdPage -> getStagedRevision ( ) ) -> getPluginWrappers ( ) -> toArray ( ) ) , $ user -> getId ( ) , __CLASS__ . '::' . __FUNCTION__ ) ; return $ createdPage ; }
Creates a new page which starts out staged instead of published .
23,208
public function createNewPageFromTemplate ( $ user , $ data ) { if ( empty ( $ user ) ) { throw new TrackingException ( 'A valid user is required in ' . get_class ( $ this ) ) ; } $ validatedData = $ data ; $ page = $ this -> pageRepo -> findOneBy ( [ 'pageId' => $ validatedData [ 'page-template' ] , 'pageType' => 't' ] ) ; if ( empty ( $ page ) ) { throw new PageNotFoundException ( 'No template found for page id: ' . $ validatedData [ 'page-template' ] ) ; } $ pageData = [ 'name' => $ validatedData [ 'name' ] , 'pageTitle' => $ validatedData [ 'pageTitle' ] , 'pageType' => 'n' , 'createdByUserId' => $ user -> getId ( ) , 'createdReason' => 'New page from template in ' . get_class ( $ this ) , 'author' => $ user -> getName ( ) , ] ; $ createdPage = $ resultRevisionId = $ this -> pageRepo -> copyPage ( $ this -> currentSite , $ page , $ pageData ) ; $ this -> immuteblePageVersionRepo -> createUnpublished ( new PageLocator ( $ this -> currentSite -> getSiteId ( ) , $ this -> rcmPageNameToPathname -> __invoke ( $ createdPage -> getName ( ) , $ createdPage -> getPageType ( ) ) ) , $ this -> immutablePageContentFactory -> __invoke ( $ createdPage -> getPageTitle ( ) , $ createdPage -> getDescription ( ) , $ createdPage -> getKeywords ( ) , $ this -> revisionRepo -> find ( $ resultRevisionId ) -> getPluginWrappers ( ) -> toArray ( ) ) , $ user -> getId ( ) , __CLASS__ . '::' . __FUNCTION__ ) ; }
Creates a new page from a template . The page starts out staged instead of published .
23,209
protected function prepSaveData ( & $ data ) { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } ksort ( $ data ) ; $ data [ 'containers' ] = [ ] ; $ data [ 'pageContainer' ] = [ ] ; if ( empty ( $ data [ 'plugins' ] ) ) { throw new InvalidArgumentException ( 'Save Data missing plugins . Please make sure the data you\'re attempting to save is correctly formatted. ' ) ; } foreach ( $ data [ 'plugins' ] as & $ plugin ) { $ this -> cleanSaveData ( $ plugin [ 'saveData' ] ) ; if ( ! empty ( $ plugin [ 'isSitewide' ] ) && $ plugin [ 'isSitewide' ] != 'false' && $ plugin [ 'isSitewide' ] != '0' ) { $ plugin [ 'isSitewide' ] = 1 ; } else { $ plugin [ 'isSitewide' ] = 0 ; } if ( empty ( $ plugin [ 'sitewideName' ] ) ) { $ plugin [ 'sitewideName' ] = null ; } $ plugin [ 'rank' ] = ( int ) $ plugin [ 'rank' ] ; $ plugin [ 'rowNumber' ] = ( int ) $ plugin [ 'rowNumber' ] ; $ plugin [ 'columnClass' ] = ( string ) $ plugin [ 'columnClass' ] ; $ plugin [ 'containerName' ] = $ plugin [ 'containerId' ] ; if ( $ plugin [ 'containerType' ] == 'layout' ) { $ data [ 'containers' ] [ $ plugin [ 'containerId' ] ] [ ] = & $ plugin ; } else { $ data [ 'pageContainer' ] [ ] = & $ plugin ; } } }
Prep and validate data array to save
23,210
protected function cleanSaveData ( & $ data ) { if ( empty ( $ data ) ) { return ; } if ( is_array ( $ data ) ) { ksort ( $ data ) ; foreach ( $ data as & $ arrayData ) { $ this -> cleanSaveData ( $ arrayData ) ; } return ; } if ( is_string ( $ data ) ) { $ data = trim ( str_replace ( [ "\n" , "\t" , "\r" ] , "" , $ data ) ) ; } return ; }
Save data clean up .
23,211
protected function registerDefinedRoutes ( Router $ router ) { $ router -> group ( [ 'prefix' => \ Flare :: config ( 'admin_url' ) , 'as' => 'flare::' , 'middleware' => [ 'flare' ] , ] , function ( $ router ) { \ Flare :: admin ( ) -> registerRoutes ( $ router ) ; $ router -> get ( '/' , $ this -> adminController ( 'getDashboard' ) ) -> name ( 'dashboard' ) ; } ) ; }
Register the Defined Routes .
23,212
protected function registerDefaultRoutes ( Router $ router ) { $ router -> group ( [ 'prefix' => \ Flare :: config ( 'admin_url' ) , 'as' => 'flare::' , 'middleware' => [ 'web' , 'flarebase' ] , ] , function ( $ router ) { $ router -> get ( 'logout' , $ this -> adminController ( 'getLogout' ) ) -> name ( 'logout' ) ; if ( \ Flare :: show ( 'login' ) ) { $ router -> get ( 'login' , $ this -> adminController ( 'getLogin' ) ) -> name ( 'login' ) ; $ router -> post ( 'login' , $ this -> adminController ( 'postLogin' ) ) -> name ( 'login' ) ; $ router -> get ( 'email' , $ this -> adminController ( 'getEmail' ) ) -> name ( 'email' ) ; $ router -> post ( 'email' , $ this -> adminController ( 'postEmail' ) ) -> name ( 'email' ) ; $ router -> get ( 'reset/{token}' , $ this -> adminController ( 'getReset' ) ) -> name ( 'reset' ) ; $ router -> post ( 'reset' , $ this -> adminController ( 'postReset' ) ) -> name ( 'reset' ) ; } } ) ; }
Register the Default Routes .
23,213
public function langUpdate ( ) { $ path = skin_path ( 'lang' . DS . $ this -> module -> name ) . DS . app_locale ( ) . '.json' ; $ data = file_exists ( $ path ) ? json_decode ( file_get_contents ( $ path ) , true ) : [ ] ; $ data = array_filter ( array_merge ( $ data , [ $ this -> name => $ this -> title , $ this -> name . '#descr' => $ this -> attributes [ 'descr' ] , 'section.' . $ this -> section => request ( 'section_lang' , __ ( 'section.' . $ this -> section ) ) , 'legend.' . $ this -> fieldset => request ( 'legend_lang' , __ ( 'legend.' . $ this -> fieldset ) ) , ] ) ) ; ksort ( $ data ) ; $ data = json_encode ( $ data , JSON_UNESCAPED_UNICODE ) ; if ( JSON_ERROR_NONE !== json_last_error ( ) ) { throw new \ RuntimeException ( sprintf ( 'Translation file `%s` contains an invalid JSON structure.' , $ path ) ) ; } file_put_contents ( $ path , $ data ) ; return $ this ; }
Update setting lang file with format json .
23,214
public static function generate_page ( Module $ module , string $ action ) { $ settings = static :: query ( ) -> where ( 'module_name' , $ module -> name ) -> where ( 'action' , $ action ) -> get ( ) -> makeFormFields ( ) ; return [ 'module' => $ module , 'sections' => $ settings -> pluck ( 'section' ) -> unique ( ) , 'fieldsets' => $ settings -> pluck ( 'fieldset' ) -> unique ( ) , 'fields' => $ settings -> groupBy ( [ 'section' , 'fieldset' ] ) , ] ; }
Automatic config screen generator .
23,215
public function isDisplayable ( ) { $ displayable = $ this -> enable && $ this -> visible ; if ( true === $ displayable ) { return true ; } foreach ( $ this -> getNodes ( ) as $ current ) { if ( false === ( $ current instanceof AbstractNavigationNode ) ) { continue ; } if ( true === $ current -> isDisplayable ( ) ) { return true ; } } return $ displayable ; }
Determines if the node is displayable .
23,216
public function onAuthenticationFailure ( Request $ request , AuthenticationException $ exception ) { $ this -> dispatcher -> dispatch ( self :: WEBSItE_STATELESS_GUARD_AUTH_FAILED , new AuthFailedEvent ( $ request , $ exception ) ) ; return $ this -> removeAuthCookieFromResponse ( new RedirectResponse ( $ this -> createLoginPath ( $ request ) ) ) ; }
4b ) If the response fails it will redirect the request to the login page with next_url for redirect purposes
23,217
public function start ( Request $ request , AuthenticationException $ authException = null ) { return new RedirectResponse ( $ this -> createLoginPath ( $ request ) ) ; }
If the does not have credentials redirect the request to the login page with next_url for redirect purposes
23,218
protected function createLoginPath ( Request $ request ) { $ url = $ this -> loginPath ; $ url .= $ this -> appendNextUrl ( $ request ) ? '?' . self :: NEXT_URL_PARAMETER . '=' . $ request -> getPathInfo ( ) : '' ; return $ url ; }
Returns the login path for the url and will append a next param
23,219
protected function appendNextUrl ( Request $ request ) { return ! empty ( $ request -> getPathInfo ( ) ) && strpos ( $ request -> getPathInfo ( ) , $ this -> loginPath ) == false ; }
Returns true if next url should be appended
23,220
public function modelHasLanguage ( $ model , $ key ) { if ( $ this -> isLanguage ( $ key ) ) { return true ; } if ( $ model -> translations -> get ( $ key ) ) { return true ; } return $ this -> model -> language === $ key ; }
Does the Model have the language created .
23,221
public function routeToViewModelTranslation ( $ key , $ model ) { if ( $ translation = $ model -> translations -> get ( $ key ) ) { return $ this -> currentUrl ( 'view/' . $ translation -> id ) ; } }
Return route to Create Model Translation Page .
23,222
protected function applyTranslationFilter ( ) { if ( ! array_key_exists ( $ lang = request ( ) -> get ( 'lang' ) , $ this -> languages ( ) ) ) { return ; } return $ this -> query -> whereLanguage ( $ lang ) ; }
Applies the Translation Filter to the current query .
23,223
public function getPluginWrappersByRow ( $ refresh = false ) { if ( $ this -> pluginWrappers -> count ( ) < 1 ) { return [ ] ; } if ( ! empty ( $ this -> wrappersByRows ) && ! $ refresh ) { return $ this -> wrappersByRows ; } $ this -> wrappersByRows = $ this -> orderPluginWrappersByRow ( $ this -> pluginWrappers -> toArray ( ) ) ; return $ this -> wrappersByRows ; }
Get Plugin Instances
23,224
public function getPluginWrapper ( $ instanceId ) { if ( $ this -> pluginWrappers -> count ( ) < 1 ) { return null ; } foreach ( $ this -> pluginWrappers as $ pluginWrapper ) { if ( $ pluginWrapper -> getInstance ( ) -> getInstanceId ( ) == $ instanceId ) { return $ pluginWrapper ; } } return null ; }
Get Plugin Instance Wrapper by Instance Id
23,225
public function orderPluginWrappersByRow ( $ pluginWrappers ) { $ wrappersByRows = [ ] ; foreach ( $ pluginWrappers as $ wrapper ) { $ rowNumber = $ wrapper -> getRowNumber ( ) ; if ( ! isset ( $ wrappersByRows [ $ rowNumber ] ) ) { $ wrappersByRows [ $ rowNumber ] = [ ] ; } $ wrappersByRows [ $ rowNumber ] [ ] = $ wrapper ; } ksort ( $ wrappersByRows ) ; return $ wrappersByRows ; }
orderPluginWrappersByRow - Assumes we have ordered them by RenderOrder the DB join
23,226
protected function registerBindings ( ) { $ this -> app -> bind ( \ LaravelFlare \ Flare \ Contracts \ Permissions \ Permissionable :: class , \ Flare :: config ( 'permissions' ) ) ; }
Register the Flare Bindings .
23,227
protected function publishAssets ( ) { $ assets = [ ] ; foreach ( $ this -> assets as $ location => $ asset ) { $ assets [ $ this -> basePath ( $ location ) ] = base_path ( $ asset ) ; } $ this -> publishes ( $ assets ) ; }
Publishes the Flare Assets to the appropriate directories .
23,228
protected function publishViews ( ) { $ this -> loadViewsFrom ( $ this -> basePath ( 'resources/views' ) , 'flare' ) ; $ this -> publishes ( [ $ this -> basePath ( 'resources/views' ) => base_path ( 'resources/views/vendor/flare' ) , ] ) ; }
Publishes the Flare Views and defines the location they should be looked for in the application .
23,229
public function getManagedModel ( ) { if ( ! isset ( $ this -> managedModel ) || $ this -> managedModel === null ) { throw new ModelAdminException ( 'You have a ModelAdmin which does not have a model assigned to it. ModelAdmins must include a model to manage.' , 1 ) ; } return $ this -> managedModel ; }
Returns the Managed Model Class .
23,230
public function getEntityTitle ( ) { if ( ! isset ( $ this -> entityTitle ) || ! $ this -> entityTitle ) { return $ this -> getTitle ( ) ; } return $ this -> entityTitle ; }
Get the Entity Title .
23,231
public function getPluralEntityTitle ( ) { if ( ! isset ( $ this -> pluralEntityTitle ) || ! $ this -> pluralEntityTitle ) { return Str :: plural ( $ this -> getEntityTitle ( ) ) ; } return $ this -> pluralEntityTitle ; }
Plural Entity Title .
23,232
public function getColumns ( ) { $ columns = [ ] ; foreach ( $ this -> columns as $ field => $ fieldTitle ) { if ( in_array ( $ field , $ this -> model -> getFillable ( ) ) ) { if ( ! $ field ) { $ field = $ fieldTitle ; $ fieldTitle = Str :: title ( $ fieldTitle ) ; } $ columns [ $ field ] = $ fieldTitle ; continue ; } if ( ( $ methodBreaker = strpos ( $ field , '.' ) ) !== false ) { $ method = substr ( $ field , 0 , $ methodBreaker ) ; if ( method_exists ( $ this -> model , $ method ) ) { if ( method_exists ( $ this -> model -> $ method ( ) , $ submethod = str_replace ( $ method . '.' , '' , $ field ) ) ) { $ this -> model -> $ method ( ) -> $ submethod ( ) ; $ columns [ $ field ] = $ fieldTitle ; continue ; } } } if ( is_numeric ( $ field ) ) { $ field = $ fieldTitle ; $ fieldTitle = Str :: title ( $ fieldTitle ) ; } $ columns [ $ field ] = $ fieldTitle ; } if ( count ( $ columns ) ) { return $ columns ; } return [ $ this -> model -> getKeyName ( ) => $ this -> model -> getKeyName ( ) ] ; }
Formats and returns the Columns .
23,233
public function getAttribute ( $ key , $ model = false ) { if ( ! $ key ) { return ; } if ( ! $ model ) { $ model = $ this -> model ; } $ formattedKey = str_replace ( '.' , '_' , $ key ) ; if ( $ this -> hasGetAccessor ( $ formattedKey ) ) { $ method = 'get' . Str :: studly ( $ formattedKey ) . 'Attribute' ; return $ this -> { $ method } ( $ model ) ; } if ( $ this -> hasGetAccessor ( $ key ) ) { $ method = 'get' . Str :: studly ( $ key ) . 'Attribute' ; return $ this -> { $ method } ( $ model ) ; } if ( $ this -> hasRelatedKey ( $ key , $ model ) ) { return $ this -> relatedKey ( $ key , $ model ) ; } return $ model -> getAttribute ( $ key ) ; }
Gets an Attribute by the provided key on either the current model or a provided model instance .
23,234
public function hasRelatedKey ( $ key , $ model = false ) { if ( ! $ model ) { $ model = $ this -> model ; } if ( ( $ methodBreaker = strpos ( $ key , '.' ) ) !== false ) { $ method = substr ( $ key , 0 , $ methodBreaker ) ; if ( method_exists ( $ model , $ method ) ) { return true ; } } return false ; }
Determines if a key resolved a related Model .
23,235
public function relatedKey ( $ key , $ model = false ) { if ( ! $ model ) { $ model = $ this -> model ; } if ( ( $ methodBreaker = strpos ( $ key , '.' ) ) !== false ) { $ method = substr ( $ key , 0 , $ methodBreaker ) ; if ( method_exists ( $ model , $ method ) ) { if ( method_exists ( $ model -> $ method , $ submethod = str_replace ( $ method . '.' , '' , $ key ) ) ) { return $ model -> $ method -> $ submethod ( ) ; } if ( isset ( $ model -> $ method -> $ submethod ) ) { return $ model -> $ method -> $ submethod ; } return $ model -> getRelationValue ( $ method ) ; } } return false ; }
Resolves a relation based on the key provided either on the current model or a provided model instance .
23,236
protected function formatFields ( ) { $ fields = $ this -> fields ; if ( ! $ fields instanceof AttributeCollection ) { $ fields = new AttributeCollection ( $ fields , $ this ) ; } return $ this -> fields = $ fields -> formatFields ( ) ; }
Format the provided Attribute Fields into a more usable format .
23,237
public function hasSoftDeleting ( ) { if ( ! $ this -> hasDeleting ( ) ) { return false ; } $ managedModelClass = $ this -> getManagedModel ( ) ; return in_array ( SoftDeletes :: class , class_uses_recursive ( get_class ( new $ managedModelClass ( ) ) ) ) && $ this -> hasDeleting ( ) ; }
Determine if the Managed Model is using the SoftDeletes Trait .
23,238
public function init ( ) { parent :: init ( ) ; \ Yii :: $ app -> getI18n ( ) -> translations [ 'core.*' ] = [ 'class' => 'yii\i18n\PhpMessageSource' , 'basePath' => __DIR__ . '/messages' , ] ; $ this -> setAliases ( [ '@core' => __DIR__ ] ) ; }
Unsuccessful Login Attempts before Captcha
23,239
public function getSeoTags ( ) { if ( $ this -> owner -> seo ) { $ seo = $ this -> owner -> seo -> attributes ; return array_filter ( array_intersect_key ( $ seo , array_flip ( [ 'meta_title' , 'meta_keywords' , 'meta_description' ] ) ) ) ; } else { return [ ] ; } }
Get the seo tags as an array
23,240
public function getView ( ) { if ( view ( ) -> exists ( static :: $ view ) ) { return static :: $ view ; } if ( view ( ) -> exists ( 'admin.widgets.' . static :: safeTitle ( ) . '.widget' ) ) { return 'admin.widgets.' . static :: safeTitle ( ) . '.widget' ; } if ( view ( ) -> exists ( 'admin.widgets.' . static :: safeTitle ( ) ) ) { return 'admin.widgets.' . static :: safeTitle ( ) ; } if ( view ( ) -> exists ( 'admin.' . static :: safeTitle ( ) ) ) { return 'admin.' . static :: safeTitle ( ) ; } if ( view ( ) -> exists ( 'flare::' . self :: $ view ) ) { return 'flare::' . self :: $ view ; } }
Returns the Widget Admin View .
23,241
public function send ( ) { $ this -> sendContentOptions ( ) ; $ this -> sendFrameOptions ( ) ; $ this -> sendXssProtection ( ) ; $ this -> sendStrictTransport ( ) ; $ this -> sendAccessControlAllowOrigin ( ) ; $ this -> sendContentSecurity ( ) ; }
Bulk send HTTP response header aiming security purposes . Each one are explained in code .
23,242
public function putItem ( $ name , $ value = null ) { if ( is_null ( $ name ) || is_int ( $ name ) ) { $ this -> _items [ ] = $ value ; } else { $ this -> _items [ $ name ] = $ value ; } }
Straight put an item .
23,243
public function rawItem ( $ name , $ default = null ) { return isset ( $ this -> _items [ $ name ] ) ? $ this -> _items [ $ name ] : $ default ; }
Get raw item .
23,244
public function addItem ( $ name , $ value = null , $ where = '' ) { if ( ! $ this -> hasItem ( $ name ) ) { $ this -> setItem ( $ name , $ value , $ where ) ; } return $ this ; }
Adds an item . Doesn t touch if already exists .
23,245
public function setItem ( $ name , $ value = null , $ where = '' ) { if ( $ name === null || $ where === '' ) { $ this -> putItem ( $ name , $ value ) ; } else { $ this -> setItems ( [ $ name => $ value ] , $ where ) ; } }
Sets an item . Silently resets if already exists and mov .
23,246
public function putItems ( array $ items ) { foreach ( $ items as $ k => $ v ) { $ this -> putItem ( $ k , $ v ) ; } }
Straight put items .
23,247
public function setItems ( $ items , $ where = '' ) { if ( empty ( $ items ) ) { return ; } if ( empty ( $ where ) ) { $ this -> putItems ( $ items ) ; } elseif ( $ where === 'last' ) { $ this -> _items = ArrayHelper :: insertLast ( $ this -> _items , $ items ) ; } elseif ( $ where === 'first' ) { $ this -> _items = ArrayHelper :: insertFirst ( $ this -> _items , $ items ) ; } else { $ this -> _items = ArrayHelper :: insertInside ( $ this -> _items , $ items , $ where ) ; } }
Adds items to specified place .
23,248
public function addItems ( array $ items , $ where = '' ) { foreach ( array_keys ( $ items ) as $ k ) { if ( ! is_int ( $ k ) && $ this -> hasItem ( $ k ) ) { unset ( $ items [ $ k ] ) ; } } if ( ! empty ( $ items ) ) { $ this -> setItems ( $ items , $ where ) ; } return $ this ; }
Adds items to specified place . Does not touch those items that already exists .
23,249
public function unsetItems ( $ keys = null ) { if ( is_null ( $ keys ) ) { $ this -> _items = [ ] ; } elseif ( is_scalar ( $ keys ) ) { unset ( $ this -> _items [ $ keys ] ) ; } else { foreach ( $ keys as $ k ) { unset ( $ this -> _items [ $ k ] ) ; } } }
Unset specified items .
23,250
public function getList ( ) { $ pageType = $ this -> params ( 'pageType' , PageTypes :: NORMAL ) ; $ pageId = $ this -> params ( 'pageId' , null ) ; $ validator = clone ( $ this -> getServiceLocator ( ) -> get ( \ Rcm \ Validator \ Page :: class ) ) ; $ validator -> setPageType ( $ pageType ) ; $ return = [ 'valid' => true ] ; if ( ! $ validator -> isValid ( $ pageId ) ) { $ return [ 'valid' ] = false ; $ return [ 'error' ] = $ validator -> getMessages ( ) ; $ response = $ this -> response ; $ errorCodes = array_keys ( $ return [ 'error' ] ) ; foreach ( $ errorCodes as & $ errorCode ) { if ( $ errorCode == $ validator :: PAGE_EXISTS ) { $ response -> setStatusCode ( 409 ) ; break ; } elseif ( $ errorCode == $ validator :: PAGE_NAME ) { $ response -> setStatusCode ( 417 ) ; } } } return new JsonModel ( $ return ) ; }
Check the page is valid and return a json response
23,251
public function attach ( $ name , $ resolver = null , $ single = false , $ override = false ) { if ( is_array ( $ name ) ) { $ resolver = current ( $ name ) ; $ name = key ( $ name ) ; $ this -> alias ( $ resolver , $ name , $ override ) ; } if ( $ name instanceof Asset ) { $ this -> setParam ( 'assets' , $ name -> is ( ) , $ name , $ override ) ; } elseif ( $ resolver instanceof \ Closure && $ single ) { $ this -> setParam ( 'assets' , $ name , function ( $ params ) use ( $ resolver ) { static $ obj ; if ( $ obj === null ) { $ obj = $ resolver ( $ params , $ this ) ; } return $ obj ; } , $ override ) ; } elseif ( $ resolver instanceof \ Closure || $ resolver instanceof Asset ) { $ this -> setParam ( 'assets' , $ name , $ resolver , $ override ) ; } elseif ( is_object ( $ resolver ) ) { $ this -> setParam ( 'instances' , $ name , $ resolver , $ override ) ; } elseif ( ( $ resolver === null ) && $ single ) { $ this -> setParam ( 'instances' , $ name , $ name , $ override ) ; } elseif ( $ single ) { $ this -> setParam ( 'instances' , $ name , $ resolver , $ override ) ; } elseif ( $ resolver === null ) { $ this -> setParam ( 'assets' , $ name , $ name , $ override ) ; } if ( $ single && isset ( $ this -> aliases [ $ name ] ) ) { unset ( $ this -> aliases [ $ name ] ) ; } return $ this ; }
Attach an asset to the service manager if it doesn t already exist .
23,252
public function singleton ( $ name , $ resolver = null , $ override = false ) { return $ this -> attach ( $ name , $ resolver , true , $ override ) ; }
A convenience method for adding a singleton .
23,253
public function overrideAsSingleton ( $ name , $ resolver = null ) { return $ this -> singleton ( $ name , $ resolver , true , true ) ; }
A convenience method for overriding an existing singleton .
23,254
public function resolve ( $ name , $ params = [ ] ) { if ( isset ( $ params [ 'resolver' ] ) && $ params [ 'resolver' ] instanceof \ Closure ) { return $ params [ 'resolver' ] ( ) ; } if ( isset ( $ params [ 'reflector' ] ) && $ params [ 'reflector' ] instanceof \ Closure ) { $ reflection = new \ ReflectionClass ( $ name ) ; if ( $ reflection -> isInstantiable ( ) ) { return $ params [ 'reflector' ] ( $ reflection , $ name ) ; } } if ( isset ( $ this -> assets [ $ name ] ) ) { if ( $ this -> assets [ $ name ] instanceof Asset || $ this -> assets [ $ name ] instanceof \ Closure ) { return $ this -> assets [ $ name ] ( $ params , $ this ) ; } } if ( isset ( $ this -> instances [ $ name ] ) ) { if ( $ this -> instances [ $ name ] instanceof Asset || $ this -> instances [ $ name ] instanceof \ Closure ) { $ object = $ this -> instances [ $ name ] ( $ params , $ this ) ; $ this -> setParam ( 'instances' , $ name , $ object , true ) ; } else if ( is_object ( $ this -> instances [ $ name ] ) ) { return $ this -> instances [ $ name ] ; } else { try { $ object = $ this -> autoResolve ( $ name , $ params ) ; $ this -> setParam ( 'instances' , $ name , $ object , true ) ; return $ this -> resolve ( $ name ) ; } catch ( \ LogicException $ e ) { try { $ object = $ this -> autoResolve ( $ this -> instances [ $ name ] , $ params ) ; $ this -> setParam ( 'instances' , $ name , $ object , true ) ; return $ this -> resolve ( $ name ) ; } catch ( \ LogicException $ e ) { throw $ e ; } } } } if ( isset ( $ this -> aliases [ $ name ] ) ) { return $ this -> resolve ( $ this -> aliases [ $ name ] ) ; } return $ this -> autoResolve ( $ name , $ params ) ; }
Return an asset by index .
23,255
public function getDependencies ( $ params ) { $ deps = [ ] ; foreach ( $ params as $ param ) { $ dependency = $ param -> getClass ( ) ; if ( $ dependency !== null ) { if ( $ dependency -> name == 'Proem\Service\AssetManager' || $ dependency -> name == 'Proem\Service\AssetManagerInterface' ) { $ deps [ ] = $ this ; } else { $ deps [ ] = $ this -> resolve ( $ dependency -> name ) ; } } else { if ( $ param -> isDefaultValueAvailable ( ) ) { $ deps [ ] = $ param -> getDefaultValue ( ) ; } } } return $ deps ; }
A simple helper to resolve dependencies given an array of dependents .
23,256
protected function setParam ( $ type , $ index , $ value , $ override = false ) { if ( $ override ) { $ this -> { $ type } [ $ index ] = $ value ; } else if ( ! isset ( $ this -> { $ type } [ $ index ] ) ) { $ this -> { $ type } [ $ index ] = $ value ; } return $ this ; }
A helper used to set aliases assets and instances .
23,257
protected function autoResolve ( $ name , $ params ) { try { $ reflection = new \ ReflectionClass ( $ name ) ; if ( $ reflection -> isInstantiable ( ) ) { $ construct = $ reflection -> getConstructor ( ) ; if ( $ construct === null ) { $ object = new $ name ; } else { $ dependencies = $ this -> getDependencies ( $ construct -> getParameters ( ) ) ; $ object = $ reflection -> newInstanceArgs ( $ dependencies ) ; } try { $ method = $ reflection -> getMethod ( 'setParams' ) ; $ method -> invokeArgs ( $ object , $ params ) ; } catch ( \ ReflectionException $ e ) { } if ( isset ( $ params [ 'methods' ] ) ) { foreach ( $ params [ 'methods' ] as $ method ) { $ method = $ reflection -> getMethod ( $ method ) ; $ method -> invokeArgs ( $ object , $ this -> getDependencies ( $ method -> getParameters ( ) ) ) ; } } if ( isset ( $ params [ 'invoke' ] ) ) { $ method = $ params [ 'invoke' ] ; $ method = $ reflection -> getMethod ( $ method ) ; return $ method -> invokeArgs ( $ object , $ this -> getDependencies ( $ method -> getParameters ( ) ) ) ; } return $ object ; } } catch ( \ ReflectionException $ e ) { throw new \ LogicException ( "Unable to resolve '{$name}'" ) ; } }
Method to do the heavy lifting in relation to reolution of assets .
23,258
public function registerProvider ( ColorProviderInterface $ colorProvider ) { $ key = ColorHelper :: getIdentifier ( $ colorProvider ) ; if ( true === array_key_exists ( $ key , $ this -> index ) ) { throw new AlreadyRegisteredProviderException ( $ colorProvider ) ; } $ this -> index [ $ key ] = $ this -> size ( ) ; return $ this -> addProvider ( $ colorProvider ) ; }
Register a color provider .
23,259
public function setDomainName ( $ domain ) { $ domain = strtolower ( $ domain ) ; if ( ! $ this -> getDomainValidator ( ) -> isValid ( $ domain ) ) { throw new InvalidArgumentException ( 'Domain name is invalid: ' . $ domain ) ; } $ this -> domain = $ domain ; }
Set the domain name
23,260
public function setPrimaryDomain ( $ primaryDomain ) { if ( empty ( $ primaryDomain ) ) { $ this -> primaryDomain = null ; $ this -> primaryId = null ; return ; } $ this -> primaryDomain = $ primaryDomain ; $ this -> primaryId = $ primaryDomain -> getDomainId ( ) ; }
Set the Primary Domain .
23,261
public function isSortable ( ) { $ this -> getSearchCriteria ( ) ; $ sortable = new \ stdClass ; if ( $ this -> searchModel -> Menu_id > 0 ) { $ sortable -> sortable = true ; $ sortable -> link = Url :: toRoute ( [ 'sort' , 'Menu_id' => $ this -> searchModel -> Menu_id ] ) ; } else { $ sortable -> sortable = false ; $ sortable -> message = 'Filter on a menu first' ; } return $ sortable ; }
Sets up the sorting option
23,262
public function actionSort ( ) { $ this -> layout = static :: FORM_LAYOUT ; $ modelName = $ this -> getCompatibilityId ( ) ; if ( isset ( $ _POST [ $ modelName ] ) && count ( $ _POST [ $ modelName ] ) ) { if ( $ _GET [ 'Menu_id' ] == - 1 ) { foreach ( $ _POST [ $ modelName ] as $ key => $ id ) { $ record = $ this -> findModel ( $ id ) ; $ record -> sort_order = $ key + 1 ; $ record -> save ( ) ; } } else { $ parent = $ this -> findModel ( $ _GET [ 'Menu_id' ] ) ; foreach ( $ _POST [ $ modelName ] as $ key => $ id ) { $ record = $ this -> findModel ( $ id ) ; $ record -> appendTo ( $ parent ) ; } } return $ this -> redirect ( [ 'index' ] ) ; } else { $ this -> getSearchCriteria ( ) ; $ searchCriteria = [ 'MenuSearch' => [ 'Menu_id' => $ this -> searchModel -> Menu_id ] ] ; $ this -> searchModel = new $ this -> MainModelSearch ; $ this -> dataProvider = $ this -> searchModel -> search ( $ searchCriteria ) ; $ this -> dataProvider -> pagination = false ; return $ this -> render ( 'sort' , [ 'searchModel' => $ this -> searchModel , 'dataProvider' => $ this -> dataProvider , ] ) ; } }
Allows sorting of the menus
23,263
public function actionStatus ( $ id ) { $ model = $ this -> findModel ( $ id ) ; if ( $ model -> status == "active" ) { $ model -> status = "inactive" ; } else { $ model -> status = "active" ; } $ model -> save ( false ) ; if ( Yii :: $ app -> request -> getIsAjax ( ) ) { Yii :: $ app -> response -> format = 'json' ; return [ 'success' => true ] ; } else { return $ this -> redirect ( [ 'index' ] ) ; } }
Deletes an existing Faq model . If deletion is successful the browser will be redirected to the index page .
23,264
public function actionCreate ( ) { $ this -> layout = static :: FORM_LAYOUT ; $ model = new $ this -> MainModel ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { if ( empty ( $ model -> Menu_id ) ) { Yii :: info ( 'Making the new node as root' ) ; $ model -> makeRoot ( ) ; } else { $ parent_node = Menu :: findOne ( $ model -> Menu_id ) ; $ model -> appendTo ( $ parent_node ) ; Yii :: info ( 'Making the new node as a child of ' . $ parent_node -> id ) ; } $ this -> saveHistory ( $ model , $ this -> historyField ) ; return $ this -> redirect ( [ 'index' ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new Faq model . If creation is successful the browser will be redirected to the view page .
23,265
private function validateImageMimeType ( ) { $ imageType = exif_imagetype ( $ this -> uploadFile -> getTemporaryFilename ( ) ) ; $ mime = image_type_to_mime_type ( $ imageType ) ; if ( ! $ imageType || ! in_array ( $ mime , parent :: getAllowedMimeTypes ( ) ) ) { throw new \ Exception ( "Uploaded image appears to be corrupt" ) ; } }
Validate that the mime type is an actual valid image .
23,266
public function attach ( ChainEventInterface $ event , $ priority = 0 ) { $ this -> queue -> insert ( $ event , $ priority ) ; return $ this ; }
Insert an event into the queue
23,267
private function parsePathParts ( Request $ request ) { if ( empty ( $ this -> apiUrlPath ) ) { throw new \ Exception ( self :: ERROR_NO_API_BASE_PATH ) ; } $ base = explode ( '/' , $ this -> apiUrlPath ) ; $ path = explode ( '/' , $ request -> getPathInfo ( ) ) ; return array_values ( array_diff ( $ path , $ base ) ) ; }
The router Symfony service cannot be used regretably .
23,268
public static function getItems ( $ array , $ keys = null ) { if ( is_null ( $ keys ) ) { return $ array ; } elseif ( is_scalar ( $ keys ) ) { $ keys = [ $ keys => $ array [ $ keys ] ] ; } $ res = [ ] ; foreach ( $ keys as $ k ) { if ( array_key_exists ( $ k , $ array ) ) { $ res [ $ k ] = $ array [ $ k ] ; } } return $ res ; }
Get specified items as array .
23,269
protected static function prepareWhere ( array $ array , $ list ) { if ( ! is_array ( $ list ) ) { $ list = [ $ list ] ; } foreach ( $ list as $ v ) { if ( array_key_exists ( $ v , $ array ) ) { return $ v ; } } return null ; }
Internal function to prepare where list for insertInside .
23,270
public static function unique ( $ array ) { $ suitable = true ; foreach ( $ array as $ k => & $ v ) { if ( is_array ( $ v ) ) { $ v = self :: unique ( $ v ) ; } elseif ( ! is_int ( $ k ) ) { $ suitable = false ; } } return $ suitable ? self :: uniqueFlat ( $ array ) : $ array ; }
Recursively removes duplicate values from non - associative arrays .
23,271
public static function uniqueFlat ( $ array ) { $ uniqs = [ ] ; $ res = [ ] ; foreach ( $ array as $ k => $ v ) { $ uv = var_export ( $ v , true ) ; if ( array_key_exists ( $ uv , $ uniqs ) ) { continue ; } $ uniqs [ $ uv ] = 1 ; $ res [ $ k ] = $ v ; } return $ res ; }
Non - recursively removes duplicate values from non - associative arrays .
23,272
public function onBootstrap ( MvcEvent $ e ) { $ serviceManager = $ e -> getApplication ( ) -> getServiceManager ( ) ; if ( $ e -> getRequest ( ) instanceof Request ) { return ; } $ onDispatchListener = $ serviceManager -> get ( \ RcmAdmin \ EventListener \ DispatchListener :: class ) ; $ eventManager = $ e -> getApplication ( ) -> getEventManager ( ) ; $ eventManager -> attach ( MvcEvent :: EVENT_DISPATCH , [ $ onDispatchListener , 'getAdminPanel' ] , 10001 ) ; }
Add Listeners to the bootstrap
23,273
public function group ( array $ attributes , callable $ callback ) { $ this -> groupAttributes = $ attributes ; $ callback ( ) ; $ this -> groupAttributes = null ; return $ this ; }
Group routes by attributes .
23,274
public function supports ( Request $ request ) { $ post = json_decode ( $ request -> getContent ( ) , true ) ; return ! empty ( $ post [ self :: EMAIL_FIELD ] ) && ! empty ( $ post [ self :: PASSWORD_FIELD ] ) ; }
1 ) Returns true if request has email and password in the json body
23,275
public function getCredentials ( Request $ request ) { $ post = json_decode ( $ request -> getContent ( ) , true ) ; return new CredentialEmailModel ( $ post [ self :: EMAIL_FIELD ] , $ post [ self :: PASSWORD_FIELD ] ) ; }
2 ) Returns CredentialEmailModel
23,276
public function checkCredentials ( $ credentials , UserInterface $ user ) { return $ this -> userPasswordEncoderFactory -> isPasswordValid ( $ user , $ credentials -> getPassword ( ) ) ; }
4 ) Returns true if the credentials are valid . For token based requests facebook etc . Token are validate by a 3rd party provider in the getUser function
23,277
public function onNotify ( NotificationEvent $ event ) { if ( true === ( $ this -> getSession ( ) instanceof Session ) ) { $ this -> getSession ( ) -> getFlashBag ( ) -> add ( $ event -> getNotification ( ) -> getType ( ) , $ event -> getNotification ( ) -> getContent ( ) ) ; } return $ event ; }
On notify .
23,278
public function setInstanceConfig ( $ instanceConfig ) { $ this -> instanceConfig = json_encode ( $ instanceConfig ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new \ Exception ( json_last_error_msg ( ) ) ; } }
Sets the config that will be stored in the DB as JSON
23,279
public function created ( string $ key ) { $ path = $ this -> path ( $ key ) ; return $ this -> files -> exists ( $ path ) ? \ Carbon \ Carbon :: createFromTimestamp ( $ this -> files -> lastModified ( $ path ) ) : null ; }
Get datetime of created cache file by key .
23,280
public function expired ( string $ key ) { $ path = $ this -> path ( $ key ) ; return $ this -> files -> exists ( $ path ) ? \ Carbon \ Carbon :: createFromTimestamp ( substr ( $ this -> files -> get ( $ path ) , 0 , 10 ) ) : null ; }
Get the expiration time from cache file by key .
23,281
public function onMenuConfigure ( ConfigureMenuEvent $ event ) { if ( ! $ this -> permissionResolver -> hasAccess ( 'uicron' , 'list' ) ) { return ; } $ menu = $ event -> getMenu ( ) ; $ cronsMenu = $ menu -> getChild ( MainMenuBuilder :: ITEM_ADMIN ) ; $ cronsMenu -> addChild ( self :: ITEM_CRONS , [ 'route' => 'edgar.ezuicron.list' ] ) ; }
Add cron to admin menu .
23,282
public function createJsonAuthResponse ( BaseUser $ user ) { $ responseModel = $ this -> createResponseAuthModel ( $ user ) ; $ response = new JsonResponse ( $ responseModel -> getBody ( ) , Response :: HTTP_CREATED ) ; return $ this -> setCookieForResponse ( $ response , $ responseModel ) ; }
Creates a json response that will contain new credentials for the user .
23,283
public function authenticateResponse ( BaseUser $ user , Response $ response ) { return $ this -> setCookieForResponse ( $ response , $ this -> createResponseAuthModel ( $ user ) ) ; }
Sets the auth cookie for an authenticated response
23,284
protected function setCookieForResponse ( Response $ response , ResponseAuthenticationModel $ responseModel ) { $ response -> headers -> setCookie ( new Cookie ( self :: AUTH_COOKIE , $ responseModel -> getAuthToken ( ) , $ responseModel -> getTokenExpirationTimeStamp ( ) , null , false , false ) ) ; return $ response ; }
Sets the auth cookie
23,285
protected function createResponseAuthModel ( BaseUser $ user ) { $ user = $ this -> userService -> updateUserRefreshToken ( $ user ) ; $ authTokenModel = $ this -> authTokenService -> createAuthTokenModel ( $ user ) ; return new ResponseAuthenticationModel ( $ user , $ authTokenModel , $ user -> getAuthRefreshModel ( ) ) ; }
Creates a credentials model for the user
23,286
private function doDelete ( ) { if ( ! $ this -> model -> trashed ( ) ) { $ this -> model -> delete ( ) ; event ( new ModelSoftDelete ( $ this ) ) ; return ; } $ this -> model -> forceDelete ( ) ; event ( new ModelDelete ( $ this ) ) ; }
The actual delete action .
23,287
public function restore ( $ modelitemId ) { event ( new BeforeRestore ( $ this ) ) ; $ this -> findOnlyTrashed ( $ modelitemId ) ; $ this -> beforeRestore ( ) ; $ this -> doRestore ( ) ; $ this -> afterRestore ( ) ; event ( new AfterRestore ( $ this ) ) ; }
Restore Action .
23,288
public function getClass ( $ class ) { $ cacheKey = self :: CACHE_KEY_CLASSES . strtolower ( $ class ) ; if ( ! $ reflectionClass = $ this -> cache -> fetch ( $ cacheKey ) ) { $ reflectionClass = new ReflectionClass ( $ class ) ; $ this -> cache -> store ( $ cacheKey , $ reflectionClass ) ; } return $ reflectionClass ; }
Retrieves ReflectionClass instances caching them for future retrieval .
23,289
public function getConstructorParams ( $ class ) { $ cacheKey = self :: CACHE_KEY_CTOR_PARAMS . strtolower ( $ class ) ; $ reflectedConstructorParams = $ this -> cache -> fetch ( $ cacheKey ) ; if ( false !== $ reflectedConstructorParams ) { return $ reflectedConstructorParams ; } elseif ( $ reflectedConstructor = $ this -> getConstructor ( $ class ) ) { $ reflectedConstructorParams = $ reflectedConstructor -> getParameters ( ) ; } else { $ reflectedConstructorParams = null ; } $ this -> cache -> store ( $ cacheKey , $ reflectedConstructorParams ) ; return $ reflectedConstructorParams ; }
Retrieves and caches an array of constructor parameters for the given class .
23,290
public function getFunction ( $ functionName ) { $ lowFunc = strtolower ( $ functionName ) ; $ cacheKey = self :: CACHE_KEY_FUNCS . $ lowFunc ; $ reflectedFunc = $ this -> cache -> fetch ( $ cacheKey ) ; if ( false === $ reflectedFunc ) { $ reflectedFunc = new ReflectionFunction ( $ functionName ) ; $ this -> cache -> store ( $ cacheKey , $ reflectedFunc ) ; } return $ reflectedFunc ; }
Retrieves and caches a reflection for the specified function .
23,291
public function getMethod ( $ classNameOrInstance , $ methodName ) { $ className = is_string ( $ classNameOrInstance ) ? $ classNameOrInstance : get_class ( $ classNameOrInstance ) ; $ cacheKey = self :: CACHE_KEY_METHODS . strtolower ( $ className ) . '.' . strtolower ( $ methodName ) ; if ( ! $ reflectedMethod = $ this -> cache -> fetch ( $ cacheKey ) ) { $ reflectedMethod = new ReflectionMethod ( $ className , $ methodName ) ; $ this -> cache -> store ( $ cacheKey , $ reflectedMethod ) ; } return $ reflectedMethod ; }
Retrieves and caches a reflection for the specified class method .
23,292
private function getServiceConfig ( string $ name ) { $ config = $ this -> services ( ) [ $ name ] ?? null ; if ( $ config === null ) { return null ; } if ( \ is_string ( $ config ) ) { return [ 'class' => $ config , ] ; } if ( \ is_array ( $ config ) && array_key_exists ( 'class' , $ config ) ) { return $ config ; } throw new InvalidConfigException ( 'Config must be either type of string (class name) or array (with `class` element' ) ; }
Get service class name
23,293
public function create ( $ data ) { if ( ! $ this -> isAllowed ( ResourceName :: RESOURCE_SITES , 'admin' ) ) { $ this -> getResponse ( ) -> setStatusCode ( Response :: STATUS_CODE_401 ) ; return $ this -> getResponse ( ) ; } $ inputFilter = new SiteInputFilter ( ) ; $ inputFilter -> setData ( $ data ) ; if ( ! $ inputFilter -> isValid ( ) ) { return new ApiJsonModel ( [ ] , 1 , 'Some values are missing or invalid.' , $ inputFilter -> getMessages ( ) ) ; } $ data = $ inputFilter -> getValues ( ) ; $ siteManager = $ this -> getSiteManager ( ) ; $ userId = $ this -> getCurrentUserId ( ) ; $ data = $ siteManager -> prepareSiteData ( $ data ) ; $ domainRepo = $ this -> getEntityManager ( ) -> getRepository ( \ Rcm \ Entity \ Domain :: class ) ; $ data [ 'domain' ] = $ domainRepo -> createDomain ( $ data [ 'domainName' ] , $ userId , 'Create new domain in ' . get_class ( $ this ) ) ; $ newSite = new Site ( $ userId , 'Create new site in ' . get_class ( $ this ) ) ; $ newSite -> populate ( $ data ) ; $ newSite -> setSiteId ( null ) ; $ newSite = $ siteManager -> createSite ( $ newSite ) ; return new ApiJsonModel ( $ newSite , 0 , 'Success' ) ; }
create - Create a site
23,294
public function getCommand ( ) { $ command = $ this -> getBinaryPath ( ) ; $ command .= true === OSHelper :: isWindows ( ) ? ".exe" : "" ; return realpath ( $ command ) ; }
Get the command .
23,295
public function getContent ( string $ namespace , string $ locale , string $ name ) : string { $ nKey = self :: getNKey ( $ namespace , $ locale ) ; $ content = $ this -> loadedData [ $ nKey ] [ $ name ] ?? false ; if ( is_string ( $ content ) ) { return $ content ; } $ this -> loadedData [ $ nKey ] = $ this -> loadedData [ $ nKey ] ?? $ this -> loadNspaceFromCache ( $ namespace , $ locale ) ; $ fallbackLocale = $ this -> config [ 'fallback' ] ?? '' ; $ content = $ this -> loadedData [ $ nKey ] [ $ name ] ?? false ; if ( is_string ( $ content ) ) { return $ content ; } if ( $ fallbackLocale === false || $ locale === $ fallbackLocale ) { return '' ; } return $ this -> getContent ( $ namespace , $ fallbackLocale , $ name ) ; }
L1 - PHP ARRAY LAYER
23,296
public function getReflectionMethod ( string $ controller ) { $ callable = $ this -> getClassAndMethod ( $ controller ) ; if ( null === $ callable ) { return null ; } list ( $ class , $ method ) = $ callable ; try { return new \ ReflectionMethod ( $ class , $ method ) ; } catch ( \ ReflectionException $ e ) { } }
Returns the ReflectionMethod for the given controller string .
23,297
public function maybe_enqueue ( $ handle ) { if ( $ this -> is_registered ( $ handle ) ) { $ enqueue = $ this -> get_enqueue_function ( ) ; $ enqueue ( $ handle ) ; return true ; } return false ; }
Maybe enqueue a dependency that has been registered outside of the Dependency Manager .
23,298
public function createWithConstructorParams ( array $ params , $ config = [ ] ) { $ definition = $ this -> prepareObjectDefinitionFromConfig ( $ config ) ; return $ this -> getContainer ( ) -> create ( $ definition , $ params ) ; }
Creates a new object with specified constructor parameters using the given or default configuration .
23,299
public function getThemesConfig ( ) { if ( empty ( $ this -> config [ 'Rcm' ] ) || empty ( $ this -> config [ 'Rcm' ] [ 'themes' ] ) ) { throw new RuntimeException ( 'No Themes found defined in configuration. Please report the issue with the themes author.' ) ; } return $ this -> config [ 'Rcm' ] [ 'themes' ] ; }
Get the installed RCM Themes configuration .